X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fhpread.c;h=2c7cc76c0e88436553b66aaa7155bae28d8b719c;hb=e1e9e218c189882084a89fdee655a0a523efbaf8;hp=099a883db49e466ecf49fc4c47f0cecb328bf230;hpb=2d336b1b5186660c5965deb7b7728fefe0f2d14d;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/hpread.c b/gdb/hpread.c index 099a883db4..2c7cc76c0e 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -1,5 +1,5 @@ /* Read hp debug symbols and convert to internal format, for GDB. - Copyright 1993 Free Software Foundation, Inc. + Copyright 1993, 1996 Free Software Foundation, Inc. This file is part of GDB. @@ -15,14 +15,15 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. Written by the Center for Software Science at the University of Utah and by Cygnus Support. */ #include "defs.h" #include "bfd.h" -#include +#include "gdb_string.h" #include "hp-symtab.h" #include "syms.h" #include "symtab.h" @@ -32,40 +33,41 @@ #include "complaints.h" #include "gdb-stabs.h" #include "gdbtypes.h" +#include "demangle.h" /* Private information attached to an objfile which we use to find and internalize the HP C debug symbols within that objfile. */ struct hpread_symfile_info -{ - /* The contents of each of the debug sections (there are 4 of them). */ - char *gntt; - char *lntt; - char *slt; - char *vt; + { + /* The contents of each of the debug sections (there are 4 of them). */ + char *gntt; + char *lntt; + char *slt; + char *vt; - /* We keep the size of the $VT$ section for range checking. */ - unsigned int vt_size; + /* We keep the size of the $VT$ section for range checking. */ + unsigned int vt_size; - /* Some routines still need to know the number of symbols in the - main debug sections ($LNTT$ and $GNTT$). */ - unsigned int lntt_symcount; - unsigned int gntt_symcount; + /* Some routines still need to know the number of symbols in the + main debug sections ($LNTT$ and $GNTT$). */ + unsigned int lntt_symcount; + unsigned int gntt_symcount; - /* To keep track of all the types we've processed. */ - struct type **type_vector; - int type_vector_length; + /* To keep track of all the types we've processed. */ + struct type **type_vector; + int type_vector_length; - /* Keeps track of the beginning of a range of source lines. */ - sltpointer sl_index; + /* Keeps track of the beginning of a range of source lines. */ + sltpointer sl_index; - /* Some state variables we'll need. */ - int within_function; + /* Some state variables we'll need. */ + int within_function; - /* Keep track of the current function's address. We may need to look - up something based on this address. */ - unsigned int current_function_value; -}; + /* Keep track of the current function's address. We may need to look + up something based on this address. */ + unsigned int current_function_value; + }; /* Accessor macros to get at the fields. */ #define HPUX_SYMFILE_INFO(o) \ @@ -99,29 +101,30 @@ struct hpread_symfile_info } \ else \ *NAMEP = (SYM)->dsfile.name + VT (OBJFILE) + +/* We put a pointer to this structure in the read_symtab_private field + of the psymtab. */ + +struct symloc + { + /* The offset within the file symbol table of first local symbol for + this file. */ -/* Each partial symbol table entry contains a pointer to private data for the - read_symtab() function to use when expanding a partial symbol table entry - to a full symbol table entry. + int ldsymoff; - For hpuxread this structure contains the offset within the file symbol table - of first local symbol for this file, and length (in bytes) of the section - of the symbol table devoted to this file's symbols (actually, the section - bracketed may contain more than just this file's symbols). + /* Length (in bytes) of the section of the symbol table devoted to + this file's symbols (actually, the section bracketed may contain + more than just this file's symbols). If ldsymlen is 0, the only + reason for this thing's existence is the dependency list. + Nothing else will happen when it is read in. */ - If ldsymlen is 0, the only reason for this thing's existence is the - dependency list. Nothing else will happen when it is read in. */ + int ldsymlen; + }; #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen) #define SYMLOC(p) ((struct symloc *)((p)->read_symtab_private)) - -struct symloc -{ - int ldsymoff; - int ldsymlen; -}; - + /* FIXME: Shouldn't this stuff be in a .h file somewhere? */ /* Nonzero means give verbose info on gdb action. */ extern int info_verbose; @@ -130,77 +133,73 @@ extern int info_verbose; extern struct complaint string_table_offset_complaint; extern struct complaint lbrac_unmatched_complaint; extern struct complaint lbrac_mismatch_complaint; - -void hpread_symfile_init PARAMS ((struct objfile *)); -static struct type *hpread_alloc_type - PARAMS ((dnttpointer, struct objfile *)); +void hpread_symfile_init (struct objfile *); + +static struct type *hpread_read_array_type (dnttpointer, union dnttentry *, + struct objfile *); + +static struct type *hpread_alloc_type (dnttpointer, struct objfile *); -static struct type **hpread_lookup_type - PARAMS ((dnttpointer, struct objfile *)); +static struct type **hpread_lookup_type (dnttpointer, struct objfile *); static struct type *hpread_read_enum_type - PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); + (dnttpointer, union dnttentry *, struct objfile *); static struct type *hpread_read_set_type - PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); + (dnttpointer, union dnttentry *, struct objfile *); static struct type *hpread_read_subrange_type - PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); + (dnttpointer, union dnttentry *, struct objfile *); static struct type *hpread_read_struct_type - PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); + (dnttpointer, union dnttentry *, struct objfile *); -void hpread_build_psymtabs - PARAMS ((struct objfile *, struct section_offsets *, int)); +void hpread_build_psymtabs (struct objfile *, int); -void hpread_symfile_finish PARAMS ((struct objfile *)); +void hpread_symfile_finish (struct objfile *); static struct partial_symtab *hpread_start_psymtab - PARAMS ((struct objfile *, struct section_offsets *, char *, CORE_ADDR, int, - struct partial_symbol *, struct partial_symbol *)); + (struct objfile *, char *, CORE_ADDR, int, + struct partial_symbol **, struct partial_symbol **); static struct partial_symtab *hpread_end_psymtab - PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR, - struct partial_symtab **, int)); + (struct partial_symtab *, char **, int, int, CORE_ADDR, + struct partial_symtab **, int); static struct symtab *hpread_expand_symtab - PARAMS ((struct objfile *, int, int, CORE_ADDR, int, - struct section_offsets *, char *)); + (struct objfile *, int, int, CORE_ADDR, int, + struct section_offsets *, char *); static void hpread_process_one_debug_symbol - PARAMS ((union dnttentry *, char *, struct section_offsets *, - struct objfile *, CORE_ADDR, int, char *, int)); + (union dnttentry *, char *, struct section_offsets *, + struct objfile *, CORE_ADDR, int, char *, int); static sltpointer hpread_record_lines - PARAMS ((struct subfile *, sltpointer, sltpointer, struct objfile *)); + (struct subfile *, sltpointer, sltpointer, struct objfile *, CORE_ADDR); static struct type *hpread_read_function_type - PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); + (dnttpointer, union dnttentry *, struct objfile *); -static struct type * hpread_type_lookup - PARAMS ((dnttpointer, struct objfile *)); +static struct type *hpread_type_lookup (dnttpointer, struct objfile *); -static unsigned long hpread_get_depth - PARAMS ((sltpointer, struct objfile *)); +static unsigned long hpread_get_depth (sltpointer, struct objfile *); -static unsigned long hpread_get_line - PARAMS ((sltpointer, struct objfile *)); +static unsigned long hpread_get_line (sltpointer, struct objfile *); -static CORE_ADDR hpread_get_location - PARAMS ((sltpointer, struct objfile *)); - -static int hpread_type_translate PARAMS ((dnttpointer)); -static unsigned long hpread_get_textlow PARAMS ((int, int, struct objfile *)); -static union dnttentry *hpread_get_gntt PARAMS ((int, struct objfile *)); -static union dnttentry *hpread_get_lntt PARAMS ((int, struct objfile *)); -static union sltentry *hpread_get_slt PARAMS ((int, struct objfile *)); -static void hpread_psymtab_to_symtab PARAMS ((struct partial_symtab *)); -static void hpread_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *)); -static int hpread_has_name PARAMS ((enum dntt_entry_type)); +static CORE_ADDR hpread_get_location (sltpointer, struct objfile *); +static int hpread_type_translate (dnttpointer); +static unsigned long hpread_get_textlow (int, int, struct objfile *); +static union dnttentry *hpread_get_gntt (int, struct objfile *); +static union dnttentry *hpread_get_lntt (int, struct objfile *); +static union sltentry *hpread_get_slt (int, struct objfile *); +static void hpread_psymtab_to_symtab (struct partial_symtab *); +static void hpread_psymtab_to_symtab_1 (struct partial_symtab *); +static int hpread_has_name (enum dntt_entry_type); + /* Initialization for reading native HP C debug symbols from OBJFILE. It's only purpose in life is to set up the symbol reader's private @@ -214,8 +213,7 @@ static int hpread_has_name PARAMS ((enum dntt_entry_type)); FIXME, there should be a cleaner peephole into the BFD environment here. */ void -hpread_symfile_init (objfile) - struct objfile *objfile; +hpread_symfile_init (struct objfile *objfile) { asection *vt_section, *slt_section, *lntt_section, *gntt_section; @@ -237,11 +235,11 @@ hpread_symfile_init (objfile) bfd_section_size (objfile->obfd, gntt_section)); bfd_get_section_contents (objfile->obfd, gntt_section, GNTT (objfile), - 0, bfd_section_size (objfile->obfd, gntt_section)); + 0, bfd_section_size (objfile->obfd, gntt_section)); GNTT_SYMCOUNT (objfile) = bfd_section_size (objfile->obfd, gntt_section) - / sizeof (struct dntt_type_block); + / sizeof (struct dntt_type_block); /* Read in data from the $LNTT$ subspace. Also keep track of the number of LNTT symbols. */ @@ -254,11 +252,11 @@ hpread_symfile_init (objfile) bfd_section_size (objfile->obfd, lntt_section)); bfd_get_section_contents (objfile->obfd, lntt_section, LNTT (objfile), - 0, bfd_section_size (objfile->obfd, lntt_section)); + 0, bfd_section_size (objfile->obfd, lntt_section)); LNTT_SYMCOUNT (objfile) = bfd_section_size (objfile->obfd, lntt_section) - / sizeof (struct dntt_type_block); + / sizeof (struct dntt_type_block); /* Read in data from the $SLT$ subspace. $SLT$ contains information on source line numbers. */ @@ -271,7 +269,7 @@ hpread_symfile_init (objfile) bfd_section_size (objfile->obfd, slt_section)); bfd_get_section_contents (objfile->obfd, slt_section, SLT (objfile), - 0, bfd_section_size (objfile->obfd, slt_section)); + 0, bfd_section_size (objfile->obfd, slt_section)); /* Read in data from the $VT$ subspace. $VT$ contains things like names and constants. Keep track of the number of symbols in the VT. */ @@ -298,16 +296,11 @@ hpread_symfile_init (objfile) We assume hpread_symfile_init has been called to initialize the symbol reader's private data structures. - SECTION_OFFSETS contains offsets relative to which the symbols in the - various sections are (depending where the sections were actually loaded). MAINLINE is true if we are reading the main symbol table (as opposed to a shared lib or dynamically loaded file). */ void -hpread_build_psymtabs (objfile, section_offsets, mainline) - struct objfile *objfile; - struct section_offsets *section_offsets; - int mainline; +hpread_build_psymtabs (struct objfile *objfile, int mainline) { char *namestring; int past_first_source_file = 0; @@ -334,7 +327,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) int dependencies_used, dependencies_allocated; /* Just in case the stabs reader left turds lying around. */ - pending_blocks = 0; + free_pending_blocks (); make_cleanup (really_free_pendings, 0); pst = (struct partial_symtab *) 0; @@ -354,7 +347,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) (struct partial_symtab **) alloca (dependencies_allocated * sizeof (struct partial_symtab *)); - old_chain = make_cleanup (free_objfile, objfile); + old_chain = make_cleanup_free_objfile (objfile); last_source_file = 0; @@ -448,7 +441,6 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) if (pst && past_first_source_file) { - texthigh += ANOFFSET (section_offsets, SECT_OFF_TEXT); hpread_end_psymtab (pst, psymtab_include_list, includes_used, (hp_symnum @@ -463,11 +455,11 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) past_first_source_file = 1; valu = hpread_get_textlow (i, hp_symnum, objfile); - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); - pst = hpread_start_psymtab (objfile, section_offsets, + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + pst = hpread_start_psymtab (objfile, namestring, valu, (hp_symnum - * sizeof (struct dntt_type_block)), + * sizeof (struct dntt_type_block)), objfile->global_psymbols.next, objfile->static_psymbols.next); texthigh = valu; @@ -477,17 +469,17 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) case DNTT_TYPE_MODULE: /* A source file. It's still unclear to me what the - real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE - is supposed to be. */ + real difference between a DNTT_TYPE_SRCFILE and DNTT_TYPE_MODULE + is supposed to be. */ SET_NAMESTRING (dn_bufp, &namestring, objfile); valu = hpread_get_textlow (i, hp_symnum, objfile); - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, namestring, valu, (hp_symnum - * sizeof (struct dntt_type_block)), + * sizeof (struct dntt_type_block)), objfile->global_psymbols.next, objfile->static_psymbols.next); texthigh = valu; @@ -497,25 +489,26 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) case DNTT_TYPE_FUNCTION: case DNTT_TYPE_ENTRY: /* The beginning of a function. DNTT_TYPE_ENTRY may also denote - a secondary entry point. */ + a secondary entry point. */ + valu = dn_bufp->dfunc.hiaddr + ANOFFSET (objfile->section_offsets, + SECT_OFF_TEXT (objfile)); + if (valu > texthigh) + texthigh = valu; valu = dn_bufp->dfunc.lowaddr + - ANOFFSET (section_offsets, SECT_OFF_TEXT); - if (dn_bufp->dfunc.hiaddr > texthigh) - texthigh = dn_bufp->dfunc.hiaddr; + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); SET_NAMESTRING (dn_bufp, &namestring, objfile); - ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), + add_psymbol_to_list (namestring, strlen (namestring), VAR_NAMESPACE, LOC_BLOCK, - objfile->static_psymbols, valu, - language_unknown, objfile); + &objfile->static_psymbols, valu, + 0, language_unknown, objfile); within_function = 1; continue; case DNTT_TYPE_BEGIN: case DNTT_TYPE_END: /* Scope block begin/end. We only care about function - and file blocks right now. */ + and file blocks right now. */ if (dn_bufp->dend.endkind == DNTT_TYPE_MODULE) { - texthigh += ANOFFSET (section_offsets, SECT_OFF_TEXT); hpread_end_psymtab (pst, psymtab_include_list, includes_used, (hp_symnum * sizeof (struct dntt_type_block)), @@ -536,7 +529,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) { /* Variables, typedefs an the like. */ enum address_class storage; - enum namespace namespace; + namespace_enum namespace; /* Don't add locals to the partial symbol table. */ if (within_function @@ -564,28 +557,28 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) SET_NAMESTRING (dn_bufp, &namestring, objfile); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, "globals", 0, (hp_symnum - * sizeof (struct dntt_type_block)), - objfile->global_psymbols.next, - objfile->static_psymbols.next); + * sizeof (struct dntt_type_block)), + objfile->global_psymbols.next, + objfile->static_psymbols.next); } if (dn_bufp->dsvar.global) { - ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), + add_psymbol_to_list (namestring, strlen (namestring), namespace, storage, - objfile->global_psymbols, + &objfile->global_psymbols, dn_bufp->dsvar.location, - language_unknown, objfile); + 0, language_unknown, objfile); } else { - ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), + add_psymbol_to_list (namestring, strlen (namestring), namespace, storage, - objfile->static_psymbols, + &objfile->static_psymbols, dn_bufp->dsvar.location, - language_unknown, objfile); + 0, language_unknown, objfile); } continue; } @@ -595,17 +588,17 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) SET_NAMESTRING (dn_bufp, &namestring, objfile); if (!pst) { - pst = hpread_start_psymtab (objfile, section_offsets, + pst = hpread_start_psymtab (objfile, "globals", 0, - (hp_symnum - * sizeof (struct dntt_type_block)), + (hp_symnum + * sizeof (struct dntt_type_block)), objfile->global_psymbols.next, objfile->static_psymbols.next); } - ADD_PSYMBOL_TO_LIST (namestring, strlen (namestring), + add_psymbol_to_list (namestring, strlen (namestring), VAR_NAMESPACE, LOC_CONST, - objfile->static_psymbols, 0, - language_unknown, objfile); + &objfile->static_psymbols, 0, + 0, language_unknown, objfile); continue; default: continue; @@ -630,8 +623,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) objfile struct from the global list of known objfiles. */ void -hpread_symfile_finish (objfile) - struct objfile *objfile; +hpread_symfile_finish (struct objfile *objfile) { if (objfile->sym_private != NULL) { @@ -645,41 +637,32 @@ hpread_symfile_finish (objfile) /* Various small functions to get entries in the debug symbol sections. */ static union dnttentry * -hpread_get_lntt (index, objfile) - int index; - struct objfile *objfile; +hpread_get_lntt (int index, struct objfile *objfile) { return (union dnttentry *) &(LNTT (objfile)[(index * sizeof (struct dntt_type_block))]); } static union dnttentry * -hpread_get_gntt (index, objfile) - int index; - struct objfile *objfile; +hpread_get_gntt (int index, struct objfile *objfile) { return (union dnttentry *) &(GNTT (objfile)[(index * sizeof (struct dntt_type_block))]); } static union sltentry * -hpread_get_slt (index, objfile) - int index; - struct objfile *objfile; +hpread_get_slt (int index, struct objfile *objfile) { - return (union sltentry *)&(SLT (objfile)[index * sizeof (union sltentry)]); + return (union sltentry *) &(SLT (objfile)[index * sizeof (union sltentry)]); } /* Get the low address associated with some symbol (typically the start of a particular source file or module). Since that information is not - stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we must infer it from - the existance of DNTT_TYPE_FUNCTION symbols. */ + stored as part of the DNTT_TYPE_MODULE or DNTT_TYPE_SRCFILE symbol we + must infer it from the existence of DNTT_TYPE_FUNCTION symbols. */ static unsigned long -hpread_get_textlow (global, index, objfile) - int global; - int index; - struct objfile *objfile; +hpread_get_textlow (int global, int index, struct objfile *objfile) { union dnttentry *dn_bufp; struct minimal_symbol *msymbol; @@ -691,8 +674,9 @@ hpread_get_textlow (global, index, objfile) dn_bufp = hpread_get_gntt (index++, objfile); else dn_bufp = hpread_get_lntt (index++, objfile); - } while (dn_bufp->dblock.kind != DNTT_TYPE_FUNCTION - && dn_bufp->dblock.kind != DNTT_TYPE_END); + } + while (dn_bufp->dblock.kind != DNTT_TYPE_FUNCTION + && dn_bufp->dblock.kind != DNTT_TYPE_END); /* Avoid going past a DNTT_TYPE_END when looking for a DNTT_TYPE_FUNCTION. This might happen when a sourcefile has no functions. */ @@ -711,9 +695,7 @@ hpread_get_textlow (global, index, objfile) /* Get the nesting depth for the source line identified by INDEX. */ static unsigned long -hpread_get_depth (index, objfile) - sltpointer index; - struct objfile *objfile; +hpread_get_depth (sltpointer index, struct objfile *objfile) { union sltentry *sl_bufp; @@ -724,9 +706,7 @@ hpread_get_depth (index, objfile) /* Get the source line number the the line identified by INDEX. */ static unsigned long -hpread_get_line (index, objfile) - sltpointer index; - struct objfile *objfile; +hpread_get_line (sltpointer index, struct objfile *objfile) { union sltentry *sl_bufp; @@ -735,9 +715,7 @@ hpread_get_line (index, objfile) } static CORE_ADDR -hpread_get_location (index, objfile) - sltpointer index; - struct objfile *objfile; +hpread_get_location (sltpointer index, struct objfile *objfile) { union sltentry *sl_bufp; int i; @@ -766,8 +744,7 @@ hpread_get_location (index, objfile) it, else return 0. */ static int -hpread_has_name (kind) - enum dntt_entry_type kind; +hpread_has_name (enum dntt_entry_type kind) { switch (kind) { @@ -818,15 +795,10 @@ hpread_has_name (kind) (normal). */ static struct partial_symtab * -hpread_start_psymtab (objfile, section_offsets, - filename, textlow, ldsymoff, global_syms, static_syms) - struct objfile *objfile; - struct section_offsets *section_offsets; - char *filename; - CORE_ADDR textlow; - int ldsymoff; - struct partial_symbol *global_syms; - struct partial_symbol *static_syms; +hpread_start_psymtab (struct objfile *objfile, char *filename, + CORE_ADDR textlow, int ldsymoff, + struct partial_symbol **global_syms, + struct partial_symbol **static_syms) { struct partial_symtab *result = start_psymtab_common (objfile, section_offsets, @@ -847,21 +819,17 @@ hpread_start_psymtab (objfile, section_offsets, FIXME: List variables and peculiarities of same. */ static struct partial_symtab * -hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, - capping_text, dependency_list, number_dependencies) - struct partial_symtab *pst; - char **include_list; - int num_includes; - int capping_symbol_offset; - CORE_ADDR capping_text; - struct partial_symtab **dependency_list; - int number_dependencies; +hpread_end_psymtab (struct partial_symtab *pst, char **include_list, + int num_includes, int capping_symbol_offset, + CORE_ADDR capping_text, + struct partial_symtab **dependency_list, + int number_dependencies) { int i; - struct objfile *objfile = pst -> objfile; + struct objfile *objfile = pst->objfile; if (capping_symbol_offset != -1) - LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst); + LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst); pst->texthigh = capping_text; pst->n_global_syms = @@ -874,9 +842,9 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, { pst->dependencies = (struct partial_symtab **) obstack_alloc (&objfile->psymbol_obstack, - number_dependencies * sizeof (struct partial_symtab *)); + number_dependencies * sizeof (struct partial_symtab *)); memcpy (pst->dependencies, dependency_list, - number_dependencies * sizeof (struct partial_symtab *)); + number_dependencies * sizeof (struct partial_symtab *)); } else pst->dependencies = 0; @@ -884,19 +852,19 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, for (i = 0; i < num_includes; i++) { struct partial_symtab *subpst = - allocate_psymtab (include_list[i], objfile); + allocate_psymtab (include_list[i], objfile); subpst->section_offsets = pst->section_offsets; subpst->read_symtab_private = - (char *) obstack_alloc (&objfile->psymbol_obstack, - sizeof (struct symloc)); - LDSYMOFF(subpst) = - LDSYMLEN(subpst) = - subpst->textlow = - subpst->texthigh = 0; + (char *) obstack_alloc (&objfile->psymbol_obstack, + sizeof (struct symloc)); + LDSYMOFF (subpst) = + LDSYMLEN (subpst) = + subpst->textlow = + subpst->texthigh = 0; /* We could save slight bits of space by only making one of these, - shared by the entire set of include files. FIXME-someday. */ + shared by the entire set of include files. FIXME-someday. */ subpst->dependencies = (struct partial_symtab **) obstack_alloc (&objfile->psymbol_obstack, sizeof (struct partial_symtab *)); @@ -905,8 +873,8 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, subpst->globals_offset = subpst->n_global_syms = - subpst->statics_offset = - subpst->n_static_syms = 0; + subpst->statics_offset = + subpst->n_static_syms = 0; subpst->readin = 0; subpst->symtab = 0; @@ -926,30 +894,17 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, && pst->n_static_syms == 0) { /* Throw away this psymtab, it's empty. We can't deallocate it, since - it is on the obstack, but we can forget to chain it on the list. */ + it is on the obstack, but we can forget to chain it on the list. */ /* Empty psymtabs happen as a result of header files which don't have - any symbols in them. There can be a lot of them. But this check - is wrong, in that a psymtab with N_SLINE entries but nothing else - is not empty, but we don't realize that. Fixing that without slowing - things down might be tricky. */ - struct partial_symtab *prev_pst; + any symbols in them. There can be a lot of them. But this check + is wrong, in that a psymtab with N_SLINE entries but nothing else + is not empty, but we don't realize that. Fixing that without slowing + things down might be tricky. */ - /* First, snip it out of the psymtab chain */ - - if (pst->objfile->psymtabs == pst) - pst->objfile->psymtabs = pst->next; - else - for (prev_pst = pst->objfile->psymtabs; prev_pst; prev_pst = pst->next) - if (prev_pst->next == pst) - prev_pst->next = pst->next; - - /* Next, put it on a free list for recycling */ - - pst->next = pst->objfile->free_psymtabs; - pst->objfile->free_psymtabs = pst; + discard_psymtab (pst); /* Indicate that psymtab was thrown away. */ - pst = (struct partial_symtab *)NULL; + pst = (struct partial_symtab *) NULL; } return pst; } @@ -958,8 +913,7 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, table. */ static void -hpread_psymtab_to_symtab_1 (pst) - struct partial_symtab *pst; +hpread_psymtab_to_symtab_1 (struct partial_symtab *pst) { struct cleanup *old_chain; int i; @@ -983,13 +937,13 @@ hpread_psymtab_to_symtab_1 (pst) /* Inform about additional files that need to be read in. */ if (info_verbose) { - fputs_filtered (" ", stdout); + fputs_filtered (" ", gdb_stdout); wrap_here (""); - fputs_filtered ("and ", stdout); + fputs_filtered ("and ", gdb_stdout); wrap_here (""); printf_filtered ("%s...", pst->dependencies[i]->filename); wrap_here (""); /* Flush output */ - fflush (stdout); + gdb_flush (gdb_stdout); } hpread_psymtab_to_symtab_1 (pst->dependencies[i]); } @@ -1017,8 +971,7 @@ hpread_psymtab_to_symtab_1 (pst) Be verbose about it if the user wants that. */ static void -hpread_psymtab_to_symtab (pst) - struct partial_symtab *pst; +hpread_psymtab_to_symtab (struct partial_symtab *pst) { /* Get out quick if given junk. */ if (!pst) @@ -1039,7 +992,7 @@ hpread_psymtab_to_symtab (pst) if (info_verbose) { printf_filtered ("Reading in symbols for %s...", pst->filename); - fflush (stdout); + gdb_flush (gdb_stdout); } hpread_psymtab_to_symtab_1 (pst); @@ -1065,15 +1018,9 @@ hpread_psymtab_to_symtab (pst) SECTION_OFFSETS are the relocation offsets which get added to each symbol. */ static struct symtab * -hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, - section_offsets, filename) - struct objfile *objfile; - int sym_offset; - int sym_size; - CORE_ADDR text_offset; - int text_size; - struct section_offsets *section_offsets; - char *filename; +hpread_expand_symtab (struct objfile *objfile, int sym_offset, int sym_size, + CORE_ADDR text_offset, int text_size, + struct section_offsets *section_offsets, char *filename) { char *namestring; union dnttentry *dn_bufp; @@ -1089,7 +1036,10 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, dn_bufp = hpread_get_lntt (sym_index, objfile); if (!((dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_SRCFILE) || (dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_MODULE))) - start_symtab ("globals", NULL, 0); + { + start_symtab ("globals", NULL, 0); + record_debugformat ("HP"); + } max_symnum = sym_size / sizeof (struct dntt_type_block); @@ -1114,18 +1064,17 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, current_objfile = NULL; - return end_symtab (text_offset + text_size, 0, 0, objfile, 0); + return end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile)); } /* Convert basic types from HP debug format into GDB internal format. */ static int -hpread_type_translate (typep) - dnttpointer typep; +hpread_type_translate (dnttpointer typep) { if (!typep.dntti.immediate) - abort (); + internal_error (__FILE__, __LINE__, "failed internal consistency check"); switch (typep.dntti.type) { @@ -1187,16 +1136,14 @@ hpread_type_translate (typep) case HP_TYPE_FTN_STRING_VAX_COMPAT: return FT_STRING; default: - abort (); + internal_error (__FILE__, __LINE__, "failed internal consistency check"); } } /* Return the type associated with the index found in HP_TYPE. */ static struct type ** -hpread_lookup_type (hp_type, objfile) - dnttpointer hp_type; - struct objfile *objfile; +hpread_lookup_type (dnttpointer hp_type, struct objfile *objfile) { unsigned old_len; int index = hp_type.dnttp.index; @@ -1213,13 +1160,15 @@ hpread_lookup_type (hp_type, objfile) { TYPE_VECTOR_LENGTH (objfile) = 100; TYPE_VECTOR (objfile) = (struct type **) - malloc (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)); + xmmalloc (objfile->md, + TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)); } while (index >= TYPE_VECTOR_LENGTH (objfile)) TYPE_VECTOR_LENGTH (objfile) *= 2; TYPE_VECTOR (objfile) = (struct type **) - xrealloc ((char *) TYPE_VECTOR (objfile), - (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); + xmrealloc (objfile->md, + (char *) TYPE_VECTOR (objfile), + (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); memset (&TYPE_VECTOR (objfile)[old_len], 0, (TYPE_VECTOR_LENGTH (objfile) - old_len) * sizeof (struct type *)); @@ -1235,9 +1184,7 @@ hpread_lookup_type (hp_type, objfile) have it lying around. */ static struct type * -hpread_alloc_type (hp_type, objfile) - dnttpointer hp_type; - struct objfile *objfile; +hpread_alloc_type (dnttpointer hp_type, struct objfile *objfile) { struct type **type_addr; @@ -1253,10 +1200,8 @@ hpread_alloc_type (hp_type, objfile) /* Read a native enumerated type and return it in GDB internal form. */ static struct type * -hpread_read_enum_type (hp_type, dn_bufp, objfile) - dnttpointer hp_type; - union dnttentry *dn_bufp; - struct objfile *objfile; +hpread_read_enum_type (dnttpointer hp_type, union dnttentry *dn_bufp, + struct objfile *objfile) { struct type *type; struct pending **symlist, *osyms, *syms; @@ -1284,7 +1229,8 @@ hpread_read_enum_type (hp_type, dn_bufp, objfile) sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); memset (sym, 0, sizeof (struct symbol)); - SYMBOL_NAME (sym) = name; + SYMBOL_NAME (sym) = obsavestring (name, strlen (name), + &objfile->symbol_obstack); SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; SYMBOL_VALUE (sym) = memp->dmember.value; @@ -1318,7 +1264,6 @@ hpread_read_enum_type (hp_type, dn_bufp, objfile) struct symbol *xsym = syms->symbol[j]; SYMBOL_TYPE (xsym) = type; TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); - TYPE_FIELD_VALUE (type, n) = 0; TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym); TYPE_FIELD_BITSIZE (type, n) = 0; } @@ -1332,10 +1277,8 @@ hpread_read_enum_type (hp_type, dn_bufp, objfile) /* Read and internalize a native function debug symbol. */ static struct type * -hpread_read_function_type (hp_type, dn_bufp, objfile) - dnttpointer hp_type; - union dnttentry *dn_bufp; - struct objfile *objfile; +hpread_read_function_type (dnttpointer hp_type, union dnttentry *dn_bufp, + struct objfile *objfile) { struct type *type, *type1; struct pending **symlist, *osyms, *syms; @@ -1375,7 +1318,8 @@ hpread_read_function_type (hp_type, dn_bufp, objfile) sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); (void) memset (sym, 0, sizeof (struct symbol)); - SYMBOL_NAME (sym) = name; + SYMBOL_NAME (sym) = obsavestring (name, strlen (name), + &objfile->symbol_obstack); /* Figure out where it lives. */ if (paramp->dfparam.regparam) @@ -1387,7 +1331,7 @@ hpread_read_function_type (hp_type, dn_bufp, objfile) SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; if (paramp->dfparam.copyparam) { - SYMBOL_VALUE (sym) = paramp->dfparam.location ; + SYMBOL_VALUE (sym) = paramp->dfparam.location; #ifdef HPREAD_ADJUST_STACK_ADDRESS SYMBOL_VALUE (sym) += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); @@ -1441,10 +1385,8 @@ hpread_read_function_type (hp_type, dn_bufp, objfile) /* Read in and internalize a structure definition. */ static struct type * -hpread_read_struct_type (hp_type, dn_bufp, objfile) - dnttpointer hp_type; - union dnttentry *dn_bufp; - struct objfile *objfile; +hpread_read_struct_type (dnttpointer hp_type, union dnttentry *dn_bufp, + struct objfile *objfile) { struct nextfield { @@ -1463,7 +1405,7 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) type = hpread_alloc_type (hp_type, objfile); if ((TYPE_CODE (type) == TYPE_CODE_STRUCT) || (TYPE_CODE (type) == TYPE_CODE_UNION)) - return type; + return type; /* Get the basic type correct. */ if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) @@ -1494,14 +1436,15 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) list = new; list->field.name = VT (objfile) + fieldp->dfield.name; - list->field.bitpos = fieldp->dfield.bitoffset; + FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset; if (fieldp->dfield.bitlength % 8) - list->field.bitsize = fieldp->dfield.bitlength; + FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength; else - list->field.bitsize = 0; + FIELD_BITSIZE (list->field) = 0; nfields++; field = fieldp->dfield.nextfield; - list->field.type = hpread_type_lookup (fieldp->dfield.type, objfile); + FIELD_TYPE (list->field) = hpread_type_lookup (fieldp->dfield.type, + objfile); } TYPE_NFIELDS (type) = nfields; @@ -1520,10 +1463,8 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) /* Read in and internalize a set debug symbol. */ static struct type * -hpread_read_set_type (hp_type, dn_bufp, objfile) - dnttpointer hp_type; - union dnttentry *dn_bufp; - struct objfile *objfile; +hpread_read_set_type (dnttpointer hp_type, union dnttentry *dn_bufp, + struct objfile *objfile) { struct type *type; @@ -1544,10 +1485,8 @@ hpread_read_set_type (hp_type, dn_bufp, objfile) /* Read in and internalize an array debug symbol. */ static struct type * -hpread_read_array_type (hp_type, dn_bufp, objfile) - dnttpointer hp_type; - union dnttentry *dn_bufp; - struct objfile *objfile; +hpread_read_array_type (dnttpointer hp_type, union dnttentry *dn_bufp, + struct objfile *objfile) { struct type *type; union dnttentry save; @@ -1562,13 +1501,13 @@ hpread_read_array_type (hp_type, dn_bufp, objfile) /* values are not normalized. */ if (!((dn_bufp->darray.arrayisbytes && dn_bufp->darray.elemisbytes) || (!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes))) - abort (); + internal_error (__FILE__, __LINE__, "failed internal consistency check"); else if (dn_bufp->darray.arraylength == 0x7fffffff) { /* The HP debug format represents char foo[]; as an array with - length 0x7fffffff. Internally GDB wants to represent this - as an array of length zero. */ - TYPE_LENGTH (type) = 0; + length 0x7fffffff. Internally GDB wants to represent this + as an array of length zero. */ + TYPE_LENGTH (type) = 0; } else TYPE_LENGTH (type) = dn_bufp->darray.arraylength / 8; @@ -1586,10 +1525,8 @@ hpread_read_array_type (hp_type, dn_bufp, objfile) /* Read in and internalize a subrange debug symbol. */ static struct type * -hpread_read_subrange_type (hp_type, dn_bufp, objfile) - dnttpointer hp_type; - union dnttentry *dn_bufp; - struct objfile *objfile; +hpread_read_subrange_type (dnttpointer hp_type, union dnttentry *dn_bufp, + struct objfile *objfile) { struct type *type; @@ -1602,8 +1539,9 @@ hpread_read_subrange_type (hp_type, dn_bufp, objfile) TYPE_CODE (type) = TYPE_CODE_RANGE; TYPE_LENGTH (type) = dn_bufp->dsubr.bitlength / 8; TYPE_NFIELDS (type) = 2; - TYPE_FIELDS (type) = (struct field *) obstack_alloc - (&objfile->type_obstack, 2 * sizeof (struct field)); + TYPE_FIELDS (type) + = (struct field *) obstack_alloc (&objfile->type_obstack, + 2 * sizeof (struct field)); if (dn_bufp->dsubr.dyn_low) TYPE_FIELD_BITPOS (type, 0) = 0; @@ -1620,9 +1558,7 @@ hpread_read_subrange_type (hp_type, dn_bufp, objfile) } static struct type * -hpread_type_lookup (hp_type, objfile) - dnttpointer hp_type; - struct objfile *objfile; +hpread_type_lookup (dnttpointer hp_type, struct objfile *objfile) { union dnttentry *dn_bufp; @@ -1664,7 +1600,7 @@ hpread_type_lookup (hp_type, objfile) TYPE_CPLUS_SPECIFIC (structtype) = (struct cplus_struct_type *) &cplus_struct_default; - TYPE_NAME (structtype) = suffix; + TYPE_NAME (structtype) = suffix; return structtype; } @@ -1682,7 +1618,7 @@ hpread_type_lookup (hp_type, objfile) if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile)) dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile); else - abort (); + internal_error (__FILE__, __LINE__, "failed internal consistency check"); if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) prefix = "struct "; @@ -1738,10 +1674,9 @@ hpread_type_lookup (hp_type, objfile) } static sltpointer -hpread_record_lines (subfile, s_idx, e_idx, objfile) - struct subfile *subfile; - sltpointer s_idx, e_idx; - struct objfile *objfile; +hpread_record_lines (struct subfile *subfile, sltpointer s_idx, + sltpointer e_idx, struct objfile *objfile, + CORE_ADDR offset) { union sltentry *sl_bufp; @@ -1751,7 +1686,8 @@ hpread_record_lines (subfile, s_idx, e_idx, objfile) /* Only record "normal" entries in the SLT. */ if (sl_bufp->snorm.sltdesc == SLT_NORMAL || sl_bufp->snorm.sltdesc == SLT_EXIT) - record_line (subfile, sl_bufp->snorm.line, sl_bufp->snorm.address); + record_line (subfile, sl_bufp->snorm.line, + sl_bufp->snorm.address + offset); s_idx++; } return e_idx; @@ -1760,21 +1696,15 @@ hpread_record_lines (subfile, s_idx, e_idx, objfile) /* Internalize one native debug symbol. */ static void -hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, - text_offset, text_size, filename, index) - union dnttentry *dn_bufp; - char *name; - struct section_offsets *section_offsets; - struct objfile *objfile; - CORE_ADDR text_offset; - int text_size; - char *filename; - int index; +hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name, + struct section_offsets *section_offsets, + struct objfile *objfile, CORE_ADDR text_offset, + int text_size, char *filename, int index) { unsigned long desc; int type; CORE_ADDR valu; - int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT); + int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); union dnttentry *dn_temp; dnttpointer hp_type; struct symbol *sym; @@ -1784,7 +1714,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); memset (sym, 0, sizeof (struct symbol)); - SYMBOL_NAME (sym) = name; + SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack); SYMBOL_LANGUAGE (sym) = language_auto; SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; @@ -1808,17 +1738,23 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, finish the symbol table of the previous source file (if any) and start accumulating a new symbol table. */ - valu = text_offset + offset; /* Relocate for dynamic loading */ + valu = text_offset; if (!last_source_file) - start_symtab (name, NULL, valu); - - SL_INDEX (objfile) = hpread_record_lines (current_subfile, - SL_INDEX (objfile), - dn_bufp->dsfile.address, - objfile); + { + start_symtab (name, NULL, valu); + record_debugformat ("HP"); + SL_INDEX (objfile) = dn_bufp->dsfile.address; + } + else + { + SL_INDEX (objfile) = hpread_record_lines (current_subfile, + SL_INDEX (objfile), + dn_bufp->dsfile.address, + objfile, offset); + } start_subfile (name, NULL); break; - + case DNTT_TYPE_MODULE: /* No need to do anything with these DNTT_TYPE_MODULE symbols anymore. */ break; @@ -1830,8 +1766,8 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SL_INDEX (objfile) = hpread_record_lines (current_subfile, SL_INDEX (objfile), dn_bufp->dfunc.address, - objfile); - + objfile, offset); + WITHIN_FUNCTION (objfile) = 1; CURRENT_FUNCTION_VALUE (objfile) = valu; @@ -1858,7 +1794,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SL_INDEX (objfile) = hpread_record_lines (current_subfile, SL_INDEX (objfile), dn_bufp->dbegin.address, - objfile); + objfile, offset); SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); record_line (current_subfile, SYMBOL_LINE (sym), valu); break; @@ -1868,7 +1804,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SL_INDEX (objfile) = hpread_record_lines (current_subfile, SL_INDEX (objfile), dn_bufp->dbegin.address, - objfile); + objfile, offset); valu = hpread_get_location (dn_bufp->dbegin.address, objfile); valu += offset; /* Relocate for dynamic loading */ desc = hpread_get_depth (dn_bufp->dbegin.address, objfile); @@ -1880,13 +1816,13 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SL_INDEX (objfile) = hpread_record_lines (current_subfile, SL_INDEX (objfile), dn_bufp->dend.address + 1, - objfile); + objfile, offset); switch (dn_bufp->dend.endkind) { case DNTT_TYPE_MODULE: /* Ending a module ends the symbol table for that module. */ valu = text_offset + text_size + offset; - (void) end_symtab (valu, 0, 0, objfile, 0); + (void) end_symtab (valu, objfile, SECT_OFF_TEXT (objfile)); break; case DNTT_TYPE_FUNCTION: