X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fdwarfread.c;h=13599fae35f045b3ee90503c225bb64278c535d8;hb=feb129926a8d12656f1ca4b7a8bb10268d3af4fb;hp=323ceaf0023960d8bc63132092d28bb8bd22d611;hpb=fa803dc60f0bf01297674c41d001798e18ade4dc;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index 323ceaf002..13599fae35 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -1,43 +1,43 @@ /* DWARF debugging format support for GDB. - Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 + Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1998 Free Software Foundation, Inc. Written by Fred Fish at Cygnus Support. Portions based on dbxread.c, mipsread.c, coffread.c, and dwarfread.c from a Data General SVR4 gdb port. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* -FIXME: Do we need to generate dependencies in partial symtabs? -(Perhaps we don't need to). + FIXME: Do we need to generate dependencies in partial symtabs? + (Perhaps we don't need to). -FIXME: Resolve minor differences between what information we put in the -partial symbol table and what dbxread puts in. For example, we don't yet -put enum constants there. And dbxread seems to invent a lot of typedefs -we never see. Use the new printpsym command to see the partial symbol table -contents. + FIXME: Resolve minor differences between what information we put in the + partial symbol table and what dbxread puts in. For example, we don't yet + put enum constants there. And dbxread seems to invent a lot of typedefs + we never see. Use the new printpsym command to see the partial symbol table + contents. -FIXME: Figure out a better way to tell gdb about the name of the function -contain the user's entry point (I.E. main()) + FIXME: Figure out a better way to tell gdb about the name of the function + contain the user's entry point (I.E. main()) -FIXME: See other FIXME's and "ifdef 0" scattered throughout the code for -other things to work on, if you get bored. :-) + FIXME: See other FIXME's and "ifdef 0" scattered throughout the code for + other things to work on, if you get bored. :-) -*/ + */ #include "defs.h" #include "symtab.h" @@ -47,7 +47,7 @@ other things to work on, if you get bored. :-) #include "elf/dwarf.h" #include "buildsym.h" #include "demangle.h" -#include "expression.h" /* Needed for enum exp_opcode in language.h, sigh... */ +#include "expression.h" /* Needed for enum exp_opcode in language.h, sigh... */ #include "language.h" #include "complaints.h" @@ -245,8 +245,8 @@ typedef unsigned int DIE_REF; /* Reference to a DIE */ /* External variables referenced. */ -extern int info_verbose; /* From main.c; nonzero => verbose */ -extern char *warning_pre_print; /* From utils.c */ +extern int info_verbose; /* From main.c; nonzero => verbose */ +extern char *warning_pre_print; /* From utils.c */ /* The DWARF debugging information consists of two major pieces, one is a block of DWARF Information Entries (DIE's) and the other @@ -272,74 +272,75 @@ extern char *warning_pre_print; /* From utils.c */ we may want to test for the presence of some attributes in the DIE, such as AT_low_pc, without restricting the values of the field, we need someway to note that we found such an attribute. - + */ - + typedef char BLOCK; -struct dieinfo { - char * die; /* Pointer to the raw DIE data */ - unsigned long die_length; /* Length of the raw DIE data */ - DIE_REF die_ref; /* Offset of this DIE */ - unsigned short die_tag; /* Tag for this DIE */ - unsigned long at_padding; - unsigned long at_sibling; - BLOCK * at_location; - char * at_name; - unsigned short at_fund_type; - BLOCK * at_mod_fund_type; - unsigned long at_user_def_type; - BLOCK * at_mod_u_d_type; - unsigned short at_ordering; - BLOCK * at_subscr_data; - unsigned long at_byte_size; - unsigned short at_bit_offset; - unsigned long at_bit_size; - BLOCK * at_element_list; - unsigned long at_stmt_list; - CORE_ADDR at_low_pc; - CORE_ADDR at_high_pc; - unsigned long at_language; - unsigned long at_member; - unsigned long at_discr; - BLOCK * at_discr_value; - BLOCK * at_string_length; - char * at_comp_dir; - char * at_producer; - unsigned long at_start_scope; - unsigned long at_stride_size; - unsigned long at_src_info; - char * at_prototyped; - unsigned int has_at_low_pc:1; - unsigned int has_at_stmt_list:1; - unsigned int has_at_byte_size:1; - unsigned int short_element_list:1; - - /* Kludge to identify register variables */ - - unsigned int isreg; - - /* Kludge to identify optimized out variables */ - - unsigned int optimized_out; - - /* Kludge to identify basereg references. - Nonzero if we have an offset relative to a basereg. */ - - unsigned int offreg; - - /* Kludge to identify which base register is it relative to. */ - - unsigned int basereg; -}; +struct dieinfo + { + char *die; /* Pointer to the raw DIE data */ + unsigned long die_length; /* Length of the raw DIE data */ + DIE_REF die_ref; /* Offset of this DIE */ + unsigned short die_tag; /* Tag for this DIE */ + unsigned long at_padding; + unsigned long at_sibling; + BLOCK *at_location; + char *at_name; + unsigned short at_fund_type; + BLOCK *at_mod_fund_type; + unsigned long at_user_def_type; + BLOCK *at_mod_u_d_type; + unsigned short at_ordering; + BLOCK *at_subscr_data; + unsigned long at_byte_size; + unsigned short at_bit_offset; + unsigned long at_bit_size; + BLOCK *at_element_list; + unsigned long at_stmt_list; + CORE_ADDR at_low_pc; + CORE_ADDR at_high_pc; + unsigned long at_language; + unsigned long at_member; + unsigned long at_discr; + BLOCK *at_discr_value; + BLOCK *at_string_length; + char *at_comp_dir; + char *at_producer; + unsigned long at_start_scope; + unsigned long at_stride_size; + unsigned long at_src_info; + char *at_prototyped; + unsigned int has_at_low_pc:1; + unsigned int has_at_stmt_list:1; + unsigned int has_at_byte_size:1; + unsigned int short_element_list:1; + + /* Kludge to identify register variables */ + + unsigned int isreg; + + /* Kludge to identify optimized out variables */ + + unsigned int optimized_out; + + /* Kludge to identify basereg references. + Nonzero if we have an offset relative to a basereg. */ + + unsigned int offreg; + + /* Kludge to identify which base register is it relative to. */ + + unsigned int basereg; + }; -static int diecount; /* Approximate count of dies for compilation unit */ +static int diecount; /* Approximate count of dies for compilation unit */ static struct dieinfo *curdie; /* For warnings and such */ -static char *dbbase; /* Base pointer to dwarf info */ -static int dbsize; /* Size of dwarf info in bytes */ -static int dbroff; /* Relative offset from start of .debug section */ -static char *lnbase; /* Base pointer to line section */ +static char *dbbase; /* Base pointer to dwarf info */ +static int dbsize; /* Size of dwarf info in bytes */ +static int dbroff; /* Relative offset from start of .debug section */ +static char *lnbase; /* Base pointer to line section */ /* This value is added to each symbol value. FIXME: Generalize to the section_offsets structure used by dbxread (once this is done, @@ -353,27 +354,28 @@ static struct section_offsets *base_section_offsets; /* We put a pointer to this structure in the read_symtab_private field of the psymtab. */ -struct dwfinfo { - /* Always the absolute file offset to the start of the ".debug" - section for the file containing the DIE's being accessed. */ - file_ptr dbfoff; - /* Relative offset from the start of the ".debug" section to the - first DIE to be accessed. When building the partial symbol - table, this value will be zero since we are accessing the - entire ".debug" section. When expanding a partial symbol - table entry, this value will be the offset to the first - DIE for the compilation unit containing the symbol that - triggers the expansion. */ - int dbroff; - /* The size of the chunk of DIE's being examined, in bytes. */ - int dblength; - /* The absolute file offset to the line table fragment. Ignored - when building partial symbol tables, but used when expanding - them, and contains the absolute file offset to the fragment - of the ".line" section containing the line numbers for the - current compilation unit. */ - file_ptr lnfoff; -}; +struct dwfinfo + { + /* Always the absolute file offset to the start of the ".debug" + section for the file containing the DIE's being accessed. */ + file_ptr dbfoff; + /* Relative offset from the start of the ".debug" section to the + first DIE to be accessed. When building the partial symbol + table, this value will be zero since we are accessing the + entire ".debug" section. When expanding a partial symbol + table entry, this value will be the offset to the first + DIE for the compilation unit containing the symbol that + triggers the expansion. */ + int dbroff; + /* The size of the chunk of DIE's being examined, in bytes. */ + int dblength; + /* The absolute file offset to the line table fragment. Ignored + when building partial symbol tables, but used when expanding + them, and contains the absolute file offset to the fragment + of the ".line" section containing the line numbers for the + current compilation unit. */ + file_ptr lnfoff; + }; #define DBFOFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->dbfoff) #define DBROFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->dbroff) @@ -430,7 +432,7 @@ static int numutypes; /* Max number of user type pointers */ FT_NUM_MEMBERS compile time constant, which is the number of predefined fundamental types gdb knows how to construct. */ -static struct type *ftypes[FT_NUM_MEMBERS]; /* Fundamental types */ +static struct type *ftypes[FT_NUM_MEMBERS]; /* Fundamental types */ /* Record the language for the compilation unit which is currently being processed. We know it once we have seen the TAG_compile_unit DIE, @@ -455,7 +457,7 @@ static int attribute_size PARAMS ((unsigned int)); static CORE_ADDR -target_to_host PARAMS ((char *, int, int, struct objfile *)); + target_to_host PARAMS ((char *, int, int, struct objfile *)); static void add_enum_psymbol PARAMS ((struct dieinfo *, struct objfile *)); @@ -506,19 +508,19 @@ read_structure_scope PARAMS ((struct dieinfo *, char *, char *, struct objfile *)); static struct type * -decode_array_element_type PARAMS ((char *)); + decode_array_element_type PARAMS ((char *)); static struct type * -decode_subscript_data_item PARAMS ((char *, char *)); + decode_subscript_data_item PARAMS ((char *, char *)); static void dwarf_read_array_type PARAMS ((struct dieinfo *)); static void -read_tag_pointer_type PARAMS ((struct dieinfo *dip)); +read_tag_pointer_type PARAMS ((struct dieinfo * dip)); static void -read_tag_string_type PARAMS ((struct dieinfo *dip)); +read_tag_string_type PARAMS ((struct dieinfo * dip)); static void read_subroutine_type PARAMS ((struct dieinfo *, char *, char *)); @@ -527,40 +529,40 @@ static void read_enumeration PARAMS ((struct dieinfo *, char *, char *, struct objfile *)); static struct type * -struct_type PARAMS ((struct dieinfo *, char *, char *, struct objfile *)); + struct_type PARAMS ((struct dieinfo *, char *, char *, struct objfile *)); static struct type * -enum_type PARAMS ((struct dieinfo *, struct objfile *)); + enum_type PARAMS ((struct dieinfo *, struct objfile *)); static void decode_line_numbers PARAMS ((char *)); static struct type * -decode_die_type PARAMS ((struct dieinfo *)); + decode_die_type PARAMS ((struct dieinfo *)); static struct type * -decode_mod_fund_type PARAMS ((char *)); + decode_mod_fund_type PARAMS ((char *)); static struct type * -decode_mod_u_d_type PARAMS ((char *)); + decode_mod_u_d_type PARAMS ((char *)); static struct type * -decode_modified_type PARAMS ((char *, unsigned int, int)); + decode_modified_type PARAMS ((char *, unsigned int, int)); static struct type * -decode_fund_type PARAMS ((unsigned int)); + decode_fund_type PARAMS ((unsigned int)); static char * -create_name PARAMS ((char *, struct obstack *)); + create_name PARAMS ((char *, struct obstack *)); static struct type * -lookup_utype PARAMS ((DIE_REF)); + lookup_utype PARAMS ((DIE_REF)); static struct type * -alloc_utype PARAMS ((DIE_REF, struct type *)); + alloc_utype PARAMS ((DIE_REF, struct type *)); static struct symbol * -new_symbol PARAMS ((struct dieinfo *, struct objfile *)); + new_symbol PARAMS ((struct dieinfo *, struct objfile *)); static void synthesize_typedef PARAMS ((struct dieinfo *, struct objfile *, @@ -573,42 +575,42 @@ static void set_cu_language PARAMS ((struct dieinfo *)); static struct type * -dwarf_fundamental_type PARAMS ((struct objfile *, int)); + dwarf_fundamental_type PARAMS ((struct objfile *, int)); /* -LOCAL FUNCTION + LOCAL FUNCTION - dwarf_fundamental_type -- lookup or create a fundamental type + dwarf_fundamental_type -- lookup or create a fundamental type -SYNOPSIS + SYNOPSIS - struct type * - dwarf_fundamental_type (struct objfile *objfile, int typeid) + struct type * + dwarf_fundamental_type (struct objfile *objfile, int typeid) -DESCRIPTION + DESCRIPTION - DWARF version 1 doesn't supply any fundamental type information, - so gdb has to construct such types. It has a fixed number of - fundamental types that it knows how to construct, which is the - union of all types that it knows how to construct for all languages - that it knows about. These are enumerated in gdbtypes.h. + DWARF version 1 doesn't supply any fundamental type information, + so gdb has to construct such types. It has a fixed number of + fundamental types that it knows how to construct, which is the + union of all types that it knows how to construct for all languages + that it knows about. These are enumerated in gdbtypes.h. - As an example, assume we find a DIE that references a DWARF - fundamental type of FT_integer. We first look in the ftypes - array to see if we already have such a type, indexed by the - gdb internal value of FT_INTEGER. If so, we simply return a - pointer to that type. If not, then we ask an appropriate - language dependent routine to create a type FT_INTEGER, using - defaults reasonable for the current target machine, and install - that type in ftypes for future reference. + As an example, assume we find a DIE that references a DWARF + fundamental type of FT_integer. We first look in the ftypes + array to see if we already have such a type, indexed by the + gdb internal value of FT_INTEGER. If so, we simply return a + pointer to that type. If not, then we ask an appropriate + language dependent routine to create a type FT_INTEGER, using + defaults reasonable for the current target machine, and install + that type in ftypes for future reference. -RETURNS + RETURNS - Pointer to a fundamental type. + Pointer to a fundamental type. -*/ + */ static struct type * dwarf_fundamental_type (objfile, typeid) @@ -626,7 +628,7 @@ dwarf_fundamental_type (objfile, typeid) if (ftypes[typeid] == NULL) { - ftypes[typeid] = cu_language_defn -> la_fund_type(objfile, typeid); + ftypes[typeid] = cu_language_defn->la_fund_type (objfile, typeid); } return (ftypes[typeid]); @@ -634,24 +636,24 @@ dwarf_fundamental_type (objfile, typeid) /* -LOCAL FUNCTION + LOCAL FUNCTION - set_cu_language -- set local copy of language for compilation unit + set_cu_language -- set local copy of language for compilation unit -SYNOPSIS + SYNOPSIS - void - set_cu_language (struct dieinfo *dip) + void + set_cu_language (struct dieinfo *dip) -DESCRIPTION + DESCRIPTION - Decode the language attribute for a compilation unit DIE and - remember what the language was. We use this at various times - when processing DIE's for a given compilation unit. + Decode the language attribute for a compilation unit DIE and + remember what the language was. We use this at various times + when processing DIE's for a given compilation unit. -RETURNS + RETURNS - No return value. + No return value. */ @@ -659,69 +661,69 @@ static void set_cu_language (dip) struct dieinfo *dip; { - switch (dip -> at_language) + switch (dip->at_language) { - case LANG_C89: - case LANG_C: - cu_language = language_c; - break; - case LANG_C_PLUS_PLUS: - cu_language = language_cplus; - break; - case LANG_CHILL: - cu_language = language_chill; - break; - case LANG_MODULA2: - cu_language = language_m2; - break; - case LANG_FORTRAN77: - case LANG_FORTRAN90: - cu_language = language_fortran; - break; - case LANG_ADA83: - case LANG_COBOL74: - case LANG_COBOL85: - case LANG_PASCAL83: - /* We don't know anything special about these yet. */ - cu_language = language_unknown; - break; - default: - /* If no at_language, try to deduce one from the filename */ - cu_language = deduce_language_from_filename (dip -> at_name); - break; + case LANG_C89: + case LANG_C: + cu_language = language_c; + break; + case LANG_C_PLUS_PLUS: + cu_language = language_cplus; + break; + case LANG_CHILL: + cu_language = language_chill; + break; + case LANG_MODULA2: + cu_language = language_m2; + break; + case LANG_FORTRAN77: + case LANG_FORTRAN90: + cu_language = language_fortran; + break; + case LANG_ADA83: + case LANG_COBOL74: + case LANG_COBOL85: + case LANG_PASCAL83: + /* We don't know anything special about these yet. */ + cu_language = language_unknown; + break; + default: + /* If no at_language, try to deduce one from the filename */ + cu_language = deduce_language_from_filename (dip->at_name); + break; } cu_language_defn = language_def (cu_language); } /* -GLOBAL FUNCTION + GLOBAL FUNCTION - dwarf_build_psymtabs -- build partial symtabs from DWARF debug info + dwarf_build_psymtabs -- build partial symtabs from DWARF debug info -SYNOPSIS + SYNOPSIS - void dwarf_build_psymtabs (struct objfile *objfile, - struct section_offsets *section_offsets, - int mainline, file_ptr dbfoff, unsigned int dbfsize, - file_ptr lnoffset, unsigned int lnsize) + void dwarf_build_psymtabs (struct objfile *objfile, + struct section_offsets *section_offsets, + int mainline, file_ptr dbfoff, unsigned int dbfsize, + file_ptr lnoffset, unsigned int lnsize) -DESCRIPTION + DESCRIPTION - This function is called upon to build partial symtabs from files - containing DIE's (Dwarf Information Entries) and DWARF line numbers. + This function is called upon to build partial symtabs from files + containing DIE's (Dwarf Information Entries) and DWARF line numbers. - It is passed a bfd* containing the DIES - and line number information, the corresponding filename for that - file, a base address for relocating the symbols, a flag indicating - whether or not this debugging information is from a "main symbol - table" rather than a shared library or dynamically linked file, - and file offset/size pairs for the DIE information and line number - information. + It is passed a bfd* containing the DIES + and line number information, the corresponding filename for that + file, a base address for relocating the symbols, a flag indicating + whether or not this debugging information is from a "main symbol + table" rather than a shared library or dynamically linked file, + and file offset/size pairs for the DIE information and line number + information. -RETURNS + RETURNS - No return value. + No return value. */ @@ -738,7 +740,7 @@ dwarf_build_psymtabs (objfile, section_offsets, mainline, dbfoff, dbfsize, { bfd *abfd = objfile->obfd; struct cleanup *back_to; - + current_objfile = objfile; dbsize = dbfsize; dbbase = xmalloc (dbsize); @@ -750,17 +752,17 @@ dwarf_build_psymtabs (objfile, section_offsets, mainline, dbfoff, dbfsize, error ("can't read DWARF data from '%s'", bfd_get_filename (abfd)); } back_to = make_cleanup (free, dbbase); - + /* If we are reinitializing, or if we have never loaded syms yet, init. Since we have no idea how many DIES we are looking at, we just guess some arbitrary value. */ - - if (mainline || objfile -> global_psymbols.size == 0 || - objfile -> static_psymbols.size == 0) + + if (mainline || objfile->global_psymbols.size == 0 || + objfile->static_psymbols.size == 0) { init_psymbol_list (objfile, 1024); } - + /* Save the relocation factor where everybody can see it. */ base_section_offsets = section_offsets; @@ -769,28 +771,28 @@ dwarf_build_psymtabs (objfile, section_offsets, mainline, dbfoff, dbfsize, /* Follow the compilation unit sibling chain, building a partial symbol table entry for each one. Save enough information about each compilation unit to locate the full DWARF information later. */ - + scan_compilation_units (dbbase, dbbase + dbsize, dbfoff, lnoffset, objfile); - + do_cleanups (back_to); current_objfile = NULL; } /* -LOCAL FUNCTION + LOCAL FUNCTION - read_lexical_block_scope -- process all dies in a lexical block + read_lexical_block_scope -- process all dies in a lexical block -SYNOPSIS + SYNOPSIS - static void read_lexical_block_scope (struct dieinfo *dip, - char *thisdie, char *enddie) + static void read_lexical_block_scope (struct dieinfo *dip, + char *thisdie, char *enddie) -DESCRIPTION + DESCRIPTION - Process all the DIES contained within a lexical block scope. - Start a new scope, process the dies, and then close the scope. + Process all the DIES contained within a lexical block scope. + Start a new scope, process the dies, and then close the scope. */ @@ -803,34 +805,34 @@ read_lexical_block_scope (dip, thisdie, enddie, objfile) { register struct context_stack *new; - push_context (0, dip -> at_low_pc); - process_dies (thisdie + dip -> die_length, enddie, objfile); + push_context (0, dip->at_low_pc); + process_dies (thisdie + dip->die_length, enddie, objfile); new = pop_context (); if (local_symbols != NULL) { - finish_block (0, &local_symbols, new -> old_blocks, new -> start_addr, - dip -> at_high_pc, objfile); + finish_block (0, &local_symbols, new->old_blocks, new->start_addr, + dip->at_high_pc, objfile); } - local_symbols = new -> locals; + local_symbols = new->locals; } /* -LOCAL FUNCTION + LOCAL FUNCTION - lookup_utype -- look up a user defined type from die reference + lookup_utype -- look up a user defined type from die reference -SYNOPSIS + SYNOPSIS - static type *lookup_utype (DIE_REF die_ref) + static type *lookup_utype (DIE_REF die_ref) -DESCRIPTION + DESCRIPTION - Given a DIE reference, lookup the user defined type associated with - that DIE, if it has been registered already. If not registered, then - return NULL. Alloc_utype() can be called to register an empty - type for this reference, which will be filled in later when the - actual referenced DIE is processed. + Given a DIE reference, lookup the user defined type associated with + that DIE, if it has been registered already. If not registered, then + return NULL. Alloc_utype() can be called to register an empty + type for this reference, which will be filled in later when the + actual referenced DIE is processed. */ static struct type * @@ -839,7 +841,7 @@ lookup_utype (die_ref) { struct type *type = NULL; int utypeidx; - + utypeidx = (die_ref - dbroff) / 4; if ((utypeidx < 0) || (utypeidx >= numutypes)) { @@ -855,23 +857,23 @@ lookup_utype (die_ref) /* -LOCAL FUNCTION + LOCAL FUNCTION - alloc_utype -- add a user defined type for die reference + alloc_utype -- add a user defined type for die reference -SYNOPSIS + SYNOPSIS - static type *alloc_utype (DIE_REF die_ref, struct type *utypep) + static type *alloc_utype (DIE_REF die_ref, struct type *utypep) -DESCRIPTION + DESCRIPTION - Given a die reference DIE_REF, and a possible pointer to a user - defined type UTYPEP, register that this reference has a user - defined type and either use the specified type in UTYPEP or - make a new empty type that will be filled in later. + Given a die reference DIE_REF, and a possible pointer to a user + defined type UTYPEP, register that this reference has a user + defined type and either use the specified type in UTYPEP or + make a new empty type that will be filled in later. - We should only be called after calling lookup_utype() to verify that - there is not currently a type registered for DIE_REF. + We should only be called after calling lookup_utype() to verify that + there is not currently a type registered for DIE_REF. */ static struct type * @@ -881,7 +883,7 @@ alloc_utype (die_ref, utypep) { struct type **typep; int utypeidx; - + utypeidx = (die_ref - dbroff) / 4; typep = utypes + utypeidx; if ((utypeidx < 0) || (utypeidx >= numutypes)) @@ -907,19 +909,19 @@ alloc_utype (die_ref, utypep) /* -LOCAL FUNCTION + LOCAL FUNCTION - free_utypes -- free the utypes array and reset pointer & count + free_utypes -- free the utypes array and reset pointer & count -SYNOPSIS + SYNOPSIS - static void free_utypes (PTR dummy) + static void free_utypes (PTR dummy) -DESCRIPTION + DESCRIPTION - Called via do_cleanups to free the utypes array, reset the pointer to NULL, - and set numutypes back to zero. This ensures that the utypes does not get - referenced after being freed. + Called via do_cleanups to free the utypes array, reset the pointer to NULL, + and set numutypes back to zero. This ensures that the utypes does not get + referenced after being freed. */ static void @@ -934,19 +936,19 @@ free_utypes (dummy) /* -LOCAL FUNCTION + LOCAL FUNCTION - decode_die_type -- return a type for a specified die + decode_die_type -- return a type for a specified die -SYNOPSIS + SYNOPSIS - static struct type *decode_die_type (struct dieinfo *dip) + static struct type *decode_die_type (struct dieinfo *dip) -DESCRIPTION + DESCRIPTION - Given a pointer to a die information structure DIP, decode the - type of the die and return a pointer to the decoded type. All - dies without specific types default to type int. + Given a pointer to a die information structure DIP, decode the + type of the die and return a pointer to the decoded type. All + dies without specific types default to type int. */ static struct type * @@ -954,25 +956,25 @@ decode_die_type (dip) struct dieinfo *dip; { struct type *type = NULL; - - if (dip -> at_fund_type != 0) + + if (dip->at_fund_type != 0) { - type = decode_fund_type (dip -> at_fund_type); + type = decode_fund_type (dip->at_fund_type); } - else if (dip -> at_mod_fund_type != NULL) + else if (dip->at_mod_fund_type != NULL) { - type = decode_mod_fund_type (dip -> at_mod_fund_type); + type = decode_mod_fund_type (dip->at_mod_fund_type); } - else if (dip -> at_user_def_type) + else if (dip->at_user_def_type) { - if ((type = lookup_utype (dip -> at_user_def_type)) == NULL) + if ((type = lookup_utype (dip->at_user_def_type)) == NULL) { - type = alloc_utype (dip -> at_user_def_type, NULL); + type = alloc_utype (dip->at_user_def_type, NULL); } } - else if (dip -> at_mod_u_d_type) + else if (dip->at_mod_u_d_type) { - type = decode_mod_u_d_type (dip -> at_mod_u_d_type); + type = decode_mod_u_d_type (dip->at_mod_u_d_type); } else { @@ -983,22 +985,22 @@ decode_die_type (dip) /* -LOCAL FUNCTION + LOCAL FUNCTION - struct_type -- compute and return the type for a struct or union + struct_type -- compute and return the type for a struct or union -SYNOPSIS + SYNOPSIS - static struct type *struct_type (struct dieinfo *dip, char *thisdie, - char *enddie, struct objfile *objfile) + static struct type *struct_type (struct dieinfo *dip, char *thisdie, + char *enddie, struct objfile *objfile) -DESCRIPTION + DESCRIPTION - Given pointer to a die information structure for a die which - defines a union or structure (and MUST define one or the other), - and pointers to the raw die data that define the range of dies which - define the members, compute and return the user defined type for the - structure or union. + Given pointer to a die information structure for a die which + defines a union or structure (and MUST define one or the other), + and pointers to the raw die data that define the range of dies which + define the members, compute and return the user defined type for the + structure or union. */ static struct type * @@ -1009,10 +1011,11 @@ struct_type (dip, thisdie, enddie, objfile) struct objfile *objfile; { struct type *type; - struct nextfield { - struct nextfield *next; - struct field field; - }; + struct nextfield + { + struct nextfield *next; + struct field field; + }; struct nextfield *list = NULL; struct nextfield *new; int nfields = 0; @@ -1020,47 +1023,47 @@ struct_type (dip, thisdie, enddie, objfile) struct dieinfo mbr; char *nextdie; int anonymous_size; - - if ((type = lookup_utype (dip -> die_ref)) == NULL) + + if ((type = lookup_utype (dip->die_ref)) == NULL) { /* No forward references created an empty type, so install one now */ - type = alloc_utype (dip -> die_ref, NULL); + type = alloc_utype (dip->die_ref, NULL); } - INIT_CPLUS_SPECIFIC(type); - switch (dip -> die_tag) + INIT_CPLUS_SPECIFIC (type); + switch (dip->die_tag) { - case TAG_class_type: - TYPE_CODE (type) = TYPE_CODE_CLASS; - break; - case TAG_structure_type: - TYPE_CODE (type) = TYPE_CODE_STRUCT; - break; - case TAG_union_type: - TYPE_CODE (type) = TYPE_CODE_UNION; - break; - default: - /* Should never happen */ - TYPE_CODE (type) = TYPE_CODE_UNDEF; - complain (&missing_tag, DIE_ID, DIE_NAME); - break; + case TAG_class_type: + TYPE_CODE (type) = TYPE_CODE_CLASS; + break; + case TAG_structure_type: + TYPE_CODE (type) = TYPE_CODE_STRUCT; + break; + case TAG_union_type: + TYPE_CODE (type) = TYPE_CODE_UNION; + break; + default: + /* Should never happen */ + TYPE_CODE (type) = TYPE_CODE_UNDEF; + complain (&missing_tag, DIE_ID, DIE_NAME); + break; } /* Some compilers try to be helpful by inventing "fake" names for anonymous enums, structures, and unions, like "~0fake" or ".0fake". Thanks, but no thanks... */ - if (dip -> at_name != NULL - && *dip -> at_name != '~' - && *dip -> at_name != '.') + if (dip->at_name != NULL + && *dip->at_name != '~' + && *dip->at_name != '.') { - TYPE_TAG_NAME (type) = obconcat (&objfile -> type_obstack, - "", "", dip -> at_name); + TYPE_TAG_NAME (type) = obconcat (&objfile->type_obstack, + "", "", dip->at_name); } /* Use whatever size is known. Zero is a valid size. We might however wish to check has_at_byte_size to make sure that some byte size was given explicitly, but DWARF doesn't specify that explicit sizes of zero have to present, so complaining about missing sizes should probably not be the default. */ - TYPE_LENGTH (type) = dip -> at_byte_size; - thisdie += dip -> die_length; + TYPE_LENGTH (type) = dip->at_byte_size; + thisdie += dip->die_length; while (thisdie < enddie) { basicdieinfo (&mbr, thisdie, objfile); @@ -1082,12 +1085,12 @@ struct_type (dip, thisdie, enddie, objfile) case TAG_member: /* Get space to record the next field's data. */ new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new -> next = list; + new->next = list; list = new; /* Save the data. */ - list -> field.name = - obsavestring (mbr.at_name, strlen (mbr.at_name), - &objfile -> type_obstack); + list->field.name = + obsavestring (mbr.at_name, strlen (mbr.at_name), + &objfile->type_obstack); FIELD_TYPE (list->field) = decode_die_type (&mbr); FIELD_BITPOS (list->field) = 8 * locval (&mbr); /* Handle bit fields. */ @@ -1095,39 +1098,39 @@ struct_type (dip, thisdie, enddie, objfile) if (BITS_BIG_ENDIAN) { /* For big endian bits, the at_bit_offset gives the - additional bit offset from the MSB of the containing - anonymous object to the MSB of the field. We don't - have to do anything special since we don't need to - know the size of the anonymous object. */ + additional bit offset from the MSB of the containing + anonymous object to the MSB of the field. We don't + have to do anything special since we don't need to + know the size of the anonymous object. */ FIELD_BITPOS (list->field) += mbr.at_bit_offset; } else { /* For little endian bits, we need to have a non-zero - at_bit_size, so that we know we are in fact dealing - with a bitfield. Compute the bit offset to the MSB - of the anonymous object, subtract off the number of - bits from the MSB of the field to the MSB of the - object, and then subtract off the number of bits of - the field itself. The result is the bit offset of - the LSB of the field. */ + at_bit_size, so that we know we are in fact dealing + with a bitfield. Compute the bit offset to the MSB + of the anonymous object, subtract off the number of + bits from the MSB of the field to the MSB of the + object, and then subtract off the number of bits of + the field itself. The result is the bit offset of + the LSB of the field. */ if (mbr.at_bit_size > 0) { if (mbr.has_at_byte_size) { /* The size of the anonymous object containing - the bit field is explicit, so use the - indicated size (in bytes). */ + the bit field is explicit, so use the + indicated size (in bytes). */ anonymous_size = mbr.at_byte_size; } else { /* The size of the anonymous object containing - the bit field matches the size of an object - of the bit field's type. DWARF allows - at_byte_size to be left out in such cases, as - a debug information size optimization. */ - anonymous_size = TYPE_LENGTH (list -> field.type); + the bit field matches the size of an object + of the bit field's type. DWARF allows + at_byte_size to be left out in such cases, as + a debug information size optimization. */ + anonymous_size = TYPE_LENGTH (list->field.type); } FIELD_BITPOS (list->field) += anonymous_size * 8 - mbr.at_bit_offset - mbr.at_bit_size; @@ -1156,46 +1159,46 @@ struct_type (dip, thisdie, enddie, objfile) TYPE_FIELDS (type) = (struct field *) TYPE_ALLOC (type, sizeof (struct field) * nfields); /* Copy the saved-up fields into the field vector. */ - for (n = nfields; list; list = list -> next) + for (n = nfields; list; list = list->next) { - TYPE_FIELD (type, --n) = list -> field; - } + TYPE_FIELD (type, --n) = list->field; + } } return (type); } /* -LOCAL FUNCTION + LOCAL FUNCTION - read_structure_scope -- process all dies within struct or union + read_structure_scope -- process all dies within struct or union -SYNOPSIS + SYNOPSIS - static void read_structure_scope (struct dieinfo *dip, - char *thisdie, char *enddie, struct objfile *objfile) + static void read_structure_scope (struct dieinfo *dip, + char *thisdie, char *enddie, struct objfile *objfile) -DESCRIPTION + DESCRIPTION - Called when we find the DIE that starts a structure or union - scope (definition) to process all dies that define the members - of the structure or union. DIP is a pointer to the die info - struct for the DIE that names the structure or union. + Called when we find the DIE that starts a structure or union + scope (definition) to process all dies that define the members + of the structure or union. DIP is a pointer to the die info + struct for the DIE that names the structure or union. -NOTES + NOTES + + Note that we need to call struct_type regardless of whether or not + the DIE has an at_name attribute, since it might be an anonymous + structure or union. This gets the type entered into our set of + user defined types. + + However, if the structure is incomplete (an opaque struct/union) + then suppress creating a symbol table entry for it since gdb only + wants to find the one with the complete definition. Note that if + it is complete, we just call new_symbol, which does it's own + checking about whether the struct/union is anonymous or not (and + suppresses creating a symbol table entry itself). - Note that we need to call struct_type regardless of whether or not - the DIE has an at_name attribute, since it might be an anonymous - structure or union. This gets the type entered into our set of - user defined types. - - However, if the structure is incomplete (an opaque struct/union) - then suppress creating a symbol table entry for it since gdb only - wants to find the one with the complete definition. Note that if - it is complete, we just call new_symbol, which does it's own - checking about whether the struct/union is anonymous or not (and - suppresses creating a symbol table entry itself). - */ static void @@ -1207,7 +1210,7 @@ read_structure_scope (dip, thisdie, enddie, objfile) { struct type *type; struct symbol *sym; - + type = struct_type (dip, thisdie, enddie, objfile); if (!(TYPE_FLAGS (type) & TYPE_FLAG_STUB)) { @@ -1225,21 +1228,21 @@ read_structure_scope (dip, thisdie, enddie, objfile) /* -LOCAL FUNCTION + LOCAL FUNCTION - decode_array_element_type -- decode type of the array elements + decode_array_element_type -- decode type of the array elements -SYNOPSIS + SYNOPSIS - static struct type *decode_array_element_type (char *scan, char *end) + static struct type *decode_array_element_type (char *scan, char *end) -DESCRIPTION + DESCRIPTION - As the last step in decoding the array subscript information for an - array DIE, we need to decode the type of the array elements. We are - passed a pointer to this last part of the subscript information and - must return the appropriate type. If the type attribute is not - recognized, just warn about the problem and return type int. + As the last step in decoding the array subscript information for an + array DIE, we need to decode the type of the array elements. We are + passed a pointer to this last part of the subscript information and + must return the appropriate type. If the type attribute is not + recognized, just warn about the problem and return type int. */ static struct type * @@ -1251,7 +1254,7 @@ decode_array_element_type (scan) unsigned short attribute; unsigned short fundtype; int nbytes; - + attribute = target_to_host (scan, SIZEOF_ATTRIBUTE, GET_UNSIGNED, current_objfile); scan += SIZEOF_ATTRIBUTE; @@ -1264,77 +1267,77 @@ decode_array_element_type (scan) { switch (attribute) { - case AT_fund_type: - fundtype = target_to_host (scan, nbytes, GET_UNSIGNED, - current_objfile); - typep = decode_fund_type (fundtype); - break; - case AT_mod_fund_type: - typep = decode_mod_fund_type (scan); - break; - case AT_user_def_type: - die_ref = target_to_host (scan, nbytes, GET_UNSIGNED, - current_objfile); - if ((typep = lookup_utype (die_ref)) == NULL) - { - typep = alloc_utype (die_ref, NULL); - } - break; - case AT_mod_u_d_type: - typep = decode_mod_u_d_type (scan); - break; - default: - complain (&bad_array_element_type, DIE_ID, DIE_NAME, attribute); - typep = dwarf_fundamental_type (current_objfile, FT_INTEGER); - break; - } + case AT_fund_type: + fundtype = target_to_host (scan, nbytes, GET_UNSIGNED, + current_objfile); + typep = decode_fund_type (fundtype); + break; + case AT_mod_fund_type: + typep = decode_mod_fund_type (scan); + break; + case AT_user_def_type: + die_ref = target_to_host (scan, nbytes, GET_UNSIGNED, + current_objfile); + if ((typep = lookup_utype (die_ref)) == NULL) + { + typep = alloc_utype (die_ref, NULL); + } + break; + case AT_mod_u_d_type: + typep = decode_mod_u_d_type (scan); + break; + default: + complain (&bad_array_element_type, DIE_ID, DIE_NAME, attribute); + typep = dwarf_fundamental_type (current_objfile, FT_INTEGER); + break; + } } return (typep); } /* -LOCAL FUNCTION + LOCAL FUNCTION - decode_subscript_data_item -- decode array subscript item + decode_subscript_data_item -- decode array subscript item -SYNOPSIS + SYNOPSIS - static struct type * - decode_subscript_data_item (char *scan, char *end) + static struct type * + decode_subscript_data_item (char *scan, char *end) -DESCRIPTION + DESCRIPTION - The array subscripts and the data type of the elements of an - array are described by a list of data items, stored as a block - of contiguous bytes. There is a data item describing each array - dimension, and a final data item describing the element type. - The data items are ordered the same as their appearance in the - source (I.E. leftmost dimension first, next to leftmost second, - etc). + The array subscripts and the data type of the elements of an + array are described by a list of data items, stored as a block + of contiguous bytes. There is a data item describing each array + dimension, and a final data item describing the element type. + The data items are ordered the same as their appearance in the + source (I.E. leftmost dimension first, next to leftmost second, + etc). - The data items describing each array dimension consist of four - parts: (1) a format specifier, (2) type type of the subscript - index, (3) a description of the low bound of the array dimension, - and (4) a description of the high bound of the array dimension. + The data items describing each array dimension consist of four + parts: (1) a format specifier, (2) type type of the subscript + index, (3) a description of the low bound of the array dimension, + and (4) a description of the high bound of the array dimension. - The last data item is the description of the type of each of - the array elements. + The last data item is the description of the type of each of + the array elements. - We are passed a pointer to the start of the block of bytes - containing the remaining data items, and a pointer to the first - byte past the data. This function recursively decodes the - remaining data items and returns a type. + We are passed a pointer to the start of the block of bytes + containing the remaining data items, and a pointer to the first + byte past the data. This function recursively decodes the + remaining data items and returns a type. - If we somehow fail to decode some data, we complain about it - and return a type "array of int". + If we somehow fail to decode some data, we complain about it + and return a type "array of int". -BUGS - FIXME: This code only implements the forms currently used - by the AT&T and GNU C compilers. + BUGS + FIXME: This code only implements the forms currently used + by the AT&T and GNU C compilers. - The end pointer is supplied for error checking, maybe we should - use it for that... + The end pointer is supplied for error checking, maybe we should + use it for that... */ static struct type * @@ -1351,7 +1354,7 @@ decode_subscript_data_item (scan, end) unsigned long lowbound; unsigned long highbound; int nbytes; - + format = target_to_host (scan, SIZEOF_FORMAT_SPECIFIER, GET_UNSIGNED, current_objfile); scan += SIZEOF_FORMAT_SPECIFIER; @@ -1378,7 +1381,7 @@ decode_subscript_data_item (scan, end) nexttype = dwarf_fundamental_type (current_objfile, FT_INTEGER); } rangetype = create_range_type ((struct type *) NULL, indextype, - lowbound, highbound); + lowbound, highbound); typep = create_array_type ((struct type *) NULL, nexttype, rangetype); break; case FMT_FT_C_X: @@ -1405,18 +1408,18 @@ decode_subscript_data_item (scan, end) /* -LOCAL FUNCTION + LOCAL FUNCTION - dwarf_read_array_type -- read TAG_array_type DIE + dwarf_read_array_type -- read TAG_array_type DIE -SYNOPSIS + SYNOPSIS - static void dwarf_read_array_type (struct dieinfo *dip) + static void dwarf_read_array_type (struct dieinfo *dip) -DESCRIPTION + DESCRIPTION - Extract all information from a TAG_array_type DIE and add to - the user defined type vector. + Extract all information from a TAG_array_type DIE and add to + the user defined type vector. */ static void @@ -1429,23 +1432,23 @@ dwarf_read_array_type (dip) char *subend; unsigned short blocksz; int nbytes; - - if (dip -> at_ordering != ORD_row_major) + + if (dip->at_ordering != ORD_row_major) { /* FIXME: Can gdb even handle column major arrays? */ complain (¬_row_major, DIE_ID, DIE_NAME); } - if ((sub = dip -> at_subscr_data) != NULL) + if ((sub = dip->at_subscr_data) != NULL) { nbytes = attribute_size (AT_subscr_data); blocksz = target_to_host (sub, nbytes, GET_UNSIGNED, current_objfile); subend = sub + nbytes + blocksz; sub += nbytes; type = decode_subscript_data_item (sub, subend); - if ((utype = lookup_utype (dip -> die_ref)) == NULL) + if ((utype = lookup_utype (dip->die_ref)) == NULL) { /* Install user defined type that has not been referenced yet. */ - alloc_utype (dip -> die_ref, type); + alloc_utype (dip->die_ref, type); } else if (TYPE_CODE (utype) == TYPE_CODE_UNDEF) { @@ -1470,18 +1473,18 @@ dwarf_read_array_type (dip) /* -LOCAL FUNCTION + LOCAL FUNCTION - read_tag_pointer_type -- read TAG_pointer_type DIE + read_tag_pointer_type -- read TAG_pointer_type DIE -SYNOPSIS + SYNOPSIS - static void read_tag_pointer_type (struct dieinfo *dip) + static void read_tag_pointer_type (struct dieinfo *dip) -DESCRIPTION + DESCRIPTION - Extract all information from a TAG_pointer_type DIE and add to - the user defined type vector. + Extract all information from a TAG_pointer_type DIE and add to + the user defined type vector. */ static void @@ -1490,12 +1493,12 @@ read_tag_pointer_type (dip) { struct type *type; struct type *utype; - + type = decode_die_type (dip); - if ((utype = lookup_utype (dip -> die_ref)) == NULL) + if ((utype = lookup_utype (dip->die_ref)) == NULL) { utype = lookup_pointer_type (type); - alloc_utype (dip -> die_ref, utype); + alloc_utype (dip->die_ref, utype); } else { @@ -1504,27 +1507,27 @@ read_tag_pointer_type (dip) /* We assume the machine has only one representation for pointers! */ /* FIXME: Possably a poor assumption */ - TYPE_LENGTH (utype) = TARGET_PTR_BIT / TARGET_CHAR_BIT ; + TYPE_LENGTH (utype) = TARGET_PTR_BIT / TARGET_CHAR_BIT; TYPE_CODE (utype) = TYPE_CODE_PTR; } } /* -LOCAL FUNCTION + LOCAL FUNCTION - read_tag_string_type -- read TAG_string_type DIE + read_tag_string_type -- read TAG_string_type DIE -SYNOPSIS + SYNOPSIS - static void read_tag_string_type (struct dieinfo *dip) + static void read_tag_string_type (struct dieinfo *dip) -DESCRIPTION + DESCRIPTION - Extract all information from a TAG_string_type DIE and add to - the user defined type vector. It isn't really a user defined - type, but it behaves like one, with other DIE's using an - AT_user_def_type attribute to reference it. + Extract all information from a TAG_string_type DIE and add to + the user defined type vector. It isn't really a user defined + type, but it behaves like one, with other DIE's using an + AT_user_def_type attribute to reference it. */ static void @@ -1537,10 +1540,10 @@ read_tag_string_type (dip) unsigned long lowbound = 0; unsigned long highbound; - if (dip -> has_at_byte_size) + if (dip->has_at_byte_size) { /* A fixed bounds string */ - highbound = dip -> at_byte_size - 1; + highbound = dip->at_byte_size - 1; } else { @@ -1550,17 +1553,17 @@ read_tag_string_type (dip) indextype = dwarf_fundamental_type (current_objfile, FT_INTEGER); rangetype = create_range_type ((struct type *) NULL, indextype, lowbound, highbound); - - utype = lookup_utype (dip -> die_ref); + + utype = lookup_utype (dip->die_ref); if (utype == NULL) { /* No type defined, go ahead and create a blank one to use. */ - utype = alloc_utype (dip -> die_ref, (struct type *) NULL); + utype = alloc_utype (dip->die_ref, (struct type *) NULL); } else { /* Already a type in our slot due to a forward reference. Make sure it - is a blank one. If not, complain and leave it alone. */ + is a blank one. If not, complain and leave it alone. */ if (TYPE_CODE (utype) != TYPE_CODE_UNDEF) { complain (&dup_user_type_definition, DIE_ID, DIE_NAME); @@ -1574,29 +1577,29 @@ read_tag_string_type (dip) /* -LOCAL FUNCTION + LOCAL FUNCTION - read_subroutine_type -- process TAG_subroutine_type dies + read_subroutine_type -- process TAG_subroutine_type dies -SYNOPSIS + SYNOPSIS - static void read_subroutine_type (struct dieinfo *dip, char thisdie, - char *enddie) + static void read_subroutine_type (struct dieinfo *dip, char thisdie, + char *enddie) -DESCRIPTION + DESCRIPTION - Handle DIES due to C code like: + Handle DIES due to C code like: - struct foo { - int (*funcp)(int a, long l); (Generates TAG_subroutine_type DIE) - int b; - }; + struct foo { + int (*funcp)(int a, long l); (Generates TAG_subroutine_type DIE) + int b; + }; -NOTES + NOTES - The parameter DIES are currently ignored. See if gdb has a way to - include this info in it's type system, and decode them if so. Is - this what the type structure's "arg_types" field is for? (FIXME) + The parameter DIES are currently ignored. See if gdb has a way to + include this info in it's type system, and decode them if so. Is + this what the type structure's "arg_types" field is for? (FIXME) */ static void @@ -1607,7 +1610,7 @@ read_subroutine_type (dip, thisdie, enddie) { struct type *type; /* Type that this function returns */ struct type *ftype; /* Function that returns above type */ - + /* Decode the type that this subroutine returns */ type = decode_die_type (dip); @@ -1615,17 +1618,17 @@ read_subroutine_type (dip, thisdie, enddie) /* Check to see if we already have a partially constructed user defined type for this DIE, from a forward reference. */ - if ((ftype = lookup_utype (dip -> die_ref)) == NULL) + if ((ftype = lookup_utype (dip->die_ref)) == NULL) { /* This is the first reference to one of these types. Make - a new one and place it in the user defined types. */ + a new one and place it in the user defined types. */ ftype = lookup_function_type (type); - alloc_utype (dip -> die_ref, ftype); + alloc_utype (dip->die_ref, ftype); } else if (TYPE_CODE (ftype) == TYPE_CODE_UNDEF) { /* We have an existing partially constructed type, so bash it - into the correct type. */ + into the correct type. */ TYPE_TARGET_TYPE (ftype) = type; TYPE_LENGTH (ftype) = 1; TYPE_CODE (ftype) = TYPE_CODE_FUNC; @@ -1638,25 +1641,25 @@ read_subroutine_type (dip, thisdie, enddie) /* -LOCAL FUNCTION + LOCAL FUNCTION - read_enumeration -- process dies which define an enumeration + read_enumeration -- process dies which define an enumeration -SYNOPSIS + SYNOPSIS - static void read_enumeration (struct dieinfo *dip, char *thisdie, - char *enddie, struct objfile *objfile) + static void read_enumeration (struct dieinfo *dip, char *thisdie, + char *enddie, struct objfile *objfile) -DESCRIPTION + DESCRIPTION - Given a pointer to a die which begins an enumeration, process all - the dies that define the members of the enumeration. + Given a pointer to a die which begins an enumeration, process all + the dies that define the members of the enumeration. -NOTES + NOTES - Note that we need to call enum_type regardless of whether or not we - have a symbol, since we might have an enum without a tag name (thus - no symbol for the tagname). + Note that we need to call enum_type regardless of whether or not we + have a symbol, since we might have an enum without a tag name (thus + no symbol for the tagname). */ static void @@ -1668,7 +1671,7 @@ read_enumeration (dip, thisdie, enddie, objfile) { struct type *type; struct symbol *sym; - + type = enum_type (dip, objfile); sym = new_symbol (dip, objfile); if (sym != NULL) @@ -1683,33 +1686,33 @@ read_enumeration (dip, thisdie, enddie, objfile) /* -LOCAL FUNCTION + LOCAL FUNCTION - enum_type -- decode and return a type for an enumeration + enum_type -- decode and return a type for an enumeration -SYNOPSIS + SYNOPSIS - static type *enum_type (struct dieinfo *dip, struct objfile *objfile) + static type *enum_type (struct dieinfo *dip, struct objfile *objfile) -DESCRIPTION + DESCRIPTION - Given a pointer to a die information structure for the die which - starts an enumeration, process all the dies that define the members - of the enumeration and return a type pointer for the enumeration. + Given a pointer to a die information structure for the die which + starts an enumeration, process all the dies that define the members + of the enumeration and return a type pointer for the enumeration. - At the same time, for each member of the enumeration, create a - symbol for it with namespace VAR_NAMESPACE and class LOC_CONST, - and give it the type of the enumeration itself. + At the same time, for each member of the enumeration, create a + symbol for it with namespace VAR_NAMESPACE and class LOC_CONST, + and give it the type of the enumeration itself. -NOTES + NOTES - Note that the DWARF specification explicitly mandates that enum - constants occur in reverse order from the source program order, - for "consistency" and because this ordering is easier for many - compilers to generate. (Draft 6, sec 3.8.5, Enumeration type - Entries). Because gdb wants to see the enum members in program - source order, we have to ensure that the order gets reversed while - we are processing them. + Note that the DWARF specification explicitly mandates that enum + constants occur in reverse order from the source program order, + for "consistency" and because this ordering is easier for many + compilers to generate. (Draft 6, sec 3.8.5, Enumeration type + Entries). Because gdb wants to see the enum members in program + source order, we have to ensure that the order gets reversed while + we are processing them. */ static struct type * @@ -1718,10 +1721,11 @@ enum_type (dip, objfile) struct objfile *objfile; { struct type *type; - struct nextfield { - struct nextfield *next; - struct field field; - }; + struct nextfield + { + struct nextfield *next; + struct field field; + }; struct nextfield *list = NULL; struct nextfield *new; int nfields = 0; @@ -1732,30 +1736,30 @@ enum_type (dip, objfile) struct symbol *sym; int nbytes; int unsigned_enum = 1; - - if ((type = lookup_utype (dip -> die_ref)) == NULL) + + if ((type = lookup_utype (dip->die_ref)) == NULL) { /* No forward references created an empty type, so install one now */ - type = alloc_utype (dip -> die_ref, NULL); + type = alloc_utype (dip->die_ref, NULL); } TYPE_CODE (type) = TYPE_CODE_ENUM; /* Some compilers try to be helpful by inventing "fake" names for anonymous enums, structures, and unions, like "~0fake" or ".0fake". Thanks, but no thanks... */ - if (dip -> at_name != NULL - && *dip -> at_name != '~' - && *dip -> at_name != '.') + if (dip->at_name != NULL + && *dip->at_name != '~' + && *dip->at_name != '.') { - TYPE_TAG_NAME (type) = obconcat (&objfile -> type_obstack, - "", "", dip -> at_name); + TYPE_TAG_NAME (type) = obconcat (&objfile->type_obstack, + "", "", dip->at_name); } - if (dip -> at_byte_size != 0) + if (dip->at_byte_size != 0) { - TYPE_LENGTH (type) = dip -> at_byte_size; + TYPE_LENGTH (type) = dip->at_byte_size; } - if ((scan = dip -> at_element_list) != NULL) + if ((scan = dip->at_element_list) != NULL) { - if (dip -> short_element_list) + if (dip->short_element_list) { nbytes = attribute_size (AT_short_element_list); } @@ -1769,7 +1773,7 @@ enum_type (dip, objfile) while (scan < listend) { new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new -> next = list; + new->next = list; list = new; FIELD_TYPE (list->field) = NULL; FIELD_BITSIZE (list->field) = 0; @@ -1777,15 +1781,15 @@ enum_type (dip, objfile) target_to_host (scan, TARGET_FT_LONG_SIZE (objfile), GET_SIGNED, objfile); scan += TARGET_FT_LONG_SIZE (objfile); - list -> field.name = obsavestring (scan, strlen (scan), - &objfile -> type_obstack); + list->field.name = obsavestring (scan, strlen (scan), + &objfile->type_obstack); scan += strlen (scan) + 1; nfields++; /* Handcraft a new symbol for this enum member. */ sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); memset (sym, 0, sizeof (struct symbol)); - SYMBOL_NAME (sym) = create_name (list -> field.name, + SYMBOL_NAME (sym) = create_name (list->field.name, &objfile->symbol_obstack); SYMBOL_INIT_LANGUAGE_SPECIFIC (sym, cu_language); SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; @@ -1797,10 +1801,10 @@ enum_type (dip, objfile) add_symbol_to_list (sym, list_in_scope); } /* Now create the vector of fields, and record how big it is. This is - where we reverse the order, by pulling the members off the list in - reverse order from how they were inserted. If we have no fields - (this is apparently possible in C++) then skip building a field - vector. */ + where we reverse the order, by pulling the members off the list in + reverse order from how they were inserted. If we have no fields + (this is apparently possible in C++) then skip building a field + vector. */ if (nfields > 0) { if (unsigned_enum) @@ -1809,10 +1813,10 @@ enum_type (dip, objfile) TYPE_FIELDS (type) = (struct field *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct field) * nfields); /* Copy the saved-up fields into the field vector. */ - for (n = 0; (n < nfields) && (list != NULL); list = list -> next) + for (n = 0; (n < nfields) && (list != NULL); list = list->next) { - TYPE_FIELD (type, n++) = list -> field; - } + TYPE_FIELD (type, n++) = list->field; + } } } return (type); @@ -1820,23 +1824,23 @@ enum_type (dip, objfile) /* -LOCAL FUNCTION + LOCAL FUNCTION - read_func_scope -- process all dies within a function scope + read_func_scope -- process all dies within a function scope -DESCRIPTION + DESCRIPTION - Process all dies within a given function scope. We are passed - a die information structure pointer DIP for the die which - starts the function scope, and pointers into the raw die data - that define the dies within the function scope. - - For now, we ignore lexical block scopes within the function. - The problem is that AT&T cc does not define a DWARF lexical - block scope for the function itself, while gcc defines a - lexical block scope for the function. We need to think about - how to handle this difference, or if it is even a problem. - (FIXME) + Process all dies within a given function scope. We are passed + a die information structure pointer DIP for the die which + starts the function scope, and pointers into the raw die data + that define the dies within the function scope. + + For now, we ignore lexical block scopes within the function. + The problem is that AT&T cc does not define a DWARF lexical + block scope for the function itself, while gcc defines a + lexical block scope for the function. We need to think about + how to handle this difference, or if it is even a problem. + (FIXME) */ static void @@ -1847,50 +1851,50 @@ read_func_scope (dip, thisdie, enddie, objfile) struct objfile *objfile; { register struct context_stack *new; - + /* AT_name is absent if the function is described with an AT_abstract_origin tag. Ignore the function description for now to avoid GDB core dumps. FIXME: Add code to handle AT_abstract_origin tags properly. */ - if (dip -> at_name == NULL) + if (dip->at_name == NULL) { complain (&missing_at_name, DIE_ID); return; } - if (objfile -> ei.entry_point >= dip -> at_low_pc && - objfile -> ei.entry_point < dip -> at_high_pc) + if (objfile->ei.entry_point >= dip->at_low_pc && + objfile->ei.entry_point < dip->at_high_pc) { - objfile -> ei.entry_func_lowpc = dip -> at_low_pc; - objfile -> ei.entry_func_highpc = dip -> at_high_pc; + objfile->ei.entry_func_lowpc = dip->at_low_pc; + objfile->ei.entry_func_highpc = dip->at_high_pc; } - if (STREQ (dip -> at_name, "main")) /* FIXME: hardwired name */ + if (STREQ (dip->at_name, "main")) /* FIXME: hardwired name */ { - objfile -> ei.main_func_lowpc = dip -> at_low_pc; - objfile -> ei.main_func_highpc = dip -> at_high_pc; + objfile->ei.main_func_lowpc = dip->at_low_pc; + objfile->ei.main_func_highpc = dip->at_high_pc; } - new = push_context (0, dip -> at_low_pc); - new -> name = new_symbol (dip, objfile); + new = push_context (0, dip->at_low_pc); + new->name = new_symbol (dip, objfile); list_in_scope = &local_symbols; - process_dies (thisdie + dip -> die_length, enddie, objfile); + process_dies (thisdie + dip->die_length, enddie, objfile); new = pop_context (); /* Make a block for the local symbols within. */ - finish_block (new -> name, &local_symbols, new -> old_blocks, - new -> start_addr, dip -> at_high_pc, objfile); + finish_block (new->name, &local_symbols, new->old_blocks, + new->start_addr, dip->at_high_pc, objfile); list_in_scope = &file_symbols; } /* -LOCAL FUNCTION + LOCAL FUNCTION - handle_producer -- process the AT_producer attribute + handle_producer -- process the AT_producer attribute -DESCRIPTION + DESCRIPTION - Perform any operations that depend on finding a particular - AT_producer attribute. + Perform any operations that depend on finding a particular + AT_producer attribute. */ @@ -1902,10 +1906,17 @@ handle_producer (producer) /* If this compilation unit was compiled with g++ or gcc, then set the processing_gcc_compilation flag. */ - processing_gcc_compilation = - STREQN (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER)) - || STREQN (producer, CHILL_PRODUCER, strlen (CHILL_PRODUCER)) - || STREQN (producer, GCC_PRODUCER, strlen (GCC_PRODUCER)); + if (STREQN (producer, GCC_PRODUCER, strlen (GCC_PRODUCER))) + { + char version = producer[strlen (GCC_PRODUCER)]; + processing_gcc_compilation = (version == '2' ? 2 : 1); + } + else + { + processing_gcc_compilation = + STREQN (producer, GPLUS_PRODUCER, strlen (GPLUS_PRODUCER)) + || STREQN (producer, CHILL_PRODUCER, strlen (CHILL_PRODUCER)); + } /* Select a demangling style if we can identify the producer and if the current style is auto. We leave the current style alone if it @@ -1928,24 +1939,24 @@ handle_producer (producer) /* -LOCAL FUNCTION + LOCAL FUNCTION - read_file_scope -- process all dies within a file scope + read_file_scope -- process all dies within a file scope -DESCRIPTION + DESCRIPTION - Process all dies within a given file scope. We are passed a - pointer to the die information structure for the die which - starts the file scope, and pointers into the raw die data which - mark the range of dies within the file scope. - - When the partial symbol table is built, the file offset for the line - number table for each compilation unit is saved in the partial symbol - table entry for that compilation unit. As the symbols for each - compilation unit are read, the line number table is read into memory - and the variable lnbase is set to point to it. Thus all we have to - do is use lnbase to access the line number table for the current - compilation unit. + Process all dies within a given file scope. We are passed a + pointer to the die information structure for the die which + starts the file scope, and pointers into the raw die data which + mark the range of dies within the file scope. + + When the partial symbol table is built, the file offset for the line + number table for each compilation unit is saved in the partial symbol + table entry for that compilation unit. As the symbols for each + compilation unit are read, the line number table is read into memory + and the variable lnbase is set to point to it. Thus all we have to + do is use lnbase to access the line number table for the current + compilation unit. */ static void @@ -1957,51 +1968,51 @@ read_file_scope (dip, thisdie, enddie, objfile) { struct cleanup *back_to; struct symtab *symtab; - - if (objfile -> ei.entry_point >= dip -> at_low_pc && - objfile -> ei.entry_point < dip -> at_high_pc) + + if (objfile->ei.entry_point >= dip->at_low_pc && + objfile->ei.entry_point < dip->at_high_pc) { - objfile -> ei.entry_file_lowpc = dip -> at_low_pc; - objfile -> ei.entry_file_highpc = dip -> at_high_pc; + objfile->ei.entry_file_lowpc = dip->at_low_pc; + objfile->ei.entry_file_highpc = dip->at_high_pc; } set_cu_language (dip); - if (dip -> at_producer != NULL) + if (dip->at_producer != NULL) { - handle_producer (dip -> at_producer); + handle_producer (dip->at_producer); } numutypes = (enddie - thisdie) / 4; utypes = (struct type **) xmalloc (numutypes * sizeof (struct type *)); back_to = make_cleanup (free_utypes, NULL); memset (utypes, 0, numutypes * sizeof (struct type *)); memset (ftypes, 0, FT_NUM_MEMBERS * sizeof (struct type *)); - start_symtab (dip -> at_name, dip -> at_comp_dir, dip -> at_low_pc); + start_symtab (dip->at_name, dip->at_comp_dir, dip->at_low_pc); record_debugformat ("DWARF 1"); decode_line_numbers (lnbase); - process_dies (thisdie + dip -> die_length, enddie, objfile); + process_dies (thisdie + dip->die_length, enddie, objfile); - symtab = end_symtab (dip -> at_high_pc, objfile, 0); + symtab = end_symtab (dip->at_high_pc, objfile, 0); if (symtab != NULL) { - symtab -> language = cu_language; - } + symtab->language = cu_language; + } do_cleanups (back_to); } /* -LOCAL FUNCTION + LOCAL FUNCTION - process_dies -- process a range of DWARF Information Entries + process_dies -- process a range of DWARF Information Entries -SYNOPSIS + SYNOPSIS - static void process_dies (char *thisdie, char *enddie, - struct objfile *objfile) + static void process_dies (char *thisdie, char *enddie, + struct objfile *objfile) -DESCRIPTION + DESCRIPTION - Process all DIE's in a specified range. May be (and almost - certainly will be) called recursively. + Process all DIE's in a specified range. May be (and almost + certainly will be) called recursively. */ static void @@ -2012,7 +2023,7 @@ process_dies (thisdie, enddie, objfile) { char *nextdie; struct dieinfo di; - + while (thisdie < enddie) { basicdieinfo (&di, thisdie, objfile); @@ -2044,8 +2055,8 @@ process_dies (thisdie, enddie, objfile) { case TAG_compile_unit: /* Skip Tag_compile_unit if we are already inside a compilation - unit, we are unable to handle nested compilation units - properly (FIXME). */ + unit, we are unable to handle nested compilation units + properly (FIXME). */ if (current_subfile == NULL) read_file_scope (&di, thisdie, nextdie, objfile); else @@ -2092,62 +2103,62 @@ process_dies (thisdie, enddie, objfile) /* -LOCAL FUNCTION + LOCAL FUNCTION - decode_line_numbers -- decode a line number table fragment + decode_line_numbers -- decode a line number table fragment -SYNOPSIS + SYNOPSIS - static void decode_line_numbers (char *tblscan, char *tblend, - long length, long base, long line, long pc) + static void decode_line_numbers (char *tblscan, char *tblend, + long length, long base, long line, long pc) -DESCRIPTION + DESCRIPTION - Translate the DWARF line number information to gdb form. + Translate the DWARF line number information to gdb form. - The ".line" section contains one or more line number tables, one for - each ".line" section from the objects that were linked. + The ".line" section contains one or more line number tables, one for + each ".line" section from the objects that were linked. - The AT_stmt_list attribute for each TAG_source_file entry in the - ".debug" section contains the offset into the ".line" section for the - start of the table for that file. + The AT_stmt_list attribute for each TAG_source_file entry in the + ".debug" section contains the offset into the ".line" section for the + start of the table for that file. - The table itself has the following structure: + The table itself has the following structure: -