/* Read dbx symbol tables and convert to internal format, for GDB.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
Free Software Foundation, Inc.
This file is part of GDB.
#include "aout/aout64.h"
#include "aout/stab_gnu.h" /* We always use GNU stabs, not native, now */
+/* defined in stabsread.c; used for completing cfront stabs strings */
+extern void
+resolve_cfront_continuation PARAMS((struct objfile * objfile,
+ struct symbol * sym, char * p));
+
\f
/* We put a pointer to this structure in the read_symtab_private field
of the psymtab. */
init_bincl_list PARAMS ((int, struct objfile *));
static char *
-dbx_next_symbol_text PARAMS ((void));
+dbx_next_symbol_text PARAMS ((struct objfile *));
static void
fill_symbuf PARAMS ((bfd *));
lowest_text_address = address;
prim_record_minimal_symbol_and_info
- (obsavestring (name, strlen (name), &objfile -> symbol_obstack),
- address,
- ms_type,
- NULL,
- section,
- objfile);
+ (name, address, ms_type, NULL, section, objfile);
}
\f
/* Scan and build partial symbols for a symbol file.
DBX_STRINGTAB (objfile) =
(char *) obstack_alloc (&objfile -> psymbol_obstack,
DBX_STRINGTAB_SIZE (objfile));
+ OBJSTAT (objfile, sz_strtab += DBX_STRINGTAB_SIZE (objfile));
/* Now read in the string table in one big gulp. */
static int symbuf_idx;
static int symbuf_end;
+/* cont_elem is used for continuing information in cfront.
+ It saves information about which types need to be fixed up and
+ completed after all the stabs are read. */
+struct cont_elem
+ {
+ /* sym and stabsstring for continuing information in cfront */
+ struct symbol * sym;
+ char * stabs;
+ /* state dependancies (statics that must be preserved) */
+ int sym_idx;
+ int sym_end;
+ int symnum;
+ /* other state dependancies include:
+ (assumption is that these will not change since process_now FIXME!!)
+ stringtab_global
+ n_stabs
+ objfile
+ symfile_bfd */
+};
+static struct cont_elem cont_list[100];
+static int cont_count = 0;
+
+void
+process_later(sym,p)
+ struct symbol * sym;
+ char * p;
+{
+ /* save state so we can process these stabs later */
+ cont_list[cont_count].sym_idx = symbuf_idx;
+ cont_list[cont_count].sym_end = symbuf_end;
+ cont_list[cont_count].symnum = symnum;
+ cont_list[cont_count].sym = sym;
+ cont_list[cont_count].stabs = p;
+ cont_count++;
+}
+
+void
+process_now(objfile)
+ struct objfile * objfile;
+{
+ int i;
+ /* save original state */
+ int save_symbuf_idx = symbuf_idx;
+ int save_symbuf_end = symbuf_end;
+ int save_symnum = symnum;
+ for (i=0; i<cont_count; i++)
+ {
+ /* set state as if we were parsing stabs strings
+ for this symbol */
+ symbuf_idx = cont_list[i].sym_idx; /* statics used by gdb */
+ symbuf_end = cont_list[i].sym_end;
+ symnum = cont_list[i].symnum;
+ resolve_cfront_continuation(objfile,cont_list[i].sym,cont_list[i].stabs);
+ }
+ /* restore original state */
+ symbuf_idx = save_symbuf_idx;
+ symbuf_end = save_symbuf_end;
+ symnum = save_symnum;
+ cont_count=0; /* reset for next run */
+}
+
+
/* Name of last function encountered. Used in Solaris to approximate
object file boundaries. */
static char *last_function_name;
call this function to get the continuation. */
static char *
-dbx_next_symbol_text ()
+dbx_next_symbol_text (objfile)
+ struct objfile *objfile;
{
if (symbuf_idx == symbuf_end)
fill_symbuf (symfile_bfd);
symnum++;
SWAP_SYMBOL(&symbuf[symbuf_idx], symfile_bfd);
+ OBJSTAT (objfile, n_stabs++);
return symbuf[symbuf_idx++].n_strx + stringtab_global
+ file_string_table_offset;
}
}
name = (char *) bfd_asymbol_name (*rel->sym_ptr_ptr);
- prim_record_minimal_symbol
- (obsavestring (name, strlen (name), &objfile -> symbol_obstack),
- address,
- mst_solib_trampoline,
- objfile);
+ prim_record_minimal_symbol (name, address, mst_solib_trampoline,
+ objfile);
}
do_cleanups (back_to);
int nsl;
int past_first_source_file = 0;
CORE_ADDR last_o_file_start = 0;
+ CORE_ADDR last_function_start = 0;
struct cleanup *back_to;
bfd *abfd;
if (bufp->n_type == (unsigned char)N_SLINE) continue;
SWAP_SYMBOL (bufp, abfd);
+ OBJSTAT (objfile, n_stabs++);
/* Ok. There is a lot of code duplicated in the rest of this
switch statement (for efficiency reasons). Since I don't
char *filename;
CORE_ADDR textlow;
int ldsymoff;
- struct partial_symbol *global_syms;
- struct partial_symbol *static_syms;
+ struct partial_symbol **global_syms;
+ struct partial_symbol **static_syms;
{
struct partial_symtab *result =
start_psymtab_common(objfile, section_offsets,
fill_symbuf (abfd);
bufp = &symbuf[symbuf_idx++];
SWAP_SYMBOL (bufp, abfd);
+ OBJSTAT (objfile, n_stabs++);
SET_NAMESTRING ();
fill_symbuf(abfd);
bufp = &symbuf[symbuf_idx++];
SWAP_SYMBOL (bufp, abfd);
+ OBJSTAT (objfile, n_stabs++);
type = bufp->n_type;
if (last_source_start_addr == 0)
last_source_start_addr = text_offset;
- pst->symtab = end_symtab (text_offset + text_size, 0, 0, objfile,
- SECT_OFF_TEXT);
+ /* In reordered executables last_source_start_addr may not be the
+ lower bound for this symtab, instead use text_offset which comes
+ from pst->textlow which is correct. */
+ if (last_source_start_addr > text_offset)
+ last_source_start_addr = text_offset;
+
+ pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT);
+
+ if (ARM_DEMANGLING) /* process incomplete C++ types now */
+ process_now(objfile);
+
end_stabs ();
}
{
case N_FUN:
case N_FNAME:
+
+ if (! strcmp (name, ""))
+ {
+ /* This N_FUN marks the end of a function. This closes off the
+ current block. */
+ within_function = 0;
+ new = pop_context ();
+
+ /* Make a block for the local symbols within. */
+ finish_block (new->name, &local_symbols, new->old_blocks,
+ function_start_offset, function_start_offset + valu,
+ objfile);
+ break;
+ }
+
/* Relocate for dynamic loading */
valu += ANOFFSET (section_offsets, SECT_OFF_TEXT);
goto define_a_symbol;
patch_subfile_names (current_subfile, name);
break; /* Ignore repeated SOs */
}
- end_symtab (valu, 0, 0, objfile, SECT_OFF_TEXT);
+ end_symtab (valu, objfile, SECT_OFF_TEXT);
end_stabs ();
}
&& SYMBOL_NAME (m) [l] == '\0')
/* last_pc_address was in this function */
valu = SYMBOL_VALUE (m);
- else if (m && STREQN (SYMBOL_NAME (m+1), name, l)
+ else if (m && SYMBOL_NAME (m+1)
+ && STREQN (SYMBOL_NAME (m+1), name, l)
&& SYMBOL_NAME (m+1) [l] == '\0')
/* last_pc_address was in last function */
valu = SYMBOL_VALUE (m+1);
error ("ridiculous string table size: %d bytes", stabstrsize);
DBX_STRINGTAB (objfile) = (char *)
obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1);
+ OBJSTAT (objfile, sz_strtab += stabstrsize+1);
/* Now read in the string table in one big gulp. */
error ("ridiculous string table size: %d bytes", stabstrsize);
DBX_STRINGTAB (objfile) = (char *)
obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1);
+ OBJSTAT (objfile, sz_strtab += stabstrsize+1);
/* Now read in the string table in one big gulp. */
error ("ridiculous string table size: %d bytes", DBX_STRINGTAB_SIZE (objfile));
DBX_STRINGTAB (objfile) = (char *)
obstack_alloc (&objfile->psymbol_obstack, DBX_STRINGTAB_SIZE (objfile) + 1);
+ OBJSTAT (objfile, sz_strtab += DBX_STRINGTAB_SIZE (objfile) + 1);
/* Now read in the string table in one big gulp. */
dbx_symfile_read (objfile, section_offsets, 0);
}
\f
-/* Parse the user's idea of an offset for dynamic linking, into our idea
- of how to represent it for fast symbol reading. */
-
-static struct section_offsets *
-dbx_symfile_offsets (objfile, addr)
- struct objfile *objfile;
- CORE_ADDR addr;
-{
- struct section_offsets *section_offsets;
- int i;
-
- objfile->num_sections = SECT_OFF_MAX;
- section_offsets = (struct section_offsets *)
- obstack_alloc (&objfile -> psymbol_obstack,
- sizeof (struct section_offsets)
- + sizeof (section_offsets->offsets) * (SECT_OFF_MAX-1));
-
- for (i = 0; i < SECT_OFF_MAX; i++)
- ANOFFSET (section_offsets, i) = addr;
-
- return section_offsets;
-}
-\f
static struct sym_fns aout_sym_fns =
{
bfd_target_aout_flavour,
dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
dbx_symfile_read, /* sym_read: read a symbol file into symtab */
dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
- dbx_symfile_offsets, /* sym_offsets: parse user's offsets to internal form */
+ default_symfile_offsets,
+ /* sym_offsets: parse user's offsets to internal form */
NULL /* next: pointer to next struct sym_fns */
};