mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2025-02-21 10:02:26 +00:00
Add tracking of object files (that contain symbols) to gdb.
This includes a "struct objfile" that owns symtabs and psymtabs that were read in from that binary file. See ChangeLog.
This commit is contained in:
parent
c466820795
commit
a048c8f537
@ -1,3 +1,77 @@
|
||||
Sat Nov 9 00:40:32 1991 John Gilmore (gnu at cygnus.com)
|
||||
|
||||
Add tracking of object files (that contain symbols) to gdb.
|
||||
This includes a "struct objfile" that owns symtabs and psymtabs
|
||||
that were read in from that binary file.
|
||||
|
||||
* symfile.h: Add struct objfile. Add pointer to the objfile
|
||||
into the struct sym_fns.
|
||||
Replace global `symfile' and `symfile_mtime' with
|
||||
`symfile_objfile'. Add global object_files chain.
|
||||
|
||||
* symfile.c: Move param.h above symtab.h.
|
||||
(sort_misc_function_vector): Add.
|
||||
(syms_from_objfile): Was syms_from_bfd.
|
||||
(symfile_open): Now returns objfile.
|
||||
(allocate_objfile): New.
|
||||
(free_objfile): New, replacing free_all_.*symtabs.
|
||||
(symfile_init): Takes objfile arg, puts it in sym_fns result.
|
||||
(reread_symbols): Searches whole chain of objfiles.
|
||||
(allocate_symtab): Takes objfile as new parameter, chains them.
|
||||
Handle INIT_EXTRA_SYMTAB_INFO.
|
||||
(free_all_psymtabs, free_all_symtabs): Move here from symmisc.c.
|
||||
|
||||
* dbxread.c: Make more errors into complaints.
|
||||
(push_subfile, pop_subfile): Move to buildsym.c.
|
||||
(dbx_symfile_read, dbx_symfile_init, fill_symbuf, read_dbx_symtab,
|
||||
start_psymtab, psymtab_to_symtab_1, read_ofile_symtab,
|
||||
dbx_psymtab_to_symtab, ): Use bfd ops, don't use file descriptor.
|
||||
Pass objfile. Change callers.
|
||||
(fill_symbuf, SWAP_SYMBOL): Take bfd as arg.
|
||||
(read_dbx_symtab): Just wipe out new symbols, not all, on error.
|
||||
(end_psymtab): Blow away psymtab if empty.
|
||||
(process_symbol_pair): Swallow into read_ofile_symtab.
|
||||
(process_one_symbol): Use push_context and pop_context.
|
||||
(virtual_context): Delete #if 0'd obsolete stuff.
|
||||
|
||||
* buildsym.c (end_symtab): Pass objfile.
|
||||
(dbx_lookup_type): Handle null typevector.
|
||||
(dbx_alloc_type): Check file number, not sym number, for -1.
|
||||
(find_symbol_in_list): Add for xcoffread.
|
||||
(start_symtab): Default typevector is empty. Keep reusing same
|
||||
context_stack.
|
||||
(end_symtab): Take objfile argument and pass it to
|
||||
allocate_symtab. Don't make a symtab if no blocks or symbols.
|
||||
Handle empty typevector.
|
||||
(push_context): New function for context stack nesting.
|
||||
(read_type): Mark FIXME where we need to reintroduce type smashing.
|
||||
|
||||
* buildsym.h (pop_context): Macro, paired with push_context.
|
||||
(subfile_stack): Move here from dbxread.c.
|
||||
|
||||
* coffread.c (end_symtab, read_coff_symtab): Take and use objfile arg.
|
||||
(read_coff_symtab): Cleanup by freeing objfile, not all symtabs.
|
||||
|
||||
* mipsread.c (read_mips_symtab, parse_partial_symbols, parse_fdr,
|
||||
new_psymtab, new_symtab): Take and use objfile arg.
|
||||
|
||||
* dwarfread.c (scan_compilation_units, start_psymtab,
|
||||
process_dies, end_symtab, dwarf_build_psymtabs,
|
||||
read_lexical_block_scope, read_func_scope, read_file_scope): Take
|
||||
and use objfile argument.
|
||||
(psymtab_to_symtab_1, read_ofile_symtab): Don't take or use file
|
||||
descriptor. Use BFD internal functions instead.
|
||||
(end_symtab): Call global allocate_symtab.
|
||||
|
||||
* elfread.c: Minor changes to accommodate objfiles.
|
||||
* symtab.h: partial_symbol_table has no symfile_name member now.
|
||||
(fn_fieldlists voffset): avoid non-int bitfield.
|
||||
(struct symtab): Add objfile * and objfile_chain * of symtabs.
|
||||
(struct partial_symtab): Add objfile * and objfile_chain * of
|
||||
psymtabs. Remove symfile_name.
|
||||
|
||||
* symfile.h, symfile.c, symtab.h: Lint
|
||||
|
||||
Fri Nov 8 23:38:48 1991 John Gilmore (gnu at cygnus.com)
|
||||
|
||||
* command.c: Include param.h.
|
||||
|
261
gdb/buildsym.c
261
gdb/buildsym.c
@ -49,7 +49,7 @@ extern void new_object_header_files ();
|
||||
extern char *next_symbol_text ();
|
||||
extern int hashname ();
|
||||
extern void patch_block_stabs (); /* AIX xcoffread.c */
|
||||
#define patch_block_stabs abort /* FIXME scaffolding */
|
||||
extern struct type *builtin_type (); /* AIX xcoffread.c */
|
||||
|
||||
|
||||
static void cleanup_undefined_types ();
|
||||
@ -118,6 +118,7 @@ dbx_lookup_type (typenums)
|
||||
int typenums[2];
|
||||
{
|
||||
register int filenum = typenums[0], index = typenums[1];
|
||||
unsigned old_len;
|
||||
|
||||
if (filenum < 0 || filenum >= n_this_object_header_files)
|
||||
error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
|
||||
@ -127,14 +128,21 @@ dbx_lookup_type (typenums)
|
||||
{
|
||||
/* Type is defined outside of header files.
|
||||
Find it in this object file's type vector. */
|
||||
while (index >= type_vector_length)
|
||||
if (index >= type_vector_length)
|
||||
{
|
||||
type_vector_length *= 2;
|
||||
old_len = type_vector_length;
|
||||
if (old_len == 0) {
|
||||
type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
|
||||
type_vector = (struct type **)
|
||||
malloc (type_vector_length * sizeof (struct type *));
|
||||
}
|
||||
while (index >= type_vector_length)
|
||||
type_vector_length *= 2;
|
||||
type_vector = (struct type **)
|
||||
xrealloc (type_vector,
|
||||
(type_vector_length * sizeof (struct type *)));
|
||||
bzero (&type_vector[type_vector_length / 2],
|
||||
type_vector_length * sizeof (struct type *) / 2);
|
||||
bzero (&type_vector[old_len],
|
||||
(type_vector_length - old_len) * sizeof (struct type *));
|
||||
}
|
||||
return &type_vector[index];
|
||||
}
|
||||
@ -181,7 +189,6 @@ dbx_create_type ()
|
||||
/* Make sure there is a type allocated for type numbers TYPENUMS
|
||||
and return the type object.
|
||||
This can create an empty (zeroed) type object.
|
||||
OBSOLETE -- call dbx_create_type instead -- FIXME:
|
||||
TYPENUMS may be (-1, -1) to return a new type object that is not
|
||||
put into the type vector, and so may not be referred to by number. */
|
||||
|
||||
@ -192,14 +199,13 @@ dbx_alloc_type (typenums)
|
||||
register struct type **type_addr;
|
||||
register struct type *type;
|
||||
|
||||
if (typenums[1] != -1)
|
||||
if (typenums[0] != -1)
|
||||
{
|
||||
type_addr = dbx_lookup_type (typenums);
|
||||
type = *type_addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
abort(); /* FIXME -- Must give a real type number now */
|
||||
type_addr = 0;
|
||||
type = 0;
|
||||
}
|
||||
@ -246,6 +252,26 @@ add_symbol_to_list (symbol, listhead)
|
||||
(*listhead)->symbol[(*listhead)->nsyms++] = symbol;
|
||||
}
|
||||
|
||||
/* Find a symbol on a pending list. */
|
||||
struct symbol *
|
||||
find_symbol_in_list (list, name, length)
|
||||
struct pending *list;
|
||||
char *name;
|
||||
int length;
|
||||
{
|
||||
int j;
|
||||
|
||||
while (list) {
|
||||
for (j = list->nsyms; --j >= 0; ) {
|
||||
char *pp = SYMBOL_NAME (list->symbol[j]);
|
||||
if (*pp == *name && strncmp (pp, name, length) == 0 && pp[length] == '\0')
|
||||
return list->symbol[j];
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* At end of reading syms, or in case of quit,
|
||||
really free as many `struct pending's as we can easily find. */
|
||||
|
||||
@ -309,13 +335,13 @@ finish_block (symbol, listhead, old_blocks, start, end)
|
||||
|
||||
/* Count the length of the list of symbols. */
|
||||
|
||||
for (next = *listhead, i = 0; next; i += next->nsyms, next = next->next)
|
||||
for (next = *listhead, i = 0;
|
||||
next;
|
||||
i += next->nsyms, next = next->next)
|
||||
/*EMPTY*/;
|
||||
|
||||
block = (struct block *) obstack_alloc (symbol_obstack,
|
||||
(sizeof (struct block)
|
||||
+ ((i - 1)
|
||||
* sizeof (struct symbol *))));
|
||||
(sizeof (struct block) + ((i - 1) * sizeof (struct symbol *))));
|
||||
|
||||
/* Copy the symbols into the block. */
|
||||
|
||||
@ -496,6 +522,42 @@ start_subfile (name, dirname)
|
||||
subfile->line_vector = 0;
|
||||
}
|
||||
|
||||
/* Handle the N_BINCL and N_EINCL symbol types
|
||||
that act like N_SOL for switching source files
|
||||
(different subfiles, as we call them) within one object file,
|
||||
but using a stack rather than in an arbitrary order. */
|
||||
|
||||
void
|
||||
push_subfile ()
|
||||
{
|
||||
register struct subfile_stack *tem
|
||||
= (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack));
|
||||
|
||||
tem->next = subfile_stack;
|
||||
subfile_stack = tem;
|
||||
if (current_subfile == 0 || current_subfile->name == 0)
|
||||
abort ();
|
||||
tem->name = current_subfile->name;
|
||||
tem->prev_index = header_file_prev_index;
|
||||
}
|
||||
|
||||
char *
|
||||
pop_subfile ()
|
||||
{
|
||||
register char *name;
|
||||
register struct subfile_stack *link = subfile_stack;
|
||||
|
||||
if (link == 0)
|
||||
abort ();
|
||||
|
||||
name = link->name;
|
||||
subfile_stack = link->next;
|
||||
header_file_prev_index = link->prev_index;
|
||||
free (link);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/* Manage the vector of line numbers for each subfile. */
|
||||
|
||||
void
|
||||
@ -561,18 +623,19 @@ start_symtab (name, dirname, start_addr)
|
||||
file_stabs = 0; /* AIX COFF */
|
||||
within_function = 0;
|
||||
|
||||
/* Context stack is initially empty, with room for 10 levels. */
|
||||
context_stack_size = INITIAL_CONTEXT_STACK_SIZE;
|
||||
context_stack = (struct context_stack *)
|
||||
xmalloc (context_stack_size * sizeof (struct context_stack));
|
||||
/* Context stack is initially empty. Allocate first one with room for
|
||||
10 levels; reuse it forever afterward. */
|
||||
if (context_stack == 0) {
|
||||
context_stack_size = INITIAL_CONTEXT_STACK_SIZE;
|
||||
context_stack = (struct context_stack *)
|
||||
xmalloc (context_stack_size * sizeof (struct context_stack));
|
||||
}
|
||||
context_stack_depth = 0;
|
||||
|
||||
new_object_header_files ();
|
||||
|
||||
type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
|
||||
type_vector = (struct type **)
|
||||
xmalloc (type_vector_length * sizeof (struct type *));
|
||||
bzero (type_vector, type_vector_length * sizeof (struct type *));
|
||||
type_vector_length = 0;
|
||||
type_vector = (struct type **) 0;
|
||||
|
||||
/* Initialize the list of sub source files with one entry
|
||||
for this file (the top-level source file). */
|
||||
@ -590,15 +653,15 @@ start_symtab (name, dirname, start_addr)
|
||||
END_ADDR is the address of the end of the file's text. */
|
||||
|
||||
struct symtab *
|
||||
end_symtab (end_addr, sort_pending, sort_linevec)
|
||||
end_symtab (end_addr, sort_pending, sort_linevec, objfile)
|
||||
CORE_ADDR end_addr;
|
||||
int sort_pending;
|
||||
int sort_linevec;
|
||||
struct objfile *objfile;
|
||||
{
|
||||
register struct symtab *symtab;
|
||||
register struct blockvector *blockvector;
|
||||
register struct subfile *subfile;
|
||||
register struct linetable *lv;
|
||||
struct subfile *nextsub;
|
||||
|
||||
/* Finish the lexical context of the last function in the file;
|
||||
@ -612,13 +675,18 @@ end_symtab (end_addr, sort_pending, sort_linevec)
|
||||
/* Make a block for the local symbols within. */
|
||||
finish_block (cstk->name, &local_symbols, cstk->old_blocks,
|
||||
cstk->start_addr, end_addr);
|
||||
|
||||
/* Debug: if context stack still has something in it, we are in
|
||||
trouble. */
|
||||
if (context_stack_depth > 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* It is unfortunate that in aixcoff, pending blocks might not be ordered
|
||||
in this stage. Especially, blocks for static functions will show up at
|
||||
the end. We need to sort them, so tools like `find_pc_function' and
|
||||
`find_pc_block' can work reliably. */
|
||||
if (sort_pending) {
|
||||
if (sort_pending && pending_blocks) {
|
||||
/* FIXME! Remove this horrid bubble sort and use qsort!!! */
|
||||
int swapped;
|
||||
do {
|
||||
@ -660,54 +728,104 @@ end_symtab (end_addr, sort_pending, sort_linevec)
|
||||
global_stabs = 0;
|
||||
}
|
||||
|
||||
/* Define the STATIC_BLOCK and GLOBAL_BLOCK, and build the blockvector. */
|
||||
finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr);
|
||||
finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr);
|
||||
blockvector = make_blockvector ();
|
||||
if (pending_blocks == 0
|
||||
&& file_symbols == 0
|
||||
&& global_symbols == 0) {
|
||||
/* Ignore symtabs that have no functions with real debugging info */
|
||||
blockvector = NULL;
|
||||
} else {
|
||||
/* Define the STATIC_BLOCK and GLOBAL_BLOCK, and build the blockvector. */
|
||||
finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr);
|
||||
finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr);
|
||||
blockvector = make_blockvector ();
|
||||
}
|
||||
|
||||
/* Now create the symtab objects proper, one for each subfile. */
|
||||
/* (The main file is the last one on the chain.) */
|
||||
|
||||
for (subfile = subfiles; subfile; subfile = nextsub)
|
||||
{
|
||||
if (subfile->line_vector) {
|
||||
/* First, shrink the linetable to make more memory. */
|
||||
subfile->line_vector = (struct linetable *)
|
||||
xrealloc (subfile->line_vector, (sizeof (struct linetable)
|
||||
+ subfile->line_vector->nitems * sizeof (struct linetable_entry)));
|
||||
/* If we have blocks of symbols, make a symtab.
|
||||
Otherwise, just ignore this file and any line number info in it. */
|
||||
symtab = 0;
|
||||
if (blockvector) {
|
||||
if (subfile->line_vector) {
|
||||
/* First, shrink the linetable to make more memory. */
|
||||
subfile->line_vector = (struct linetable *)
|
||||
xrealloc (subfile->line_vector, (sizeof (struct linetable)
|
||||
+ subfile->line_vector->nitems * sizeof (struct linetable_entry)));
|
||||
|
||||
if (sort_linevec)
|
||||
qsort (subfile->line_vector->item, subfile->line_vector->nitems,
|
||||
sizeof (struct linetable_entry), compare_line_numbers);
|
||||
if (sort_linevec)
|
||||
qsort (subfile->line_vector->item, subfile->line_vector->nitems,
|
||||
sizeof (struct linetable_entry), compare_line_numbers);
|
||||
}
|
||||
|
||||
/* Now, allocate a symbol table. */
|
||||
symtab = allocate_symtab (subfile->name, objfile);
|
||||
|
||||
/* Fill in its components. */
|
||||
symtab->blockvector = blockvector;
|
||||
symtab->linetable = subfile->line_vector;
|
||||
symtab->dirname = subfile->dirname;
|
||||
symtab->free_code = free_linetable;
|
||||
symtab->free_ptr = 0;
|
||||
|
||||
/* Link the new symtab into the list of such. */
|
||||
symtab->next = symtab_list;
|
||||
symtab_list = symtab;
|
||||
} else {
|
||||
/* No blocks for this file. Delete any line number info we have
|
||||
for it. */
|
||||
if (subfile->line_vector)
|
||||
free (subfile->line_vector);
|
||||
}
|
||||
|
||||
/* Now, allocate a symbol table. */
|
||||
symtab = allocate_symtab (subfile->name);
|
||||
|
||||
/* Fill in its components. */
|
||||
symtab->blockvector = blockvector;
|
||||
symtab->linetable = subfile->line_vector;
|
||||
symtab->dirname = subfile->dirname;
|
||||
symtab->free_code = free_linetable;
|
||||
symtab->free_ptr = 0;
|
||||
|
||||
/* Link the new symtab into the list of such. */
|
||||
symtab->next = symtab_list;
|
||||
symtab_list = symtab;
|
||||
|
||||
nextsub = subfile->next;
|
||||
free (subfile);
|
||||
}
|
||||
|
||||
free ((char *) type_vector);
|
||||
if (type_vector)
|
||||
free ((char *) type_vector);
|
||||
type_vector = 0;
|
||||
type_vector_length = -1;
|
||||
type_vector_length = 0;
|
||||
|
||||
last_source_file = 0;
|
||||
current_subfile = 0;
|
||||
|
||||
return symtab;
|
||||
}
|
||||
|
||||
|
||||
/* Push a context block. Args are an identifying nesting level (checkable
|
||||
when you pop it), and the starting PC address of this context. */
|
||||
|
||||
struct context_stack *
|
||||
push_context (desc, valu)
|
||||
int desc;
|
||||
CORE_ADDR valu;
|
||||
{
|
||||
register struct context_stack *new;
|
||||
|
||||
if (context_stack_depth == context_stack_size)
|
||||
{
|
||||
context_stack_size *= 2;
|
||||
context_stack = (struct context_stack *)
|
||||
xrealloc (context_stack,
|
||||
(context_stack_size
|
||||
* sizeof (struct context_stack)));
|
||||
}
|
||||
|
||||
new = &context_stack[context_stack_depth++];
|
||||
new->depth = desc;
|
||||
new->locals = local_symbols;
|
||||
new->old_blocks = pending_blocks;
|
||||
new->start_addr = valu;
|
||||
new->name = 0;
|
||||
|
||||
local_symbols = 0;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/* Initialize anything that needs initializing when starting to read
|
||||
a fresh piece of a symbol file, e.g. reading in the stuff corresponding
|
||||
@ -1245,7 +1363,7 @@ define_symbol (valu, string, desc, type)
|
||||
scope? */
|
||||
/* Add a type to the list of undefined types to be checked through
|
||||
once this file has been read in. */
|
||||
static void
|
||||
void
|
||||
add_undefined_type (type)
|
||||
struct type *type;
|
||||
{
|
||||
@ -1375,11 +1493,28 @@ read_type (pp)
|
||||
{
|
||||
read_type_number (pp, typenums);
|
||||
|
||||
/* Detect random reference to type not yet defined.
|
||||
Allocate a type object but leave it zeroed. */
|
||||
/* Type is not being defined here. Either it already exists,
|
||||
or this is a forward reference to it. dbx_alloc_type handles
|
||||
both cases. */
|
||||
if (**pp != '=')
|
||||
return dbx_alloc_type (typenums);
|
||||
|
||||
/* Type is being defined here. */
|
||||
#if 0 /* Callers aren't prepared for a NULL result! FIXME -- metin! */
|
||||
{
|
||||
struct type *tt;
|
||||
|
||||
/* if such a type already exists, this is an unnecessary duplication
|
||||
of the stab string, which is common in (RS/6000) xlc generated
|
||||
objects. In that case, simply return NULL and let the caller take
|
||||
care of it. */
|
||||
|
||||
tt = *dbx_lookup_type (typenums);
|
||||
if (tt && tt->length && tt->code)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
*pp += 2;
|
||||
}
|
||||
else
|
||||
@ -1389,7 +1524,7 @@ read_type (pp)
|
||||
typenums[0] = typenums[1] = -1;
|
||||
*pp += 1;
|
||||
}
|
||||
|
||||
|
||||
switch ((*pp)[-1])
|
||||
{
|
||||
case 'x':
|
||||
@ -1521,6 +1656,9 @@ read_type (pp)
|
||||
(*pp)--;
|
||||
read_type_number (pp, xtypenums);
|
||||
type = *dbx_lookup_type (xtypenums);
|
||||
/* fall through */
|
||||
|
||||
after_digits:
|
||||
if (type == 0)
|
||||
type = builtin_type_void;
|
||||
if (typenums[0] != -1)
|
||||
@ -1529,6 +1667,15 @@ read_type (pp)
|
||||
|
||||
case '*':
|
||||
type1 = read_type (pp);
|
||||
/* FIXME -- we should be doing smash_to_XXX types here. */
|
||||
#if 0
|
||||
/* postponed type decoration should be allowed. */
|
||||
if (typenums[1] > 0 && typenums[1] < type_vector_length &&
|
||||
(type = type_vector[typenums[1]])) {
|
||||
smash_to_pointer_type (type, type1);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
type = lookup_pointer_type (type1);
|
||||
if (typenums[0] != -1)
|
||||
*dbx_lookup_type (typenums) = type;
|
||||
@ -2687,6 +2834,7 @@ read_range_type (pp, typenums)
|
||||
|
||||
else if (n2 == 0 && n3 == -1)
|
||||
{
|
||||
/* FIXME -- this confuses host and target type sizes. */
|
||||
if (sizeof (int) == sizeof (long))
|
||||
return builtin_type_unsigned_int;
|
||||
else
|
||||
@ -2699,7 +2847,7 @@ read_range_type (pp, typenums)
|
||||
return builtin_type_char;
|
||||
|
||||
/* Assumptions made here: Subrange of self is equivalent to subrange
|
||||
of int. */
|
||||
of int. FIXME: Host and target type-sizes assumed the same. */
|
||||
else if (n2 == 0
|
||||
&& (self_subrange ||
|
||||
*dbx_lookup_type (rangenums) == builtin_type_int))
|
||||
@ -2841,6 +2989,7 @@ read_args (pp, end)
|
||||
char **pp;
|
||||
int end;
|
||||
{
|
||||
/* FIXME! Remove this arbitrary limit! */
|
||||
struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
|
||||
int n = 0;
|
||||
|
||||
|
@ -34,6 +34,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#endif
|
||||
|
||||
extern void add_symbol_to_list ();
|
||||
struct symbol *find_symbol_in_list ();
|
||||
extern void read_type_number ();
|
||||
extern struct type *read_type ();
|
||||
extern struct type *read_range_type ();
|
||||
extern struct type *read_enum_type ();
|
||||
@ -44,12 +46,19 @@ extern struct type **dbx_lookup_type ();
|
||||
extern long read_number ();
|
||||
extern void finish_block ();
|
||||
extern struct blockvector *make_blockvector ();
|
||||
extern void add_undefined_type ();
|
||||
extern void really_free_pendings ();
|
||||
extern void start_subfile ();
|
||||
extern void push_subfile ();
|
||||
extern char *pop_subfile ();
|
||||
extern struct symtab *end_symtab ();
|
||||
extern void scan_file_globals ();
|
||||
extern void buildsym_new_init ();
|
||||
extern void buildsym_init ();
|
||||
extern struct context_stack *push_context ();
|
||||
extern void record_line ();
|
||||
extern void start_symtab ();
|
||||
extern struct symbol *define_symbol ();
|
||||
|
||||
/* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
|
||||
|
||||
@ -161,12 +170,12 @@ EXTERN int common_block_i;
|
||||
|
||||
struct context_stack
|
||||
{
|
||||
struct pending *locals;
|
||||
struct pending_block *old_blocks;
|
||||
struct symbol *name;
|
||||
CORE_ADDR start_addr;
|
||||
struct pending *locals; /* Outer locals at the time we entered */
|
||||
struct pending_block *old_blocks; /* Pointer into blocklist as of entry */
|
||||
struct symbol *name; /* Name of function, if any, defining context*/
|
||||
CORE_ADDR start_addr; /* PC where this context starts */
|
||||
CORE_ADDR end_addr; /* Temp slot for exception handling. */
|
||||
int depth;
|
||||
int depth; /* For error-checking matching push/pop */
|
||||
};
|
||||
|
||||
EXTERN struct context_stack *context_stack;
|
||||
@ -178,6 +187,13 @@ EXTERN int context_stack_depth;
|
||||
|
||||
EXTERN int context_stack_size;
|
||||
|
||||
/* Macro "function" for popping contexts from the stack. Pushing is done
|
||||
by a real function, push_context. This returns a pointer to a struct
|
||||
context_stack. */
|
||||
|
||||
#define pop_context() \
|
||||
(&context_stack[--context_stack_depth]);
|
||||
|
||||
/* Nonzero if within a function (so symbols should be local,
|
||||
if nothing says specifically). */
|
||||
|
||||
@ -262,3 +278,19 @@ EXTERN int *this_object_header_files;
|
||||
EXTERN int n_this_object_header_files;
|
||||
|
||||
EXTERN int n_allocated_this_object_header_files;
|
||||
|
||||
/* When a header file is getting special overriding definitions
|
||||
for one source file, record here the header_files index
|
||||
of its normal definition vector.
|
||||
At other times, this is -1. */
|
||||
|
||||
EXTERN int header_file_prev_index;
|
||||
|
||||
struct subfile_stack
|
||||
{
|
||||
struct subfile_stack *next;
|
||||
char *name;
|
||||
int prev_index;
|
||||
};
|
||||
|
||||
EXTERN struct subfile_stack *subfile_stack;
|
||||
|
@ -57,8 +57,6 @@ static void enter_linenos ();
|
||||
static void read_one_sym ();
|
||||
|
||||
extern int fclose ();
|
||||
extern void free_all_symtabs ();
|
||||
extern void free_all_psymtabs ();
|
||||
|
||||
/* To be an sdb debug type, type must have at least a basic or primary
|
||||
derived type. Using this rather than checking against T_NULL is
|
||||
@ -517,7 +515,8 @@ complete_symtab (name, start_addr, size)
|
||||
struct symtab for that file and put it in the list of all such. */
|
||||
|
||||
static void
|
||||
end_symtab ()
|
||||
end_symtab (objfile)
|
||||
struct objfile *objfile;
|
||||
{
|
||||
register struct symtab *symtab;
|
||||
register struct context_stack *cstk;
|
||||
@ -555,7 +554,7 @@ end_symtab ()
|
||||
blockvector = make_blockvector ();
|
||||
|
||||
/* Now create the symtab object for this source file. */
|
||||
symtab = allocate_symtab (last_source_file);
|
||||
symtab = allocate_symtab (last_source_file, objfile);
|
||||
|
||||
/* Fill in its components. */
|
||||
symtab->blockvector = blockvector;
|
||||
@ -734,7 +733,7 @@ coff_symfile_read (sf, addr, mainline)
|
||||
int mainline;
|
||||
{
|
||||
struct coff_symfile_info *info = (struct coff_symfile_info *)sf->sym_private;
|
||||
bfd *abfd = sf->sym_bfd;
|
||||
bfd *abfd = sf->objfile->obfd;
|
||||
coff_data_type *cdata = coff_data (abfd);
|
||||
char *name = bfd_get_filename (abfd);
|
||||
int desc;
|
||||
@ -785,12 +784,7 @@ coff_symfile_read (sf, addr, mainline)
|
||||
|
||||
val = init_stringtab (desc, stringtab_offset);
|
||||
if (val < 0)
|
||||
{
|
||||
free_all_symtabs (); /* FIXME blows whole symtab */
|
||||
printf ("\"%s\": can't get string table", name);
|
||||
fflush (stdout);
|
||||
return;
|
||||
}
|
||||
error ("\"%s\": can't get string table", name);
|
||||
make_cleanup (free_stringtab, 0);
|
||||
|
||||
/* Position to read the symbol table. Do not read it all at once. */
|
||||
@ -804,7 +798,7 @@ coff_symfile_read (sf, addr, mainline)
|
||||
/* Now that the executable file is positioned at symbol table,
|
||||
process it and define symbols accordingly. */
|
||||
|
||||
read_coff_symtab (desc, num_symbols);
|
||||
read_coff_symtab (desc, num_symbols, sf->objfile);
|
||||
|
||||
patch_opaque_types ();
|
||||
|
||||
@ -824,8 +818,7 @@ coff_symfile_read (sf, addr, mainline)
|
||||
static void
|
||||
coff_new_init ()
|
||||
{
|
||||
/* There seems to be nothing to do except free_all_symtabs and set
|
||||
symfile to zero, which is done by our caller. */
|
||||
/* Nothin' to do */
|
||||
}
|
||||
|
||||
/* Simplified internal version of coff symbol table information */
|
||||
@ -846,9 +839,10 @@ struct coff_symbol {
|
||||
We read them one at a time using read_one_sym (). */
|
||||
|
||||
static void
|
||||
read_coff_symtab (desc, nsyms)
|
||||
read_coff_symtab (desc, nsyms, objfile)
|
||||
int desc;
|
||||
int nsyms;
|
||||
struct objfile *objfile;
|
||||
{
|
||||
int newfd; /* Avoid multiple closes on same desc */
|
||||
FILE *stream;
|
||||
@ -881,8 +875,10 @@ read_coff_symtab (desc, nsyms)
|
||||
fatal ("Too many open files");
|
||||
stream = fdopen (newfd, "r");
|
||||
|
||||
old_chain = make_cleanup (free_all_symtabs, 0);
|
||||
/* These cleanups will be discarded below if we succeed. */
|
||||
old_chain = make_cleanup (free_objfile, objfile);
|
||||
make_cleanup (fclose, stream);
|
||||
|
||||
nlist_stream_global = stream;
|
||||
nlist_nsyms_global = nsyms;
|
||||
last_source_file = 0;
|
||||
@ -913,7 +909,7 @@ read_coff_symtab (desc, nsyms)
|
||||
if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE)
|
||||
{
|
||||
if (last_source_file)
|
||||
end_symtab ();
|
||||
end_symtab (objfile);
|
||||
|
||||
start_symtab ();
|
||||
complete_symtab ("_globals_", 0, first_object_file_end);
|
||||
@ -966,7 +962,7 @@ read_coff_symtab (desc, nsyms)
|
||||
*/
|
||||
if (last_source_file)
|
||||
{
|
||||
end_symtab ();
|
||||
end_symtab (objfile);
|
||||
start_symtab ();
|
||||
}
|
||||
in_source_file = 1;
|
||||
@ -1153,7 +1149,7 @@ read_coff_symtab (desc, nsyms)
|
||||
}
|
||||
|
||||
if (last_source_file)
|
||||
end_symtab ();
|
||||
end_symtab (objfile);
|
||||
fclose (stream);
|
||||
discard_cleanups (old_chain);
|
||||
}
|
||||
|
171
gdb/dwarfread.c
171
gdb/dwarfread.c
@ -308,10 +308,11 @@ EXFUN (scan_partial_symbols, (char *thisdie AND char *enddie));
|
||||
static void
|
||||
EXFUN (scan_compilation_units,
|
||||
(char *filename AND CORE_ADDR addr AND char *thisdie AND char *enddie
|
||||
AND unsigned int dbfoff AND unsigned int lnoffset));
|
||||
AND unsigned int dbfoff AND unsigned int lnoffset
|
||||
AND struct objfile *objfile));
|
||||
|
||||
static struct partial_symtab *
|
||||
EXFUN(start_psymtab, (char *symfile_name AND CORE_ADDR addr
|
||||
EXFUN(start_psymtab, (struct objfile *objfile AND CORE_ADDR addr
|
||||
AND char *filename AND CORE_ADDR textlow
|
||||
AND CORE_ADDR texthigh AND int dbfoff
|
||||
AND int curoff AND int culength AND int lnfoff
|
||||
@ -339,17 +340,14 @@ static void
|
||||
EXFUN(dwarf_psymtab_to_symtab, (struct partial_symtab *pst));
|
||||
|
||||
static void
|
||||
EXFUN(psymtab_to_symtab_1, (struct partial_symtab *pst AND int desc ));
|
||||
EXFUN(psymtab_to_symtab_1, (struct partial_symtab *pst));
|
||||
|
||||
static struct symtab *
|
||||
EXFUN(read_ofile_symtab, (struct partial_symtab *pst AND int desc));
|
||||
EXFUN(read_ofile_symtab, (struct partial_symtab *pst));
|
||||
|
||||
static void
|
||||
EXFUN(process_dies, (char *thisdie AND char *enddie));
|
||||
|
||||
static void
|
||||
EXFUN(read_lexical_block_scope,
|
||||
(struct dieinfo *dip AND char *thisdie AND char *enddie));
|
||||
EXFUN(process_dies,
|
||||
(char *thisdie AND char *enddie AND struct objfile *objfile));
|
||||
|
||||
static void
|
||||
EXFUN(read_structure_scope,
|
||||
@ -379,19 +377,12 @@ EXFUN(struct_type,
|
||||
static struct type *
|
||||
EXFUN(enum_type, (struct dieinfo *dip));
|
||||
|
||||
static void
|
||||
EXFUN(read_func_scope,
|
||||
(struct dieinfo *dip AND char *thisdie AND char *enddie));
|
||||
|
||||
static void
|
||||
EXFUN(read_file_scope,
|
||||
(struct dieinfo *dip AND char *thisdie AND char *enddie));
|
||||
|
||||
static void
|
||||
EXFUN(start_symtab, (void));
|
||||
|
||||
static void
|
||||
EXFUN(end_symtab, (char *filename AND long language));
|
||||
EXFUN(end_symtab,
|
||||
(char *filename AND long language AND struct objfile *objfile));
|
||||
|
||||
static int
|
||||
EXFUN(scopecount, (struct scopenode *node));
|
||||
@ -474,7 +465,8 @@ SYNOPSIS
|
||||
|
||||
void dwarf_build_psymtabs (int desc, char *filename, CORE_ADDR addr,
|
||||
int mainline, unsigned int dbfoff, unsigned int dbsize,
|
||||
unsigned int lnoffset, unsigned int lnsize)
|
||||
unsigned int lnoffset, unsigned int lnsize,
|
||||
struct objfile *objfile)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
@ -497,7 +489,8 @@ RETURNS
|
||||
|
||||
void
|
||||
DEFUN(dwarf_build_psymtabs,
|
||||
(desc, filename, addr, mainline, dbfoff, dbsize, lnoffset, lnsize),
|
||||
(desc, filename, addr, mainline, dbfoff, dbsize, lnoffset, lnsize,
|
||||
objfile),
|
||||
int desc AND
|
||||
char *filename AND
|
||||
CORE_ADDR addr AND
|
||||
@ -505,7 +498,8 @@ DEFUN(dwarf_build_psymtabs,
|
||||
unsigned int dbfoff AND
|
||||
unsigned int dbsize AND
|
||||
unsigned int lnoffset AND
|
||||
unsigned int lnsize)
|
||||
unsigned int lnsize AND
|
||||
struct objfile *objfile)
|
||||
{
|
||||
struct cleanup *back_to;
|
||||
|
||||
@ -536,7 +530,7 @@ DEFUN(dwarf_build_psymtabs,
|
||||
unit to locate the full DWARF information later. */
|
||||
|
||||
scan_compilation_units (filename, addr, dbbase, dbbase + dbsize,
|
||||
dbfoff, lnoffset);
|
||||
dbfoff, lnoffset, objfile);
|
||||
|
||||
/* Go over the miscellaneous functions and install them in the miscellaneous
|
||||
function vector. */
|
||||
@ -691,13 +685,14 @@ DESCRIPTION
|
||||
*/
|
||||
|
||||
static void
|
||||
DEFUN(read_lexical_block_scope, (dip, thisdie, enddie),
|
||||
DEFUN(read_lexical_block_scope, (dip, thisdie, enddie, objfile),
|
||||
struct dieinfo *dip AND
|
||||
char *thisdie AND
|
||||
char *enddie)
|
||||
char *enddie AND
|
||||
struct objfile *objfile)
|
||||
{
|
||||
openscope (NULL, dip -> at_low_pc, dip -> at_high_pc);
|
||||
process_dies (thisdie + dip -> dielength, enddie);
|
||||
process_dies (thisdie + dip -> dielength, enddie, objfile);
|
||||
closescope ();
|
||||
}
|
||||
|
||||
@ -1369,11 +1364,6 @@ LOCAL FUNCTION
|
||||
|
||||
read_func_scope -- process all dies within a function scope
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
static void read_func_scope (struct dieinfo dip, char *thisdie,
|
||||
char *enddie)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Process all dies within a given function scope. We are passed
|
||||
@ -1390,10 +1380,11 @@ DESCRIPTION
|
||||
*/
|
||||
|
||||
static void
|
||||
DEFUN(read_func_scope, (dip, thisdie, enddie),
|
||||
DEFUN(read_func_scope, (dip, thisdie, enddie, objfile),
|
||||
struct dieinfo *dip AND
|
||||
char *thisdie AND
|
||||
char *enddie)
|
||||
char *enddie AND
|
||||
struct objfile *objfile)
|
||||
{
|
||||
struct symbol *sym;
|
||||
|
||||
@ -1409,7 +1400,7 @@ DEFUN(read_func_scope, (dip, thisdie, enddie),
|
||||
}
|
||||
sym = new_symbol (dip);
|
||||
openscope (sym, dip -> at_low_pc, dip -> at_high_pc);
|
||||
process_dies (thisdie + dip -> dielength, enddie);
|
||||
process_dies (thisdie + dip -> dielength, enddie, objfile);
|
||||
closescope ();
|
||||
}
|
||||
|
||||
@ -1419,11 +1410,6 @@ LOCAL FUNCTION
|
||||
|
||||
read_file_scope -- process all dies within a file scope
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
static void read_file_scope (struct dieinfo *dip, char *thisdie
|
||||
char *enddie)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Process all dies within a given file scope. We are passed a
|
||||
@ -1441,10 +1427,11 @@ DESCRIPTION
|
||||
*/
|
||||
|
||||
static void
|
||||
DEFUN(read_file_scope, (dip, thisdie, enddie),
|
||||
DEFUN(read_file_scope, (dip, thisdie, enddie, objfile),
|
||||
struct dieinfo *dip AND
|
||||
char *thisdie AND
|
||||
char *enddie)
|
||||
char *enddie AND
|
||||
struct objfile *objfile)
|
||||
{
|
||||
struct cleanup *back_to;
|
||||
|
||||
@ -1460,9 +1447,9 @@ DEFUN(read_file_scope, (dip, thisdie, enddie),
|
||||
start_symtab ();
|
||||
openscope (NULL, dip -> at_low_pc, dip -> at_high_pc);
|
||||
decode_line_numbers (lnbase);
|
||||
process_dies (thisdie + dip -> dielength, enddie);
|
||||
process_dies (thisdie + dip -> dielength, enddie, objfile);
|
||||
closescope ();
|
||||
end_symtab (dip -> at_name, dip -> at_language);
|
||||
end_symtab (dip -> at_name, dip -> at_language, objfile);
|
||||
do_cleanups (back_to);
|
||||
utypes = NULL;
|
||||
numutypes = 0;
|
||||
@ -1516,7 +1503,8 @@ DESCRIPTION
|
||||
*/
|
||||
|
||||
static void
|
||||
DEFUN(process_dies, (thisdie, enddie), char *thisdie AND char *enddie)
|
||||
DEFUN(process_dies, (thisdie, enddie, objfile),
|
||||
char *thisdie AND char *enddie AND struct objfile *objfile)
|
||||
{
|
||||
char *nextdie;
|
||||
struct dieinfo di;
|
||||
@ -1546,17 +1534,17 @@ DEFUN(process_dies, (thisdie, enddie), char *thisdie AND char *enddie)
|
||||
switch (di.dietag)
|
||||
{
|
||||
case TAG_compile_unit:
|
||||
read_file_scope (&di, thisdie, nextdie);
|
||||
read_file_scope (&di, thisdie, nextdie, objfile);
|
||||
break;
|
||||
case TAG_global_subroutine:
|
||||
case TAG_subroutine:
|
||||
if (!di.at_is_external_p)
|
||||
{
|
||||
read_func_scope (&di, thisdie, nextdie);
|
||||
read_func_scope (&di, thisdie, nextdie, objfile);
|
||||
}
|
||||
break;
|
||||
case TAG_lexical_block:
|
||||
read_lexical_block_scope (&di, thisdie, nextdie);
|
||||
read_lexical_block_scope (&di, thisdie, nextdie, objfile);
|
||||
break;
|
||||
case TAG_structure_type:
|
||||
case TAG_union_type:
|
||||
@ -1599,7 +1587,8 @@ DESCRIPTION
|
||||
*/
|
||||
|
||||
static void
|
||||
DEFUN(end_symtab, (filename, language), char *filename AND long language)
|
||||
DEFUN(end_symtab, (filename, language, objfile),
|
||||
char *filename AND long language AND struct objfile *objfile)
|
||||
{
|
||||
struct symtab *symtab;
|
||||
struct blockvector *blockvector;
|
||||
@ -1621,15 +1610,14 @@ DEFUN(end_symtab, (filename, language), char *filename AND long language)
|
||||
|
||||
/* Now create the symtab object for this source file. */
|
||||
|
||||
symtab = (struct symtab *) xmalloc (sizeof (struct symtab));
|
||||
(void) memset (symtab, 0, sizeof (struct symtab));
|
||||
symtab = allocate_symtab (savestring (filename, strlen (filename)),
|
||||
objfile);
|
||||
|
||||
symtab -> free_ptr = 0;
|
||||
|
||||
/* Fill in its components. */
|
||||
symtab -> blockvector = blockvector;
|
||||
symtab -> free_code = free_linetable;
|
||||
symtab -> filename = savestring (filename, strlen (filename));
|
||||
|
||||
/* Save the line number information. */
|
||||
|
||||
@ -1640,8 +1628,6 @@ DEFUN(end_symtab, (filename, language), char *filename AND long language)
|
||||
nbytes += (line_vector_index - 1) * sizeof (struct linetable_entry);
|
||||
}
|
||||
symtab -> linetable = (struct linetable *) xrealloc (line_vector, nbytes);
|
||||
symtab -> nlines = 0;
|
||||
symtab -> line_charpos = 0;
|
||||
|
||||
/* FIXME: The following may need to be expanded for other languages */
|
||||
switch (language)
|
||||
@ -2269,29 +2255,21 @@ LOCAL FUNCTION
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
static struct symtab *read_ofile_symtab (struct partial_symtab *pst,
|
||||
int desc)
|
||||
static struct symtab *read_ofile_symtab (struct partial_symtab *pst)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
DESC is the file descriptor for the file, positioned at the
|
||||
beginning of the symtab
|
||||
SYM_SIZE is the size of the symbol section to read
|
||||
TEXT_OFFSET is the beginning of the text segment we are reading
|
||||
symbols for
|
||||
TEXT_SIZE is the size of the text segment read in.
|
||||
OFFSET is a relocation offset which gets added to each symbol
|
||||
|
||||
OFFSET is a relocation offset which gets added to each symbol (FIXME).
|
||||
*/
|
||||
|
||||
static struct symtab *
|
||||
DEFUN(read_ofile_symtab, (pst, desc),
|
||||
struct partial_symtab *pst AND
|
||||
int desc)
|
||||
DEFUN(read_ofile_symtab, (pst),
|
||||
struct partial_symtab *pst)
|
||||
{
|
||||
struct cleanup *back_to;
|
||||
long lnsize;
|
||||
int foffset;
|
||||
bfd *abfd = pst->objfile->obfd;
|
||||
|
||||
/* Allocate a buffer for the entire chunk of DIE's for this compilation
|
||||
unit, seek to the location in the file, and read in all the DIE's. */
|
||||
@ -2300,8 +2278,8 @@ DEFUN(read_ofile_symtab, (pst, desc),
|
||||
dbbase = xmalloc (DBLENGTH(pst));
|
||||
dbroff = DBROFF(pst);
|
||||
foffset = DBFOFF(pst) + dbroff;
|
||||
if ((lseek (desc, foffset, 0) != foffset) ||
|
||||
(read (desc, dbbase, DBLENGTH(pst)) != DBLENGTH(pst)))
|
||||
if (bfd_seek (abfd, foffset, 0) ||
|
||||
(bfd_read (dbbase, DBLENGTH(pst), 1, abfd) != DBLENGTH(pst)))
|
||||
{
|
||||
free (dbbase);
|
||||
error ("can't read DWARF data");
|
||||
@ -2317,14 +2295,14 @@ DEFUN(read_ofile_symtab, (pst, desc),
|
||||
lnbase = NULL;
|
||||
if (LNFOFF (pst))
|
||||
{
|
||||
if ((lseek (desc, LNFOFF (pst), 0) != LNFOFF (pst)) ||
|
||||
(read (desc, &lnsize, sizeof(long)) != sizeof(long)))
|
||||
if (bfd_seek (abfd, LNFOFF (pst), 0) ||
|
||||
(bfd_read (&lnsize, sizeof(long), 1, abfd) != sizeof(long)))
|
||||
{
|
||||
error ("can't read DWARF line number table size");
|
||||
}
|
||||
lnbase = xmalloc (lnsize);
|
||||
if ((lseek (desc, LNFOFF (pst), 0) != LNFOFF (pst)) ||
|
||||
(read (desc, lnbase, lnsize) != lnsize))
|
||||
if (bfd_seek (abfd, LNFOFF (pst), 0) ||
|
||||
(bfd_read (lnbase, lnsize, 1, abfd) != lnsize))
|
||||
{
|
||||
free (lnbase);
|
||||
error ("can't read DWARF line numbers");
|
||||
@ -2332,7 +2310,7 @@ DEFUN(read_ofile_symtab, (pst, desc),
|
||||
make_cleanup (free, lnbase);
|
||||
}
|
||||
|
||||
process_dies (dbbase, dbbase + DBLENGTH(pst));
|
||||
process_dies (dbbase, dbbase + DBLENGTH(pst), pst->objfile);
|
||||
do_cleanups (back_to);
|
||||
return (symtab_list);
|
||||
}
|
||||
@ -2345,7 +2323,7 @@ LOCAL FUNCTION
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
static void psymtab_to_symtab_1 (struct partial_symtab *pst, int desc)
|
||||
static void psymtab_to_symtab_1 (struct partial_symtab *pst)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
@ -2356,9 +2334,8 @@ DESCRIPTION
|
||||
|
||||
static void
|
||||
DEFUN(psymtab_to_symtab_1,
|
||||
(pst, desc),
|
||||
struct partial_symtab *pst AND
|
||||
int desc)
|
||||
(pst),
|
||||
struct partial_symtab *pst)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -2388,13 +2365,13 @@ DEFUN(psymtab_to_symtab_1,
|
||||
wrap_here (""); /* Flush output */
|
||||
fflush (stdout);
|
||||
}
|
||||
psymtab_to_symtab_1 (pst -> dependencies[i], desc);
|
||||
psymtab_to_symtab_1 (pst -> dependencies[i]);
|
||||
}
|
||||
|
||||
if (DBLENGTH(pst)) /* Otherwise it's a dummy */
|
||||
{
|
||||
/* Init stuff necessary for reading in symbols */
|
||||
pst -> symtab = read_ofile_symtab (pst, desc);
|
||||
pst -> symtab = read_ofile_symtab (pst);
|
||||
if (info_verbose)
|
||||
{
|
||||
printf_filtered ("%d DIE's, sorting...", diecount);
|
||||
@ -2451,30 +2428,7 @@ DEFUN(dwarf_psymtab_to_symtab, (pst), struct partial_symtab *pst)
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
/* Open symbol file. Symbol_file_command guarantees that the symbol
|
||||
file name will be absolute, so there is no need for openp. */
|
||||
desc = open (pst -> symfile_name, O_RDONLY, 0);
|
||||
|
||||
if (desc < 0)
|
||||
{
|
||||
perror_with_name (pst -> symfile_name);
|
||||
}
|
||||
|
||||
sym_bfd = bfd_fdopenr (pst -> symfile_name, NULL, desc);
|
||||
if (!sym_bfd)
|
||||
{
|
||||
(void) close (desc);
|
||||
error ("Could not open `%s' to read symbols: %s",
|
||||
pst -> symfile_name, bfd_errmsg (bfd_error));
|
||||
}
|
||||
old_chain = make_cleanup (bfd_close, sym_bfd);
|
||||
if (!bfd_check_format (sym_bfd, bfd_object))
|
||||
{
|
||||
error ("\"%s\": can't read symbols: %s.",
|
||||
pst -> symfile_name, bfd_errmsg (bfd_error));
|
||||
}
|
||||
|
||||
psymtab_to_symtab_1 (pst, desc);
|
||||
psymtab_to_symtab_1 (pst);
|
||||
|
||||
#if 0 /* FIXME: Check to see what dbxread is doing here and see if
|
||||
we need to do an equivalent or is this something peculiar to
|
||||
@ -2560,9 +2514,9 @@ DESCRIPTION
|
||||
|
||||
static struct partial_symtab *
|
||||
DEFUN(start_psymtab,
|
||||
(symfile_name, addr, filename, textlow, texthigh, dbfoff, curoff,
|
||||
(objfile, addr, filename, textlow, texthigh, dbfoff, curoff,
|
||||
culength, lnfoff, global_syms, static_syms),
|
||||
char *symfile_name AND
|
||||
struct objfile *objfile AND
|
||||
CORE_ADDR addr AND
|
||||
char *filename AND
|
||||
CORE_ADDR textlow AND
|
||||
@ -2580,7 +2534,7 @@ DEFUN(start_psymtab,
|
||||
obstack_alloc (psymbol_obstack, sizeof (struct partial_symtab));
|
||||
(void) memset (result, 0, sizeof (struct partial_symtab));
|
||||
result -> addr = addr;
|
||||
result -> symfile_name = create_name (symfile_name, psymbol_obstack);
|
||||
result -> objfile = objfile;
|
||||
result -> filename = create_name (filename, psymbol_obstack);
|
||||
result -> textlow = textlow;
|
||||
result -> texthigh = texthigh;
|
||||
@ -2799,13 +2753,14 @@ RETURNS
|
||||
|
||||
static void
|
||||
DEFUN(scan_compilation_units,
|
||||
(filename, addr, thisdie, enddie, dbfoff, lnoffset),
|
||||
(filename, addr, thisdie, enddie, dbfoff, lnoffset, objfile),
|
||||
char *filename AND
|
||||
CORE_ADDR addr AND
|
||||
char *thisdie AND
|
||||
char *enddie AND
|
||||
unsigned int dbfoff AND
|
||||
unsigned int lnoffset)
|
||||
unsigned int lnoffset AND
|
||||
struct objfile *objfile)
|
||||
{
|
||||
char *nextdie;
|
||||
struct dieinfo di;
|
||||
@ -2839,7 +2794,7 @@ DEFUN(scan_compilation_units,
|
||||
curoff = thisdie - dbbase;
|
||||
culength = nextdie - thisdie;
|
||||
curlnoffset = di.at_stmt_list_p ? lnoffset + di.at_stmt_list : 0;
|
||||
pst = start_psymtab (filename, addr, di.at_name,
|
||||
pst = start_psymtab (objfile, addr, di.at_name,
|
||||
di.at_low_pc, di.at_high_pc,
|
||||
dbfoff, curoff, culength, curlnoffset,
|
||||
global_psymbols.next,
|
||||
|
@ -48,7 +48,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include "symtab.h"
|
||||
#include "ansidecl.h"
|
||||
|
||||
extern int EXFUN(strcmp, (CONST char *a, CONST char *b));
|
||||
extern int EXFUN (strcmp, (CONST char *a, CONST char *b));
|
||||
extern int EXFUN (dwarf_build_psymtabs,
|
||||
(int desc, char *filename, CORE_ADDR addr, int mainline,
|
||||
unsigned int dbfoff, unsigned int dbsize, unsigned int lnoffset,
|
||||
unsigned int lnsize, struct objfile *objfile));
|
||||
|
||||
#define STREQ(a,b) (strcmp((a),(b))==0)
|
||||
|
||||
struct elfinfo {
|
||||
@ -127,7 +132,7 @@ DEFUN(elf_symfile_read, (sf, addr, mainline),
|
||||
CORE_ADDR addr AND
|
||||
int mainline)
|
||||
{
|
||||
bfd *abfd = sf -> sym_bfd;
|
||||
bfd *abfd = sf->objfile->obfd;
|
||||
struct elfinfo ei;
|
||||
|
||||
bfd_map_over_sections (abfd, elf_locate_sections, &ei);
|
||||
@ -138,7 +143,7 @@ DEFUN(elf_symfile_read, (sf, addr, mainline),
|
||||
bfd_get_filename (abfd),
|
||||
addr, mainline,
|
||||
ei.dboffset, ei.dbsize,
|
||||
ei.lnoffset, ei.lnsize);
|
||||
ei.lnoffset, ei.lnsize, sf->objfile);
|
||||
}
|
||||
if (!partial_symtab_list)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include <sym.h>
|
||||
#endif /* not CMUCS */
|
||||
|
||||
#include "ecoff.h"
|
||||
#include "coff-mips.h"
|
||||
|
||||
struct coff_exec {
|
||||
struct external_filehdr f;
|
||||
@ -63,9 +63,7 @@ struct coff_exec {
|
||||
|
||||
For mipsread this structure contains the index of the FDR that this psymtab
|
||||
represents and a pointer to the symbol table header HDRR from the symbol
|
||||
file that the psymtab was created from.
|
||||
|
||||
Note: This code is currently untested. -fnf */
|
||||
file that the psymtab was created from. */
|
||||
|
||||
#define FDR_IDX(p) (((struct symloc *)((p)->read_symtab_private))->fdr_idx)
|
||||
#define CUR_HDR(p) (((struct symloc *)((p)->read_symtab_private))->cur_hdr)
|
||||
@ -229,7 +227,6 @@ void
|
||||
mipscoff_symfile_init (sf)
|
||||
struct sym_fns *sf;
|
||||
{
|
||||
bfd *abfd = sf->sym_bfd;
|
||||
sf->sym_private = NULL;
|
||||
}
|
||||
|
||||
@ -240,7 +237,7 @@ mipscoff_symfile_read(sf, addr, mainline)
|
||||
int mainline;
|
||||
{
|
||||
struct coff_symfile_info *info = (struct coff_symfile_info *)sf->sym_private;
|
||||
bfd *abfd = sf->sym_bfd;
|
||||
bfd *abfd = sf->objfile->obfd;
|
||||
char *name = bfd_get_filename (abfd);
|
||||
int desc;
|
||||
register int val;
|
||||
@ -265,7 +262,7 @@ mipscoff_symfile_read(sf, addr, mainline)
|
||||
/* Now that the executable file is positioned at symbol table,
|
||||
process it and define symbols accordingly. */
|
||||
|
||||
read_mips_symtab(abfd, desc);
|
||||
read_mips_symtab(sf->objfile, desc);
|
||||
|
||||
/* Go over the misc symbol bunches and install them in vector. */
|
||||
|
||||
@ -547,15 +544,15 @@ fdr_name(name)
|
||||
FIXME: INCREMENTAL is currently always zero, though it should not be. */
|
||||
|
||||
static
|
||||
read_mips_symtab (abfd, desc)
|
||||
bfd *abfd;
|
||||
read_mips_symtab (objfile, desc)
|
||||
struct objfile *objfile;
|
||||
int desc;
|
||||
{
|
||||
CORE_ADDR end_of_text_seg;
|
||||
|
||||
read_the_mips_symtab(abfd, desc, &end_of_text_seg);
|
||||
read_the_mips_symtab(objfile->obfd, desc, &end_of_text_seg);
|
||||
|
||||
parse_partial_symbols(end_of_text_seg);
|
||||
parse_partial_symbols(end_of_text_seg, objfile);
|
||||
|
||||
/*
|
||||
* Check to make sure file was compiled with -g.
|
||||
@ -565,7 +562,7 @@ read_mips_symtab (abfd, desc)
|
||||
if (max_gdbinfo == 0)
|
||||
printf (
|
||||
"\n%s not compiled with -g, debugging support is limited.\n",
|
||||
bfd_get_filename (abfd));
|
||||
objfile->name);
|
||||
printf(
|
||||
"You should compile with -g2 or -g3 for best debugging support.\n");
|
||||
fflush(stdout);
|
||||
@ -1554,8 +1551,9 @@ parse_one_file(fh, f_idx, bound)
|
||||
the symtab we are reading. */
|
||||
|
||||
static
|
||||
parse_partial_symbols(end_of_text_seg)
|
||||
parse_partial_symbols(end_of_text_seg, objfile)
|
||||
int end_of_text_seg;
|
||||
struct objfile *objfile;
|
||||
{
|
||||
int f_idx, s_idx, h_max, stat_idx;
|
||||
HDRR *hdr;
|
||||
@ -1585,14 +1583,14 @@ parse_partial_symbols(end_of_text_seg)
|
||||
fdr_to_pst = (struct pst_map *)xzalloc((hdr->ifdMax+1) * sizeof *fdr_to_pst);
|
||||
fdr_to_pst++;
|
||||
{
|
||||
struct partial_symtab * pst = new_psymtab("");
|
||||
struct partial_symtab * pst = new_psymtab("", objfile);
|
||||
fdr_to_pst[-1].pst = pst;
|
||||
FDR_IDX(pst) = -1;
|
||||
}
|
||||
|
||||
/* Now scan the FDRs, mostly for dependencies */
|
||||
for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++)
|
||||
(void) parse_fdr(f_idx, 1);
|
||||
(void) parse_fdr(f_idx, 1, objfile);
|
||||
|
||||
/* Take a good guess at how many symbols we might ever need */
|
||||
h_max = hdr->iextMax;
|
||||
@ -1804,8 +1802,10 @@ parse_partial_symbols(end_of_text_seg)
|
||||
of recursion we are called (to pretty up debug traces) */
|
||||
|
||||
static struct partial_symtab *
|
||||
parse_fdr(f_idx, lev)
|
||||
parse_fdr(f_idx, lev, objfile)
|
||||
int f_idx;
|
||||
int lev;
|
||||
struct objfile *objfile;
|
||||
{
|
||||
register FDR *fh;
|
||||
register struct partial_symtab *pst;
|
||||
@ -1822,7 +1822,7 @@ parse_fdr(f_idx, lev)
|
||||
max_glevel = fh->glevel;
|
||||
|
||||
/* Make a new partial_symtab */
|
||||
pst = new_psymtab(fh->rss);
|
||||
pst = new_psymtab(fh->rss, objfile);
|
||||
if (fh->cpd == 0){
|
||||
pst->textlow = 0;
|
||||
pst->texthigh = 0;
|
||||
@ -1859,7 +1859,7 @@ parse_fdr(f_idx, lev)
|
||||
for (s_idx = s_id0; s_idx < fh->crfd; s_idx++) {
|
||||
RFDT *rh = (RFDT *) (fh->rfdBase) + s_idx;
|
||||
|
||||
pst->dependencies[s_idx-s_id0] = parse_fdr(*rh, lev+1);
|
||||
pst->dependencies[s_idx-s_id0] = parse_fdr(*rh, lev+1, objfile);
|
||||
}
|
||||
|
||||
return pst;
|
||||
@ -1897,11 +1897,12 @@ psymtab_to_symtab_1(pst, filename)
|
||||
f_max = pst->n_global_syms + pst->n_static_syms;
|
||||
if (FDR_IDX(pst) == -1) {
|
||||
fh = 0;
|
||||
st = new_symtab( "unknown", f_max, 0);
|
||||
st = new_symtab ("unknown", f_max, 0, pst->objfile);
|
||||
} else {
|
||||
fh = (FDR *) (cur_hdr->cbFdOffset) + FDR_IDX(pst);
|
||||
f_max += fh->csym + fh->cpd;
|
||||
st = new_symtab(pst->filename, 2 * f_max, 2 * fh->cline);
|
||||
st = new_symtab (pst->filename, 2 * f_max, 2 * fh->cline,
|
||||
pst->objfile);
|
||||
}
|
||||
|
||||
/* Read in all partial symbtabs on which this one is dependent.
|
||||
@ -2356,10 +2357,10 @@ reorder_psymtabs()
|
||||
|
||||
static
|
||||
struct symtab *
|
||||
new_symtab(name, maxsyms, maxlines)
|
||||
new_symtab(name, maxsyms, maxlines, objfile)
|
||||
char *name;
|
||||
{
|
||||
struct symtab *s = allocate_symtab (name);
|
||||
struct symtab *s = allocate_symtab (name, objfile);
|
||||
|
||||
LINETABLE(s) = new_linetable(maxlines);
|
||||
|
||||
@ -2382,8 +2383,9 @@ new_symtab(name, maxsyms, maxlines)
|
||||
/* Allocate a new partial_symtab NAME */
|
||||
|
||||
static struct partial_symtab *
|
||||
new_psymtab(name)
|
||||
new_psymtab(name, objfile)
|
||||
char *name;
|
||||
struct objfile *objfile;
|
||||
{
|
||||
struct partial_symtab *pst;
|
||||
|
||||
@ -2396,6 +2398,11 @@ new_psymtab(name)
|
||||
else
|
||||
pst->filename = name;
|
||||
|
||||
/* Chain it to its object file */
|
||||
pst->objfile = objfile;
|
||||
pst->objfile_chain = sym_objfile->psymtabs;
|
||||
sym_objfile->psymtabs = pst;
|
||||
|
||||
pst->next = partial_symtab_list;
|
||||
partial_symtab_list = pst;
|
||||
|
||||
|
26
gdb/symtab.h
26
gdb/symtab.h
@ -233,10 +233,6 @@ struct type
|
||||
/* The list of methods. */
|
||||
struct fn_field
|
||||
{
|
||||
#if 0
|
||||
/* The overloaded name */
|
||||
char *name;
|
||||
#endif
|
||||
/* The return value of the method */
|
||||
struct type *type;
|
||||
/* The argument list */
|
||||
@ -251,7 +247,7 @@ struct type
|
||||
unsigned int is_volatile : 1;
|
||||
/* Index into that baseclass's virtual function table,
|
||||
minus 2; else if static: VOFFSET_STATIC; else: 0. */
|
||||
unsigned long voffset : 30;
|
||||
unsigned voffset : 30;
|
||||
# define VOFFSET_STATIC 1
|
||||
} *fn_fields;
|
||||
|
||||
@ -543,6 +539,11 @@ struct symtab
|
||||
0 if not yet known. */
|
||||
char *fullname;
|
||||
|
||||
/* Object file from which this symbol information was read. */
|
||||
struct objfile *objfile;
|
||||
/* Chain of all symtabs owned by that objfile. */
|
||||
struct symtab *objfile_chain;
|
||||
|
||||
/* Anything extra for this symtab. This is for target machines
|
||||
with special debugging info of some sort (which cannot just
|
||||
be represented in a normal symtab). */
|
||||
@ -568,8 +569,11 @@ struct partial_symtab
|
||||
/* Name of the source file which this partial_symtab defines */
|
||||
char *filename;
|
||||
|
||||
/* Name of the symbol file from which symbols should be read. */
|
||||
char *symfile_name;
|
||||
/* Information about the object file from which symbols should be read. */
|
||||
struct objfile *objfile;
|
||||
/* Chain of psymtabs owned by this objfile */
|
||||
struct partial_symtab *objfile_chain;
|
||||
|
||||
/* Address relative to which the symbols in this file are. Need to
|
||||
relocate by this amount when reading in symbols from the symbol
|
||||
file. */
|
||||
@ -634,15 +638,12 @@ struct symtab *current_source_symtab;
|
||||
|
||||
int current_source_line;
|
||||
|
||||
#define BLOCKLIST(symtab) (symtab)->blockvector
|
||||
#define BLOCKVECTOR(symtab) (symtab)->blockvector
|
||||
|
||||
#define LINETABLE(symtab) (symtab)->linetable
|
||||
|
||||
/* Macros normally used to access components of symbol table structures. */
|
||||
|
||||
#define BLOCKLIST_NBLOCKS(blocklist) (blocklist)->nblocks
|
||||
#define BLOCKLIST_BLOCK(blocklist,n) (blocklist)->block[n]
|
||||
#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
|
||||
#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
|
||||
|
||||
@ -783,7 +784,6 @@ extern struct type *lookup_enum ();
|
||||
extern struct type *lookup_struct_elt_type ();
|
||||
extern struct type *lookup_pointer_type ();
|
||||
extern struct type *lookup_function_type ();
|
||||
extern struct type *lookup_basetype_type ();
|
||||
extern struct type *create_array_type ();
|
||||
extern struct symbol *block_function ();
|
||||
extern struct symbol *find_pc_function ();
|
||||
@ -802,7 +802,6 @@ extern int contained_in();
|
||||
extern struct type *lookup_reference_type ();
|
||||
extern struct type *lookup_member_type ();
|
||||
extern struct type *lookup_method_type ();
|
||||
extern struct type *lookup_class ();
|
||||
extern void smash_to_method_type ();
|
||||
void smash_to_member_type (
|
||||
#ifdef __STDC__
|
||||
@ -812,9 +811,6 @@ void smash_to_member_type (
|
||||
extern struct type *allocate_stub_method ();
|
||||
/* end of C++ stuff. */
|
||||
|
||||
extern void free_all_symtabs ();
|
||||
extern void free_all_psymtabs ();
|
||||
extern void free_inclink_symtabs ();
|
||||
extern void reread_symbols ();
|
||||
|
||||
extern struct type *builtin_type_void;
|
||||
|
Loading…
x
Reference in New Issue
Block a user