From 73a8f35a0b2516d7ac8a19e111fe3006a9d27df0 Mon Sep 17 00:00:00 2001 From: ezannoni Date: Thu, 4 May 2000 16:52:33 +0000 Subject: [PATCH] Elena Zannoni * objfiles.h (SECT_OFF_DATA, SECT_OFF_TEXT, SECT_OFF_BSS, SECT_OFF_RODATA): Define as functions of OBJFILE. Add sect_index_text, sect_index_data, sect_index_rodata, sect_index_bss to objfile structure. * gdb-stabs.h (SECT_OFF_DATA, SECT_OFF_TEXT, SECT_OFF_BSS, SECT_OFF_RODATA): Remove. * objfiles.c (allocate_objfile): Initialize sect_index_{text,data,bss,rodata} to -1, for error detection. * symfile.c (default_symfile_offsets): Initialize sect_index_{text,data,bss,rodata} from bfd information. * xcoffread.c (xcoff_symfile_offsets): Ditto. * somread.c (som_symfile_offsets): Initialize sect_index_{text,data,bss,rodata}. * coffread.c, dbxread.c, elfread.c, hp-psymtab-read.c, hp-symtab-read.c, hpread.c, mdebugread.c, minsyms.c, mipsread.c, objfiles.c, os9kread.c, pa64solib.c, partial-stab.h, remote-os9k.c, remote-vx.c, remote.c, rs6000-nat.c, somsolib.c, stabsread.c, symfile.c, xcoffread.c: Update use of SECT_OFF_{TEXT,DATA,BSS,RODATA} to depend on the current objfile. * xcoffread.c: Add new field objfile to find_targ_sec_arg. --- gdb/ChangeLog | 27 + gdb/coffread.c | 52 +- gdb/dbxread.c | 907 ++++++++-------- gdb/elfread.c | 14 +- gdb/gdb-stabs.h | 9 - gdb/hp-psymtab-read.c | 236 ++-- gdb/hp-symtab-read.c | 2851 +++++++++++++++++++++++++------------------------ gdb/hpread.c | 222 ++-- gdb/mdebugread.c | 1071 ++++++++++--------- gdb/minsyms.c | 6 +- gdb/mipsread.c | 114 +- gdb/objfiles.c | 38 +- gdb/objfiles.h | 28 + gdb/os9kread.c | 1001 ++++++++--------- gdb/pa64solib.c | 12 +- gdb/partial-stab.h | 26 +- gdb/remote-os9k.c | 4 +- gdb/remote-vx.c | 6 +- gdb/remote.c | 12 +- gdb/rs6000-nat.c | 6 +- gdb/somread.c | 14 + gdb/somsolib.c | 24 +- gdb/stabsread.c | 6 +- gdb/symfile.c | 50 +- gdb/xcoffread.c | 907 ++++++++-------- 25 files changed, 3939 insertions(+), 3704 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6a898b6f0c..c69168d238 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,30 @@ +Elena Zannoni + + * objfiles.h (SECT_OFF_DATA, SECT_OFF_TEXT, SECT_OFF_BSS, + SECT_OFF_RODATA): Define as functions of OBJFILE. Add + sect_index_text, sect_index_data, sect_index_rodata, + sect_index_bss to objfile structure. + * gdb-stabs.h (SECT_OFF_DATA, SECT_OFF_TEXT, SECT_OFF_BSS, + SECT_OFF_RODATA): Remove. + * objfiles.c (allocate_objfile): Initialize + sect_index_{text,data,bss,rodata} to -1, for error detection. + + * symfile.c (default_symfile_offsets): Initialize + sect_index_{text,data,bss,rodata} from bfd information. + * xcoffread.c (xcoff_symfile_offsets): Ditto. + * somread.c (som_symfile_offsets): Initialize + sect_index_{text,data,bss,rodata}. + + * coffread.c, dbxread.c, elfread.c, hp-psymtab-read.c, + hp-symtab-read.c, hpread.c, mdebugread.c, minsyms.c, + mipsread.c, objfiles.c, os9kread.c, pa64solib.c, partial-stab.h, + remote-os9k.c, remote-vx.c, remote.c, rs6000-nat.c, somsolib.c, + stabsread.c, symfile.c, xcoffread.c: + Update use of SECT_OFF_{TEXT,DATA,BSS,RODATA} to depend on the + current objfile. + + * xcoffread.c: Add new field objfile to find_targ_sec_arg. + Thu May 4 20:54:00 2000 Andrew Cagney * config/mips/tm-mipsv4.h (Dest_Reg), config/mips/tm-irix5.h diff --git a/gdb/coffread.c b/gdb/coffread.c index 75a90f737c..6f6e6cb75f 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -340,7 +340,7 @@ cs_to_section (cs, objfile) { asection *sect = NULL; struct find_targ_sec_arg args; - int off = SECT_OFF_TEXT; + int off = SECT_OFF_TEXT (objfile); args.targ_index = cs->c_secnum; args.resultp = § @@ -349,11 +349,11 @@ cs_to_section (cs, objfile) { /* This is the section. Figure out what SECT_OFF_* code it is. */ if (bfd_get_section_flags (abfd, sect) & SEC_CODE) - off = SECT_OFF_TEXT; + off = SECT_OFF_TEXT (objfile); else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD) - off = SECT_OFF_DATA; + off = SECT_OFF_DATA (objfile); else - off = SECT_OFF_BSS; + off = SECT_OFF_BSS (objfile); } return off; } @@ -843,7 +843,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile) if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF) { /* Record all functions -- external and static -- in minsyms. */ - tmpaddr = cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + tmpaddr = cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); record_minimal_symbol (cs->c_name, tmpaddr, mst_text, objfile); fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr; @@ -908,7 +908,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile) followed by a later file with no symbols. */ if (in_source_file) complete_symtab (filestring, - cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT), + cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)), main_aux.x_scn.x_scnlen); in_source_file = 0; } @@ -969,10 +969,8 @@ coff_symtab_read (symtab_offset, nsyms, objfile) || cs->c_sclass == C_THUMBEXT) tmpaddr += ANOFFSET (objfile->section_offsets, sec); - switch (sec) + if (sec == SECT_OFF_TEXT (objfile) || sec == SECT_OFF_RODATA (objfile)) { - case SECT_OFF_TEXT: - case SECT_OFF_RODATA: ms_type = cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXTFUNC || cs->c_sclass == C_THUMBEXT ? @@ -981,21 +979,23 @@ coff_symtab_read (symtab_offset, nsyms, objfile) if (tmpaddr & 1) /* FIXME: delete this line */ SMASH_TEXT_ADDRESS (tmpaddr); #endif - break; - case SECT_OFF_DATA: + } + else + if (sec == SECT_OFF_DATA (objfile)) + { ms_type = cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT ? mst_data : mst_file_data; - break; - case SECT_OFF_BSS: + } + else + if (sec == SECT_OFF_BSS (objfile)) + { ms_type = cs->c_sclass == C_EXT || cs->c_sclass == C_THUMBEXT ? mst_data : mst_file_data; - break; - default: - ms_type = mst_unknown; - break; - } + } + else + ms_type = mst_unknown; } if (cs->c_name[0] != '@' /* Skip tdesc symbols */ ) @@ -1099,11 +1099,11 @@ coff_symtab_read (symtab_offset, nsyms, objfile) of the epilogue. */ cs->c_value + FUNCTION_EPILOGUE_SIZE - + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT), + + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)), #else fcn_cs_saved.c_value + fcn_aux_saved.x_sym.x_misc.x_fsize - + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT), + + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)), #endif objfile ); @@ -1115,7 +1115,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile) if (STREQ (cs->c_name, ".bb")) { tmpaddr = cs->c_value; - tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + tmpaddr += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); push_context (++depth, tmpaddr); } else if (STREQ (cs->c_name, ".eb")) @@ -1135,7 +1135,7 @@ coff_symtab_read (symtab_offset, nsyms, objfile) if (local_symbols && context_stack_depth > 0) { tmpaddr = - cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + cs->c_value + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); /* Make a block for the local symbols within. */ finish_block (0, &local_symbols, new->old_blocks, new->start_addr, tmpaddr, objfile); @@ -1427,7 +1427,7 @@ enter_linenos (file_offset, first_line, last_line, objfile) if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line) record_line (current_subfile, first_line + L_LNNO32 (&lptr), lptr.l_addr.l_paddr - + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT)); + + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))); else break; } @@ -1547,7 +1547,7 @@ process_coff_symbol (cs, aux, objfile) if (ISFCN (cs->c_type)) { - SYMBOL_VALUE (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + SYMBOL_VALUE (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); SYMBOL_TYPE (sym) = lookup_function_type (decode_function_type (cs, cs->c_type, aux)); @@ -1577,7 +1577,7 @@ process_coff_symbol (cs, aux, objfile) case C_EXT: SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value; - SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); add_symbol_to_list (sym, &global_symbols); break; @@ -1586,7 +1586,7 @@ process_coff_symbol (cs, aux, objfile) case C_STAT: SYMBOL_CLASS (sym) = LOC_STATIC; SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value; - SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); if (within_function) { /* Static symbol of local scope */ diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 0749412cc3..25302de1cc 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -2,21 +2,22 @@ Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. -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. */ /* This module provides three functions: dbx_symfile_init, which initializes to read a symbol file; dbx_new_init, which @@ -48,7 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "command.h" #include "target.h" #include "gdbcore.h" /* for bfd stuff */ -#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ +#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ #include "symfile.h" #include "objfiles.h" #include "buildsym.h" @@ -60,8 +61,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "aout/aout64.h" #include "aout/stab_gnu.h" /* We always use GNU stabs, not native, now */ - + /* This macro returns the size field of a minimal symbol, which is normally stored in the "info" field. The macro can be overridden for specific targets (e.g. MIPS16) that use the info field for other purposes. */ @@ -73,32 +74,33 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* We put a pointer to this structure in the read_symtab_private field of the psymtab. */ -struct symloc { +struct symloc + { - /* Offset within the file symbol table of first local symbol for this - file. */ + /* Offset within the file symbol table of first local symbol for this + file. */ - int ldsymoff; + int ldsymoff; - /* 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. */ + /* 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. */ - int ldsymlen; + int ldsymlen; - /* The size of each symbol in the symbol file (in external form). */ + /* The size of each symbol in the symbol file (in external form). */ - int symbol_size; + int symbol_size; - /* Further information needed to locate the symbols if they are in - an ELF file. */ + /* Further information needed to locate the symbols if they are in + an ELF file. */ - int symbol_offset; - int string_offset; - int file_string_offset; -}; + int symbol_offset; + int string_offset; + int file_string_offset; + }; #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen) @@ -107,8 +109,8 @@ struct symloc { #define SYMBOL_OFFSET(p) (SYMLOC(p)->symbol_offset) #define STRING_OFFSET(p) (SYMLOC(p)->string_offset) #define FILE_STRING_OFFSET(p) (SYMLOC(p)->file_string_offset) - + /* Remember what we deduced to be the source language of this psymtab. */ static enum language psymtab_language = language_unknown; @@ -170,33 +172,80 @@ static int has_line_numbers; /* Complaints about the symbols we have encountered. */ -struct complaint lbrac_complaint = - {"bad block start address patched", 0, 0}; +struct complaint lbrac_complaint = +{"bad block start address patched", 0, 0}; struct complaint string_table_offset_complaint = - {"bad string table offset in symbol %d", 0, 0}; +{"bad string table offset in symbol %d", 0, 0}; struct complaint unknown_symtype_complaint = - {"unknown symbol type %s", 0, 0}; +{"unknown symbol type %s", 0, 0}; struct complaint unknown_symchar_complaint = - {"unknown symbol descriptor `%c'", 0, 0}; +{"unknown symbol descriptor `%c'", 0, 0}; struct complaint lbrac_rbrac_complaint = - {"block start larger than block end", 0, 0}; +{"block start larger than block end", 0, 0}; struct complaint lbrac_unmatched_complaint = - {"unmatched N_LBRAC before symtab pos %d", 0, 0}; +{"unmatched N_LBRAC before symtab pos %d", 0, 0}; struct complaint lbrac_mismatch_complaint = - {"N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d", 0, 0}; +{"N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d", 0, 0}; struct complaint repeated_header_complaint = - {"\"repeated\" header file %s not previously seen, at symtab pos %d", 0, 0}; +{"\"repeated\" header file %s not previously seen, at symtab pos %d", 0, 0}; struct complaint unclaimed_bincl_complaint = - {"N_BINCL %s not in entries for any file, at symtab pos %d", 0, 0}; +{"N_BINCL %s not in entries for any file, at symtab pos %d", 0, 0}; + +/* find_text_range --- find start and end of loadable code sections + + The find_text_range function finds the shortest address range that + encloses all sections containing executable code, and stores it in + objfile's text_addr and text_size members. + + dbx_symfile_read will use this to finish off the partial symbol + table, in some cases. */ + +static void +find_text_range (bfd * sym_bfd, struct objfile *objfile) +{ + asection *sec; + int found_any = 0; + CORE_ADDR start, end; + + for (sec = sym_bfd->sections; sec; sec = sec->next) + if (bfd_get_section_flags (sym_bfd, sec) & SEC_CODE) + { + CORE_ADDR sec_start = bfd_section_vma (sym_bfd, sec); + CORE_ADDR sec_end = sec_start + bfd_section_size (sym_bfd, sec); + + if (found_any) + { + if (sec_start < start) + start = sec_start; + if (sec_end > end) + end = sec_end; + } + else + { + start = sec_start; + end = sec_end; + } + + found_any = 1; + } + + if (!found_any) + error ("Can't find any code sections in symbol file"); + + DBX_TEXT_ADDR (objfile) = start; + DBX_TEXT_SIZE (objfile) = end - start; +} + + /* During initial symbol readin, we need to have a structure to keep track of which psymtabs have which bincls in them. This structure is used during readin to setup the list of dependencies within each @@ -216,7 +265,9 @@ static int bincls_allocated; /* Local function prototypes */ -static void +extern void _initialize_dbxread PARAMS ((void)); + +static void process_now PARAMS ((struct objfile *)); static void @@ -235,18 +286,16 @@ static void dbx_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *)); static void -read_dbx_dynamic_symtab PARAMS ((struct section_offsets *, - struct objfile *objfile)); +read_dbx_dynamic_symtab PARAMS ((struct objfile * objfile)); static void -read_dbx_symtab PARAMS ((struct section_offsets *, struct objfile *, - CORE_ADDR, int)); +read_dbx_symtab PARAMS ((struct objfile *)); static void free_bincl_list PARAMS ((struct objfile *)); static struct partial_symtab * -find_corresponding_bincl_psymtab PARAMS ((char *, int)); + find_corresponding_bincl_psymtab PARAMS ((char *, int)); static void add_bincl_to_list PARAMS ((struct partial_symtab *, char *, int)); @@ -255,7 +304,7 @@ static void init_bincl_list PARAMS ((int, struct objfile *)); static char * -dbx_next_symbol_text PARAMS ((struct objfile *)); + dbx_next_symbol_text PARAMS ((struct objfile *)); static void fill_symbuf PARAMS ((bfd *)); @@ -267,7 +316,7 @@ static void dbx_new_init PARAMS ((struct objfile *)); static void -dbx_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int)); +dbx_symfile_read PARAMS ((struct objfile *, int)); static void dbx_symfile_finish PARAMS ((struct objfile *)); @@ -284,6 +333,10 @@ add_old_header_file PARAMS ((char *, int)); static void add_this_object_header_file PARAMS ((int)); +static struct partial_symtab * +start_psymtab PARAMS ((struct objfile *, char *, CORE_ADDR, int, + struct partial_symbol **, struct partial_symbol **)); + /* Free up old header file tables */ static void @@ -291,7 +344,7 @@ free_header_files () { if (this_object_header_files) { - free ((PTR)this_object_header_files); + free ((PTR) this_object_header_files); this_object_header_files = NULL; } n_allocated_this_object_header_files = 0; @@ -318,7 +371,7 @@ add_this_object_header_file (i) n_allocated_this_object_header_files *= 2; this_object_header_files = (int *) xrealloc ((char *) this_object_header_files, - n_allocated_this_object_header_files * sizeof (int)); + n_allocated_this_object_header_files * sizeof (int)); } this_object_header_files[n_this_object_header_files++] = i; @@ -391,7 +444,7 @@ add_new_header_file (name, instance) i = N_HEADER_FILES (current_objfile)++; hfile = HEADER_FILES (current_objfile) + i; - hfile->name = savestring (name, strlen(name)); + hfile->name = savestring (name, strlen (name)); hfile->instance = instance; hfile->length = 10; hfile->vector @@ -414,7 +467,7 @@ explicit_lookup_type (real_filenum, index) f->vector = (struct type **) xrealloc (f->vector, f->length * sizeof (struct type *)); memset (&f->vector[f->length / 2], - '\0', f->length * sizeof (struct type *) / 2); + '\0', f->length * sizeof (struct type *) / 2); } return &f->vector[index]; } @@ -435,17 +488,17 @@ record_minimal_symbol (name, address, type, objfile) { case N_TEXT | N_EXT: ms_type = mst_text; - section = SECT_OFF_TEXT; + section = SECT_OFF_TEXT (objfile); bfd_section = DBX_TEXT_SECTION (objfile); break; case N_DATA | N_EXT: ms_type = mst_data; - section = SECT_OFF_DATA; + section = SECT_OFF_DATA (objfile); bfd_section = DBX_DATA_SECTION (objfile); break; case N_BSS | N_EXT: ms_type = mst_bss; - section = SECT_OFF_BSS; + section = SECT_OFF_BSS (objfile); bfd_section = DBX_BSS_SECTION (objfile); break; case N_ABS | N_EXT: @@ -456,15 +509,15 @@ record_minimal_symbol (name, address, type, objfile) #ifdef N_SETV case N_SETV | N_EXT: ms_type = mst_data; - section = SECT_OFF_DATA; + section = SECT_OFF_DATA (objfile); bfd_section = DBX_DATA_SECTION (objfile); break; case N_SETV: /* I don't think this type actually exists; since a N_SETV is the result - of going over many .o files, it doesn't make sense to have one - file local. */ + of going over many .o files, it doesn't make sense to have one + file local. */ ms_type = mst_file_data; - section = SECT_OFF_DATA; + section = SECT_OFF_DATA (objfile); bfd_section = DBX_DATA_SECTION (objfile); break; #endif @@ -473,16 +526,16 @@ record_minimal_symbol (name, address, type, objfile) case N_FN: case N_FN_SEQ: ms_type = mst_file_text; - section = SECT_OFF_TEXT; + section = SECT_OFF_TEXT (objfile); bfd_section = DBX_TEXT_SECTION (objfile); break; case N_DATA: ms_type = mst_file_data; /* Check for __DYNAMIC, which is used by Sun shared libraries. - Record it as global even if it's local, not global, so - lookup_minimal_symbol can find it. We don't check symbol_leading_char - because for SunOS4 it always is '_'. */ + Record it as global even if it's local, not global, so + lookup_minimal_symbol can find it. We don't check symbol_leading_char + because for SunOS4 it always is '_'. */ if (name[8] == 'C' && STREQ ("__DYNAMIC", name)) ms_type = mst_data; @@ -494,12 +547,12 @@ record_minimal_symbol (name, address, type, objfile) if (VTBL_PREFIX_P ((tempstring))) ms_type = mst_data; } - section = SECT_OFF_DATA; + section = SECT_OFF_DATA (objfile); bfd_section = DBX_DATA_SECTION (objfile); break; case N_BSS: ms_type = mst_file_bss; - section = SECT_OFF_BSS; + section = SECT_OFF_BSS (objfile); bfd_section = DBX_BSS_SECTION (objfile); break; default: @@ -507,7 +560,7 @@ record_minimal_symbol (name, address, type, objfile) section = -1; bfd_section = NULL; break; - } + } if ((ms_type == mst_file_text || ms_type == mst_text) && address < lowest_text_address) @@ -522,23 +575,18 @@ record_minimal_symbol (name, address, type, objfile) put all the relevant info into a "struct dbx_symfile_info", hung off the objfile structure. - 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). */ static void -dbx_symfile_read (objfile, section_offsets, mainline) +dbx_symfile_read (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; - int mainline; /* FIXME comments above */ + int mainline; /* FIXME comments above */ { bfd *sym_bfd; int val; struct cleanup *back_to; - val = strlen (objfile->name); - sym_bfd = objfile->obfd; /* .o and .nlm files are relocatables with text, data and bss segs based at @@ -556,6 +604,7 @@ dbx_symfile_read (objfile, section_offsets, mainline) || (0 == strncmp (bfd_get_target (sym_bfd), "som", 3)) || (0 == strncmp (bfd_get_target (sym_bfd), "coff", 4)) || (0 == strncmp (bfd_get_target (sym_bfd), "pe", 2)) + || (0 == strncmp (bfd_get_target (sym_bfd), "epoc-pe", 7)) || (0 == strncmp (bfd_get_target (sym_bfd), "nlm", 3))); val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET); @@ -572,21 +621,18 @@ dbx_symfile_read (objfile, section_offsets, mainline) symbol_table_offset = DBX_SYMTAB_OFFSET (objfile); free_pending_blocks (); - back_to = make_cleanup ((make_cleanup_func) really_free_pendings, 0); + back_to = make_cleanup (really_free_pendings, 0); init_minimal_symbol_collection (); make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0); - /* Now that the symbol table data of the executable file are all in core, - process them and define symbols accordingly. */ + /* Read stabs data from executable file and define symbols. */ - read_dbx_symtab (section_offsets, objfile, - DBX_TEXT_ADDR (objfile), - DBX_TEXT_SIZE (objfile)); + read_dbx_symtab (objfile); /* Add the dynamic symbols. */ - read_dbx_dynamic_symtab (section_offsets, objfile); + read_dbx_dynamic_symtab (objfile); /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ @@ -623,7 +669,7 @@ dbx_new_init (ignore) be called unless this is an a.out (or very similar) file. FIXME, there should be a cleaner peephole into the BFD environment here. */ -#define DBX_STRINGTAB_SIZE_SIZE sizeof(long) /* FIXME */ +#define DBX_STRINGTAB_SIZE_SIZE sizeof(long) /* FIXME */ static void dbx_symfile_init (objfile) @@ -637,7 +683,7 @@ dbx_symfile_init (objfile) /* Allocate struct to keep track of the symfile */ objfile->sym_stab_info = (struct dbx_symfile_info *) - xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info)); + xmmalloc (objfile->md, sizeof (struct dbx_symfile_info)); memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info)); DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text"); @@ -651,7 +697,7 @@ dbx_symfile_init (objfile) /* FIXME POKING INSIDE BFD DATA STRUCTURES */ DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL; - + text_sect = bfd_get_section_by_name (sym_bfd, ".text"); if (!text_sect) error ("Can't find .text section in symbol file"); @@ -679,8 +725,8 @@ dbx_symfile_init (objfile) if (STRING_TABLE_OFFSET == 0) { /* It appears that with the existing bfd code, STRING_TABLE_OFFSET - will never be zero, even when there is no string table. This - would appear to be a bug in bfd. */ + will never be zero, even when there is no string table. This + would appear to be a bug in bfd. */ DBX_STRINGTAB_SIZE (objfile) = 0; DBX_STRINGTAB (objfile) = NULL; } @@ -689,7 +735,7 @@ dbx_symfile_init (objfile) val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, SEEK_SET); if (val < 0) perror_with_name (name); - + memset ((PTR) size_temp, 0, sizeof (size_temp)); val = bfd_read ((PTR) size_temp, sizeof (size_temp), 1, sym_bfd); if (val < 0) @@ -714,19 +760,19 @@ dbx_symfile_init (objfile) bfd can't tell us there is no string table, the sanity checks may or may not catch this. */ DBX_STRINGTAB_SIZE (objfile) = bfd_h_get_32 (sym_bfd, size_temp); - + if (DBX_STRINGTAB_SIZE (objfile) < sizeof (size_temp) || DBX_STRINGTAB_SIZE (objfile) > bfd_get_size (sym_bfd)) error ("ridiculous string table size (%d bytes).", DBX_STRINGTAB_SIZE (objfile)); - + DBX_STRINGTAB (objfile) = - (char *) obstack_alloc (&objfile -> psymbol_obstack, + (char *) obstack_alloc (&objfile->psymbol_obstack, DBX_STRINGTAB_SIZE (objfile)); OBJSTAT (objfile, sz_strtab += DBX_STRINGTAB_SIZE (objfile)); - + /* Now read in the string table in one big gulp. */ - + val = bfd_seek (sym_bfd, STRING_TABLE_OFFSET, SEEK_SET); if (val < 0) perror_with_name (name); @@ -756,17 +802,17 @@ dbx_symfile_finish (objfile) while (--i >= 0) { - free (hfiles [i].name); - free (hfiles [i].vector); + free (hfiles[i].name); + free (hfiles[i].vector); } free ((PTR) hfiles); } - mfree (objfile -> md, objfile->sym_stab_info); + mfree (objfile->md, objfile->sym_stab_info); } free_header_files (); } - + /* Buffer for reading the symbol table entries. */ static struct external_nlist symbuf[4096]; static int symbuf_idx; @@ -775,11 +821,11 @@ static int symbuf_end; /* cont_elem is used for continuing information in cfront. It saves information about which types need to be fixed up and completed after all the stabs are read. */ -struct cont_elem +struct cont_elem { /* sym and stabsstring for continuing information in cfront */ - struct symbol * sym; - char * stabs; + struct symbol *sym; + char *stabs; /* state dependancies (statics that must be preserved) */ int sym_idx; int sym_end; @@ -787,11 +833,11 @@ struct cont_elem int (*func) PARAMS ((struct objfile *, struct symbol *, char *)); /* other state dependancies include: (assumption is that these will not change since process_now FIXME!!) - stringtab_global - n_stabs - objfile - symfile_bfd */ -}; + stringtab_global + n_stabs + objfile + symfile_bfd */ + }; static struct cont_elem *cont_list = 0; static int cont_limit = 0; @@ -799,24 +845,24 @@ static int cont_count = 0; /* Arrange for function F to be called with arguments SYM and P later in the stabs reading process. */ -void +void process_later (sym, p, f) - struct symbol *sym; - char *p; - int (*f) PARAMS ((struct objfile *, struct symbol *, char *)); + struct symbol *sym; + char *p; + int (*f) PARAMS ((struct objfile *, struct symbol *, char *)); { /* Allocate more space for the deferred list. */ if (cont_count >= cont_limit - 1) { - cont_limit += 32; /* chunk size */ + cont_limit += 32; /* chunk size */ cont_list - = (struct cont_elem *) xrealloc (cont_list, - (cont_limit - * sizeof (struct cont_elem))); + = (struct cont_elem *) xrealloc (cont_list, + (cont_limit + * sizeof (struct cont_elem))); if (!cont_list) - error ("Virtual memory exhausted\n"); + error ("Virtual memory exhausted\n"); } /* Save state variables so we can process these stabs later. */ @@ -831,9 +877,9 @@ process_later (sym, p, f) /* Call deferred funtions in CONT_LIST. */ -static void -process_now (objfile) - struct objfile *objfile; +static void +process_now (objfile) + struct objfile *objfile; { int i; int save_symbuf_idx; @@ -855,8 +901,8 @@ process_now (objfile) { /* Restore the state for this deferred stab. */ symbuf_idx = cont_list[i].sym_idx; - symbuf_end = cont_list[i].sym_end; - symnum = cont_list[i].symnum; + symbuf_end = cont_list[i].sym_end; + symnum = cont_list[i].symnum; sym = cont_list[i].sym; stabs = cont_list[i].stabs; func = cont_list[i].func; @@ -927,7 +973,7 @@ fill_symbuf (sym_bfd) count = sizeof (symbuf); } - nbytes = bfd_read ((PTR)symbuf, count, 1, sym_bfd); + nbytes = bfd_read ((PTR) symbuf, count, 1, sym_bfd); if (nbytes < 0) perror_with_name (bfd_get_filename (sym_bfd)); else if (nbytes == 0) @@ -975,7 +1021,7 @@ dbx_next_symbol_text (objfile) fill_symbuf (symfile_bfd); symnum++; - INTERNALIZE_SYMBOL(nlist, &symbuf[symbuf_idx], symfile_bfd); + INTERNALIZE_SYMBOL (nlist, &symbuf[symbuf_idx], symfile_bfd); OBJSTAT (objfile, n_stabs++); symbuf_idx++; @@ -993,7 +1039,7 @@ init_bincl_list (number, objfile) { bincls_allocated = number; next_bincl = bincl_list = (struct header_file_location *) - xmmalloc (objfile -> md, bincls_allocated * sizeof(struct header_file_location)); + xmmalloc (objfile->md, bincls_allocated * sizeof (struct header_file_location)); } /* Add a bincl to the list. */ @@ -1009,8 +1055,8 @@ add_bincl_to_list (pst, name, instance) int offset = next_bincl - bincl_list; bincls_allocated *= 2; bincl_list = (struct header_file_location *) - xmrealloc (pst->objfile->md, (char *)bincl_list, - bincls_allocated * sizeof (struct header_file_location)); + xmrealloc (pst->objfile->md, (char *) bincl_list, + bincls_allocated * sizeof (struct header_file_location)); next_bincl = bincl_list + offset; } next_bincl->pst = pst; @@ -1044,7 +1090,7 @@ static void free_bincl_list (objfile) struct objfile *objfile; { - mfree (objfile -> md, (PTR)bincl_list); + mfree (objfile->md, (PTR) bincl_list); bincls_allocated = 0; } @@ -1052,8 +1098,7 @@ free_bincl_list (objfile) add them to the minimal symbol table. */ static void -read_dbx_dynamic_symtab (section_offsets, objfile) - struct section_offsets *section_offsets; +read_dbx_dynamic_symtab (objfile) struct objfile *objfile; { bfd *abfd = objfile->obfd; @@ -1112,17 +1157,17 @@ read_dbx_dynamic_symtab (section_offsets, objfile) if (bfd_get_section_flags (abfd, sec) & SEC_CODE) { - sym_value += ANOFFSET (section_offsets, SECT_OFF_TEXT); + sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); type = N_TEXT; } else if (bfd_get_section_flags (abfd, sec) & SEC_DATA) { - sym_value += ANOFFSET (section_offsets, SECT_OFF_DATA); + sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); type = N_DATA; } else if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC) { - sym_value += ANOFFSET (section_offsets, SECT_OFF_BSS); + sym_value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); type = N_BSS; } else @@ -1146,7 +1191,7 @@ read_dbx_dynamic_symtab (section_offsets, objfile) do_cleanups (back_to); return; } - + dynrels = (arelent **) xmalloc (dynrel_size); make_cleanup (free, dynrels); @@ -1163,7 +1208,7 @@ read_dbx_dynamic_symtab (section_offsets, objfile) { arelent *rel = *relptr; CORE_ADDR address = - rel->address + ANOFFSET (section_offsets, SECT_OFF_DATA); + rel->address + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); switch (bfd_get_arch (abfd)) { @@ -1192,22 +1237,17 @@ read_dbx_dynamic_symtab (section_offsets, objfile) do_cleanups (back_to); } -/* Given pointers to an a.out symbol table in core containing dbx - style data, setup partial_symtab's describing each source file for - which debugging information is available. - SYMFILE_NAME is the name of the file we are reading from - and SECTION_OFFSETS is the set of offsets for the various sections - of the file (a set of zeros if the mainline program). */ +/* Setup partial_symtab's describing each source file for which + debugging information is available. */ static void -read_dbx_symtab (section_offsets, objfile, text_addr, text_size) - struct section_offsets *section_offsets; +read_dbx_symtab (objfile) struct objfile *objfile; - CORE_ADDR text_addr; - int text_size; { register struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch */ struct internal_nlist nlist; + CORE_ADDR text_addr; + int text_size; register char *namestring; int nsl; @@ -1230,13 +1270,16 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) struct partial_symtab **dependency_list; int dependencies_used, dependencies_allocated; + text_addr = DBX_TEXT_ADDR (objfile); + text_size = DBX_TEXT_SIZE (objfile); + /* FIXME. We probably want to change stringtab_global rather than add this while processing every symbol entry. FIXME. */ file_string_table_offset = 0; next_file_string_table_offset = 0; stringtab_global = DBX_STRINGTAB (objfile); - + pst = (struct partial_symtab *) 0; includes_allocated = 30; @@ -1256,7 +1299,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) last_source_file = NULL; - lowest_text_address = (CORE_ADDR)-1; + lowest_text_address = (CORE_ADDR) -1; symfile_bfd = objfile->obfd; /* For next_text_symbol */ abfd = objfile->obfd; @@ -1268,7 +1311,7 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++) { /* Get the symbol for this run and pull out some info */ - QUIT; /* allow this to be interruptable */ + QUIT; /* allow this to be interruptable */ if (symbuf_idx == symbuf_end) fill_symbuf (abfd); bufp = &symbuf[symbuf_idx++]; @@ -1290,13 +1333,13 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) like duplicating code, I will do my penance here, and describe the code which is duplicated: - *) The assignment to namestring. - *) The call to strchr. - *) The addition of a partial symbol the the two partial - symbol lists. This last is a large section of code, so - I've imbedded it in the following macro. - */ - + *) The assignment to namestring. + *) The call to strchr. + *) The addition of a partial symbol the the two partial + symbol lists. This last is a large section of code, so + I've imbedded it in the following macro. + */ + /* Set namestring based on nlist. If the string table index is invalid, give a fake name, and print a single error message per symbol file read, rather than abort the symbol reading or flood the user with messages. */ @@ -1315,8 +1358,8 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) #define CUR_SYMBOL_VALUE nlist.n_value #define CUR_SYMBOL_STRX nlist.n_strx #define DBXREAD_ONLY -#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\ - start_psymtab(ofile, secoff, fname, low, symoff, global_syms, static_syms) +#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms)\ + start_psymtab(ofile, fname, low, symoff, global_syms, static_syms) #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)\ end_psymtab(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) @@ -1324,24 +1367,24 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) } /* If there's stuff to be cleaned up, clean it up. */ - if (DBX_SYMCOUNT (objfile) > 0 /* We have some syms */ + if (DBX_SYMCOUNT (objfile) > 0 /* We have some syms */ /*FIXME, does this have a bug at start address 0? */ && last_o_file_start - && objfile -> ei.entry_point < nlist.n_value - && objfile -> ei.entry_point >= last_o_file_start) + && objfile->ei.entry_point < nlist.n_value + && objfile->ei.entry_point >= last_o_file_start) { - objfile -> ei.entry_file_lowpc = last_o_file_start; - objfile -> ei.entry_file_highpc = nlist.n_value; + objfile->ei.entry_file_lowpc = last_o_file_start; + objfile->ei.entry_file_highpc = nlist.n_value; } if (pst) { /* Don't set pst->texthigh lower than it already is. */ CORE_ADDR text_end = - (lowest_text_address == (CORE_ADDR)-1 - ? (text_addr + section_offsets->offsets[SECT_OFF_TEXT]) - : lowest_text_address) - + text_size; + (lowest_text_address == (CORE_ADDR) -1 + ? (text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))) + : lowest_text_address) + + text_size; end_psymtab (pst, psymtab_include_list, includes_used, symnum * symbol_size, @@ -1360,11 +1403,9 @@ read_dbx_symtab (section_offsets, objfile, text_addr, text_size) (normal). */ -struct partial_symtab * -start_psymtab (objfile, section_offsets, - filename, textlow, ldsymoff, global_syms, static_syms) +static struct partial_symtab * +start_psymtab (objfile, filename, textlow, ldsymoff, global_syms, static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; int ldsymoff; @@ -1372,17 +1413,17 @@ start_psymtab (objfile, section_offsets, struct partial_symbol **static_syms; { struct partial_symtab *result = - start_psymtab_common(objfile, section_offsets, - filename, textlow, global_syms, static_syms); + start_psymtab_common (objfile, objfile->section_offsets, + filename, textlow, global_syms, static_syms); result->read_symtab_private = (char *) - obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct symloc)); - LDSYMOFF(result) = ldsymoff; + obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc)); + LDSYMOFF (result) = ldsymoff; result->read_symtab = dbx_psymtab_to_symtab; - SYMBOL_SIZE(result) = symbol_size; - SYMBOL_OFFSET(result) = symbol_table_offset; - STRING_OFFSET(result) = string_table_offset; - FILE_STRING_OFFSET(result) = file_string_table_offset; + SYMBOL_SIZE (result) = symbol_size; + SYMBOL_OFFSET (result) = symbol_table_offset; + STRING_OFFSET (result) = string_table_offset; + FILE_STRING_OFFSET (result) = file_string_table_offset; /* If we're handling an ELF file, drag some section-relocation info for this source file out of the ELF symbol table, to compensate for @@ -1403,7 +1444,7 @@ start_psymtab (objfile, section_offsets, struct partial_symtab * end_psymtab (pst, include_list, num_includes, capping_symbol_offset, - capping_text, dependency_list, number_dependencies, textlow_not_set) + capping_text, dependency_list, number_dependencies, textlow_not_set) struct partial_symtab *pst; char **include_list; int num_includes; @@ -1414,10 +1455,10 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset, int textlow_not_set; { 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; #ifdef SOFUN_ADDRESS_MAYBE_MISSING @@ -1449,7 +1490,7 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset, p = alloca (n + 2); strncpy (p, last_function_name, n); p[n] = 0; - + minsym = lookup_minimal_symbol (p, pst->filename, objfile); if (minsym == NULL) { @@ -1475,21 +1516,21 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset, struct partial_symtab *p1; /* If we know our own starting text address, then walk through all other - psymtabs for this objfile, and if any didn't know their ending text - address, set it to our starting address. Take care to not set our - own ending address to our starting address, nor to set addresses on - `dependency' files that have both textlow and texthigh zero. */ + psymtabs for this objfile, and if any didn't know their ending text + address, set it to our starting address. Take care to not set our + own ending address to our starting address, nor to set addresses on + `dependency' files that have both textlow and texthigh zero. */ ALL_OBJFILE_PSYMTABS (objfile, p1) - { - if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst) - { - p1->texthigh = pst->textlow; - /* if this file has only data, then make textlow match texthigh */ - if (p1->textlow == 0) - p1->textlow = p1->texthigh; - } - } + { + if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst) + { + p1->texthigh = pst->textlow; + /* if this file has only data, then make textlow match texthigh */ + if (p1->textlow == 0) + p1->textlow = p1->texthigh; + } + } } /* End of kludge for patching Solaris textlow and texthigh. */ @@ -1505,9 +1546,9 @@ 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; @@ -1515,19 +1556,20 @@ 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); + /* Copy the sesction_offsets array from the main psymtab. */ 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 *)); @@ -1536,8 +1578,8 @@ 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; @@ -1558,17 +1600,17 @@ end_psymtab (pst, include_list, num_includes, capping_symbol_offset, && has_line_numbers == 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. */ + 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. */ discard_psymtab (pst); /* Indicate that psymtab was thrown away. */ - pst = (struct partial_symtab *)NULL; + pst = (struct partial_symtab *) NULL; } return pst; } @@ -1579,14 +1621,14 @@ dbx_psymtab_to_symtab_1 (pst) { struct cleanup *old_chain; int i; - + if (!pst) return; if (pst->readin) { fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); + pst->filename); return; } @@ -1602,18 +1644,18 @@ dbx_psymtab_to_symtab_1 (pst) fputs_filtered ("and ", gdb_stdout); wrap_here (""); printf_filtered ("%s...", pst->dependencies[i]->filename); - wrap_here (""); /* Flush output */ + wrap_here (""); /* Flush output */ gdb_flush (gdb_stdout); } dbx_psymtab_to_symtab_1 (pst->dependencies[i]); } - if (LDSYMLEN(pst)) /* Otherwise it's a dummy */ + if (LDSYMLEN (pst)) /* Otherwise it's a dummy */ { /* Init stuff necessary for reading in symbols */ stabsread_init (); buildsym_init (); - old_chain = make_cleanup ((make_cleanup_func) really_free_pendings, 0); + old_chain = make_cleanup (really_free_pendings, 0); file_string_table_offset = FILE_STRING_OFFSET (pst); symbol_size = SYMBOL_SIZE (pst); @@ -1643,14 +1685,14 @@ dbx_psymtab_to_symtab (pst) if (pst->readin) { fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); + pst->filename); return; } - if (LDSYMLEN(pst) || pst->number_of_dependencies) + if (LDSYMLEN (pst) || pst->number_of_dependencies) { /* Print the message now, before reading the string table, - to avoid disconcerting pauses. */ + to avoid disconcerting pauses. */ if (info_verbose) { printf_filtered ("Reading in symbols for %s...", pst->filename); @@ -1674,7 +1716,7 @@ dbx_psymtab_to_symtab (pst) } /* Read in a defined section of a specific object file's symbols. */ - + static void read_ofile_symtab (pst) struct partial_symtab *pst; @@ -1693,10 +1735,14 @@ read_ofile_symtab (pst) struct section_offsets *section_offsets; objfile = pst->objfile; - sym_offset = LDSYMOFF(pst); - sym_size = LDSYMLEN(pst); + sym_offset = LDSYMOFF (pst); + sym_size = LDSYMLEN (pst); text_offset = pst->textlow; text_size = pst->texthigh - pst->textlow; + /* This cannot be simply objfile->section_offsets because of + elfstab_offset_sections() which initializes the psymtab section + offsets information in a special way, and that is different from + objfile->section_offsets. */ section_offsets = pst->section_offsets; current_objfile = objfile; @@ -1715,7 +1761,7 @@ read_ofile_symtab (pst) Detecting this in read_dbx_symtab would slow down initial readin, so we look for it here instead. */ - if (!processing_acc_compilation && sym_offset >= (int)symbol_size) + if (!processing_acc_compilation && sym_offset >= (int) symbol_size) { bfd_seek (symfile_bfd, sym_offset - symbol_size, SEEK_CUR); fill_symbuf (abfd); @@ -1741,7 +1787,7 @@ read_ofile_symtab (pst) } /* Try to select a C++ demangling based on the compilation unit - producer. */ + producer. */ if (processing_gcc_compilation) { @@ -1754,8 +1800,8 @@ read_ofile_symtab (pst) else { /* The N_SO starting this symtab is the first symbol, so we - better not check the symbol before it. I'm not this can - happen, but it doesn't hurt to check for it. */ + better not check the symbol before it. I'm not this can + happen, but it doesn't hurt to check for it. */ bfd_seek (symfile_bfd, sym_offset, SEEK_CUR); processing_gcc_compilation = 0; } @@ -1764,7 +1810,7 @@ read_ofile_symtab (pst) fill_symbuf (abfd); bufp = &symbuf[symbuf_idx]; if (bfd_h_get_8 (abfd, bufp->e_type) != N_SO) - error("First symbol in segment of executable not a source symbol"); + error ("First symbol in segment of executable not a source symbol"); max_symnum = sym_size / symbol_size; @@ -1774,7 +1820,7 @@ read_ofile_symtab (pst) { QUIT; /* Allow this to be interruptable */ if (symbuf_idx == symbuf_end) - fill_symbuf(abfd); + fill_symbuf (abfd); bufp = &symbuf[symbuf_idx++]; INTERNALIZE_SYMBOL (nlist, bufp, abfd); OBJSTAT (objfile, n_stabs++); @@ -1783,10 +1829,11 @@ read_ofile_symtab (pst) SET_NAMESTRING (); - if (type & N_STAB) { + if (type & N_STAB) + { process_one_symbol (type, nlist.n_desc, nlist.n_value, namestring, section_offsets, objfile); - } + } /* We skip checking for a new .o or -l file; that should never happen in this routine. */ else if (type == N_TEXT) @@ -1807,9 +1854,10 @@ read_ofile_symtab (pst) set_demangling_style (GNU_DEMANGLING_STYLE_STRING); } } - else if (type & N_EXT || type == (unsigned char)N_TEXT - || type == (unsigned char)N_NBTEXT - ) { + else if (type & N_EXT || type == (unsigned char) N_TEXT + || type == (unsigned char) N_NBTEXT + ) + { /* Global symbol: see if we came across a dbx defintion for a corresponding symbol. If so, store the value. Remove syms from the chain when their values are stored, but @@ -1820,7 +1868,7 @@ read_ofile_symtab (pst) be satisfied in each file as it appears. So we skip this section. */ ; - } + } } current_objfile = NULL; @@ -1837,16 +1885,16 @@ read_ofile_symtab (pst) if (last_source_start_addr > text_offset) last_source_start_addr = text_offset; - pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT); + pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile)); /* Process items which we had to "process_later" due to dependancies on other stabs. */ - process_now (objfile); + process_now (objfile); end_stabs (); } - + /* This handles a single symbol from the symbol-file, building symbols into a GDB symtab. It takes these arguments and an implicit argument. @@ -1855,11 +1903,13 @@ read_ofile_symtab (pst) VALU is the value field of the ".stab" entry. NAME is the symbol name, in our address space. SECTION_OFFSETS is a set of amounts by which the sections of this object - file were relocated when it was loaded into memory. - All symbols that refer - to memory locations need to be offset by these amounts. + file were relocated when it was loaded into memory. + Note that these section_offsets are not the + objfile->section_offsets but the pst->section_offsets. + All symbols that refer + to memory locations need to be offset by these amounts. OBJFILE is the object file from which we are reading symbols. - It is used in end_symtab. */ + It is used in end_symtab. */ void process_one_symbol (type, desc, valu, name, section_offsets, objfile) @@ -1899,17 +1949,17 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) if (!block_address_function_relative) /* N_LBRAC, N_RBRAC and N_SLINE entries are not relative to the function start address, so just use the text offset. */ - function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT); + function_start_offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); /* Something is wrong if we see real data before seeing a source file name. */ - if (last_source_file == NULL && type != (unsigned char)N_SO) + if (last_source_file == NULL && type != (unsigned char) N_SO) { /* Ignore any symbols which appear before an N_SO symbol. - Currently no one puts symbols there, but we should deal - gracefully with the case. A complain()t might be in order, - but this should not be an error (). */ + Currently no one puts symbols there, but we should deal + gracefully with the case. A complain()t might be in order, + but this should not be an error (). */ return; } @@ -1939,7 +1989,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) } /* Relocate for dynamic loading */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); #ifdef SMASH_TEXT_ADDRESS SMASH_TEXT_ADDRESS (valu); #endif @@ -1947,7 +1997,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) case N_LBRAC: /* This "symbol" just indicates the start of an inner lexical - context within a function. */ + context within a function. */ /* Ignore extra outermost context from SunPRO cc and acc. */ if (n_opt_found && desc == 1) @@ -1962,18 +2012,19 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) valu += last_source_start_addr; #ifdef SUN_FIXED_LBRAC_BUG - if (!SUN_FIXED_LBRAC_BUG && valu < last_pc_address) { - /* Patch current LBRAC pc value to match last handy pc value */ - complain (&lbrac_complaint); - valu = last_pc_address; - } + if (!SUN_FIXED_LBRAC_BUG && valu < last_pc_address) + { + /* Patch current LBRAC pc value to match last handy pc value */ + complain (&lbrac_complaint); + valu = last_pc_address; + } #endif new = push_context (desc, valu); break; case N_RBRAC: /* This "symbol" just indicates the end of an inner lexical - context that was started with N_LBRAC. */ + context that was started with N_LBRAC. */ /* Ignore extra outermost context from SunPRO cc and acc. */ if (n_opt_found && desc == 1) @@ -1987,26 +2038,26 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) N_SO, the linker did not relocate them (sigh). */ valu += last_source_start_addr; - new = pop_context(); + new = pop_context (); if (desc != new->depth) complain (&lbrac_mismatch_complaint, symnum); /* Some compilers put the variable decls inside of an LBRAC/RBRAC block. This macro should be nonzero if this - is true. DESC is N_DESC from the N_RBRAC symbol. - GCC_P is true if we've detected the GCC_COMPILED_SYMBOL - or the GCC2_COMPILED_SYMBOL. */ + is true. DESC is N_DESC from the N_RBRAC symbol. + GCC_P is true if we've detected the GCC_COMPILED_SYMBOL + or the GCC2_COMPILED_SYMBOL. */ #if !defined (VARIABLES_INSIDE_BLOCK) #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) 0 #endif /* Can only use new->locals as local symbols here if we're in gcc or on a machine that puts them before the lbrack. */ - if (!VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) + if (!VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation)) local_symbols = new->locals; if (context_stack_depth - > !VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) + > !VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation)) { /* This is not the outermost LBRAC...RBRAC pair in the function, its local symbols preceded it, and are the ones just recovered @@ -2017,7 +2068,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) if (local_symbols != NULL) { /* Muzzle a compiler bug that makes end < start. (which - compilers? Is this ever harmful?). */ + compilers? Is this ever harmful?). */ if (new->start_addr > valu) { complain (&lbrac_rbrac_complaint); @@ -2037,7 +2088,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) within_function = 0; } - if (VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) + if (VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation)) /* Now pop locals of block just finished. */ local_symbols = new->locals; break; @@ -2046,16 +2097,16 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) case N_FN_SEQ: /* This kind of symbol indicates the start of an object file. */ /* Relocate for dynamic loading */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); break; case N_SO: /* This type of symbol indicates the start of data - for one source file. - Finish the symbol table of the previous source file - (if any) and start accumulating a new symbol table. */ + for one source file. + Finish the symbol table of the previous source file + (if any) and start accumulating a new symbol table. */ /* Relocate for dynamic loading */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); n_opt_found = 0; @@ -2076,23 +2127,23 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) /* Check if previous symbol was also an N_SO (with some sanity checks). If so, that one was actually the directory name, and the current one is the real file name. - Patch things up. */ + Patch things up. */ if (previous_stab_code == (unsigned char) N_SO) { patch_subfile_names (current_subfile, name); break; /* Ignore repeated SOs */ } - end_symtab (valu, objfile, SECT_OFF_TEXT); + end_symtab (valu, objfile, SECT_OFF_TEXT (objfile)); end_stabs (); } /* Null name means this just marks the end of text for this .o file. - Don't start a new symtab in this case. */ + Don't start a new symtab in this case. */ if (*name == '\000') break; if (block_address_function_relative) - function_start_offset = 0; + function_start_offset = 0; start_stabs (); start_symtab (name, NULL, valu); @@ -2101,11 +2152,11 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) case N_SOL: /* This type of symbol indicates the start of data for - a sub-source-file, one whose contents were copied or - included in the compilation of the main source file - (whose name was given in the N_SO symbol.) */ + a sub-source-file, one whose contents were copied or + included in the compilation of the main source file + (whose name was given in the N_SO symbol.) */ /* Relocate for dynamic loading */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); start_subfile (name, current_subfile->dirname); break; @@ -2125,8 +2176,8 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) case N_SLINE: /* This type of "symbol" really just records - one line-number -- core-address correspondence. - Enter it in the line list for this symbol table. */ + one line-number -- core-address correspondence. + Enter it in the line list for this symbol table. */ /* Relocate for dynamic loading and for ELF acc fn-relative syms. */ valu += function_start_offset; @@ -2145,21 +2196,21 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) common_block_end (objfile); break; - /* The following symbol types need to have the appropriate offset added - to their value; then we process symbol definitions in the name. */ + /* The following symbol types need to have the appropriate offset added + to their value; then we process symbol definitions in the name. */ case N_STSYM: /* Static symbol in data seg */ case N_LCSYM: /* Static symbol in BSS seg */ case N_ROSYM: /* Static symbol in Read-only data seg */ - /* HORRID HACK DEPT. However, it's Sun's furgin' fault. - Solaris2's stabs-in-elf makes *most* symbols relative - but leaves a few absolute (at least for Solaris 2.1 and version - 2.0.1 of the SunPRO compiler). N_STSYM and friends sit on the fence. - .stab "foo:S...",N_STSYM is absolute (ld relocates it) - .stab "foo:V...",N_STSYM is relative (section base subtracted). - This leaves us no choice but to search for the 'S' or 'V'... - (or pass the whole section_offsets stuff down ONE MORE function - call level, which we really don't want to do). */ + /* HORRID HACK DEPT. However, it's Sun's furgin' fault. + Solaris2's stabs-in-elf makes *most* symbols relative + but leaves a few absolute (at least for Solaris 2.1 and version + 2.0.1 of the SunPRO compiler). N_STSYM and friends sit on the fence. + .stab "foo:S...",N_STSYM is absolute (ld relocates it) + .stab "foo:V...",N_STSYM is relative (section base subtracted). + This leaves us no choice but to search for the 'S' or 'V'... + (or pass the whole section_offsets stuff down ONE MORE function + call level, which we really don't want to do). */ { char *p; @@ -2183,47 +2234,52 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) elfstab_offset_sections ever starts dealing with the text offset, and we still need to do this, we need to invent a SECT_OFF_ADDR_KLUDGE or something. */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); goto define_a_symbol; } } /* Since it's not the kludge case, re-dispatch to the right handler. */ - switch (type) { - case N_STSYM: goto case_N_STSYM; - case N_LCSYM: goto case_N_LCSYM; - case N_ROSYM: goto case_N_ROSYM; - default: abort(); - } + switch (type) + { + case N_STSYM: + goto case_N_STSYM; + case N_LCSYM: + goto case_N_LCSYM; + case N_ROSYM: + goto case_N_ROSYM; + default: + abort (); + } } case_N_STSYM: /* Static symbol in data seg */ case N_DSLINE: /* Source line number, data seg */ - valu += ANOFFSET (section_offsets, SECT_OFF_DATA); + valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile)); goto define_a_symbol; case_N_LCSYM: /* Static symbol in BSS seg */ case N_BSLINE: /* Source line number, bss seg */ - /* N_BROWS: overlaps with N_BSLINE */ - valu += ANOFFSET (section_offsets, SECT_OFF_BSS); + /* N_BROWS: overlaps with N_BSLINE */ + valu += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile)); goto define_a_symbol; case_N_ROSYM: /* Static symbol in Read-only data seg */ - valu += ANOFFSET (section_offsets, SECT_OFF_RODATA); + valu += ANOFFSET (section_offsets, SECT_OFF_RODATA (objfile)); goto define_a_symbol; case N_ENTRY: /* Alternate entry point */ /* Relocate for dynamic loading */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); goto define_a_symbol; - /* The following symbol types we don't know how to process. Handle - them in a "default" way, but complain to people who care. */ + /* The following symbol types we don't know how to process. Handle + them in a "default" way, but complain to people who care. */ default: case N_CATCH: /* Exception handler catcher */ case N_EHDECL: /* Exception handler name */ case N_PC: /* Global symbol in Pascal */ - case N_M2C: /* Modula-2 compilation unit */ - /* N_MOD2: overlaps with N_EHDECL */ + case N_M2C: /* Modula-2 compilation unit */ + /* N_MOD2: overlaps with N_EHDECL */ case N_SCOPE: /* Modula-2 scope information */ case N_ECOML: /* End common (local name) */ case N_NBTEXT: /* Gould Non-Base-Register symbols??? */ @@ -2234,8 +2290,8 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) complain (&unknown_symtype_complaint, local_hex_string (type)); /* FALLTHROUGH */ - /* The following symbol types don't need the address field relocated, - since it is either unused, or is absolute. */ + /* The following symbol types don't need the address field relocated, + since it is either unused, or is absolute. */ define_a_symbol: case N_GSYM: /* Global variable */ case N_NSYMS: /* Number of symbols (ultrix) */ @@ -2263,63 +2319,37 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) #ifdef SOFUN_ADDRESS_MAYBE_MISSING /* Deal with the SunPRO 3.0 compiler which omits the address - from N_FUN symbols. */ + from N_FUN symbols. */ if (type == N_FUN - && valu == ANOFFSET (section_offsets, SECT_OFF_TEXT)) - { - struct minimal_symbol *msym; - char *p; - int n; - - p = strchr (name, ':'); - if (p == NULL) - p = name; - n = p - name; - p = alloca (n + 2); - strncpy (p, name, n); - p[n] = 0; - - msym = lookup_minimal_symbol (p, last_source_file, - objfile); - if (msym == NULL) - { - /* Sun Fortran appends an underscore to the minimal - symbol name, try again with an appended underscore - if the minimal symbol was not found. */ - p[n] = '_'; - p[n + 1] = 0; - msym = lookup_minimal_symbol (p, last_source_file, - objfile); - } - if (msym) - valu = SYMBOL_VALUE_ADDRESS (msym); - } + && valu == ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile))) + valu = + find_stab_function_addr (name, last_source_file, objfile); #endif #ifdef SUN_FIXED_LBRAC_BUG /* The Sun acc compiler, under SunOS4, puts out - functions with N_GSYM or N_STSYM. The problem is - that the address of the symbol is no good (for N_GSYM - it doesn't even attept an address; for N_STSYM it - puts out an address but then it gets relocated - relative to the data segment, not the text segment). - Currently we can't fix this up later as we do for - some types of symbol in scan_file_globals. - Fortunately we do have a way of finding the address - - we know that the value in last_pc_address is either - the one we want (if we're dealing with the first - function in an object file), or somewhere in the - previous function. This means that we can use the - minimal symbol table to get the address. */ + functions with N_GSYM or N_STSYM. The problem is + that the address of the symbol is no good (for N_GSYM + it doesn't even attept an address; for N_STSYM it + puts out an address but then it gets relocated + relative to the data segment, not the text segment). + Currently we can't fix this up later as we do for + some types of symbol in scan_file_globals. + Fortunately we do have a way of finding the address - + we know that the value in last_pc_address is either + the one we want (if we're dealing with the first + function in an object file), or somewhere in the + previous function. This means that we can use the + minimal symbol table to get the address. */ /* Starting with release 3.0, the Sun acc compiler, - under SunOS4, puts out functions with N_FUN and a value - of zero. This gets relocated to the start of the text - segment of the module, which is no good either. - Under SunOS4 we can deal with this as N_SLINE and N_SO - entries contain valid absolute addresses. - Release 3.0 acc also puts out N_OPT entries, which makes - it possible to discern acc from cc or gcc. */ + under SunOS4, puts out functions with N_FUN and a value + of zero. This gets relocated to the start of the text + segment of the module, which is no good either. + Under SunOS4 we can deal with this as N_SLINE and N_SO + entries contain valid absolute addresses. + Release 3.0 acc also puts out N_OPT entries, which makes + it possible to discern acc from cc or gcc. */ if (type == N_GSYM || type == N_STSYM || (type == N_FUN @@ -2330,14 +2360,14 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) m = lookup_minimal_symbol_by_pc (last_pc_address); if (m && STREQN (SYMBOL_NAME (m), name, l) - && SYMBOL_NAME (m) [l] == '\0') + && SYMBOL_NAME (m)[l] == '\0') /* last_pc_address was in this function */ valu = SYMBOL_VALUE (m); - else if (m && SYMBOL_NAME (m+1) - && STREQN (SYMBOL_NAME (m+1), name, l) - && SYMBOL_NAME (m+1) [l] == '\0') + else if (m && SYMBOL_NAME (m + 1) + && STREQN (SYMBOL_NAME (m + 1), name, l) + && SYMBOL_NAME (m + 1)[l] == '\0') /* last_pc_address was in last function */ - valu = SYMBOL_VALUE (m+1); + valu = SYMBOL_VALUE (m + 1); else /* Not found - use last_pc_address (for finish_block) */ valu = last_pc_address; @@ -2353,9 +2383,16 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) Solaris 2.0, these addresses are just absolute, or relative to the N_SO, depending on BLOCK_ADDRESS_ABSOLUTE. */ - function_start_offset = valu; + function_start_offset = valu; within_function = 1; + + if (context_stack_depth > 1) + { + complain (&lbrac_unmatched_complaint, symnum); + break; + } + if (context_stack_depth > 0) { new = pop_context (); @@ -2363,9 +2400,6 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) finish_block (new->name, &local_symbols, new->old_blocks, new->start_addr, valu, objfile); } - /* Stack must be empty now. */ - if (context_stack_depth != 0) - complain (&lbrac_unmatched_complaint, symnum); new = push_context (0, valu); new->name = define_symbol (valu, name, desc, type, objfile); @@ -2378,16 +2412,16 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) } break; - /* We use N_OPT to carry the gcc2_compiled flag. Sun uses it - for a bunch of other flags, too. Someday we may parse their - flags; for now we ignore theirs and hope they'll ignore ours. */ - case N_OPT: /* Solaris 2: Compiler options */ + /* We use N_OPT to carry the gcc2_compiled flag. Sun uses it + for a bunch of other flags, too. Someday we may parse their + flags; for now we ignore theirs and hope they'll ignore ours. */ + case N_OPT: /* Solaris 2: Compiler options */ if (name) { if (STREQ (name, GCC2_COMPILED_FLAG_SYMBOL)) { processing_gcc_compilation = 2; -#if 1 /* Works, but is experimental. -fnf */ +#if 1 /* Works, but is experimental. -fnf */ if (AUTO_DEMANGLING) { set_demangling_style (GNU_DEMANGLING_STYLE_STRING); @@ -2399,11 +2433,11 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) } break; - /* The following symbol types can be ignored. */ - case N_OBJ: /* Solaris 2: Object file dir and name */ - /* N_UNDF: Solaris 2: file separator mark */ - /* N_UNDF: -- we will never encounter it, since we only process one - file's symbols at once. */ + /* The following symbol types can be ignored. */ + case N_OBJ: /* Solaris 2: Object file dir and name */ + /* N_UNDF: Solaris 2: file separator mark */ + /* N_UNDF: -- we will never encounter it, since we only process one + file's symbols at once. */ case N_ENDM: /* Solaris 2: End of module */ case N_MAIN: /* Name of main routine. */ case N_ALIAS: /* SunPro F77: alias name, ignore for now. */ @@ -2414,7 +2448,7 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) related symbol. Generally this is used so that an alias can refer to its main - symbol. */ + symbol. */ if (name[0] == '#') { /* Initialize symbol reference names and determine if this is @@ -2425,10 +2459,10 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) int refnum; /* If this stab defines a new reference ID that is not on the - reference list, then put it on the reference list. + reference list, then put it on the reference list. - We go ahead and advance NAME past the reference, even though - it is not strictly necessary at this time. */ + We go ahead and advance NAME past the reference, even though + it is not strictly necessary at this time. */ refnum = symbol_reference_defined (&s); if (refnum >= 0) if (!ref_search (refnum)) @@ -2466,17 +2500,16 @@ process_one_symbol (type, desc, valu, name, section_offsets, objfile) adjusted for coff details. */ void -coffstab_build_psymtabs (objfile, section_offsets, mainline, - textaddr, textsize, stabsects, - stabstroffset, stabstrsize) - struct objfile *objfile; - struct section_offsets *section_offsets; - int mainline; - CORE_ADDR textaddr; - unsigned int textsize; - struct stab_section_list *stabsects; - file_ptr stabstroffset; - unsigned int stabstrsize; +coffstab_build_psymtabs (objfile, mainline, + textaddr, textsize, stabsects, + stabstroffset, stabstrsize) + struct objfile *objfile; + int mainline; + CORE_ADDR textaddr; + unsigned int textsize; + struct stab_section_list *stabsects; + file_ptr stabstroffset; + unsigned int stabstrsize; { int val; bfd *sym_bfd = objfile->obfd; @@ -2492,14 +2525,14 @@ coffstab_build_psymtabs (objfile, section_offsets, mainline, DBX_TEXT_SIZE (objfile) = textsize; #define COFF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */ - DBX_SYMBOL_SIZE (objfile) = COFF_STABS_SYMBOL_SIZE; + DBX_SYMBOL_SIZE (objfile) = COFF_STABS_SYMBOL_SIZE; DBX_STRINGTAB_SIZE (objfile) = stabstrsize; - + if (stabstrsize > bfd_get_size (sym_bfd)) error ("ridiculous string table size: %d bytes", stabstrsize); DBX_STRINGTAB (objfile) = (char *) - obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1); - OBJSTAT (objfile, sz_strtab += stabstrsize+1); + obstack_alloc (&objfile->psymbol_obstack, stabstrsize + 1); + OBJSTAT (objfile, sz_strtab += stabstrsize + 1); /* Now read in the string table in one big gulp. */ @@ -2544,7 +2577,7 @@ coffstab_build_psymtabs (objfile, section_offsets, mainline, symbuf_read = 0; } - dbx_symfile_read (objfile, section_offsets, 0); + dbx_symfile_read (objfile, 0); } /* Scan and build partial symbols for an ELF symbol file. @@ -2568,44 +2601,40 @@ coffstab_build_psymtabs (objfile, section_offsets, mainline, adjusted for elf details. */ void -elfstab_build_psymtabs (objfile, section_offsets, mainline, - staboffset, stabsize, - stabstroffset, stabstrsize) - struct objfile *objfile; - struct section_offsets *section_offsets; - int mainline; - file_ptr staboffset; - unsigned int stabsize; - file_ptr stabstroffset; - unsigned int stabstrsize; +elfstab_build_psymtabs (objfile, mainline, + staboffset, stabsize, + stabstroffset, stabstrsize) + struct objfile *objfile; + int mainline; + file_ptr staboffset; + unsigned int stabsize; + file_ptr stabstroffset; + unsigned int stabstrsize; { int val; bfd *sym_bfd = objfile->obfd; char *name = bfd_get_filename (sym_bfd); struct dbx_symfile_info *info; - asection *text_sect; /* There is already a dbx_symfile_info allocated by our caller. It might even contain some info from the ELF symtab to help us. */ info = objfile->sym_stab_info; - text_sect = bfd_get_section_by_name (sym_bfd, ".text"); - if (!text_sect) - error ("Can't find .text section in symbol file"); - DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect); - DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect); + /* Find the first and last text address. dbx_symfile_read seems to + want this. */ + find_text_range (sym_bfd, objfile); #define ELF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */ - DBX_SYMBOL_SIZE (objfile) = ELF_STABS_SYMBOL_SIZE; - DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile); + DBX_SYMBOL_SIZE (objfile) = ELF_STABS_SYMBOL_SIZE; + DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile); DBX_STRINGTAB_SIZE (objfile) = stabstrsize; - DBX_SYMTAB_OFFSET (objfile) = staboffset; - + DBX_SYMTAB_OFFSET (objfile) = staboffset; + if (stabstrsize > bfd_get_size (sym_bfd)) error ("ridiculous string table size: %d bytes", stabstrsize); DBX_STRINGTAB (objfile) = (char *) - obstack_alloc (&objfile->psymbol_obstack, stabstrsize+1); - OBJSTAT (objfile, sz_strtab += stabstrsize+1); + obstack_alloc (&objfile->psymbol_obstack, stabstrsize + 1); + OBJSTAT (objfile, sz_strtab += stabstrsize + 1); /* Now read in the string table in one big gulp. */ @@ -2627,7 +2656,7 @@ elfstab_build_psymtabs (objfile, section_offsets, mainline, /* In an elf file, we've already installed the minimal symbols that came from the elf (non-stab) symbol table, so always act like an incremental load here. */ - dbx_symfile_read (objfile, section_offsets, 0); + dbx_symfile_read (objfile, 0); } /* Scan and build partial symbols for a file with special sections for stabs @@ -2639,19 +2668,18 @@ elfstab_build_psymtabs (objfile, section_offsets, mainline, OBJFILE is the object file we are reading symbols from. ADDR is the address relative to which the symbols are (e.g. the base address - of the text segment). + of the text segment). MAINLINE is true if we are reading the main symbol table (as opposed to a - shared lib or dynamically loaded file). + shared lib or dynamically loaded file). STAB_NAME is the name of the section that contains the stabs. STABSTR_NAME is the name of the section that contains the stab strings. This routine is mostly copied from dbx_symfile_init and dbx_symfile_read. */ void -stabsect_build_psymtabs (objfile, section_offsets, mainline, stab_name, +stabsect_build_psymtabs (objfile, mainline, stab_name, stabstr_name, text_name) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; char *stab_name; char *stabstr_name; @@ -2684,12 +2712,12 @@ stabsect_build_psymtabs (objfile, section_offsets, mainline, stab_name, DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect); DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect); - DBX_SYMBOL_SIZE (objfile) = sizeof (struct external_nlist); - DBX_SYMCOUNT (objfile) = bfd_section_size (sym_bfd, stabsect) + DBX_SYMBOL_SIZE (objfile) = sizeof (struct external_nlist); + DBX_SYMCOUNT (objfile) = bfd_section_size (sym_bfd, stabsect) / DBX_SYMBOL_SIZE (objfile); DBX_STRINGTAB_SIZE (objfile) = bfd_section_size (sym_bfd, stabstrsect); - DBX_SYMTAB_OFFSET (objfile) = stabsect->filepos; /* XXX - FIXME: POKING INSIDE BFD DATA STRUCTURES */ - + DBX_SYMTAB_OFFSET (objfile) = stabsect->filepos; /* XXX - FIXME: POKING INSIDE BFD DATA STRUCTURES */ + if (DBX_STRINGTAB_SIZE (objfile) > bfd_get_size (sym_bfd)) error ("ridiculous string table size: %d bytes", DBX_STRINGTAB_SIZE (objfile)); DBX_STRINGTAB (objfile) = (char *) @@ -2698,11 +2726,11 @@ stabsect_build_psymtabs (objfile, section_offsets, mainline, stab_name, /* Now read in the string table in one big gulp. */ - val = bfd_get_section_contents (sym_bfd, /* bfd */ - stabstrsect, /* bfd section */ - DBX_STRINGTAB (objfile), /* input buffer */ - 0, /* offset into section */ - DBX_STRINGTAB_SIZE (objfile)); /* amount to read */ + val = bfd_get_section_contents (sym_bfd, /* bfd */ + stabstrsect, /* bfd section */ + DBX_STRINGTAB (objfile), /* input buffer */ + 0, /* offset into section */ + DBX_STRINGTAB_SIZE (objfile)); /* amount to read */ if (!val) perror_with_name (name); @@ -2716,23 +2744,22 @@ stabsect_build_psymtabs (objfile, section_offsets, mainline, stab_name, /* Now, do an incremental load */ processing_acc_compilation = 1; - dbx_symfile_read (objfile, section_offsets, 0); + dbx_symfile_read (objfile, 0); } static struct sym_fns aout_sym_fns = { bfd_target_aout_flavour, - dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */ - dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - dbx_symfile_read, /* sym_read: read a symbol file into symtab */ - dbx_symfile_finish, /* sym_finish: finished with file, cleanup */ - default_symfile_offsets, - /* sym_offsets: parse user's offsets to internal form */ - NULL /* next: pointer to next struct sym_fns */ + dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */ + dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */ + dbx_symfile_read, /* sym_read: read a symbol file into symtab */ + dbx_symfile_finish, /* sym_finish: finished with file, cleanup */ + default_symfile_offsets, /* sym_offsets: parse user's offsets to internal form */ + NULL /* next: pointer to next struct sym_fns */ }; void _initialize_dbxread () { - add_symtab_fns(&aout_sym_fns); + add_symtab_fns (&aout_sym_fns); } diff --git a/gdb/elfread.c b/gdb/elfread.c index d63d16a30f..e76d5cda7f 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -191,18 +191,18 @@ record_minimal_symbol_and_info (name, address, ms_type, info, bfd_section, { case mst_text: case mst_file_text: - section = SECT_OFF_TEXT; + section = SECT_OFF_TEXT (objfile); #ifdef SMASH_TEXT_ADDRESS SMASH_TEXT_ADDRESS (address); #endif break; case mst_data: case mst_file_data: - section = SECT_OFF_DATA; + section = SECT_OFF_DATA (objfile); break; case mst_bss: case mst_file_bss: - section = SECT_OFF_BSS; + section = SECT_OFF_BSS (objfile); break; default: section = -1; @@ -294,7 +294,7 @@ elf_symtab_read (objfile, dynamic) error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd), bfd_errmsg (bfd_get_error ())); /* FIXME: Should use section specific offset, not SECT_OFF_TEXT. */ - offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); for (i = 0; i < number_of_symbols; i++) { sym = symbol_table[i]; @@ -460,15 +460,15 @@ elf_symtab_read (objfile, dynamic) index = SECT_OFF_MAX; if (STREQ ("Bbss.bss", sym->name)) { - index = SECT_OFF_BSS; + index = SECT_OFF_BSS (objfile); } else if (STREQ ("Ddata.data", sym->name)) { - index = SECT_OFF_DATA; + index = SECT_OFF_DATA (objfile); } else if (STREQ ("Drodata.rodata", sym->name)) { - index = SECT_OFF_RODATA; + index = SECT_OFF_RODATA (objfile); } if (index != SECT_OFF_MAX) { diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h index 7e498fb060..3ec13930f5 100644 --- a/gdb/gdb-stabs.h +++ b/gdb/gdb-stabs.h @@ -28,15 +28,6 @@ #if !defined (GDBSTABS_H) #define GDBSTABS_H -/* Offsets in the psymtab's section_offsets array for various kinds of - stabs symbols. Every psymtab built from stabs will have these offsets - filled in by these guidelines, so that when actually reading symbols, the - proper offset can simply be selected and added to the symbol value. */ - -#define SECT_OFF_TEXT 0 -#define SECT_OFF_DATA 1 -#define SECT_OFF_BSS 2 -#define SECT_OFF_RODATA 3 #define SECT_OFF_MAX 40 /* Count of possible values */ /* The stab_section_info chain remembers info from the ELF symbol table, diff --git a/gdb/hp-psymtab-read.c b/gdb/hp-psymtab-read.c index 5926ada3f3..33153091e3 100644 --- a/gdb/hp-psymtab-read.c +++ b/gdb/hp-psymtab-read.c @@ -15,7 +15,8 @@ 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. + 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. */ @@ -44,7 +45,7 @@ void do_pxdb PARAMS ((bfd *)); void hpread_build_psymtabs - PARAMS ((struct objfile *, struct section_offsets *, int)); + PARAMS ((struct objfile *, int)); void hpread_symfile_finish PARAMS ((struct objfile *)); @@ -56,7 +57,7 @@ static unsigned long hpread_get_textlow PARAMS ((int, int, struct objfile *, int)); static struct partial_symtab *hpread_start_psymtab - PARAMS ((struct objfile *, struct section_offsets *, char *, CORE_ADDR, int, + PARAMS ((struct objfile *, char *, CORE_ADDR, int, struct partial_symbol **, struct partial_symbol **)); static struct partial_symtab *hpread_end_psymtab @@ -74,7 +75,6 @@ static struct partial_symtab *hpread_end_psymtab #include #include -#include /* check for the existance of a file, given its full pathname */ int @@ -99,7 +99,7 @@ trans_lang (in_lang) else if (in_lang == HP_LANGUAGE_CPLUSPLUS) return language_cplus; - else if (in_lang == HP_LANGUAGE_F77) + else if (in_lang == HP_LANGUAGE_FORTRAN) return language_fortran; else @@ -282,7 +282,7 @@ hpread_pxdb_needed (sym_bfd) /* Check whether the file needs to be preprocessed by pxdb. If so, call pxdb. */ -void +void do_pxdb (sym_bfd) bfd *sym_bfd; { @@ -292,22 +292,22 @@ do_pxdb (sym_bfd) /* This code will not be executed if the file is not in SOM format (i.e. if compiled with gcc) */ - if (hpread_pxdb_needed (sym_bfd)) - { - /*This file has not been pre-processed. Preprocess now */ - - if (hpread_call_pxdb (sym_bfd->filename)) - { - /* The call above has changed the on-disk file, - we can close the file anyway, because the - symbols will be reread in when the target is run */ - bfd_close (sym_bfd); - } - } -} + if (hpread_pxdb_needed (sym_bfd)) + { + /*This file has not been pre-processed. Preprocess now */ + if (hpread_call_pxdb (sym_bfd->filename)) + { + /* The call above has changed the on-disk file, + we can close the file anyway, because the + symbols will be reread in when the target is run */ + bfd_close (sym_bfd); + } + } +} + #ifdef QUICK_LOOK_UP /* Code to handle quick lookup-tables follows. */ @@ -363,10 +363,10 @@ do_pxdb (sym_bfd) psymtabs created so far */ typedef struct - { - int start; - int end; - } +{ + int start; + int end; +} pst_syms_struct; static pst_syms_struct *pst_syms_array = 0; @@ -516,7 +516,7 @@ find_next_module_isym (index, qMD, curr_md, pxdb_header_p) organized in a separate routine, although it does take lots of arguments. pai/1997-10-08 */ static int -scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile, section_offsets) +scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile) int *curr_pd_p; /* pointer to current proc index */ quick_procedure_entry *qPD; /* the procedure quick lookup table */ int max_procs; /* number of entries in proc. table */ @@ -525,7 +525,6 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile struct partial_symtab *pst; /* current psymtab */ char *vt_bits; /* strings table of SOM debug space */ struct objfile *objfile; /* current object file */ - struct section_offsets *section_offsets; /* not really used for HP-UX currently */ { union dnttentry *dn_bufp; int symbol_count = 0; /* Total number of symbols in this psymtab */ @@ -601,10 +600,10 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile VAR_NAMESPACE, LOC_BLOCK, /* "I am a routine" */ &objfile->global_psymbols, - (qPD[curr_pd].adrStart + /* Starting address of rtn */ - ANOFFSET (section_offsets, SECT_OFF_TEXT)), + (qPD[curr_pd].adrStart + /* Starting address of rtn */ + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))), 0, /* core addr?? */ - trans_lang ((enum hp_language) qPD[curr_pd].language), + trans_lang ((enum hp_language) qPD[curr_pd].language), objfile); else add_psymbol_with_dem_name_to_list (rtn_name, @@ -614,10 +613,10 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile VAR_NAMESPACE, LOC_BLOCK, /* "I am a routine" */ &objfile->static_psymbols, - (qPD[curr_pd].adrStart + /* Starting address of rtn */ - ANOFFSET (section_offsets, SECT_OFF_TEXT)), + (qPD[curr_pd].adrStart + /* Starting address of rtn */ + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile))), 0, /* core addr?? */ - trans_lang ((enum hp_language) qPD[curr_pd].language), + trans_lang ((enum hp_language) qPD[curr_pd].language), objfile); symbol_count++; @@ -647,12 +646,11 @@ scan_procs (curr_pd_p, qPD, max_procs, start_adr, end_adr, pst, vt_bits, objfile entry for it, so in such cases we create a psymtab for the file. */ int -hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header_p) - struct objfile *objfile; /* The object file descriptor */ - struct section_offsets *section_offsets; /* ?? Null for HP */ - char *gntt_bits; /* GNTT entries, loaded in from the file */ - char *vt_bits; /* VT (string) entries ditto. */ - PXDB_header_ptr pxdb_header_p; /* Pointer to pxdb header ditto */ +hpread_quick_traverse (objfile, gntt_bits, vt_bits, pxdb_header_p) + struct objfile *objfile; /* The object file descriptor */ + char *gntt_bits; /* GNTT entries, loaded in from the file */ + char *vt_bits; /* VT (string) entries ditto. */ + PXDB_header_ptr pxdb_header_p; /* Pointer to pxdb header ditto */ { struct partial_symtab *pst; @@ -679,8 +677,8 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header struct partial_symbol **global_syms; /* We'll be filling in the "global" */ struct partial_symbol **static_syms; /* and "static" tables in the objfile - as we go, so we need a pair of - current pointers. */ + as we go, so we need a pair of + current pointers. */ #ifdef DUMPING /* Turn this on for lots of debugging information in this routine. @@ -862,24 +860,23 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header might help. */ pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ mod_name_string, CURR_MODULE_START, /* Low text address: bogus! */ - (CURR_MODULE_ISYM * sizeof (struct dntt_type_block)), - /* ldsymoff */ + (CURR_MODULE_ISYM * sizeof (struct dntt_type_block)), + /* ldsymoff */ global_syms, static_syms); pst = hpread_end_psymtab (pst, NULL, /* psymtab_include_list */ - 0, /* includes_used */ - end_sym * sizeof (struct dntt_type_block), - /* byte index in LNTT of end - = capping symbol offset - = LDSYMOFF of nextfile */ - 0, /* text high */ + 0, /* includes_used */ + end_sym * sizeof (struct dntt_type_block), + /* byte index in LNTT of end + = capping symbol offset + = LDSYMOFF of nextfile */ + 0, /* text high */ NULL, /* dependency_list */ - 0); /* dependencies_used */ + 0); /* dependencies_used */ global_syms = objfile->global_psymbols.next; static_syms = objfile->static_psymbols.next; @@ -964,11 +961,10 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header And it's not even the right byte offset, as we're using the size of a union! FIXME! */ pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ full_name_string, - start_adr, /* Low text address */ - (start_sym * sizeof (struct dntt_type_block)), - /* ldsymoff */ + start_adr, /* Low text address */ + (start_sym * sizeof (struct dntt_type_block)), + /* ldsymoff */ global_syms, static_syms); @@ -980,8 +976,7 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header file, based on the starting addresses. */ syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries, - start_adr, end_adr, - pst, vt_bits, objfile, section_offsets); + start_adr, end_adr, pst, vt_bits, objfile); /* Get ending symbol offset */ @@ -1030,10 +1025,10 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header pst = hpread_end_psymtab (pst, NULL, /* psymtab_include_list */ 0, /* includes_used */ - end_sym * sizeof (struct dntt_type_block), - /* byte index in LNTT of end - = capping symbol offset - = LDSYMOFF of nextfile */ + end_sym * sizeof (struct dntt_type_block), + /* byte index in LNTT of end + = capping symbol offset + = LDSYMOFF of nextfile */ end_adr, /* text high */ NULL, /* dependency_list */ 0); /* dependencies_used */ @@ -1194,11 +1189,10 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header And it's not even the right byte offset, as we're using the size of a union! FIXME! */ pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ full_name_string, start_adr, /* Low text address */ - (start_sym * sizeof (struct dntt_type_block)), - /* ldsymoff */ + (start_sym * sizeof (struct dntt_type_block)), + /* ldsymoff */ global_syms, static_syms); @@ -1210,8 +1204,7 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header module, based on the starting addresses. */ syms_in_pst = scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries, - start_adr, end_adr, - pst, vt_bits, objfile, section_offsets); + start_adr, end_adr, pst, vt_bits, objfile); /* Get ending symbol offset */ @@ -1260,10 +1253,10 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header pst = hpread_end_psymtab (pst, NULL, /* psymtab_include_list */ 0, /* includes_used */ - end_sym * sizeof (struct dntt_type_block), - /* byte index in LNTT of end - = capping symbol offset - = LDSYMOFF of nextfile */ + end_sym * sizeof (struct dntt_type_block), + /* byte index in LNTT of end + = capping symbol offset + = LDSYMOFF of nextfile */ end_adr, /* text high */ NULL, /* dependency_list */ 0); /* dependencies_used */ @@ -1308,25 +1301,23 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header } #endif pst = hpread_start_psymtab (objfile, - section_offsets, /* ?? */ "orphans", start_adr, /* Low text address */ - (CURR_PROC_ISYM * sizeof (struct dntt_type_block)), - /* ldsymoff */ + (CURR_PROC_ISYM * sizeof (struct dntt_type_block)), + /* ldsymoff */ global_syms, static_syms); scan_procs (&curr_pd, qPD, pxdb_header_p->pd_entries, - start_adr, end_adr, - pst, vt_bits, objfile, section_offsets); + start_adr, end_adr, pst, vt_bits, objfile); pst = hpread_end_psymtab (pst, NULL, /* psymtab_include_list */ 0, /* includes_used */ - pxdb_header_p->globals * sizeof (struct dntt_type_block), - /* byte index in LNTT of end - = capping symbol offset - = LDSYMOFF of nextfile */ + pxdb_header_p->globals * sizeof (struct dntt_type_block), + /* byte index in LNTT of end + = capping symbol offset + = LDSYMOFF of nextfile */ end_adr, /* text high */ NULL, /* dependency_list */ 0); /* dependencies_used */ @@ -1340,7 +1331,6 @@ hpread_quick_traverse (objfile, section_offsets, gntt_bits, vt_bits, pxdb_header If null psts were kept on the chain, this would be a solution. FIXME */ pst = hpread_start_psymtab (objfile, - section_offsets, "globals", 0, (pxdb_header_p->globals @@ -1507,7 +1497,7 @@ 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) @@ -1529,7 +1519,7 @@ 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) @@ -1546,7 +1536,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. */ @@ -1578,14 +1568,12 @@ 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) +hpread_build_psymtabs (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { @@ -1621,7 +1609,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) /* Just in case the stabs reader left turds lying around. */ free_pending_blocks (); - make_cleanup ((make_cleanup_func) really_free_pendings, 0); + make_cleanup (really_free_pendings, 0); pst = (struct partial_symtab *) 0; @@ -1679,23 +1667,22 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) not found we give up on the quick table stuff, and fall back on the slower method */ found_modules_in_program = hpread_quick_traverse (objfile, - section_offsets, GNTT (objfile), VT (objfile), &pxdb_header); discard_cleanups (old_chain); - /* Set up to scan the global section of the LNTT. + /* Set up to scan the global section of the LNTT. - This field is not always correct: if there are - no globals, it will point to the last record in - the regular LNTT, which is usually an END MODULE. + This field is not always correct: if there are + no globals, it will point to the last record in + the regular LNTT, which is usually an END MODULE. - Since it might happen that there could be a file - with just one global record, there's no way to - tell other than by looking at the record, so that's - done below. */ + Since it might happen that there could be a file + with just one global record, there's no way to + tell other than by looking at the record, so that's + done below. */ if (found_modules_in_program) scan_start = pxdb_header.globals; } @@ -1709,8 +1696,8 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) } #endif /* QUICK_LOOK_UP */ - /* Make two passes, one over the GNTT symbols, the other for the - LNTT symbols. + /* Make two passes, one over the GNTT symbols, the other for the + LNTT symbols. JB comment: above isn't true--they only make one pass, over the LNTT. */ @@ -1829,11 +1816,11 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) past_first_source_file = 1; valu = hpread_get_textlow (i, hp_symnum, objfile, symcount); - 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; @@ -1863,13 +1850,13 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) /* Now begin a new module and a new psymtab for it */ SET_NAMESTRING (dn_bufp, &namestring, objfile); valu = hpread_get_textlow (i, hp_symnum, objfile, symcount); - 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; @@ -1881,12 +1868,12 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) case DNTT_TYPE_ENTRY: /* The beginning of a function. DNTT_TYPE_ENTRY may also denote a secondary entry point. */ - valu = dn_bufp->dfunc.hiaddr + ANOFFSET (section_offsets, - SECT_OFF_TEXT); + 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); + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); SET_NAMESTRING (dn_bufp, &namestring, objfile); if (dn_bufp->dfunc.global) add_psymbol_to_list (namestring, strlen (namestring), @@ -1902,12 +1889,12 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) continue; case DNTT_TYPE_DOC_FUNCTION: - valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (section_offsets, - SECT_OFF_TEXT); + valu = dn_bufp->ddocfunc.hiaddr + ANOFFSET (objfile->section_offsets, + SECT_OFF_TEXT (objfile)); if (valu > texthigh) texthigh = valu; valu = dn_bufp->ddocfunc.lowaddr + - ANOFFSET (section_offsets, SECT_OFF_TEXT); + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); SET_NAMESTRING (dn_bufp, &namestring, objfile); if (dn_bufp->ddocfunc.global) add_psymbol_to_list (namestring, strlen (namestring), @@ -1985,19 +1972,19 @@ 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); } /* Compute address of the data symbol */ valu = dn_bufp->dsvar.location; /* Relocate in case it's in a shared library */ if (storage == LOC_STATIC) - valu += ANOFFSET (section_offsets, SECT_OFF_DATA); + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); /* Luckily, dvar, svar, typedef, and tagdef all have their "global" bit in the same place, so it works @@ -2048,7 +2035,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) VAR_NAMESPACE, storage, &objfile->global_psymbols, dn_bufp->dsvar.location, - 0, language_unknown, objfile); + 0, language_unknown, objfile); } else { @@ -2056,7 +2043,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) VAR_NAMESPACE, storage, &objfile->static_psymbols, dn_bufp->dsvar.location, - 0, language_unknown, objfile); + 0, language_unknown, objfile); } } } @@ -2069,10 +2056,10 @@ 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)), + * sizeof (struct dntt_type_block)), objfile->global_psymbols.next, objfile->static_psymbols.next); } @@ -2212,20 +2199,19 @@ hpread_get_textlow (global, index, objfile, symcount) (normal). */ static struct partial_symtab * -hpread_start_psymtab (objfile, section_offsets, +hpread_start_psymtab (objfile, 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; { - int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT); + int offset = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); extern void hpread_psymtab_to_symtab (); struct partial_symtab *result = - start_psymtab_common (objfile, section_offsets, + start_psymtab_common (objfile, objfile->section_offsets, filename, textlow, global_syms, static_syms); result->textlow += offset; @@ -2260,7 +2246,7 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, { int i; struct objfile *objfile = pst->objfile; - int offset = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT); + int offset = ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (objfile)); #ifdef DUMPING /* Turn on to see what kind of a psymtab we've built. */ @@ -2296,7 +2282,7 @@ 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 *)); } @@ -2377,5 +2363,3 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, ***c - basic - offset:4 *** End: #endif - - diff --git a/gdb/hp-symtab-read.c b/gdb/hp-symtab-read.c index 90d4a10c6b..1e67972196 100644 --- a/gdb/hp-symtab-read.c +++ b/gdb/hp-symtab-read.c @@ -15,7 +15,8 @@ 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. + 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. */ @@ -29,21 +30,21 @@ #include "hpread.h" #include "demangle.h" #include "complaints.h" - -static struct complaint hpread_unhandled_end_common_complaint = + +static struct complaint hpread_unhandled_end_common_complaint = { "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON/DNTT_TYPE_END.\n", 0, 0 }; -static struct complaint hpread_unhandled_type_complaint = +static struct complaint hpread_unhandled_type_complaint = { "hpread_type_translate: unhandled type code.", 0, 0 }; -static struct complaint hpread_struct_complaint = +static struct complaint hpread_struct_complaint = { "hpread_read_struct_type: expected SVAR type...", 0, 0 }; @@ -53,28 +54,28 @@ static struct complaint hpread_array_complaint = "error in hpread_array_type.", 0, 0 }; -static struct complaint hpread_type_lookup_complaint = +static struct complaint hpread_type_lookup_complaint = { "error in hpread_type_lookup().", 0, 0 }; -static struct complaint hpread_unexpected_end_complaint = +static struct complaint hpread_unexpected_end_complaint = { "internal error in hp-symtab-read.c: Unexpected DNTT_TYPE_END kind.", 0, 0 }; -static struct complaint hpread_tagdef_complaint = +static struct complaint hpread_tagdef_complaint = { "error processing class tagdef", 0, 0 }; -static struct complaint hpread_unhandled_common_complaint = +static struct complaint hpread_unhandled_common_complaint = { "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_COMMON.", 0, 0 }; -static struct complaint hpread_unhandled_blockdata_complaint = +static struct complaint hpread_unhandled_blockdata_complaint = { "unhandled symbol in hp-symtab-read.c: DNTT_TYPE_BLOCKDATA.", 0, 0 }; @@ -91,17 +92,17 @@ static unsigned long hpread_get_line static CORE_ADDR hpread_get_location PARAMS ((sltpointer, struct objfile *)); -static void hpread_psymtab_to_symtab_1 +static void hpread_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *)); -void hpread_psymtab_to_symtab +void hpread_psymtab_to_symtab PARAMS ((struct partial_symtab *)); static struct symtab *hpread_expand_symtab PARAMS ((struct objfile *, int, int, CORE_ADDR, int, struct section_offsets *, char *)); -static int hpread_type_translate +static int hpread_type_translate PARAMS ((dnttpointer)); static struct type **hpread_lookup_type @@ -125,19 +126,19 @@ static struct type *hpread_read_struct_type static struct type *hpread_get_nth_template_arg PARAMS ((struct objfile *, int)); -static struct type * hpread_read_templ_arg_type +static struct type *hpread_read_templ_arg_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *, char *)); static struct type *hpread_read_set_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); -static struct type * hpread_read_array_type - PARAMS ((dnttpointer, union dnttentry *dn_bufp, struct objfile *objfile)); +static struct type *hpread_read_array_type + PARAMS ((dnttpointer, union dnttentry * dn_bufp, struct objfile * objfile)); static struct type *hpread_read_subrange_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); -static struct type * hpread_type_lookup +static struct type *hpread_type_lookup PARAMS ((dnttpointer, struct objfile *)); static sltpointer hpread_record_lines @@ -146,12 +147,12 @@ static sltpointer hpread_record_lines static void hpread_process_one_debug_symbol PARAMS ((union dnttentry *, char *, struct section_offsets *, - struct objfile *, CORE_ADDR, int, char *, int, int * )); + struct objfile *, CORE_ADDR, int, char *, int, int *)); static int hpread_get_scope_depth PARAMS ((union dnttentry *, struct objfile *, int)); -static void fix_static_member_physnames +static void fix_static_member_physnames PARAMS ((struct type *, char *, struct objfile *)); static void fixup_class_method_type @@ -164,19 +165,19 @@ static dnttpointer hpread_get_next_skip_over_anon_unions /* Global to indicate presence of HP-compiled objects, in particular, SOM executable file with SOM debug info - Defined in symtab.c, used in hppa-tdep.c. */ + Defined in symtab.c, used in hppa-tdep.c. */ extern int hp_som_som_object_present; /* Static used to indicate a class type that requires a fix-up of one of its method types */ -static struct type * fixup_class = NULL; +static struct type *fixup_class = NULL; /* Static used to indicate the method type that is to be used to fix-up the type for fixup_class */ -static struct type * fixup_method = NULL; - +static struct type *fixup_method = NULL; + /* Get the nesting depth for the source line identified by INDEX. */ static unsigned long @@ -220,24 +221,24 @@ hpread_get_location (index, objfile) { /* find previous normal sltentry and get address */ for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) && - (sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) && + (sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) && (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++) sl_bufp = hpread_get_slt (index - i, objfile); if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET) - return sl_bufp->snormoff.address; + return sl_bufp->snormoff.address; else - return sl_bufp->snorm.address; + return sl_bufp->snorm.address; } /* find next normal sltentry and get address */ for (i = 0; ((sl_bufp->snorm.sltdesc != SLT_NORMAL) && (sl_bufp->snorm.sltdesc != SLT_NORMAL_OFFSET) && - (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++) + (sl_bufp->snorm.sltdesc != SLT_EXIT)); i++) sl_bufp = hpread_get_slt (index + i, objfile); - if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET) - return sl_bufp->snormoff.address; - else - return sl_bufp->snorm.address; + if (sl_bufp->snorm.sltdesc == SLT_NORMAL_OFFSET) + return sl_bufp->snormoff.address; + else + return sl_bufp->snorm.address; } @@ -301,18 +302,18 @@ hpread_has_name (kind) case DNTT_TYPE_INHERITANCE: case DNTT_TYPE_FRIEND_CLASS: case DNTT_TYPE_FRIEND_FUNC: - case DNTT_TYPE_MODIFIER: + case DNTT_TYPE_MODIFIER: case DNTT_TYPE_OBJECT_ID: case DNTT_TYPE_TEMPLATE: case DNTT_TYPE_TEMPLATE_ARG: case DNTT_TYPE_FUNC_TEMPLATE: case DNTT_TYPE_LINK: - /* DNTT_TYPE_DYN_ARRAY_DESC ? */ - /* DNTT_TYPE_DESC_SUBRANGE ? */ - /* DNTT_TYPE_BEGIN_EXT ? */ - /* DNTT_TYPE_INLN ? */ - /* DNTT_TYPE_INLN_LIST ? */ - /* DNTT_TYPE_ALIAS ? */ + /* DNTT_TYPE_DYN_ARRAY_DESC ? */ + /* DNTT_TYPE_DESC_SUBRANGE ? */ + /* DNTT_TYPE_BEGIN_EXT ? */ + /* DNTT_TYPE_INLN ? */ + /* DNTT_TYPE_INLN_LIST ? */ + /* DNTT_TYPE_ALIAS ? */ default: return 0; } @@ -400,7 +401,7 @@ hpread_psymtab_to_symtab (pst) was compiled using an HP compiler (aCC, cc) the processing_acc_compilation variable is declared in the file buildsym.h, the HP_COMPILED_TARGET is defined to be equal - to 3 in the file tm_hppa.h*/ + to 3 in the file tm_hppa.h */ processing_gcc_compilation = 0; @@ -448,11 +449,11 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, struct section_offsets *section_offsets; char *filename; { - char *namestring; + char *namestring; union dnttentry *dn_bufp; - unsigned max_symnum; - int at_module_boundary = 0; - /* 1 => at end, -1 => at beginning */ + unsigned max_symnum; + int at_module_boundary = 0; + /* 1 => at end, -1 => at beginning */ int sym_index = sym_offset / sizeof (struct dntt_type_block); @@ -462,11 +463,12 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, last_source_file = 0; /* Demangling style -- if EDG style already set, don't change it, - as HP style causes some problems with the KAI EDG compiler */ - if (current_demangling_style != edg_demangling) { - /* Otherwise, ensure that we are using HP style demangling */ - set_demangling_style (HP_DEMANGLING_STYLE_STRING); - } + as HP style causes some problems with the KAI EDG compiler */ + if (current_demangling_style != edg_demangling) + { + /* Otherwise, ensure that we are using HP style demangling */ + set_demangling_style (HP_DEMANGLING_STYLE_STRING); + } dn_bufp = hpread_get_lntt (sym_index, objfile); if (!((dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_SRCFILE) || @@ -492,12 +494,12 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, * in to prepare for backing this out again. -JB */ max_symnum = sym_size / sizeof (struct dntt_type_block); - /* No reason to multiply on pst side and divide on sym side... FIXME */ + /* No reason to multiply on pst side and divide on sym side... FIXME */ /* Read in and process each debug symbol within the specified range. */ for (symnum = 0; - symnum < max_symnum; + symnum < max_symnum; symnum++) { QUIT; /* Allow this to be interruptable */ @@ -512,9 +514,9 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, hpread_process_one_debug_symbol (dn_bufp, namestring, section_offsets, objfile, text_offset, text_size, filename, symnum + sym_index, - &at_module_boundary - ); - + &at_module_boundary + ); + /* OLD COMMENTS: This routine is only called for psts. All psts * correspond to MODULES. If we ever do lazy-reading of globals * from the LNTT, then there will be a pst which ends when the @@ -522,7 +524,7 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, * to re-visit this break. if( at_end_of_module ) - break; + break; */ @@ -535,12 +537,12 @@ hpread_expand_symtab (objfile, sym_offset, sym_size, text_offset, text_size, the psymtab, so we break out if we enter a new module. */ if (at_module_boundary == -1) - break; + break; } current_objfile = NULL; - hp_som_som_object_present = 1; /* Indicate we've processed an HP SOM SOM file */ - + hp_som_som_object_present = 1; /* Indicate we've processed an HP SOM SOM file */ + return end_symtab (text_offset + text_size, objfile, 0); } @@ -553,10 +555,11 @@ static int hpread_type_translate (typep) dnttpointer typep; { - if (!typep.dntti.immediate) { - error ("error in hpread_type_translate\n."); - return; - } + if (!typep.dntti.immediate) + { + error ("error in hpread_type_translate\n."); + return; + } switch (typep.dntti.type) { @@ -564,13 +567,13 @@ hpread_type_translate (typep) case HP_TYPE_BOOLEAN_S300_COMPAT: case HP_TYPE_BOOLEAN_VAX_COMPAT: return FT_BOOLEAN; - case HP_TYPE_CHAR: /* C signed char, C++ plain char */ - + case HP_TYPE_CHAR: /* C signed char, C++ plain char */ + case HP_TYPE_WIDE_CHAR: return FT_CHAR; case HP_TYPE_INT: if (typep.dntti.bitlength <= 8) - return FT_SIGNED_CHAR; /* C++ signed char */ + return FT_SIGNED_CHAR; /* C++ signed char */ if (typep.dntti.bitlength <= 16) return FT_SHORT; if (typep.dntti.bitlength <= 32) @@ -578,11 +581,11 @@ hpread_type_translate (typep) return FT_LONG_LONG; case HP_TYPE_LONG: if (typep.dntti.bitlength <= 8) - return FT_SIGNED_CHAR; /* C++ signed char. */ + return FT_SIGNED_CHAR; /* C++ signed char. */ return FT_LONG; case HP_TYPE_UNSIGNED_LONG: if (typep.dntti.bitlength <= 8) - return FT_UNSIGNED_CHAR; /* C/C++ unsigned char */ + return FT_UNSIGNED_CHAR; /* C/C++ unsigned char */ if (typep.dntti.bitlength <= 16) return FT_UNSIGNED_SHORT; if (typep.dntti.bitlength <= 32) @@ -626,9 +629,9 @@ hpread_type_translate (typep) case HP_TYPE_TEXT: case HP_TYPE_FLABEL: case HP_TYPE_PACKED_DECIMAL: - case HP_TYPE_ANYPOINTER: + case HP_TYPE_ANYPOINTER: case HP_TYPE_GLOBAL_ANYPOINTER: - case HP_TYPE_LOCAL_ANYPOINTER: + case HP_TYPE_LOCAL_ANYPOINTER: default: warning ("hpread_type_translate: unhandled type code.\n"); return FT_VOID; @@ -685,35 +688,37 @@ hpread_lookup_type (hp_type, objfile) { old_len = TYPE_VECTOR_LENGTH (objfile); - /* See if we need to allocate a type-vector. */ + /* See if we need to allocate a type-vector. */ if (old_len == 0) { - TYPE_VECTOR_LENGTH(objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile); + TYPE_VECTOR_LENGTH (objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile); TYPE_VECTOR (objfile) = (struct type **) xmmalloc (objfile->md, TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *)); memset (&TYPE_VECTOR (objfile)[old_len], 0, - (TYPE_VECTOR_LENGTH (objfile) - old_len) * - sizeof (struct type *)); + (TYPE_VECTOR_LENGTH (objfile) - old_len) * + sizeof (struct type *)); } - /* See if we need to resize type-vector. With my change to - * initially allocate a correct-size type-vector, this code - * should no longer trigger. - */ - while (index >= TYPE_VECTOR_LENGTH (objfile)) { - TYPE_VECTOR_LENGTH (objfile) *= 2; - size_changed = 1; - } - if (size_changed) { - TYPE_VECTOR (objfile) = (struct type **) - xmrealloc (objfile -> md, - (char *) TYPE_VECTOR (objfile), - (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); + /* See if we need to resize type-vector. With my change to + * initially allocate a correct-size type-vector, this code + * should no longer trigger. + */ + while (index >= TYPE_VECTOR_LENGTH (objfile)) + { + TYPE_VECTOR_LENGTH (objfile) *= 2; + size_changed = 1; + } + if (size_changed) + { + TYPE_VECTOR (objfile) = (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 *)); - } + (TYPE_VECTOR_LENGTH (objfile) - old_len) * + sizeof (struct type *)); + } } return &TYPE_VECTOR (objfile)[index]; @@ -734,15 +739,16 @@ hpread_alloc_type (hp_type, objfile) struct type **type_addr; type_addr = hpread_lookup_type (hp_type, objfile); - if (*type_addr == 0) { - *type_addr = alloc_type (objfile); + if (*type_addr == 0) + { + *type_addr = alloc_type (objfile); - /* A hack - if we really are a C++ class symbol, then this default - * will get overriden later on. - */ - TYPE_CPLUS_SPECIFIC (*type_addr) - = (struct cplus_struct_type *) &cplus_struct_default; - } + /* A hack - if we really are a C++ class symbol, then this default + * will get overriden later on. + */ + TYPE_CPLUS_SPECIFIC (*type_addr) + = (struct cplus_struct_type *) &cplus_struct_default; + } return *type_addr; } @@ -797,7 +803,7 @@ 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) = obsavestring (name, strlen (name), + SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack); SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; @@ -866,24 +872,24 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) type = hpread_alloc_type (hp_type, objfile); if (TYPE_CODE (type) == TYPE_CODE_FUNC) { - record_args = 0; /* already read in, don't modify type */ + record_args = 0; /* already read in, don't modify type */ } else { /* Nope, so read it in and store it away. */ if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTION || - dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC) - type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc.retval, - objfile)); + dn_bufp->dblock.kind == DNTT_TYPE_MEMFUNC) + type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc.retval, + objfile)); else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE) - type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunctype.retval, - objfile)); - else /* expect DNTT_TYPE_FUNC_TEMPLATE */ - type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc_template.retval, - objfile)); + type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunctype.retval, + objfile)); + else /* expect DNTT_TYPE_FUNC_TEMPLATE */ + type1 = lookup_function_type (hpread_type_lookup (dn_bufp->dfunc_template.retval, + objfile)); memcpy ((char *) type, (char *) type1, sizeof (struct type)); - - /* Mark it -- in the middle of processing */ + + /* Mark it -- in the middle of processing */ TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE; } @@ -894,7 +900,7 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) param = dn_bufp->dfunc.firstparam; else if (dn_bufp->dblock.kind == DNTT_TYPE_FUNCTYPE) param = dn_bufp->dfunctype.firstparam; - else /* expect DNTT_TYPE_FUNC_TEMPLATE */ + else /* expect DNTT_TYPE_FUNC_TEMPLATE */ param = dn_bufp->dfunc_template.firstparam; while (param.word && param.word != DNTTNIL) { @@ -920,18 +926,18 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) 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)); #endif /* This is likely a pass-by-invisible reference parameter, Hack on the symbol class to make GDB happy. */ - /* ??rehrauer: This appears to be broken w/r/t to passing - C values of type float and struct. Perhaps this ought - to be highighted as a special case, but for now, just - allowing these to be LOC_ARGs seems to work fine. - */ + /* ??rehrauer: This appears to be broken w/r/t to passing + C values of type float and struct. Perhaps this ought + to be highighted as a special case, but for now, just + allowing these to be LOC_ARGs seems to work fine. + */ #if 0 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; #endif @@ -953,7 +959,7 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put each fparam on the local_symbols list from here. Now we use the local_list to which fparams are added below, and set the param_symbols - global to point to that at the end of this routine. */ + global to point to that at the end of this routine. */ /* elz: I added this new list of symbols which is local to the function. this list is the one which is actually used to build the type for the function rather than the gloabal list pointed to by symlist. @@ -962,16 +968,16 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) a function itself with more parameters in it. Adding parameters to the same global symbol list would not work! Actually it did work in case of cc compiled programs where you do - not check the parameter lists of the arguments. */ + not check the parameter lists of the arguments. */ add_symbol_to_list (sym, &local_list); } /* If type was read in earlier, don't bother with modifying - the type struct */ + the type struct */ if (!record_args) goto finish; - + /* Note how many parameters we found. */ TYPE_NFIELDS (type) = nsyms; TYPE_FIELDS (type) = (struct field *) @@ -984,14 +990,14 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) /* Note that we preserve the order of the parameters, so that in something like "enum {FOO, LAST_THING=FOO}" we print FOO, not LAST_THING. */ - + /* get the parameters types from the local list not the global list so that the type can be correctly constructed for functions which have function as parameters */ for (syms = local_list, n = 0; syms; syms = syms->next) { int j = 0; - for (j=0; j < syms->nsyms; j++, n++) + for (j = 0; j < syms->nsyms; j++, n++) { struct symbol *xsym = syms->symbol[j]; TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); @@ -1000,7 +1006,7 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) TYPE_FIELD_BITSIZE (type, n) = 0; } } - /* Mark it as having been processed */ + /* Mark it as having been processed */ TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE); /* Check whether we need to fix-up a class type with this function's type */ @@ -1016,11 +1022,11 @@ hpread_read_function_type (hp_type, dn_bufp, objfile, newblock) called for creating a new block, and not if it was called simply to get the function type. This prevents recursive invocations from trashing param_symbols. */ -finish: +finish: if (newblock) param_symbols = local_list; - - return type; + + return type; } @@ -1052,18 +1058,18 @@ hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock) type = hpread_alloc_type (hp_type, objfile); if (TYPE_CODE (type) == TYPE_CODE_FUNC) { - record_args = 0; /* already read in, don't modify type */ + record_args = 0; /* already read in, don't modify type */ } else { /* Nope, so read it in and store it away. */ if (dn_bufp->dblock.kind == DNTT_TYPE_DOC_FUNCTION || - dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) - type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval, - objfile)); + dn_bufp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) + type1 = lookup_function_type (hpread_type_lookup (dn_bufp->ddocfunc.retval, + objfile)); memcpy ((char *) type, (char *) type1, sizeof (struct type)); - - /* Mark it -- in the middle of processing */ + + /* Mark it -- in the middle of processing */ TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE; } @@ -1095,18 +1101,18 @@ hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock) 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)); #endif /* This is likely a pass-by-invisible reference parameter, Hack on the symbol class to make GDB happy. */ - /* ??rehrauer: This appears to be broken w/r/t to passing - C values of type float and struct. Perhaps this ought - to be highighted as a special case, but for now, just - allowing these to be LOC_ARGs seems to work fine. - */ + /* ??rehrauer: This appears to be broken w/r/t to passing + C values of type float and struct. Perhaps this ought + to be highighted as a special case, but for now, just + allowing these to be LOC_ARGs seems to work fine. + */ #if 0 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; #endif @@ -1128,8 +1134,8 @@ hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock) /* Note 3 (pai/1997-08-11) I removed the add_symbol_to_list() which put each fparam on the local_symbols list from here. Now we use the local_list to which fparams are added below, and set the param_symbols - global to point to that at the end of this routine. */ - + global to point to that at the end of this routine. */ + /* elz: I added this new list of symbols which is local to the function. this list is the one which is actually used to build the type for the function rather than the gloabal list pointed to by symlist. @@ -1143,15 +1149,15 @@ hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock) } /* If type was read in earlier, don't bother with modifying - the type struct */ + the type struct */ if (!record_args) goto finish; - + /* Note how many parameters we found. */ TYPE_NFIELDS (type) = nsyms; TYPE_FIELDS (type) = (struct field *) obstack_alloc (&objfile->type_obstack, - sizeof (struct field) * nsyms); + sizeof (struct field) * nsyms); /* Find the symbols for the parameters and use them to fill parameter-type information into the function-type. @@ -1159,25 +1165,25 @@ hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock) /* Note that we preserve the order of the parameters, so that in something like "enum {FOO, LAST_THING=FOO}" we print FOO, not LAST_THING. */ - + /* get the parameters types from the local list not the global list so that the type can be correctly constructed for functions which have function as parameters - */ + */ for (syms = local_list, n = 0; syms; syms = syms->next) { int j = 0; for (j = 0; j < syms->nsyms; j++, n++) - { - struct symbol *xsym = syms->symbol[j]; - TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); - TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym); - TYPE_FIELD_BITPOS (type, n) = n; - TYPE_FIELD_BITSIZE (type, n) = 0; - } + { + struct symbol *xsym = syms->symbol[j]; + TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); + TYPE_FIELD_TYPE (type, n) = SYMBOL_TYPE (xsym); + TYPE_FIELD_BITPOS (type, n) = n; + TYPE_FIELD_BITSIZE (type, n) = 0; + } } - - /* Mark it as having been processed */ + + /* Mark it as having been processed */ TYPE_FLAGS (type) &= ~(TYPE_FLAG_INCOMPLETE); /* Check whether we need to fix-up a class type with this function's type */ @@ -1193,10 +1199,10 @@ hpread_read_doc_function_type (hp_type, dn_bufp, objfile, newblock) called for creating a new block, and not if it was called simply to get the function type. This prevents recursive invocations from trashing param_symbols. */ -finish: +finish: if (newblock) param_symbols = local_list; - + return type; } @@ -1215,7 +1221,7 @@ finish: * * There may be problems handling nested templates... tough. */ -static struct type * current_template = NULL; +static struct type *current_template = NULL; /* Read in and internalize a structure definition. * This same routine is called for struct, union, and class types. @@ -1234,10 +1240,10 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) { struct nextfield *next; struct field field; - unsigned char attributes; /* store visibility and virtuality info */ -# define ATTR_VIRTUAL 1 -# define ATTR_PRIVATE 2 -# define ATTR_PROTECT 3 + unsigned char attributes; /* store visibility and virtuality info */ +#define ATTR_VIRTUAL 1 +#define ATTR_PRIVATE 2 +#define ATTR_PROTECT 3 }; @@ -1248,7 +1254,7 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) struct fn_fieldlist field; struct fn_field fn_field; int num_fn_fields; - }; + }; /* The template args get linked together into a list of struct next_template's */ struct next_template @@ -1258,10 +1264,10 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) }; /* The template instantiations get linked together into a list of these... */ - struct next_instantiation + struct next_instantiation { - struct next_instantiation * next; - struct type * t; + struct next_instantiation *next; + struct type *t; }; struct type *type; @@ -1285,9 +1291,9 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) int volatile_member = 0; unsigned long vtbl_offset; int need_bitvectors = 0; - char * method_name = NULL; - char * method_alias = NULL; - + char *method_name = NULL; + char *method_alias = NULL; + /* Is it something we've already dealt with? */ type = hpread_alloc_type (hp_type, objfile); @@ -1295,7 +1301,7 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) (TYPE_CODE (type) == TYPE_CODE_UNION) || (TYPE_CODE (type) == TYPE_CODE_CLASS) || (TYPE_CODE (type) == TYPE_CODE_TEMPLATE)) - return type; + return type; /* Get the basic type correct. */ if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) @@ -1310,13 +1316,13 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) } else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) { - TYPE_CODE (type) = TYPE_CODE_CLASS; + TYPE_CODE (type) = TYPE_CODE_CLASS; TYPE_LENGTH (type) = dn_bufp->dclass.bitlength / 8; /* Overrides the TYPE_CPLUS_SPECIFIC(type) with allocated memory * rather than &cplus_struct_default. */ - allocate_cplus_struct_type(type); + allocate_cplus_struct_type (type); /* Fill in declared-type. * (The C++ compiler will emit TYPE_CODE_CLASS @@ -1325,14 +1331,14 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) * want to know how it was really declared) */ /* (0==class, 1==union, 2==struct) */ - TYPE_DECLARED_TYPE(type) = dn_bufp->dclass.class_decl; + TYPE_DECLARED_TYPE (type) = dn_bufp->dclass.class_decl; } else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { /* Get the basic type correct. */ - TYPE_CODE (type) = TYPE_CODE_TEMPLATE; - allocate_cplus_struct_type(type); - TYPE_DECLARED_TYPE(type) = DECLARED_TYPE_TEMPLATE; + TYPE_CODE (type) = TYPE_CODE_TEMPLATE; + allocate_cplus_struct_type (type); + TYPE_DECLARED_TYPE (type) = DECLARED_TYPE_TEMPLATE; } else return type; @@ -1343,60 +1349,62 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) /* For classes, read the parent list. * Question (RT): Do we need to do this for templates also? */ - if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) { + if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) + { - /* First read the parent-list (classes from which we derive fields) */ - parent = dn_bufp->dclass.parentlist; - while (parent.word && parent.word != DNTTNIL) { - parentp = hpread_get_lntt (parent.dnttp.index, objfile); + /* First read the parent-list (classes from which we derive fields) */ + parent = dn_bufp->dclass.parentlist; + while (parent.word && parent.word != DNTTNIL) + { + parentp = hpread_get_lntt (parent.dnttp.index, objfile); - /* "parentp" should point to a DNTT_TYPE_INHERITANCE record */ + /* "parentp" should point to a DNTT_TYPE_INHERITANCE record */ - /* Get space to record the next field/data-member. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; + /* Get space to record the next field/data-member. */ + new = (struct nextfield *) alloca (sizeof (struct nextfield)); + new->next = list; + list = new; - FIELD_BITSIZE (list->field) = 0; + FIELD_BITSIZE (list->field) = 0; - /* The "classname" field is actually a DNTT pointer to the base class */ - baseclass = hpread_type_lookup (parentp->dinheritance.classname, - objfile); - FIELD_TYPE (list->field) = baseclass; + /* The "classname" field is actually a DNTT pointer to the base class */ + baseclass = hpread_type_lookup (parentp->dinheritance.classname, + objfile); + FIELD_TYPE (list->field) = baseclass; - list->field.name = type_name_no_tag(FIELD_TYPE (list->field)); + list->field.name = type_name_no_tag (FIELD_TYPE (list->field)); - list->attributes = 0; + list->attributes = 0; - /* Check for virtuality of base, and set the - * offset of the base subobject within the object. - * (Offset set to -1 for virtual bases (for now).) - */ - if (parentp->dinheritance.Virtual) - { - B_SET(&(list->attributes), ATTR_VIRTUAL); - parentp->dinheritance.offset = -1; - } - else - FIELD_BITPOS (list->field) = parentp->dinheritance.offset; - - /* Check visibility */ - switch (parentp->dinheritance.visibility) - { - case 1: - B_SET(&(list->attributes), ATTR_PROTECT); - break; - case 2: - B_SET(&(list->attributes), ATTR_PRIVATE); - break; - } - - n_base_classes++; - nfields++; - - parent = parentp->dinheritance.next; + /* Check for virtuality of base, and set the + * offset of the base subobject within the object. + * (Offset set to -1 for virtual bases (for now).) + */ + if (parentp->dinheritance.Virtual) + { + B_SET (&(list->attributes), ATTR_VIRTUAL); + parentp->dinheritance.offset = -1; + } + else + FIELD_BITPOS (list->field) = parentp->dinheritance.offset; + + /* Check visibility */ + switch (parentp->dinheritance.visibility) + { + case 1: + B_SET (&(list->attributes), ATTR_PROTECT); + break; + case 2: + B_SET (&(list->attributes), ATTR_PRIVATE); + break; + } + + n_base_classes++; + nfields++; + + parent = parentp->dinheritance.next; + } } - } /* For templates, read the template argument list. * This must be done before processing the member list, because @@ -1408,46 +1416,48 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) * }; * We need to read the argument list "T1", "T2" first. */ - if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { - /* Kludge alert: This stuffs a global "current_template" which - * is referred to by hpread_get_nth_templ_arg(). The global - * is cleared at the end of this routine. - */ - current_template = type; + if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) + { + /* Kludge alert: This stuffs a global "current_template" which + * is referred to by hpread_get_nth_templ_arg(). The global + * is cleared at the end of this routine. + */ + current_template = type; - /* Read in the argument list */ - field = dn_bufp->dtemplate.arglist; - while (field.word && field.word != DNTTNIL) { - /* Get this template argument*/ - fieldp = hpread_get_lntt (field.dnttp.index, objfile); - if (fieldp->dblock.kind != DNTT_TYPE_TEMPLATE_ARG) - { - warning ("Invalid debug info: Template argument entry is of wrong kind"); - break; - } - /* Bump the count */ - n_templ_args++; - /* Allocate and fill in a struct next_template */ - t_new = (struct next_template *) alloca (sizeof (struct next_template)); - t_new->next = t_list; - t_list = t_new; - t_list->arg.name = VT (objfile) + fieldp->dtempl_arg.name; - t_list->arg.type = hpread_read_templ_arg_type(field, fieldp, - objfile, t_list->arg.name); - /* Walk to the next template argument */ - field = fieldp->dtempl_arg.nextarg; + /* Read in the argument list */ + field = dn_bufp->dtemplate.arglist; + while (field.word && field.word != DNTTNIL) + { + /* Get this template argument */ + fieldp = hpread_get_lntt (field.dnttp.index, objfile); + if (fieldp->dblock.kind != DNTT_TYPE_TEMPLATE_ARG) + { + warning ("Invalid debug info: Template argument entry is of wrong kind"); + break; + } + /* Bump the count */ + n_templ_args++; + /* Allocate and fill in a struct next_template */ + t_new = (struct next_template *) alloca (sizeof (struct next_template)); + t_new->next = t_list; + t_list = t_new; + t_list->arg.name = VT (objfile) + fieldp->dtempl_arg.name; + t_list->arg.type = hpread_read_templ_arg_type (field, fieldp, + objfile, t_list->arg.name); + /* Walk to the next template argument */ + field = fieldp->dtempl_arg.nextarg; + } } - } - TYPE_NTEMPLATE_ARGS(type) = n_templ_args; + TYPE_NTEMPLATE_ARGS (type) = n_templ_args; if (n_templ_args > 0) - TYPE_TEMPLATE_ARGS(type) = (struct template_arg *) + TYPE_TEMPLATE_ARGS (type) = (struct template_arg *) obstack_alloc (&objfile->type_obstack, sizeof (struct template_arg) * n_templ_args); for (n = n_templ_args; t_list; t_list = t_list->next) { n -= 1; - TYPE_TEMPLATE_ARG(type, n) = t_list->arg; + TYPE_TEMPLATE_ARG (type, n) = t_list->arg; } /* Next read in and internalize all the fields/members. */ @@ -1473,453 +1483,471 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) static_member = 0; const_member = 0; volatile_member = 0; - - if (fieldp->dblock.kind == DNTT_TYPE_GENFIELD) { - - /* The type will be GENFIELD if the field is a method or - * a static member (or some other cases -- see below) - */ - - /* Follow a link to get to the record for the field. */ - fn_field = fieldp->dgenfield.field; - fn_fieldp = hpread_get_lntt(fn_field.dnttp.index, objfile); - - /* Virtual funcs are indicated by a VFUNC which points to the - * real entry - */ - if (fn_fieldp->dblock.kind == DNTT_TYPE_VFUNC) { - vtbl_offset = fn_fieldp->dvfunc.vtbl_offset; - fn_field = fn_fieldp->dvfunc.funcptr; - fn_fieldp = hpread_get_lntt(fn_field.dnttp.index, objfile); - } - - /* A function's entry may be preceded by a modifier which - * labels it static/constant/volatile. - */ - if (fn_fieldp->dblock.kind == DNTT_TYPE_MODIFIER) { - static_member = fn_fieldp->dmodifier.m_static; - const_member = fn_fieldp->dmodifier.m_const; - volatile_member = fn_fieldp->dmodifier.m_volatile; - fn_field = fn_fieldp->dmodifier.type; - fn_fieldp = hpread_get_lntt(fn_field.dnttp.index, objfile); - } - - /* Check whether we have a method */ - if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) || - (fn_fieldp->dblock.kind == DNTT_TYPE_FUNCTION) || - (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) || - (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_FUNCTION)) { - /* Method found */ - - short ix = 0; - - /* Look up function type of method */ - memtype = hpread_type_lookup (fn_field, objfile); - - /* Methods can be seen before classes in the SOM records. - If we are processing this class because it's a parameter of a - method, at this point the method's type is actually incomplete; - we'll have to fix it up later; mark the class for this. */ - - if (TYPE_INCOMPLETE (memtype)) - { - TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE; - if (fixup_class) - warning ("Two classes to fix up for method?? Type information may be incorrect for some classes."); - if (fixup_method) - warning ("Two methods to be fixed up at once?? Type information may be incorrect for some classes."); - fixup_class = type; /* remember this class has to be fixed up */ - fixup_method = memtype; /* remember the method type to be used in fixup */ - } - - /* HP aCC generates operator names without the "operator" keyword, and - generates null strings as names for operators that are - user-defined type conversions to basic types (e.g. operator int ()). - So try to reconstruct name as best as possible. */ - - method_name = (char *) (VT (objfile) + fn_fieldp->dfunc.name); - method_alias = (char *) (VT (objfile) + fn_fieldp->dfunc.alias); - - if (!method_name || /* no name */ - !*method_name || /* or null name */ - cplus_mangle_opname (method_name, DMGL_ANSI)) /* or name is an operator like "<" */ - { - char * tmp_name = cplus_demangle (method_alias, DMGL_ANSI); - char * op_string = strstr (tmp_name, "operator"); - method_name = xmalloc (strlen (op_string) + 1); /* don't overwrite VT! */ - strcpy (method_name, op_string); - } - - /* First check if a method of the same name has already been seen. */ - fn_p = fn_list; - while (fn_p) - { - if (STREQ (fn_p->field.name, method_name)) - break; - fn_p = fn_p->next; - } - - /* If no such method was found, allocate a new entry in the list */ - if (!fn_p) - { - /* Get space to record this member function */ - /* Note: alloca used; this will disappear on routine exit */ - fn_new = (struct next_fn_field *) alloca (sizeof (struct next_fn_field)); - fn_new->next = fn_list; - fn_list = fn_new; - - /* Fill in the fields of the struct nextfield */ - - /* Record the (unmangled) method name */ - fn_list->field.name = method_name; - /* Initial space for overloaded methods */ - /* Note: xmalloc is used; this will persist after this routine exits */ - fn_list->field.fn_fields = (struct fn_field *) xmalloc (5 * (sizeof (struct fn_field))); - fn_list->field.length = 1; /* Init # of overloaded instances */ - fn_list->num_fn_fields = 5; /* # of entries for which space allocated */ - fn_p = fn_list; - ix = 0; /* array index for fn_field */ - /* Bump the total count of the distinctly named methods */ - n_fn_fields++; - } - else /* Another overloaded instance of an already seen method name */ - { - if (++(fn_p->field.length) > fn_p->num_fn_fields) - { - /* Increase space allocated for overloaded instances */ - fn_p->field.fn_fields - = (struct fn_field *) xrealloc (fn_p->field.fn_fields, - (fn_p->num_fn_fields + 5) * sizeof (struct fn_field)); - fn_p->num_fn_fields += 5; - } - ix = fn_p->field.length -1; /* array index for fn_field */ - } - - /* "physname" is intended to be the name of this overloaded instance. */ - if ((fn_fieldp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) && - method_alias && - *method_alias) /* not a null string */ - fn_p->field.fn_fields[ix].physname = method_alias; + + if (fieldp->dblock.kind == DNTT_TYPE_GENFIELD) + { + + /* The type will be GENFIELD if the field is a method or + * a static member (or some other cases -- see below) + */ + + /* Follow a link to get to the record for the field. */ + fn_field = fieldp->dgenfield.field; + fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile); + + /* Virtual funcs are indicated by a VFUNC which points to the + * real entry + */ + if (fn_fieldp->dblock.kind == DNTT_TYPE_VFUNC) + { + vtbl_offset = fn_fieldp->dvfunc.vtbl_offset; + fn_field = fn_fieldp->dvfunc.funcptr; + fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile); + } + + /* A function's entry may be preceded by a modifier which + * labels it static/constant/volatile. + */ + if (fn_fieldp->dblock.kind == DNTT_TYPE_MODIFIER) + { + static_member = fn_fieldp->dmodifier.m_static; + const_member = fn_fieldp->dmodifier.m_const; + volatile_member = fn_fieldp->dmodifier.m_volatile; + fn_field = fn_fieldp->dmodifier.type; + fn_fieldp = hpread_get_lntt (fn_field.dnttp.index, objfile); + } + + /* Check whether we have a method */ + if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) || + (fn_fieldp->dblock.kind == DNTT_TYPE_FUNCTION) || + (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC) || + (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_FUNCTION)) + { + /* Method found */ + + short ix = 0; + + /* Look up function type of method */ + memtype = hpread_type_lookup (fn_field, objfile); + + /* Methods can be seen before classes in the SOM records. + If we are processing this class because it's a parameter of a + method, at this point the method's type is actually incomplete; + we'll have to fix it up later; mark the class for this. */ + + if (TYPE_INCOMPLETE (memtype)) + { + TYPE_FLAGS (type) |= TYPE_FLAG_INCOMPLETE; + if (fixup_class) + warning ("Two classes to fix up for method?? Type information may be incorrect for some classes."); + if (fixup_method) + warning ("Two methods to be fixed up at once?? Type information may be incorrect for some classes."); + fixup_class = type; /* remember this class has to be fixed up */ + fixup_method = memtype; /* remember the method type to be used in fixup */ + } + + /* HP aCC generates operator names without the "operator" keyword, and + generates null strings as names for operators that are + user-defined type conversions to basic types (e.g. operator int ()). + So try to reconstruct name as best as possible. */ + + method_name = (char *) (VT (objfile) + fn_fieldp->dfunc.name); + method_alias = (char *) (VT (objfile) + fn_fieldp->dfunc.alias); + + if (!method_name || /* no name */ + !*method_name || /* or null name */ + cplus_mangle_opname (method_name, DMGL_ANSI)) /* or name is an operator like "<" */ + { + char *tmp_name = cplus_demangle (method_alias, DMGL_ANSI); + char *op_string = strstr (tmp_name, "operator"); + method_name = xmalloc (strlen (op_string) + 1); /* don't overwrite VT! */ + strcpy (method_name, op_string); + } + + /* First check if a method of the same name has already been seen. */ + fn_p = fn_list; + while (fn_p) + { + if (STREQ (fn_p->field.name, method_name)) + break; + fn_p = fn_p->next; + } + + /* If no such method was found, allocate a new entry in the list */ + if (!fn_p) + { + /* Get space to record this member function */ + /* Note: alloca used; this will disappear on routine exit */ + fn_new = (struct next_fn_field *) alloca (sizeof (struct next_fn_field)); + fn_new->next = fn_list; + fn_list = fn_new; + + /* Fill in the fields of the struct nextfield */ + + /* Record the (unmangled) method name */ + fn_list->field.name = method_name; + /* Initial space for overloaded methods */ + /* Note: xmalloc is used; this will persist after this routine exits */ + fn_list->field.fn_fields = (struct fn_field *) xmalloc (5 * (sizeof (struct fn_field))); + fn_list->field.length = 1; /* Init # of overloaded instances */ + fn_list->num_fn_fields = 5; /* # of entries for which space allocated */ + fn_p = fn_list; + ix = 0; /* array index for fn_field */ + /* Bump the total count of the distinctly named methods */ + n_fn_fields++; + } + else + /* Another overloaded instance of an already seen method name */ + { + if (++(fn_p->field.length) > fn_p->num_fn_fields) + { + /* Increase space allocated for overloaded instances */ + fn_p->field.fn_fields + = (struct fn_field *) xrealloc (fn_p->field.fn_fields, + (fn_p->num_fn_fields + 5) * sizeof (struct fn_field)); + fn_p->num_fn_fields += 5; + } + ix = fn_p->field.length - 1; /* array index for fn_field */ + } + + /* "physname" is intended to be the name of this overloaded instance. */ + if ((fn_fieldp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) && + method_alias && + *method_alias) /* not a null string */ + fn_p->field.fn_fields[ix].physname = method_alias; + else + fn_p->field.fn_fields[ix].physname = method_name; + /* What's expected here is the function type */ + /* But mark it as NULL if the method was incompletely processed + We'll fix this up later when the method is fully processed */ + if (TYPE_INCOMPLETE (memtype)) + { + fn_p->field.fn_fields[ix].type = NULL; + fn_p->field.fn_fields[ix].args = NULL; + } + else + { + fn_p->field.fn_fields[ix].type = memtype; + + /* The argument list */ + fn_p->field.fn_fields[ix].type->type_specific.arg_types = + (struct type **) obstack_alloc (&objfile->type_obstack, + sizeof (struct type *) * (memtype->nfields + 1)); + for (i = 0; i < memtype->nfields; i++) + fn_p->field.fn_fields[ix].type->type_specific.arg_types[i] = memtype->fields[i].type; + /* void termination */ + fn_p->field.fn_fields[ix].type->type_specific.arg_types[memtype->nfields] = builtin_type_void; + + /* pai: It's not clear why this args field has to be set. Perhaps + * it should be eliminated entirely. */ + fn_p->field.fn_fields[ix].args = + (struct type **) obstack_alloc (&objfile->type_obstack, + sizeof (struct type *) * (memtype->nfields + 1)); + for (i = 0; i < memtype->nfields; i++) + fn_p->field.fn_fields[ix].args[i] = memtype->fields[i].type; + /* null-terminated, unlike arg_types above e */ + fn_p->field.fn_fields[ix].args[memtype->nfields] = NULL; + } + /* For virtual functions, fill in the voffset field with the + * virtual table offset. (This is just copied over from the + * SOM record; not sure if it is what GDB expects here...). + * But if the function is a static method, set it to 1. + * + * Note that we have to add 1 because 1 indicates a static + * method, and 0 indicates a non-static, non-virtual method */ + + if (static_member) + fn_p->field.fn_fields[ix].voffset = VOFFSET_STATIC; + else + fn_p->field.fn_fields[ix].voffset = vtbl_offset ? vtbl_offset + 1 : 0; + + /* Also fill in the fcontext field with the current + * class. (The latter isn't quite right: should be the baseclass + * that defines the virtual function... Note we do have + * a variable "baseclass" that we could stuff into the fcontext + * field, but "baseclass" isn't necessarily right either, + * since the virtual function could have been defined more + * than one level up). + */ + + if (vtbl_offset != 0) + fn_p->field.fn_fields[ix].fcontext = type; + else + fn_p->field.fn_fields[ix].fcontext = NULL; + + /* Other random fields pertaining to this method */ + fn_p->field.fn_fields[ix].is_const = const_member; + fn_p->field.fn_fields[ix].is_volatile = volatile_member; /* ?? */ + switch (fieldp->dgenfield.visibility) + { + case 1: + fn_p->field.fn_fields[ix].is_protected = 1; + fn_p->field.fn_fields[ix].is_private = 0; + break; + case 2: + fn_p->field.fn_fields[ix].is_protected = 0; + fn_p->field.fn_fields[ix].is_private = 1; + break; + default: /* public */ + fn_p->field.fn_fields[ix].is_protected = 0; + fn_p->field.fn_fields[ix].is_private = 0; + } + fn_p->field.fn_fields[ix].is_stub = 0; + + /* HP aCC emits both MEMFUNC and FUNCTION entries for a method; + if the class points to the FUNCTION, there is usually separate + code for the method; but if we have a MEMFUNC, the method has + been inlined (and there is usually no FUNCTION entry) + FIXME Not sure if this test is accurate. pai/1997-08-22 */ + if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) || + (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)) + fn_p->field.fn_fields[ix].is_inlined = 1; + else + fn_p->field.fn_fields[ix].is_inlined = 0; + + fn_p->field.fn_fields[ix].dummy = 0; + + /* Bump the total count of the member functions */ + n_fn_fields_total++; + + } + else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR) + { + /* This case is for static data members of classes */ + + /* pai:: FIXME -- check that "staticmem" bit is set */ + + /* Get space to record this static member */ + new = (struct nextfield *) alloca (sizeof (struct nextfield)); + new->next = list; + list = new; + + list->field.name = VT (objfile) + fn_fieldp->dsvar.name; + FIELD_BITSIZE (list->field) = -1; /* indicates static member */ + SET_FIELD_PHYSNAME (list->field, 0); /* initialize to empty */ + memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile); + + FIELD_TYPE (list->field) = memtype; + list->attributes = 0; + switch (fieldp->dgenfield.visibility) + { + case 1: + B_SET (&(list->attributes), ATTR_PROTECT); + break; + case 2: + B_SET (&(list->attributes), ATTR_PRIVATE); + break; + } + nfields++; + } + + else if (fn_fieldp->dblock.kind == DNTT_TYPE_FIELD) + { + /* FIELDs follow GENFIELDs for fields of anonymous unions. + Code below is replicated from the case for FIELDs further + below, except that fieldp is replaced by fn_fieldp */ + if (!fn_fieldp->dfield.a_union) + warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set"); + /* Get space to record the next field/data-member. */ + new = (struct nextfield *) alloca (sizeof (struct nextfield)); + new->next = list; + list = new; + + list->field.name = VT (objfile) + fn_fieldp->dfield.name; + FIELD_BITPOS (list->field) = fn_fieldp->dfield.bitoffset; + if (fn_fieldp->dfield.bitlength % 8) + list->field.bitsize = fn_fieldp->dfield.bitlength; + else + list->field.bitsize = 0; + + memtype = hpread_type_lookup (fn_fieldp->dfield.type, objfile); + list->field.type = memtype; + list->attributes = 0; + switch (fn_fieldp->dfield.visibility) + { + case 1: + B_SET (&(list->attributes), ATTR_PROTECT); + break; + case 2: + B_SET (&(list->attributes), ATTR_PRIVATE); + break; + } + nfields++; + } + else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR) + { + /* Field of anonymous union; union is not inside a class */ + if (!fn_fieldp->dsvar.a_union) + warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set"); + /* Get space to record the next field/data-member. */ + new = (struct nextfield *) alloca (sizeof (struct nextfield)); + new->next = list; + list = new; + + list->field.name = VT (objfile) + fn_fieldp->dsvar.name; + FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */ + FIELD_BITSIZE (list->field) = 0; /* use length from type */ + memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile); + list->field.type = memtype; + list->attributes = 0; + /* No info to set visibility -- always public */ + nfields++; + } + else if (fn_fieldp->dblock.kind == DNTT_TYPE_DVAR) + { + /* Field of anonymous union; union is not inside a class */ + if (!fn_fieldp->ddvar.a_union) + warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set"); + /* Get space to record the next field/data-member. */ + new = (struct nextfield *) alloca (sizeof (struct nextfield)); + new->next = list; + list = new; + + list->field.name = VT (objfile) + fn_fieldp->ddvar.name; + FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */ + FIELD_BITSIZE (list->field) = 0; /* use length from type */ + memtype = hpread_type_lookup (fn_fieldp->ddvar.type, objfile); + list->field.type = memtype; + list->attributes = 0; + /* No info to set visibility -- always public */ + nfields++; + } else - fn_p->field.fn_fields[ix].physname = method_name; - /* What's expected here is the function type */ - /* But mark it as NULL if the method was incompletely processed - We'll fix this up later when the method is fully processed */ - if (TYPE_INCOMPLETE (memtype)) - { - fn_p->field.fn_fields[ix].type = NULL; - fn_p->field.fn_fields[ix].args = NULL; - } - else - { - fn_p->field.fn_fields[ix].type = memtype; - - /* The argument list */ - fn_p->field.fn_fields[ix].type->type_specific.arg_types = - (struct type **) obstack_alloc(&objfile->type_obstack, - sizeof(struct type *) * (memtype->nfields + 1)); - for (i = 0; i < memtype->nfields; i++) - fn_p->field.fn_fields[ix].type->type_specific.arg_types[i] = memtype->fields[i].type; - /* void termination */ - fn_p->field.fn_fields[ix].type->type_specific.arg_types[memtype->nfields] = builtin_type_void; - - /* pai: It's not clear why this args field has to be set. Perhaps - * it should be eliminated entirely. */ - fn_p->field.fn_fields[ix].args = - (struct type **) obstack_alloc(&objfile->type_obstack, - sizeof(struct type *) * (memtype->nfields + 1)); - for (i = 0; i < memtype->nfields; i++) - fn_p->field.fn_fields[ix].args[i] = memtype->fields[i].type; - /* null-terminated, unlike arg_types above e*/ - fn_p->field.fn_fields[ix].args[memtype->nfields] = NULL; - } - /* For virtual functions, fill in the voffset field with the - * virtual table offset. (This is just copied over from the - * SOM record; not sure if it is what GDB expects here...). - * But if the function is a static method, set it to 1. - * - * Note that we have to add 1 because 1 indicates a static - * method, and 0 indicates a non-static, non-virtual method */ - - if (static_member) - fn_p->field.fn_fields[ix].voffset = VOFFSET_STATIC; - else - fn_p->field.fn_fields[ix].voffset = vtbl_offset ? vtbl_offset + 1 : 0; - - /* Also fill in the fcontext field with the current - * class. (The latter isn't quite right: should be the baseclass - * that defines the virtual function... Note we do have - * a variable "baseclass" that we could stuff into the fcontext - * field, but "baseclass" isn't necessarily right either, - * since the virtual function could have been defined more - * than one level up). - */ - - if (vtbl_offset != 0) - fn_p->field.fn_fields[ix].fcontext = type; - else - fn_p->field.fn_fields[ix].fcontext = NULL; - - /* Other random fields pertaining to this method */ - fn_p->field.fn_fields[ix].is_const = const_member; - fn_p->field.fn_fields[ix].is_volatile = volatile_member; /* ?? */ - switch (fieldp->dgenfield.visibility) { - case 1: - fn_p->field.fn_fields[ix].is_protected = 1; - fn_p->field.fn_fields[ix].is_private = 0; - break; - case 2: - fn_p->field.fn_fields[ix].is_protected = 0; - fn_p->field.fn_fields[ix].is_private = 1; - break; - default: /* public */ - fn_p->field.fn_fields[ix].is_protected = 0; - fn_p->field.fn_fields[ix].is_private = 0; - } - fn_p->field.fn_fields[ix].is_stub = 0; - - /* HP aCC emits both MEMFUNC and FUNCTION entries for a method; - if the class points to the FUNCTION, there is usually separate - code for the method; but if we have a MEMFUNC, the method has - been inlined (and there is usually no FUNCTION entry) - FIXME Not sure if this test is accurate. pai/1997-08-22 */ - if ((fn_fieldp->dblock.kind == DNTT_TYPE_MEMFUNC) || - (fn_fieldp->dblock.kind == DNTT_TYPE_DOC_MEMFUNC)) - fn_p->field.fn_fields[ix].is_inlined = 1; - else - fn_p->field.fn_fields[ix].is_inlined = 0; - - fn_p->field.fn_fields[ix].dummy = 0; - - /* Bump the total count of the member functions */ - n_fn_fields_total++; - - } else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR) { - /* This case is for static data members of classes */ - - /* pai:: FIXME -- check that "staticmem" bit is set */ - - /* Get space to record this static member */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - list->field.name = VT (objfile) + fn_fieldp->dsvar.name; - FIELD_BITSIZE (list->field) = -1; /* indicates static member */ - SET_FIELD_PHYSNAME (list->field, 0); /* initialize to empty */ - memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile); - - FIELD_TYPE (list->field) = memtype; - list->attributes = 0; - switch (fieldp->dgenfield.visibility) { - case 1: - B_SET(&(list->attributes), ATTR_PROTECT); - break; - case 2: - B_SET(&(list->attributes), ATTR_PRIVATE); - break; - } - nfields++; - } - - else if (fn_fieldp->dblock.kind == DNTT_TYPE_FIELD) - { - /* FIELDs follow GENFIELDs for fields of anonymous unions. - Code below is replicated from the case for FIELDs further - below, except that fieldp is replaced by fn_fieldp */ - if (!fn_fieldp->dfield.a_union) - warning ("Debug info inconsistent: FIELD of anonymous union doesn't have a_union bit set"); - /* Get space to record the next field/data-member. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - list->field.name = VT (objfile) + fn_fieldp->dfield.name; - FIELD_BITPOS (list->field) = fn_fieldp->dfield.bitoffset; - if (fn_fieldp->dfield.bitlength % 8) - list->field.bitsize = fn_fieldp->dfield.bitlength; - else - list->field.bitsize = 0; - - memtype = hpread_type_lookup (fn_fieldp->dfield.type, objfile); - list->field.type = memtype; - list->attributes = 0; - switch (fn_fieldp->dfield.visibility) { - case 1: - B_SET(&(list->attributes), ATTR_PROTECT); - break; - case 2: - B_SET(&(list->attributes), ATTR_PRIVATE); - break; - } - nfields++; - } - else if (fn_fieldp->dblock.kind == DNTT_TYPE_SVAR) - { - /* Field of anonymous union; union is not inside a class */ - if (!fn_fieldp->dsvar.a_union) - warning ("Debug info inconsistent: SVAR field in anonymous union doesn't have a_union bit set"); - /* Get space to record the next field/data-member. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - list->field.name = VT (objfile) + fn_fieldp->dsvar.name; - FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */ - FIELD_BITSIZE (list->field) = 0; /* use length from type */ - memtype = hpread_type_lookup (fn_fieldp->dsvar.type, objfile); - list->field.type = memtype; - list->attributes = 0; - /* No info to set visibility -- always public */ - nfields++; - } - else if (fn_fieldp->dblock.kind == DNTT_TYPE_DVAR) - { - /* Field of anonymous union; union is not inside a class */ - if (!fn_fieldp->ddvar.a_union) - warning ("Debug info inconsistent: DVAR field in anonymous union doesn't have a_union bit set"); - /* Get space to record the next field/data-member. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - list->field.name = VT (objfile) + fn_fieldp->ddvar.name; - FIELD_BITPOS (list->field) = 0; /* FIXME is this always true? */ - FIELD_BITSIZE (list->field) = 0; /* use length from type */ - memtype = hpread_type_lookup (fn_fieldp->ddvar.type, objfile); - list->field.type = memtype; - list->attributes = 0; - /* No info to set visibility -- always public */ - nfields++; - } - else { /* Not a method, nor a static data member, nor an anon union field */ - - /* This case is for miscellaneous type entries (local enums, - local function templates, etc.) that can be present - inside a class. */ - - /* Enums -- will be handled by other code that takes care - of DNTT_TYPE_ENUM; here we see only DNTT_TYPE_MEMENUM so - it's not clear we could have handled them here at all. */ - /* FUNC_TEMPLATE: is handled by other code (??). */ - /* MEMACCESS: modified access for inherited member. Not - sure what to do with this, ignoriing it at present. */ - - /* What other entries can appear following a GENFIELD which - we do not handle above? (MODIFIER, VFUNC handled above.) */ - - if ((fn_fieldp->dblock.kind != DNTT_TYPE_MEMACCESS) && - (fn_fieldp->dblock.kind != DNTT_TYPE_MEMENUM) && - (fn_fieldp->dblock.kind != DNTT_TYPE_FUNC_TEMPLATE)) - warning ("Internal error: Unexpected debug record kind %d found following DNTT_GENFIELD", - fn_fieldp->dblock.kind); - } - /* walk to the next FIELD or GENFIELD */ - field = fieldp->dgenfield.nextfield; - - } - else if (fieldp->dblock.kind == DNTT_TYPE_FIELD) { - - /* Ordinary structure/union/class field */ - struct type * anon_union_type; - - /* Get space to record the next field/data-member. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - list->field.name = VT (objfile) + fieldp->dfield.name; - - - /* A FIELD by itself (without a GENFIELD) can also be a static member */ - if (fieldp->dfield.staticmem) - { - FIELD_BITPOS (list->field) = -1; - FIELD_BITSIZE (list->field) = 0; - } - else /* Non-static data member */ - { - FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset; - if (fieldp->dfield.bitlength % 8) - FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength; - else + { /* Not a method, nor a static data member, nor an anon union field */ + + /* This case is for miscellaneous type entries (local enums, + local function templates, etc.) that can be present + inside a class. */ + + /* Enums -- will be handled by other code that takes care + of DNTT_TYPE_ENUM; here we see only DNTT_TYPE_MEMENUM so + it's not clear we could have handled them here at all. */ + /* FUNC_TEMPLATE: is handled by other code (??). */ + /* MEMACCESS: modified access for inherited member. Not + sure what to do with this, ignoriing it at present. */ + + /* What other entries can appear following a GENFIELD which + we do not handle above? (MODIFIER, VFUNC handled above.) */ + + if ((fn_fieldp->dblock.kind != DNTT_TYPE_MEMACCESS) && + (fn_fieldp->dblock.kind != DNTT_TYPE_MEMENUM) && + (fn_fieldp->dblock.kind != DNTT_TYPE_FUNC_TEMPLATE)) + warning ("Internal error: Unexpected debug record kind %d found following DNTT_GENFIELD", + fn_fieldp->dblock.kind); + } + /* walk to the next FIELD or GENFIELD */ + field = fieldp->dgenfield.nextfield; + + } + else if (fieldp->dblock.kind == DNTT_TYPE_FIELD) + { + + /* Ordinary structure/union/class field */ + struct type *anon_union_type; + + /* Get space to record the next field/data-member. */ + new = (struct nextfield *) alloca (sizeof (struct nextfield)); + new->next = list; + list = new; + + list->field.name = VT (objfile) + fieldp->dfield.name; + + + /* A FIELD by itself (without a GENFIELD) can also be a static member */ + if (fieldp->dfield.staticmem) + { + FIELD_BITPOS (list->field) = -1; FIELD_BITSIZE (list->field) = 0; - } - - memtype = hpread_type_lookup (fieldp->dfield.type, objfile); - FIELD_TYPE (list->field) = memtype; - list->attributes = 0; - switch (fieldp->dfield.visibility) { - case 1: - B_SET(&(list->attributes), ATTR_PROTECT); - break; - case 2: - B_SET(&(list->attributes), ATTR_PRIVATE); - break; - } - nfields++; - - - /* Note 1: First, we have to check if the current field is an anonymous - union. If it is, then *its* fields are threaded along in the - nextfield chain. :-( This was supposed to help debuggers, but is - really just a nuisance since we deal with anonymous unions anyway by - checking that the name is null. So anyway, we skip over the fields - of the anonymous union. pai/1997-08-22 */ - /* Note 2: In addition, the bitoffsets for the fields of the anon union - are relative to the enclosing struct, *NOT* relative to the anon - union! This is an even bigger nuisance -- we have to go in and munge - the anon union's type information appropriately. pai/1997-08-22 */ - - /* Both tasks noted above are done by a separate function. This takes us - to the next FIELD or GENFIELD, skipping anon unions, and recursively - processing intermediate types. */ - field = hpread_get_next_skip_over_anon_unions (1, field, &fieldp, objfile); - - } else { - /* neither field nor genfield ?? is this possible?? */ - /* pai:: FIXME walk to the next -- how? */ - warning ("Internal error: unexpected DNTT kind %d encountered as field of struct"); - warning ("Skipping remaining fields of struct"); - break; /* get out of loop of fields */ - } + } + else + /* Non-static data member */ + { + FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset; + if (fieldp->dfield.bitlength % 8) + FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength; + else + FIELD_BITSIZE (list->field) = 0; + } + + memtype = hpread_type_lookup (fieldp->dfield.type, objfile); + FIELD_TYPE (list->field) = memtype; + list->attributes = 0; + switch (fieldp->dfield.visibility) + { + case 1: + B_SET (&(list->attributes), ATTR_PROTECT); + break; + case 2: + B_SET (&(list->attributes), ATTR_PRIVATE); + break; + } + nfields++; + + + /* Note 1: First, we have to check if the current field is an anonymous + union. If it is, then *its* fields are threaded along in the + nextfield chain. :-( This was supposed to help debuggers, but is + really just a nuisance since we deal with anonymous unions anyway by + checking that the name is null. So anyway, we skip over the fields + of the anonymous union. pai/1997-08-22 */ + /* Note 2: In addition, the bitoffsets for the fields of the anon union + are relative to the enclosing struct, *NOT* relative to the anon + union! This is an even bigger nuisance -- we have to go in and munge + the anon union's type information appropriately. pai/1997-08-22 */ + + /* Both tasks noted above are done by a separate function. This takes us + to the next FIELD or GENFIELD, skipping anon unions, and recursively + processing intermediate types. */ + field = hpread_get_next_skip_over_anon_unions (1, field, &fieldp, objfile); + + } + else + { + /* neither field nor genfield ?? is this possible?? */ + /* pai:: FIXME walk to the next -- how? */ + warning ("Internal error: unexpected DNTT kind %d encountered as field of struct"); + warning ("Skipping remaining fields of struct"); + break; /* get out of loop of fields */ + } } /* If it's a template, read in the instantiation list */ - if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { - ninstantiations = 0; - field = dn_bufp->dtemplate.expansions; - while (field.word && field.word != DNTTNIL) { - fieldp = hpread_get_lntt (field.dnttp.index, objfile); - - /* The expansions or nextexp should point to a tagdef */ - if (fieldp->dblock.kind != DNTT_TYPE_TAGDEF) - break; - - i_new = (struct next_instantiation *) alloca (sizeof (struct next_instantiation)); - i_new->next = i_list; - i_list = i_new; - i_list->t = hpread_type_lookup (field, objfile); - ninstantiations++; - - /* And the "type" field of that should point to a class */ - field = fieldp->dtag.type; - fieldp = hpread_get_lntt (field.dnttp.index, objfile); - if (fieldp->dblock.kind != DNTT_TYPE_CLASS) - break; - - /* Get the next expansion */ - field = fieldp->dclass.nextexp; + if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) + { + ninstantiations = 0; + field = dn_bufp->dtemplate.expansions; + while (field.word && field.word != DNTTNIL) + { + fieldp = hpread_get_lntt (field.dnttp.index, objfile); + + /* The expansions or nextexp should point to a tagdef */ + if (fieldp->dblock.kind != DNTT_TYPE_TAGDEF) + break; + + i_new = (struct next_instantiation *) alloca (sizeof (struct next_instantiation)); + i_new->next = i_list; + i_list = i_new; + i_list->t = hpread_type_lookup (field, objfile); + ninstantiations++; + + /* And the "type" field of that should point to a class */ + field = fieldp->dtag.type; + fieldp = hpread_get_lntt (field.dnttp.index, objfile); + if (fieldp->dblock.kind != DNTT_TYPE_CLASS) + break; + + /* Get the next expansion */ + field = fieldp->dclass.nextexp; + } } - } - TYPE_NINSTANTIATIONS(type) = ninstantiations; - if (ninstantiations > 0) - TYPE_INSTANTIATIONS(type) = (struct type **) + TYPE_NINSTANTIATIONS (type) = ninstantiations; + if (ninstantiations > 0) + TYPE_INSTANTIATIONS (type) = (struct type **) obstack_alloc (&objfile->type_obstack, sizeof (struct type *) * ninstantiations); for (n = ninstantiations; i_list; i_list = i_list->next) { n -= 1; - TYPE_INSTANTIATION(type, n) = i_list->t; + TYPE_INSTANTIATION (type, n) = i_list->t; } @@ -1940,12 +1968,12 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) */ TYPE_NFN_FIELDS (type) = n_fn_fields; TYPE_NFN_FIELDS_TOTAL (type) = n_fn_fields_total; - TYPE_FN_FIELDLISTS(type) = (struct fn_fieldlist *) + TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *) obstack_alloc (&objfile->type_obstack, sizeof (struct fn_fieldlist) * n_fn_fields); for (n = n_fn_fields; fn_list; fn_list = fn_list->next) { n -= 1; - TYPE_FN_FIELDLIST(type, n) = fn_list->field; + TYPE_FN_FIELDLIST (type, n) = fn_list->field; } /* pai:: FIXME -- perhaps each bitvector should be created individually */ @@ -1953,15 +1981,15 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) { n -= 1; if (tmp_list->attributes) - { - need_bitvectors = 1; - break; - } + { + need_bitvectors = 1; + break; + } } if (need_bitvectors) { - /* pai:: this step probably redundant */ + /* pai:: this step probably redundant */ ALLOCATE_CPLUS_STRUCT_TYPE (type); TYPE_FIELD_VIRTUAL_BITS (type) = @@ -1971,7 +1999,7 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) TYPE_FIELD_PRIVATE_BITS (type) = (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields); - + TYPE_FIELD_PROTECTED_BITS (type) = (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields); @@ -1982,48 +2010,48 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields); while (nfields-- > 0) - { - if (B_TST(&(list->attributes),ATTR_VIRTUAL)) - SET_TYPE_FIELD_VIRTUAL (type, nfields); - if (B_TST(&(list->attributes),ATTR_PRIVATE)) - SET_TYPE_FIELD_PRIVATE (type, nfields); - if (B_TST(&(list->attributes),ATTR_PROTECT)) - SET_TYPE_FIELD_PROTECTED (type, nfields); - - list = list->next; - } + { + if (B_TST (&(list->attributes), ATTR_VIRTUAL)) + SET_TYPE_FIELD_VIRTUAL (type, nfields); + if (B_TST (&(list->attributes), ATTR_PRIVATE)) + SET_TYPE_FIELD_PRIVATE (type, nfields); + if (B_TST (&(list->attributes), ATTR_PROTECT)) + SET_TYPE_FIELD_PROTECTED (type, nfields); + + list = list->next; + } } else { - TYPE_FIELD_VIRTUAL_BITS(type) = NULL; - TYPE_FIELD_PROTECTED_BITS(type) = NULL; - TYPE_FIELD_PRIVATE_BITS(type) = NULL; + TYPE_FIELD_VIRTUAL_BITS (type) = NULL; + TYPE_FIELD_PROTECTED_BITS (type) = NULL; + TYPE_FIELD_PRIVATE_BITS (type) = NULL; } - - if (has_vtable(type)) + + if (has_vtable (type)) { /* Allocate space for class runtime information */ - TYPE_RUNTIME_PTR(type) = (struct runtime_info *) xmalloc (sizeof(struct runtime_info)); + TYPE_RUNTIME_PTR (type) = (struct runtime_info *) xmalloc (sizeof (struct runtime_info)); /* Set flag for vtable */ - TYPE_VTABLE(type) = 1; + TYPE_VTABLE (type) = 1; /* The first non-virtual base class with a vtable. */ - TYPE_PRIMARY_BASE(type) = primary_base_class(type); + TYPE_PRIMARY_BASE (type) = primary_base_class (type); /* The virtual base list. */ - TYPE_VIRTUAL_BASE_LIST(type) = virtual_base_list(type); + TYPE_VIRTUAL_BASE_LIST (type) = virtual_base_list (type); } else - TYPE_RUNTIME_PTR(type) = NULL; + TYPE_RUNTIME_PTR (type) = NULL; /* If this is a local type (C++ - declared inside a function), record file name & line # */ - if (hpread_get_scope_depth (dn_bufp, objfile, 1 /* no need for real depth */)) + if (hpread_get_scope_depth (dn_bufp, objfile, 1 /* no need for real depth */ )) { TYPE_LOCALTYPE_PTR (type) = (struct local_type_info *) xmalloc (sizeof (struct local_type_info)); TYPE_LOCALTYPE_FILE (type) = (char *) xmalloc (strlen (current_subfile->name) + 1); strcpy (TYPE_LOCALTYPE_FILE (type), current_subfile->name); if (current_subfile->line_vector && (current_subfile->line_vector->nitems > 0)) - TYPE_LOCALTYPE_LINE (type) = current_subfile->line_vector->item[current_subfile->line_vector->nitems - 1].line; + TYPE_LOCALTYPE_LINE (type) = current_subfile->line_vector->item[current_subfile->line_vector->nitems - 1].line; else - TYPE_LOCALTYPE_LINE (type) = 0; + TYPE_LOCALTYPE_LINE (type) = 0; } else TYPE_LOCALTYPE_PTR (type) = NULL; @@ -2040,32 +2068,32 @@ hpread_read_struct_type (hp_type, dn_bufp, objfile) work correctly. TYPE is a pointer to the struct/class type NAME is a char * (string) which is the class/struct name - Void return */ + Void return */ static void fix_static_member_physnames (type, class_name, objfile) - struct type * type; - char * class_name; - struct objfile * objfile; + struct type *type; + char *class_name; + struct objfile *objfile; { int i; - /* We fix the member names only for classes or structs */ + /* We fix the member names only for classes or structs */ if (TYPE_CODE (type) != TYPE_CODE_STRUCT) return; - for (i=0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < TYPE_NFIELDS (type); i++) if (TYPE_FIELD_STATIC (type, i)) { - if (TYPE_FIELD_STATIC_PHYSNAME (type, i)) - return; /* physnames are already set */ - - SET_FIELD_PHYSNAME (type->fields[i], - obstack_alloc (&objfile->type_obstack, - strlen (class_name) + strlen (TYPE_FIELD_NAME (type, i)) + 3)); - strcpy (TYPE_FIELD_STATIC_PHYSNAME (type, i), class_name); - strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), "::"); - strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), TYPE_FIELD_NAME (type, i)); + if (TYPE_FIELD_STATIC_PHYSNAME (type, i)) + return; /* physnames are already set */ + + SET_FIELD_PHYSNAME (type->fields[i], + obstack_alloc (&objfile->type_obstack, + strlen (class_name) + strlen (TYPE_FIELD_NAME (type, i)) + 3)); + strcpy (TYPE_FIELD_STATIC_PHYSNAME (type, i), class_name); + strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), "::"); + strcat (TYPE_FIELD_STATIC_PHYSNAME (type, i), TYPE_FIELD_NAME (type, i)); } } @@ -2073,13 +2101,13 @@ fix_static_member_physnames (type, class_name, objfile) * for a method (previously marked with a null type in hpread_read_struct_type() * is set correctly to METHOD. * OBJFILE is as for other such functions. - * Void return. */ - + * Void return. */ + static void fixup_class_method_type (class, method, objfile) - struct type * class; - struct type * method; - struct objfile * objfile; + struct type *class; + struct type *method; + struct objfile *objfile; { int i, j, k; @@ -2091,38 +2119,38 @@ fixup_class_method_type (class, method, objfile) (TYPE_CODE (class) != TYPE_CODE_UNION)) return; - /* Loop over all methods and find the one marked with a NULL type */ + /* Loop over all methods and find the one marked with a NULL type */ for (i = 0; i < TYPE_NFN_FIELDS (class); i++) for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (class, i); j++) if (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) == NULL) - { - /* Set the method type */ - TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) = method; - /* The argument list */ - (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types - = (struct type **) obstack_alloc(&objfile->type_obstack, - sizeof(struct type *) * (method->nfields + 1)); - for (k = 0; k < method->nfields; k++) - (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[k] = method->fields[k].type; - /* void termination */ - (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[method->nfields] = builtin_type_void; - - /* pai: It's not clear why this args field has to be set. Perhaps - * it should be eliminated entirely. */ - (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args - = (struct type **) obstack_alloc(&objfile->type_obstack, - sizeof(struct type *) * (method->nfields + 1)); - for (k = 0; k < method->nfields; k++) - (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[k] = method->fields[k].type; - /* null-terminated, unlike arg_types above */ - (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[method->nfields] = NULL; - - /* Break out of both loops -- only one method to fix up in a class */ - goto finish; - } + { + /* Set the method type */ + TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j) = method; + /* The argument list */ + (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types + = (struct type **) obstack_alloc (&objfile->type_obstack, + sizeof (struct type *) * (method->nfields + 1)); + for (k = 0; k < method->nfields; k++) + (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[k] = method->fields[k].type; + /* void termination */ + (TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (class, i), j))->type_specific.arg_types[method->nfields] = builtin_type_void; + + /* pai: It's not clear why this args field has to be set. Perhaps + * it should be eliminated entirely. */ + (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args + = (struct type **) obstack_alloc (&objfile->type_obstack, + sizeof (struct type *) * (method->nfields + 1)); + for (k = 0; k < method->nfields; k++) + (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[k] = method->fields[k].type; + /* null-terminated, unlike arg_types above */ + (TYPE_FN_FIELD (TYPE_FN_FIELDLIST1 (class, i), j)).args[method->nfields] = NULL; + + /* Break out of both loops -- only one method to fix up in a class */ + goto finish; + } finish: - TYPE_FLAGS (class) &= ~TYPE_FLAG_INCOMPLETE; + TYPE_FLAGS (class) &= ~TYPE_FLAG_INCOMPLETE; } @@ -2139,15 +2167,15 @@ finish: * We need to look these up in order to fill in "a" and "b"'s type. * This is called from hpread_type_lookup(). */ -static struct type * -hpread_get_nth_template_arg(objfile, n) +static struct type * +hpread_get_nth_template_arg (objfile, n) struct objfile *objfile; int n; { - if (current_template != NULL) - return TYPE_TEMPLATE_ARG(current_template, n).type; - else - return lookup_fundamental_type (objfile, FT_TEMPLATE_ARG); + if (current_template != NULL) + return TYPE_TEMPLATE_ARG (current_template, n).type; + else + return lookup_fundamental_type (objfile, FT_TEMPLATE_ARG); } /* Read in and internalize a TEMPL_ARG (template arg) symbol. */ @@ -2157,7 +2185,7 @@ hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name) dnttpointer hp_type; union dnttentry *dn_bufp; struct objfile *objfile; - char * name; + char *name; { struct type *type; @@ -2207,7 +2235,7 @@ hpread_read_array_type (hp_type, dn_bufp, objfile) struct objfile *objfile; { struct type *type; - + /* Allocate an array type symbol. * Why no check for already-read here, like in the other * hpread_read_xxx_type routines? Because it kept us @@ -2223,18 +2251,22 @@ hpread_read_array_type (hp_type, dn_bufp, objfile) * or express both array-length and element-length in bytes. */ if (!((dn_bufp->darray.arrayisbytes && dn_bufp->darray.elemisbytes) || - (!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes))) { - warning ("error in hpread_array_type.\n"); - return; - } 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; - } else if (dn_bufp->darray.arrayisbytes) + (!dn_bufp->darray.arrayisbytes && !dn_bufp->darray.elemisbytes))) + { + warning ("error in hpread_array_type.\n"); + return; + } + 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; + } + else if (dn_bufp->darray.arrayisbytes) TYPE_LENGTH (type) = dn_bufp->darray.arraylength; - else /* arraylength is in bits */ + else /* arraylength is in bits */ TYPE_LENGTH (type) = dn_bufp->darray.arraylength / 8; TYPE_TARGET_TYPE (type) = hpread_type_lookup (dn_bufp->darray.elemtype, @@ -2325,7 +2357,7 @@ hpread_type_lookup (hp_type, objfile) struct objfile *objfile; { union dnttentry *dn_bufp; - struct type * tmp_type; + struct type *tmp_type; /* First see if it's a simple builtin type. */ if (hp_type.dntti.immediate) @@ -2334,7 +2366,7 @@ hpread_type_lookup (hp_type, objfile) * GDB's representation of this fundamental type. */ if (hp_type.dntti.type == HP_TYPE_TEMPLATE_ARG) - return hpread_get_nth_template_arg(objfile, hp_type.dntti.bitlength); + return hpread_get_nth_template_arg (objfile, hp_type.dntti.bitlength); else return lookup_fundamental_type (objfile, hpread_type_translate (hp_type)); @@ -2390,54 +2422,54 @@ hpread_type_lookup (hp_type, objfile) case DNTT_TYPE_TYPEDEF: { - /* A typedef - chase it down by making a recursive call */ + /* A typedef - chase it down by making a recursive call */ struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type, objfile); - /* The following came from the base hpread.c that we inherited. - * It is WRONG so I have commented it out. - RT - *... - - char *suffix; - suffix = VT (objfile) + dn_bufp->dtype.name; - TYPE_NAME (structtype) = suffix; - - * ... further explanation .... - * - * What we have here is a typedef pointing to a typedef. - * E.g., - * typedef int foo; - * typedef foo fum; - * - * What we desire to build is (these are pictures - * of "struct type"'s): - * - * +---------+ +----------+ +------------+ - * | typedef | | typedef | | fund. type | - * | type| -> | type| -> | | - * | "fum" | | "foo" | | "int" | - * +---------+ +----------+ +------------+ - * - * What this commented-out code is doing is smashing the - * name of pointed-to-type to be the same as the pointed-from - * type. So we wind up with something like: - * - * +---------+ +----------+ +------------+ - * | typedef | | typedef | | fund. type | - * | type| -> | type| -> | | - * | "fum" | | "fum" | | "fum" | - * +---------+ +----------+ +------------+ - * - */ + /* The following came from the base hpread.c that we inherited. + * It is WRONG so I have commented it out. - RT + *... + + char *suffix; + suffix = VT (objfile) + dn_bufp->dtype.name; + TYPE_NAME (structtype) = suffix; + + * ... further explanation .... + * + * What we have here is a typedef pointing to a typedef. + * E.g., + * typedef int foo; + * typedef foo fum; + * + * What we desire to build is (these are pictures + * of "struct type"'s): + * + * +---------+ +----------+ +------------+ + * | typedef | | typedef | | fund. type | + * | type| -> | type| -> | | + * | "fum" | | "foo" | | "int" | + * +---------+ +----------+ +------------+ + * + * What this commented-out code is doing is smashing the + * name of pointed-to-type to be the same as the pointed-from + * type. So we wind up with something like: + * + * +---------+ +----------+ +------------+ + * | typedef | | typedef | | fund. type | + * | type| -> | type| -> | | + * | "fum" | | "fum" | | "fum" | + * +---------+ +----------+ +------------+ + * + */ return structtype; } case DNTT_TYPE_TAGDEF: - { + { /* Just a little different from above. We have to tack on * an identifier of some kind (struct, union, enum, class, etc). - */ + */ struct type *structtype = hpread_type_lookup (dn_bufp->dtype.type, objfile); char *prefix, *suffix; @@ -2445,37 +2477,49 @@ hpread_type_lookup (hp_type, objfile) /* Lookup the next type in the list. It should be a structure, * union, class, enum, or template type. - * We will need to attach that to our name. - */ + * We will need to attach that to our name. + */ if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile)) dn_bufp = hpread_get_lntt (dn_bufp->dtype.type.dnttp.index, objfile); - else { - complain (&hpread_type_lookup_complaint); - return; - } - - if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) { - prefix = "struct "; - } else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION) { - prefix = "union "; - } else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) { - /* Further field for CLASS saying how it was really declared */ - /* 0==class, 1==union, 2==struct */ - if (dn_bufp->dclass.class_decl == 0) - prefix = "class "; - else if (dn_bufp->dclass.class_decl == 1) - prefix = "union "; - else if (dn_bufp->dclass.class_decl == 2) + else + { + complain (&hpread_type_lookup_complaint); + return; + } + + if (dn_bufp->dblock.kind == DNTT_TYPE_STRUCT) + { prefix = "struct "; - else - prefix = ""; - } else if (dn_bufp->dblock.kind == DNTT_TYPE_ENUM) { - prefix = "enum "; - } else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { - prefix = "template "; - } else { - prefix = ""; - } + } + else if (dn_bufp->dblock.kind == DNTT_TYPE_UNION) + { + prefix = "union "; + } + else if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS) + { + /* Further field for CLASS saying how it was really declared */ + /* 0==class, 1==union, 2==struct */ + if (dn_bufp->dclass.class_decl == 0) + prefix = "class "; + else if (dn_bufp->dclass.class_decl == 1) + prefix = "union "; + else if (dn_bufp->dclass.class_decl == 2) + prefix = "struct "; + else + prefix = ""; + } + else if (dn_bufp->dblock.kind == DNTT_TYPE_ENUM) + { + prefix = "enum "; + } + else if (dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) + { + prefix = "template "; + } + else + { + prefix = ""; + } /* Build the correct name. */ structtype->name @@ -2485,10 +2529,10 @@ hpread_type_lookup (hp_type, objfile) TYPE_NAME (structtype) = strcat (TYPE_NAME (structtype), suffix); TYPE_TAG_NAME (structtype) = suffix; - /* For classes/structs, we have to set the static member "physnames" - to point to strings like "Class::Member" */ - if (TYPE_CODE (structtype) == TYPE_CODE_STRUCT) - fix_static_member_physnames (structtype, suffix, objfile); + /* For classes/structs, we have to set the static member "physnames" + to point to strings like "Class::Member" */ + if (TYPE_CODE (structtype) == TYPE_CODE_STRUCT) + fix_static_member_physnames (structtype, suffix, objfile); return structtype; } @@ -2498,19 +2542,19 @@ hpread_type_lookup (hp_type, objfile) * the appropriate GDB type. */ return make_pointer_type ( - hpread_type_lookup (dn_bufp->dptr.pointsto, - objfile), - NULL); + hpread_type_lookup (dn_bufp->dptr.pointsto, + objfile), + NULL); case DNTT_TYPE_REFERENCE: /* C++ reference type - call a routine in gdbtypes.c that constructs * the appropriate GDB type. */ return make_reference_type ( - hpread_type_lookup (dn_bufp->dreference.pointsto, - objfile), - NULL); - + hpread_type_lookup (dn_bufp->dreference.pointsto, + objfile), + NULL); + case DNTT_TYPE_ENUM: return hpread_read_enum_type (hp_type, dn_bufp, objfile); case DNTT_TYPE_SET: @@ -2538,16 +2582,16 @@ hpread_type_lookup (hp_type, objfile) * while the "memtype" field defines the pointed-to-type. */ { - struct type * ptrmemtype; - struct type * class_type; - struct type * memtype; - memtype = hpread_type_lookup (dn_bufp->dptrmem.memtype, - objfile), - class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, - objfile), - ptrmemtype = alloc_type(objfile); - smash_to_member_type(ptrmemtype, class_type, memtype); - return make_pointer_type(ptrmemtype, NULL); + struct type *ptrmemtype; + struct type *class_type; + struct type *memtype; + memtype = hpread_type_lookup (dn_bufp->dptrmem.memtype, + objfile), + class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, + objfile), + ptrmemtype = alloc_type (objfile); + smash_to_member_type (ptrmemtype, class_type, memtype); + return make_pointer_type (ptrmemtype, NULL); } break; @@ -2557,31 +2601,32 @@ hpread_type_lookup (hp_type, objfile) * while the "memtype" field defines the pointed-to-type. */ { - struct type * ptrmemtype; - struct type * class_type; - struct type * functype; - struct type * retvaltype; - int nargs; - int i; - struct type ** args_type; - class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, - objfile); - functype = hpread_type_lookup (dn_bufp->dptrmem.memtype, - objfile); - retvaltype = TYPE_TARGET_TYPE (functype); - nargs = TYPE_NFIELDS (functype); - args_type = (struct type **) xmalloc ((nargs+1) * sizeof (struct type *)); - for (i = 0; i < nargs; i++) { - args_type[i] = TYPE_FIELD_TYPE (functype, i); - } - args_type[nargs] = NULL; - ptrmemtype = alloc_type(objfile); - smash_to_method_type(ptrmemtype, class_type, retvaltype, args_type); - return make_pointer_type(ptrmemtype, NULL); + struct type *ptrmemtype; + struct type *class_type; + struct type *functype; + struct type *retvaltype; + int nargs; + int i; + struct type **args_type; + class_type = hpread_type_lookup (dn_bufp->dptrmem.pointsto, + objfile); + functype = hpread_type_lookup (dn_bufp->dptrmem.memtype, + objfile); + retvaltype = TYPE_TARGET_TYPE (functype); + nargs = TYPE_NFIELDS (functype); + args_type = (struct type **) xmalloc ((nargs + 1) * sizeof (struct type *)); + for (i = 0; i < nargs; i++) + { + args_type[i] = TYPE_FIELD_TYPE (functype, i); + } + args_type[nargs] = NULL; + ptrmemtype = alloc_type (objfile); + smash_to_method_type (ptrmemtype, class_type, retvaltype, args_type); + return make_pointer_type (ptrmemtype, NULL); } break; - case DNTT_TYPE_CLASS: + case DNTT_TYPE_CLASS: return hpread_read_struct_type (hp_type, dn_bufp, objfile); case DNTT_TYPE_GENFIELD: @@ -2606,12 +2651,12 @@ hpread_type_lookup (hp_type, objfile) * "m_void" modifiers? Is static_flag really needed here? * (m_static used for methods of classes, elsewhere). */ - tmp_type = make_cv_type (dn_bufp->dmodifier.m_const, - dn_bufp->dmodifier.m_volatile, - hpread_type_lookup (dn_bufp->dmodifier.type, objfile), - 0); + tmp_type = make_cv_type (dn_bufp->dmodifier.m_const, + dn_bufp->dmodifier.m_volatile, + hpread_type_lookup (dn_bufp->dmodifier.type, objfile), + 0); return tmp_type; - + case DNTT_TYPE_MEMFUNC: /* Member function. Treat like a function. @@ -2632,13 +2677,13 @@ hpread_type_lookup (hp_type, objfile) case DNTT_TYPE_TEMPLATE_ARG: { - char * name; - /* The TEMPLATE record points to an argument list of - * TEMPLATE_ARG records, each of which describes one - * of the type-arguments. - */ - name = VT (objfile) + dn_bufp->dtempl_arg.name; - return hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name); + char *name; + /* The TEMPLATE record points to an argument list of + * TEMPLATE_ARG records, each of which describes one + * of the type-arguments. + */ + name = VT (objfile) + dn_bufp->dtempl_arg.name; + return hpread_read_templ_arg_type (hp_type, dn_bufp, objfile, name); } case DNTT_TYPE_FUNC_TEMPLATE: @@ -2654,13 +2699,13 @@ hpread_type_lookup (hp_type, objfile) */ return lookup_fundamental_type (objfile, FT_VOID); - /* Also not yet handled... */ - /* case DNTT_TYPE_DYN_ARRAY_DESC: */ - /* case DNTT_TYPE_DESC_SUBRANGE: */ - /* case DNTT_TYPE_BEGIN_EXT: */ - /* case DNTT_TYPE_INLN: */ - /* case DNTT_TYPE_INLN_LIST: */ - /* case DNTT_TYPE_ALIAS: */ + /* Also not yet handled... */ + /* case DNTT_TYPE_DYN_ARRAY_DESC: */ + /* case DNTT_TYPE_DESC_SUBRANGE: */ + /* case DNTT_TYPE_BEGIN_EXT: */ + /* case DNTT_TYPE_INLN: */ + /* case DNTT_TYPE_INLN_LIST: */ + /* case DNTT_TYPE_ALIAS: */ default: /* A fancy way of returning NULL */ return lookup_fundamental_type (objfile, FT_VOID); @@ -2699,47 +2744,48 @@ hpread_record_lines (subfile, s_idx, e_idx, objfile, offset) * Called from hpread_process_one_debug_symbol() * If "f" is not a member function, return NULL. */ -char * class_of (functype) -struct type * functype; +char * +class_of (functype) + struct type *functype; { - struct type * first_param_type; - char * first_param_name; - struct type * pointed_to_type; - char * class_name; + struct type *first_param_type; + char *first_param_name; + struct type *pointed_to_type; + char *class_name; /* Check that the function has a first argument "this", * and that "this" is a pointer to a class. If not, * functype is not a member function, so return NULL. */ - if (TYPE_NFIELDS(functype) == 0) + if (TYPE_NFIELDS (functype) == 0) return NULL; first_param_name = TYPE_FIELD_NAME (functype, 0); if (first_param_name == NULL) - return NULL; /* paranoia */ - if (strcmp(first_param_name, "this")) + return NULL; /* paranoia */ + if (strcmp (first_param_name, "this")) return NULL; first_param_type = TYPE_FIELD_TYPE (functype, 0); if (first_param_type == NULL) - return NULL; /* paranoia */ - if (TYPE_CODE(first_param_type) != TYPE_CODE_PTR) + return NULL; /* paranoia */ + if (TYPE_CODE (first_param_type) != TYPE_CODE_PTR) return NULL; /* Get the thing that "this" points to, check that * it's a class, and get its class name. */ - pointed_to_type = TYPE_TARGET_TYPE(first_param_type); - if (pointed_to_type == NULL) - return NULL; /* paranoia */ - if (TYPE_CODE(pointed_to_type) != TYPE_CODE_CLASS) + pointed_to_type = TYPE_TARGET_TYPE (first_param_type); + if (pointed_to_type == NULL) + return NULL; /* paranoia */ + if (TYPE_CODE (pointed_to_type) != TYPE_CODE_CLASS) return NULL; - class_name = TYPE_NAME(pointed_to_type); + class_name = TYPE_NAME (pointed_to_type); if (class_name == NULL) - return NULL; /* paranoia */ + return NULL; /* paranoia */ /* The class name may be of the form "class c", in which case * we want to strip off the leading "class ". */ - if (strncmp(class_name, "class ", 6) == 0) + if (strncmp (class_name, "class ", 6) == 0) class_name += 6; return class_name; @@ -2755,37 +2801,36 @@ struct type * functype; * text_offset: * text_size: * filename: - * index: Index of this symbol + * index: Index of this symbol * at_module_boundary_p Pointer to boolean flag to control caller's loop. */ static void hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, text_offset, text_size, filename, - index, at_module_boundary_p - ) + index, at_module_boundary_p +) 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; - int *at_module_boundary_p; + int text_size; + char *filename; + int index; + int *at_module_boundary_p; { unsigned long desc; int type; CORE_ADDR valu; - int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT); - int data_offset = ANOFFSET (section_offsets, SECT_OFF_DATA); + int offset = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); + int data_offset = ANOFFSET (section_offsets, SECT_OFF_DATA (objfile)); union dnttentry *dn_temp; dnttpointer hp_type; struct symbol *sym; struct context_stack *new; - char * class_scope_name; - extern int is_in_import_list (); /* in somread.c */ - + char *class_scope_name; + /* Allocate one GDB debug symbol and fill in some default values. */ sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); @@ -2833,35 +2878,37 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, */ valu = text_offset; - if (!last_source_file ) { - /* - * A note on "last_source_file": this is a char* pointing - * to the actual file name. "start_symtab" sets it, - * "end_symtab" clears it. - * - * So if "last_source_file" is NULL, then either this is - * the first record we are looking at, or a previous call - * to "end_symtab()" was made to close out the previous - * module. Since we're now quitting the scan loop when we - * see a MODULE END record, we should never get here, except - * in the case that we're not using the quick look-up tables - * and have to use the old system as a fall-back. - */ + if (!last_source_file) + { + /* + * A note on "last_source_file": this is a char* pointing + * to the actual file name. "start_symtab" sets it, + * "end_symtab" clears it. + * + * So if "last_source_file" is NULL, then either this is + * the first record we are looking at, or a previous call + * to "end_symtab()" was made to close out the previous + * module. Since we're now quitting the scan loop when we + * see a MODULE END record, we should never get here, except + * in the case that we're not using the quick look-up tables + * and have to use the old system as a fall-back. + */ start_symtab (name, NULL, valu); record_debugformat ("HP"); SL_INDEX (objfile) = dn_bufp->dsfile.address; - } + } - else { - /* Either a new include file, or a SRCFILE record - * saying we are back in the main source (or out of - * a nested include file) again. - */ + else + { + /* Either a new include file, or a SRCFILE record + * saying we are back in the main source (or out of + * a nested include file) again. + */ SL_INDEX (objfile) = hpread_record_lines (current_subfile, SL_INDEX (objfile), dn_bufp->dsfile.address, objfile, offset); - } + } /* A note on "start_subfile". This routine will check * the name we pass it and look for an existing subfile @@ -2872,7 +2919,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, */ start_subfile (name, NULL); break; - + case DNTT_TYPE_MODULE: /* * We no longer ignore DNTT_TYPE_MODULE symbols. The module @@ -2902,27 +2949,27 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, */ valu = text_offset; - if (!last_source_file ) + if (!last_source_file) { - /* Start of a new module. We know this because "last_source_file" - * is NULL, which can only happen the first time or if we just - * made a call to end_symtab() to close out the previous module. - */ + /* Start of a new module. We know this because "last_source_file" + * is NULL, which can only happen the first time or if we just + * made a call to end_symtab() to close out the previous module. + */ start_symtab (name, NULL, valu); SL_INDEX (objfile) = dn_bufp->dmodule.address; } else { - /* This really shouldn't happen if we're using the quick - * look-up tables, as it would mean we'd scanned past an - * END MODULE entry. But if we're not using the tables, - * we started the module on the SRCFILE entry, so it's ok. - * For now, accept this. - */ - /* warning( "Error expanding psymtab, missed module end, found entry for %s", - * name ); - */ - *at_module_boundary_p = -1; + /* This really shouldn't happen if we're using the quick + * look-up tables, as it would mean we'd scanned past an + * END MODULE entry. But if we're not using the tables, + * we started the module on the SRCFILE entry, so it's ok. + * For now, accept this. + */ + /* warning( "Error expanding psymtab, missed module end, found entry for %s", + * name ); + */ + *at_module_boundary_p = -1; } start_subfile (name, NULL); @@ -2938,7 +2985,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SL_INDEX (objfile), dn_bufp->dfunc.address, objfile, offset); - + WITHIN_FUNCTION (objfile) = 1; CURRENT_FUNCTION_VALUE (objfile) = valu; @@ -2957,64 +3004,66 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, * (if any), which we get from the "alias" field of the SOM record * if that exists. */ - if ((dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) && - dn_bufp->dfunc.alias && /* has an alias */ - *(char *)(VT (objfile) + dn_bufp->dfunc.alias)) /* not a null string */ - SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.alias; + if ((dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) && + dn_bufp->dfunc.alias && /* has an alias */ + *(char *) (VT (objfile) + dn_bufp->dfunc.alias)) /* not a null string */ + SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.alias; else - SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name; + SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name; /* Special hack to get around HP compilers' insistence on * reporting "main" as "_MAIN_" for C/C++ */ if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) && - (strcmp (VT (objfile) + dn_bufp->dfunc.name, "main") == 0)) - SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name; - + (strcmp (VT (objfile) + dn_bufp->dfunc.name, "main") == 0)) + SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->dfunc.name; + /* The SYMBOL_CPLUS_DEMANGLED_NAME field is expected to * be the demangled name. */ if (dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) { - /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up - * calling the demangler in libiberty (cplus_demangle()) to - * do the job. This generally does the job, even though - * it's intended for the GNU compiler and not the aCC compiler - * Note that SYMBOL_INIT_DEMANGLED_NAME calls the - * demangler with arguments DMGL_PARAMS | DMGL_ANSI. - * Generally, we don't want params when we display - * a demangled name, but when I took out the DMGL_PARAMS, - * some things broke, so I'm leaving it in here, and - * working around the issue in stack.c. - RT - */ - SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); - if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->dfunc.alias) && - (!SYMBOL_CPLUS_DEMANGLED_NAME(sym))) { - - /* Well, the symbol name is mangled, but the - * demangler in libiberty failed so the demangled - * field is still NULL. Try to - * do the job ourselves based on the "name" field - * in the SOM record. A complication here is that - * the name field contains only the function name - * (like "f"), whereas we want the class qualification - * (as in "c::f"). Try to reconstruct that. - */ - char * basename; - char * classname; - char * dem_name; - basename = VT (objfile) + dn_bufp->dfunc.name; - classname = class_of(SYMBOL_TYPE(sym)); - if (classname) { - dem_name = xmalloc(strlen(basename)+strlen(classname)+3); - strcpy(dem_name, classname); - strcat(dem_name, "::"); - strcat(dem_name, basename); - SYMBOL_CPLUS_DEMANGLED_NAME(sym) = dem_name; - SYMBOL_LANGUAGE (sym) = language_cplus; - } - } - } - + /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up + * calling the demangler in libiberty (cplus_demangle()) to + * do the job. This generally does the job, even though + * it's intended for the GNU compiler and not the aCC compiler + * Note that SYMBOL_INIT_DEMANGLED_NAME calls the + * demangler with arguments DMGL_PARAMS | DMGL_ANSI. + * Generally, we don't want params when we display + * a demangled name, but when I took out the DMGL_PARAMS, + * some things broke, so I'm leaving it in here, and + * working around the issue in stack.c. - RT + */ + SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); + if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->dfunc.alias) && + (!SYMBOL_CPLUS_DEMANGLED_NAME (sym))) + { + + /* Well, the symbol name is mangled, but the + * demangler in libiberty failed so the demangled + * field is still NULL. Try to + * do the job ourselves based on the "name" field + * in the SOM record. A complication here is that + * the name field contains only the function name + * (like "f"), whereas we want the class qualification + * (as in "c::f"). Try to reconstruct that. + */ + char *basename; + char *classname; + char *dem_name; + basename = VT (objfile) + dn_bufp->dfunc.name; + classname = class_of (SYMBOL_TYPE (sym)); + if (classname) + { + dem_name = xmalloc (strlen (basename) + strlen (classname) + 3); + strcpy (dem_name, classname); + strcat (dem_name, "::"); + strcat (dem_name, basename); + SYMBOL_CPLUS_DEMANGLED_NAME (sym) = dem_name; + SYMBOL_LANGUAGE (sym) = language_cplus; + } + } + } + /* Add the function symbol to the list of symbols in this blockvector */ if (dn_bufp->dfunc.global) add_symbol_to_list (sym, &global_symbols); @@ -3030,19 +3079,20 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, * So I made it C/C++ specific. - RT */ if (dn_bufp->dfunc.language == HP_LANGUAGE_C || - dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) { - while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN) - { - dn_bufp = hpread_get_lntt (++index, objfile); - if (dn_bufp->dblock.extension) - continue; - } - SL_INDEX (objfile) = hpread_record_lines (current_subfile, - SL_INDEX (objfile), - dn_bufp->dbegin.address, - objfile, offset); - SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); - } + dn_bufp->dfunc.language == HP_LANGUAGE_CPLUSPLUS) + { + while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN) + { + dn_bufp = hpread_get_lntt (++index, objfile); + if (dn_bufp->dblock.extension) + continue; + } + SL_INDEX (objfile) = hpread_record_lines (current_subfile, + SL_INDEX (objfile), + dn_bufp->dbegin.address, + objfile, offset); + SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); + } record_line (current_subfile, SYMBOL_LINE (sym), valu); break; @@ -3054,7 +3104,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SL_INDEX (objfile), dn_bufp->ddocfunc.address, objfile, offset); - + WITHIN_FUNCTION (objfile) = 1; CURRENT_FUNCTION_VALUE (objfile) = valu; /* Stack must be empty now. */ @@ -3072,61 +3122,64 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, * (if any), which we get from the "alias" field of the SOM record * if that exists. */ - if ((dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) && - dn_bufp->ddocfunc.alias && /* has an alias */ - *(char *)(VT (objfile) + dn_bufp->ddocfunc.alias)) /* not a null string */ - SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.alias; + if ((dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) && + dn_bufp->ddocfunc.alias && /* has an alias */ + *(char *) (VT (objfile) + dn_bufp->ddocfunc.alias)) /* not a null string */ + SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.alias; else - SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name; + SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name; /* Special hack to get around HP compilers' insistence on * reporting "main" as "_MAIN_" for C/C++ */ if ((strcmp (SYMBOL_NAME (sym), "_MAIN_") == 0) && - (strcmp (VT (objfile) + dn_bufp->ddocfunc.name, "main") == 0)) - SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name; - - if (dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) { - - /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up - * calling the demangler in libiberty (cplus_demangle()) to - * do the job. This generally does the job, even though - * it's intended for the GNU compiler and not the aCC compiler - * Note that SYMBOL_INIT_DEMANGLED_NAME calls the - * demangler with arguments DMGL_PARAMS | DMGL_ANSI. - * Generally, we don't want params when we display - * a demangled name, but when I took out the DMGL_PARAMS, - * some things broke, so I'm leaving it in here, and - * working around the issue in stack.c. - RT - */ - SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); - - if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->ddocfunc.alias) && - (!SYMBOL_CPLUS_DEMANGLED_NAME(sym))) { - - /* Well, the symbol name is mangled, but the - * demangler in libiberty failed so the demangled - * field is still NULL. Try to - * do the job ourselves based on the "name" field - * in the SOM record. A complication here is that - * the name field contains only the function name - * (like "f"), whereas we want the class qualification - * (as in "c::f"). Try to reconstruct that. - */ - char * basename; - char * classname; - char * dem_name; - basename = VT (objfile) + dn_bufp->ddocfunc.name; - classname = class_of(SYMBOL_TYPE(sym)); - if (classname) { - dem_name = xmalloc(strlen(basename)+strlen(classname)+3); - strcpy(dem_name, classname); - strcat(dem_name, "::"); - strcat(dem_name, basename); - SYMBOL_CPLUS_DEMANGLED_NAME(sym) = dem_name; - SYMBOL_LANGUAGE (sym) = language_cplus; - } - } - } + (strcmp (VT (objfile) + dn_bufp->ddocfunc.name, "main") == 0)) + SYMBOL_NAME (sym) = VT (objfile) + dn_bufp->ddocfunc.name; + + if (dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) + { + + /* SYMBOL_INIT_DEMANGLED_NAME is a macro which winds up + * calling the demangler in libiberty (cplus_demangle()) to + * do the job. This generally does the job, even though + * it's intended for the GNU compiler and not the aCC compiler + * Note that SYMBOL_INIT_DEMANGLED_NAME calls the + * demangler with arguments DMGL_PARAMS | DMGL_ANSI. + * Generally, we don't want params when we display + * a demangled name, but when I took out the DMGL_PARAMS, + * some things broke, so I'm leaving it in here, and + * working around the issue in stack.c. - RT + */ + SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); + + if ((SYMBOL_NAME (sym) == VT (objfile) + dn_bufp->ddocfunc.alias) && + (!SYMBOL_CPLUS_DEMANGLED_NAME (sym))) + { + + /* Well, the symbol name is mangled, but the + * demangler in libiberty failed so the demangled + * field is still NULL. Try to + * do the job ourselves based on the "name" field + * in the SOM record. A complication here is that + * the name field contains only the function name + * (like "f"), whereas we want the class qualification + * (as in "c::f"). Try to reconstruct that. + */ + char *basename; + char *classname; + char *dem_name; + basename = VT (objfile) + dn_bufp->ddocfunc.name; + classname = class_of (SYMBOL_TYPE (sym)); + if (classname) + { + dem_name = xmalloc (strlen (basename) + strlen (classname) + 3); + strcpy (dem_name, classname); + strcat (dem_name, "::"); + strcat (dem_name, basename); + SYMBOL_CPLUS_DEMANGLED_NAME (sym) = dem_name; + SYMBOL_LANGUAGE (sym) = language_cplus; + } + } + } /* Add the function symbol to the list of symbols in this blockvector */ if (dn_bufp->ddocfunc.global) @@ -3143,69 +3196,72 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, * So I made it C/C++ specific. - RT */ if (dn_bufp->ddocfunc.language == HP_LANGUAGE_C || - dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) { - while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN) - { - dn_bufp = hpread_get_lntt (++index, objfile); - if (dn_bufp->dblock.extension) - continue; - } - SL_INDEX (objfile) = hpread_record_lines (current_subfile, - SL_INDEX (objfile), - dn_bufp->dbegin.address, - objfile, offset); - SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); - } + dn_bufp->ddocfunc.language == HP_LANGUAGE_CPLUSPLUS) + { + while (dn_bufp->dblock.kind != DNTT_TYPE_BEGIN) + { + dn_bufp = hpread_get_lntt (++index, objfile); + if (dn_bufp->dblock.extension) + continue; + } + SL_INDEX (objfile) = hpread_record_lines (current_subfile, + SL_INDEX (objfile), + dn_bufp->dbegin.address, + objfile, offset); + SYMBOL_LINE (sym) = hpread_get_line (dn_bufp->dbegin.address, objfile); + } record_line (current_subfile, SYMBOL_LINE (sym), valu); break; case DNTT_TYPE_BEGIN: /* Begin a new scope. */ - if (context_stack_depth == 1 /* this means we're at function level */ && - context_stack[0].name != NULL /* this means it's a function */ && - context_stack[0].depth == 0 /* this means it's the first BEGIN - we've seen after the FUNCTION */ - ) - { - /* This is the first BEGIN after a FUNCTION. - * We ignore this one, since HP compilers always insert - * at least one BEGIN, i.e. it's: - * - * FUNCTION - * argument symbols - * BEGIN - * local symbols - * (possibly nested BEGIN ... END's if there are inner { } blocks) - * END - * END - * - * By ignoring this first BEGIN, the local symbols get treated - * as belonging to the function scope, and "print func::local_sym" - * works (which is what we want). - */ - - /* All we do here is increase the depth count associated with - * the FUNCTION entry in the context stack. This ensures that - * the next BEGIN we see (if any), representing a real nested { } - * block, will get processed. - */ - - context_stack[0].depth++; - - } else { - - /* Record lines up to this SLT pointer. */ - SL_INDEX (objfile) = hpread_record_lines (current_subfile, - SL_INDEX (objfile), - dn_bufp->dbegin.address, - objfile, offset); - /* Calculate start address of new scope */ - valu = hpread_get_location (dn_bufp->dbegin.address, objfile); - valu += offset; /* Relocate for dynamic loading */ - /* We use the scope start DNTT index as nesting depth identifier! */ - desc = hpread_get_scope_start (dn_bufp->dbegin.address, objfile); - new = push_context (desc, valu); - } + if (context_stack_depth == 1 /* this means we're at function level */ && + context_stack[0].name != NULL /* this means it's a function */ && + context_stack[0].depth == 0 /* this means it's the first BEGIN + we've seen after the FUNCTION */ + ) + { + /* This is the first BEGIN after a FUNCTION. + * We ignore this one, since HP compilers always insert + * at least one BEGIN, i.e. it's: + * + * FUNCTION + * argument symbols + * BEGIN + * local symbols + * (possibly nested BEGIN ... END's if there are inner { } blocks) + * END + * END + * + * By ignoring this first BEGIN, the local symbols get treated + * as belonging to the function scope, and "print func::local_sym" + * works (which is what we want). + */ + + /* All we do here is increase the depth count associated with + * the FUNCTION entry in the context stack. This ensures that + * the next BEGIN we see (if any), representing a real nested { } + * block, will get processed. + */ + + context_stack[0].depth++; + + } + else + { + + /* Record lines up to this SLT pointer. */ + SL_INDEX (objfile) = hpread_record_lines (current_subfile, + SL_INDEX (objfile), + dn_bufp->dbegin.address, + objfile, offset); + /* Calculate start address of new scope */ + valu = hpread_get_location (dn_bufp->dbegin.address, objfile); + valu += offset; /* Relocate for dynamic loading */ + /* We use the scope start DNTT index as nesting depth identifier! */ + desc = hpread_get_scope_start (dn_bufp->dbegin.address, objfile); + new = push_context (desc, valu); + } break; case DNTT_TYPE_END: @@ -3228,22 +3284,22 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, { case DNTT_TYPE_MODULE: /* Ending a module ends the symbol table for that module. - * Calling end_symtab() has the side effect of clearing the - * last_source_file pointer, which in turn signals - * process_one_debug_symbol() to treat the next DNTT_TYPE_SRCFILE - * record as a module-begin. - */ + * Calling end_symtab() has the side effect of clearing the + * last_source_file pointer, which in turn signals + * process_one_debug_symbol() to treat the next DNTT_TYPE_SRCFILE + * record as a module-begin. + */ valu = text_offset + text_size + offset; - /* Tell our caller that we're done with expanding the - * debug information for a module. - */ - *at_module_boundary_p = 1; + /* Tell our caller that we're done with expanding the + * debug information for a module. + */ + *at_module_boundary_p = 1; + + /* Don't do this, as our caller will do it! - /* Don't do this, as our caller will do it! - * - * (void) end_symtab (valu, objfile, 0); - */ + * (void) end_symtab (valu, objfile, 0); + */ break; case DNTT_TYPE_FUNCTION: @@ -3251,63 +3307,65 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, dn_temp = hpread_get_lntt (dn_bufp->dend.beginscope.dnttp.index, objfile); valu = dn_temp->dfunc.hiaddr + offset; - /* Insert func params into local list */ - merge_symbol_lists (¶m_symbols, &local_symbols); + /* Insert func params into local list */ + merge_symbol_lists (¶m_symbols, &local_symbols); new = pop_context (); /* Make a block for the local symbols within. */ finish_block (new->name, &local_symbols, new->old_blocks, new->start_addr, valu, objfile); - WITHIN_FUNCTION (objfile) = 0; /* This may have to change for Pascal */ - local_symbols = new->locals; - param_symbols = new->params; + WITHIN_FUNCTION (objfile) = 0; /* This may have to change for Pascal */ + local_symbols = new->locals; + param_symbols = new->params; break; case DNTT_TYPE_BEGIN: - if (context_stack_depth == 1 && - context_stack[0].name != NULL && - context_stack[0].depth == 1) - { - /* This is the END corresponding to the - * BEGIN which we ignored - see DNTT_TYPE_BEGIN case above. - */ - context_stack[0].depth--; - } else { - /* Ending a local scope. */ - valu = hpread_get_location (dn_bufp->dend.address, objfile); - /* Why in the hell is this needed? */ - valu += offset + 9; /* Relocate for dynamic loading */ - new = pop_context (); - desc = dn_bufp->dend.beginscope.dnttp.index; - if (desc != new->depth) - complain (&lbrac_mismatch_complaint, (char *) symnum); - - /* Make a block for the local symbols within. */ - finish_block (new->name, &local_symbols, new->old_blocks, - new->start_addr, valu, objfile); - local_symbols = new->locals; - param_symbols = new->params; - } + if (context_stack_depth == 1 && + context_stack[0].name != NULL && + context_stack[0].depth == 1) + { + /* This is the END corresponding to the + * BEGIN which we ignored - see DNTT_TYPE_BEGIN case above. + */ + context_stack[0].depth--; + } + else + { + /* Ending a local scope. */ + valu = hpread_get_location (dn_bufp->dend.address, objfile); + /* Why in the hell is this needed? */ + valu += offset + 9; /* Relocate for dynamic loading */ + new = pop_context (); + desc = dn_bufp->dend.beginscope.dnttp.index; + if (desc != new->depth) + complain (&lbrac_mismatch_complaint, (char *) symnum); + + /* Make a block for the local symbols within. */ + finish_block (new->name, &local_symbols, new->old_blocks, + new->start_addr, valu, objfile); + local_symbols = new->locals; + param_symbols = new->params; + } break; - case DNTT_TYPE_WITH: - /* Since we ignore the DNTT_TYPE_WITH that starts the scope, - * we can ignore the DNTT_TYPE_END that ends it. - */ + case DNTT_TYPE_WITH: + /* Since we ignore the DNTT_TYPE_WITH that starts the scope, + * we can ignore the DNTT_TYPE_END that ends it. + */ break; - case DNTT_TYPE_COMMON: - /* End a FORTRAN common block. We don't currently handle these */ - complain (&hpread_unhandled_end_common_complaint); + case DNTT_TYPE_COMMON: + /* End a FORTRAN common block. We don't currently handle these */ + complain (&hpread_unhandled_end_common_complaint); break; - case DNTT_TYPE_CLASS_SCOPE: + case DNTT_TYPE_CLASS_SCOPE: - /* pai: FIXME Not handling nested classes for now -- must - * maintain a stack */ - class_scope_name = NULL; + /* pai: FIXME Not handling nested classes for now -- must + * maintain a stack */ + class_scope_name = NULL; #if 0 - /* End a class scope */ + /* End a class scope */ valu = hpread_get_location (dn_bufp->dend.address, objfile); /* Why in the hell is this needed? */ valu += offset + 9; /* Relocate for dynamic loading */ @@ -3323,13 +3381,13 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, #endif break; - default: - complain (&hpread_unexpected_end_complaint); - break; + default: + complain (&hpread_unexpected_end_complaint); + break; } break; - /* DNTT_TYPE_IMPORT is not handled */ + /* DNTT_TYPE_IMPORT is not handled */ case DNTT_TYPE_LABEL: SYMBOL_NAMESPACE (sym) = LABEL_NAMESPACE; @@ -3356,28 +3414,28 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, So I've added code in hpread_read_function_type() to add fparams to a param_symbols list for the current context level. These are then merged into local_symbols when a function end is reached. - pai/1997-08-11 */ - - break; /* do nothing; handled in hpread_read_function_type() */ - -#if 0 /* Old code */ + pai/1997-08-11 */ + + break; /* do nothing; handled in hpread_read_function_type() */ + +#if 0 /* Old code */ if (dn_bufp->dfparam.regparam) - SYMBOL_CLASS (sym) = LOC_REGISTER; + SYMBOL_CLASS (sym) = LOC_REGISTER; else if (dn_bufp->dfparam.indirect) SYMBOL_CLASS (sym) = LOC_REF_ARG; else SYMBOL_CLASS (sym) = LOC_ARG; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; if (dn_bufp->dfparam.copyparam) - { - SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; + { + SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; #ifdef HPREAD_ADJUST_STACK_ADDRESS - SYMBOL_VALUE (sym) - += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); + SYMBOL_VALUE (sym) + += HPREAD_ADJUST_STACK_ADDRESS (CURRENT_FUNCTION_VALUE (objfile)); #endif - } + } else - SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; + SYMBOL_VALUE (sym) = dn_bufp->dfparam.location; SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dfparam.type, objfile); add_symbol_to_list (sym, &fparam_symbols); break; @@ -3385,7 +3443,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, case DNTT_TYPE_SVAR: /* Static variables. */ - SYMBOL_CLASS (sym) = LOC_STATIC; + SYMBOL_CLASS (sym) = LOC_STATIC; /* Note: There is a case that arises with globals in shared * libraries where we need to set the address to LOC_INDIRECT. @@ -3396,54 +3454,55 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, * in the symbol table contains a pointer to the real "g". * We use the storage class LOC_INDIRECT to indicate this. RT */ - if (is_in_import_list (SYMBOL_NAME(sym), objfile)) - SYMBOL_CLASS (sym) = LOC_INDIRECT; + if (is_in_import_list (SYMBOL_NAME (sym), objfile)) + SYMBOL_CLASS (sym) = LOC_INDIRECT; SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location + data_offset; SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dsvar.type, objfile); if (dn_bufp->dsvar.global) add_symbol_to_list (sym, &global_symbols); - + else if (WITHIN_FUNCTION (objfile)) add_symbol_to_list (sym, &local_symbols); - + else add_symbol_to_list (sym, &file_symbols); if (dn_bufp->dsvar.thread_specific) - { - /* Thread-local variable. - */ - SYMBOL_CLASS (sym) = LOC_THREAD_LOCAL_STATIC; - SYMBOL_BASEREG (sym) = CR27_REGNUM; - - if( objfile->flags & OBJF_SHARED ) { - /* - * This variable is not only thread local but - * in a shared library. - * - * Alas, the shared lib structures are private - * to "somsolib.c". But C lets us point to one. - */ - struct so_list *so; - - if( objfile->obj_private == NULL ) - error( "Internal error in reading shared library information." ); - - so = ((obj_private_data_t *)(objfile->obj_private))->so_info; - if( so == NULL ) - error( "Internal error in reading shared library information." ); - - /* Thread-locals in shared libraries do NOT have the - * standard offset ("data_offset"), so we re-calculate - * where to look for this variable, using a call-back - * to interpret the private shared-library data. - */ - SYMBOL_VALUE_ADDRESS(sym) = dn_bufp->dsvar.location + - so_lib_thread_start_addr( so ); - } - } + { + /* Thread-local variable. + */ + SYMBOL_CLASS (sym) = LOC_THREAD_LOCAL_STATIC; + SYMBOL_BASEREG (sym) = CR27_REGNUM; + + if (objfile->flags & OBJF_SHARED) + { + /* + * This variable is not only thread local but + * in a shared library. + * + * Alas, the shared lib structures are private + * to "somsolib.c". But C lets us point to one. + */ + struct so_list *so; + + if (objfile->obj_private == NULL) + error ("Internal error in reading shared library information."); + + so = ((obj_private_data_t *) (objfile->obj_private))->so_info; + if (so == NULL) + error ("Internal error in reading shared library information."); + + /* Thread-locals in shared libraries do NOT have the + * standard offset ("data_offset"), so we re-calculate + * where to look for this variable, using a call-back + * to interpret the private shared-library data. + */ + SYMBOL_VALUE_ADDRESS (sym) = dn_bufp->dsvar.location + + so_lib_thread_start_addr (so); + } + } break; case DNTT_TYPE_DVAR: @@ -3452,7 +3511,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SYMBOL_CLASS (sym) = LOC_REGISTER; else SYMBOL_CLASS (sym) = LOC_LOCAL; - + SYMBOL_VALUE (sym) = dn_bufp->ddvar.location; #ifdef HPREAD_ADJUST_STACK_ADDRESS SYMBOL_VALUE (sym) @@ -3496,79 +3555,81 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, case DNTT_TYPE_TAGDEF: { - int global = dn_bufp->dtag.global; - /* Structure, union, enum, template, or class tag definition */ - /* We do want to process these, since a name is - * added to the namespace for the tag name (and if C++ class, - * for the typename also). - */ - SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - - /* The tag contains in its "type" field a pointer to the - * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION, DNTT_TYPE_ENUM, - * DNTT_TYPE_CLASS or DNTT_TYPE_TEMPLATE - * record that actually defines the type. - */ - SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile); - TYPE_NAME (sym->type) = SYMBOL_NAME (sym); - TYPE_TAG_NAME (sym->type) = SYMBOL_NAME (sym); - if (dn_bufp->dtag.global) - add_symbol_to_list (sym, &global_symbols); - else if (WITHIN_FUNCTION (objfile)) - add_symbol_to_list (sym, &local_symbols); - else - add_symbol_to_list (sym, &file_symbols); - - /* If this is a C++ class, then we additionally - * need to define a typedef for the - * class type. E.g., so that the name "c" becomes visible as - * a type name when the user says "class c { ... }". - * In order to figure this out, we need to chase down the "type" - * field to get to the DNTT_TYPE_CLASS record. - * - * We also add the typename for ENUM. Though this isn't - * strictly correct, it is necessary because of the debug info - * generated by the aCC compiler, in which we cannot - * distinguish between: - * enum e { ... }; - * and - * typedef enum { ... } e; - * I.e., the compiler emits the same debug info for the above - * two cases, in both cases "e" appearing as a tagdef. - * Therefore go ahead and generate the typename so that - * "ptype e" will work in the above cases. - * - * We also add the typename for TEMPLATE, so as to allow "ptype t" - * when "t" is a template name. - */ - if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile)) - dn_bufp = hpread_get_lntt (dn_bufp->dtag.type.dnttp.index, objfile); - else { - complain (&hpread_tagdef_complaint); - return; - } - if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS || - dn_bufp->dblock.kind == DNTT_TYPE_ENUM || - dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) { - struct symbol *newsym; - - newsym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, - sizeof (struct symbol)); - memset (newsym, 0, sizeof (struct symbol)); - SYMBOL_NAME (newsym) = name; - SYMBOL_LANGUAGE (newsym) = language_auto; - SYMBOL_NAMESPACE (newsym) = VAR_NAMESPACE; - SYMBOL_LINE (newsym) = 0; - SYMBOL_VALUE (newsym) = 0; - SYMBOL_CLASS (newsym) = LOC_TYPEDEF; - SYMBOL_TYPE (newsym) = sym->type; - if (global) - add_symbol_to_list (newsym, &global_symbols); - else if (WITHIN_FUNCTION (objfile)) - add_symbol_to_list (newsym, &local_symbols); - else - add_symbol_to_list (newsym, &file_symbols); - } + int global = dn_bufp->dtag.global; + /* Structure, union, enum, template, or class tag definition */ + /* We do want to process these, since a name is + * added to the namespace for the tag name (and if C++ class, + * for the typename also). + */ + SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; + + /* The tag contains in its "type" field a pointer to the + * DNTT_TYPE_STRUCT, DNTT_TYPE_UNION, DNTT_TYPE_ENUM, + * DNTT_TYPE_CLASS or DNTT_TYPE_TEMPLATE + * record that actually defines the type. + */ + SYMBOL_TYPE (sym) = hpread_type_lookup (dn_bufp->dtype.type, objfile); + TYPE_NAME (sym->type) = SYMBOL_NAME (sym); + TYPE_TAG_NAME (sym->type) = SYMBOL_NAME (sym); + if (dn_bufp->dtag.global) + add_symbol_to_list (sym, &global_symbols); + else if (WITHIN_FUNCTION (objfile)) + add_symbol_to_list (sym, &local_symbols); + else + add_symbol_to_list (sym, &file_symbols); + + /* If this is a C++ class, then we additionally + * need to define a typedef for the + * class type. E.g., so that the name "c" becomes visible as + * a type name when the user says "class c { ... }". + * In order to figure this out, we need to chase down the "type" + * field to get to the DNTT_TYPE_CLASS record. + * + * We also add the typename for ENUM. Though this isn't + * strictly correct, it is necessary because of the debug info + * generated by the aCC compiler, in which we cannot + * distinguish between: + * enum e { ... }; + * and + * typedef enum { ... } e; + * I.e., the compiler emits the same debug info for the above + * two cases, in both cases "e" appearing as a tagdef. + * Therefore go ahead and generate the typename so that + * "ptype e" will work in the above cases. + * + * We also add the typename for TEMPLATE, so as to allow "ptype t" + * when "t" is a template name. + */ + if (dn_bufp->dtype.type.dnttp.index < LNTT_SYMCOUNT (objfile)) + dn_bufp = hpread_get_lntt (dn_bufp->dtag.type.dnttp.index, objfile); + else + { + complain (&hpread_tagdef_complaint); + return; + } + if (dn_bufp->dblock.kind == DNTT_TYPE_CLASS || + dn_bufp->dblock.kind == DNTT_TYPE_ENUM || + dn_bufp->dblock.kind == DNTT_TYPE_TEMPLATE) + { + struct symbol *newsym; + + newsym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack, + sizeof (struct symbol)); + memset (newsym, 0, sizeof (struct symbol)); + SYMBOL_NAME (newsym) = name; + SYMBOL_LANGUAGE (newsym) = language_auto; + SYMBOL_NAMESPACE (newsym) = VAR_NAMESPACE; + SYMBOL_LINE (newsym) = 0; + SYMBOL_VALUE (newsym) = 0; + SYMBOL_CLASS (newsym) = LOC_TYPEDEF; + SYMBOL_TYPE (newsym) = sym->type; + if (global) + add_symbol_to_list (newsym, &global_symbols); + else if (WITHIN_FUNCTION (objfile)) + add_symbol_to_list (newsym, &local_symbols); + else + add_symbol_to_list (newsym, &file_symbols); + } } break; @@ -3630,9 +3691,9 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, */ break; - /* DNTT_TYPE_VARIANT is not handled by GDB */ + /* DNTT_TYPE_VARIANT is not handled by GDB */ - /* DNTT_TYPE_FILE is not handled by GDB */ + /* DNTT_TYPE_FILE is not handled by GDB */ case DNTT_TYPE_FUNCTYPE: /* Function type */ @@ -3654,10 +3715,10 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, complain (&hpread_unhandled_common_complaint); break; - /* DNTT_TYPE_COBSTRUCT is not handled by GDB. */ - /* DNTT_TYPE_XREF is not handled by GDB. */ - /* DNTT_TYPE_SA is not handled by GDB. */ - /* DNTT_TYPE_MACRO is not handled by GDB */ + /* DNTT_TYPE_COBSTRUCT is not handled by GDB. */ + /* DNTT_TYPE_XREF is not handled by GDB. */ + /* DNTT_TYPE_SA is not handled by GDB. */ + /* DNTT_TYPE_MACRO is not handled by GDB */ case DNTT_TYPE_BLOCKDATA: /* Not sure what this is - part of FORTRAN support maybe? @@ -3693,16 +3754,16 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, dn_temp = hpread_get_lntt (dn_bufp->dclass_scope.type.dnttp.index, objfile); if (dn_temp->dblock.kind == DNTT_TYPE_TAGDEF) - class_scope_name = VT (objfile) + dn_temp->dtag.name; + class_scope_name = VT (objfile) + dn_temp->dtag.name; else - class_scope_name = NULL; + class_scope_name = NULL; #if 0 /* Begin a new scope. */ SL_INDEX (objfile) = hpread_record_lines (current_subfile, SL_INDEX (objfile), - dn_bufp->dclass_scope.address, + dn_bufp->dclass_scope.address, objfile, offset); valu = hpread_get_location (dn_bufp->dclass_scope.address, objfile); valu += offset; /* Relocate for dynamic loading */ @@ -3775,7 +3836,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, * info. DDE only uses it in "describe". We may later want * to extend GDB's "ptype" to give this info, but for now * it seems safe enough to ignore it. - */ + */ break; case DNTT_TYPE_MODIFIER: @@ -3835,12 +3896,12 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, */ break; - /* DNTT_TYPE_DYN_ARRAY_DESC is not handled by GDB */ - /* DNTT_TYPE_DESC_SUBRANGE is not handled by GDB */ - /* DNTT_TYPE_BEGIN_EXT is not handled by GDB */ - /* DNTT_TYPE_INLN is not handled by GDB */ - /* DNTT_TYPE_INLN_LIST is not handled by GDB */ - /* DNTT_TYPE_ALIAS is not handled by GDB */ + /* DNTT_TYPE_DYN_ARRAY_DESC is not handled by GDB */ + /* DNTT_TYPE_DESC_SUBRANGE is not handled by GDB */ + /* DNTT_TYPE_BEGIN_EXT is not handled by GDB */ + /* DNTT_TYPE_INLN is not handled by GDB */ + /* DNTT_TYPE_INLN_LIST is not handled by GDB */ + /* DNTT_TYPE_ALIAS is not handled by GDB */ default: break; @@ -3857,54 +3918,54 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, * Return value is an integer. 0 => not a local type / name * positive return => type or name is local to some * block or function. - */ + */ /* elz: ATTENTION: FIXME: NOTE: WARNING!!!! this function now returns 0 right away. It was taking too much time at start up. Now, though, the local types are not handled correctly. -*/ + */ static int hpread_get_scope_depth (dn_bufp, objfile, report_nested) - union dnttentry * dn_bufp; - struct objfile * objfile; - int report_nested; + union dnttentry *dn_bufp; + struct objfile *objfile; + int report_nested; { register int index; - register union dnttentry * dn_tmp; + register union dnttentry *dn_tmp; register short depth = 0; /****************************/ return 0; /****************************/ index = (((char *) dn_bufp) - LNTT (objfile)) / (sizeof (struct dntt_type_block)); - + while (--index >= 0) { dn_tmp = hpread_get_lntt (index, objfile); switch (dn_tmp->dblock.kind) - { - case DNTT_TYPE_MODULE: - return depth; - case DNTT_TYPE_END: - /* index is signed int; dnttp.index is 29-bit unsigned int! */ - index = (int) dn_tmp->dend.beginscope.dnttp.index; - break; - case DNTT_TYPE_BEGIN: - case DNTT_TYPE_FUNCTION: - case DNTT_TYPE_DOC_FUNCTION: - case DNTT_TYPE_WITH: - case DNTT_TYPE_COMMON: - case DNTT_TYPE_CLASS_SCOPE: - depth++; - if (report_nested) - return 1; - break; - default: - break; - } + { + case DNTT_TYPE_MODULE: + return depth; + case DNTT_TYPE_END: + /* index is signed int; dnttp.index is 29-bit unsigned int! */ + index = (int) dn_tmp->dend.beginscope.dnttp.index; + break; + case DNTT_TYPE_BEGIN: + case DNTT_TYPE_FUNCTION: + case DNTT_TYPE_DOC_FUNCTION: + case DNTT_TYPE_WITH: + case DNTT_TYPE_COMMON: + case DNTT_TYPE_CLASS_SCOPE: + depth++; + if (report_nested) + return 1; + break; + default: + break; + } } return depth; } @@ -3912,17 +3973,17 @@ hpread_get_scope_depth (dn_bufp, objfile, report_nested) /* Adjust the bitoffsets for all fields of an anonymous union of type TYPE by negative BITS. This handles HP aCC's hideous habit of giving members of anonymous unions bit offsets relative to the - enclosing structure instead of relative to the union itself. */ + enclosing structure instead of relative to the union itself. */ static void hpread_adjust_bitoffsets (type, bits) - struct type * type; - int bits; + struct type *type; + int bits; { register int i; /* This is done only for unions; caller had better check that - it is an anonymous one. */ + it is an anonymous one. */ if (TYPE_CODE (type) != TYPE_CODE_UNION) return; @@ -3944,7 +4005,7 @@ hpread_adjust_bitoffsets (type, bits) This function does a "next" in the chain of FIELD entries, but transparently skips over anonymous unions' fields (recursively). - + Inputs are the number of times to do "next" at the top level, the dnttpointer (FIELD) and entry pointer (FIELDP) for the dntt record corresponding to it, and the ubiquitous objfile parameter. (Note: FIELDP is a **.) Return value @@ -3952,17 +4013,17 @@ hpread_adjust_bitoffsets (type, bits) static dnttpointer hpread_get_next_skip_over_anon_unions (skip_fields, field, fieldp, objfile) - int skip_fields; - dnttpointer field; - union dnttentry ** fieldp; - struct objfile * objfile; + int skip_fields; + dnttpointer field; + union dnttentry **fieldp; + struct objfile *objfile; { - struct type * anon_type; + struct type *anon_type; register int i; int bitoffset; - char * name; + char *name; - for (i=0; i < skip_fields; i++) + for (i = 0; i < skip_fields; i++) { /* Get type of item we're looking at now; recursively processes the types of these intermediate items we skip over, so they aren't lost. */ @@ -3970,19 +4031,17 @@ hpread_get_next_skip_over_anon_unions (skip_fields, field, fieldp, objfile) anon_type = CHECK_TYPEDEF (anon_type); bitoffset = (*fieldp)->dfield.bitoffset; name = VT (objfile) + (*fieldp)->dfield.name; - /* First skip over one item to avoid stack death on recursion */ + /* First skip over one item to avoid stack death on recursion */ field = (*fieldp)->dfield.nextfield; *fieldp = hpread_get_lntt (field.dnttp.index, objfile); /* Do we have another anonymous union? If so, adjust the bitoffsets of its members and skip over its members. */ if ((TYPE_CODE (anon_type) == TYPE_CODE_UNION) && - (!name || STREQ (name, ""))) - { - hpread_adjust_bitoffsets (anon_type, bitoffset); - field = hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type), field, fieldp, objfile); - } + (!name || STREQ (name, ""))) + { + hpread_adjust_bitoffsets (anon_type, bitoffset); + field = hpread_get_next_skip_over_anon_unions (TYPE_NFIELDS (anon_type), field, fieldp, objfile); + } } return field; } - - diff --git a/gdb/hpread.c b/gdb/hpread.c index 0b464ec3a3..b36531a85f 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -15,7 +15,8 @@ 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. + 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. */ @@ -38,35 +39,35 @@ 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) \ @@ -105,20 +106,20 @@ struct hpread_symfile_info of the psymtab. */ struct symloc -{ - /* The offset within the file symbol table of first local symbol for - this file. */ + { + /* The offset within the file symbol table of first local symbol for + this file. */ - int ldsymoff; + int ldsymoff; - /* 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. */ + /* 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. */ - int ldsymlen; -}; + int ldsymlen; + }; #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) #define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen) @@ -132,12 +133,12 @@ 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 *)); + +void hpread_symfile_init PARAMS ((struct objfile *)); static struct type * -hpread_read_array_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); + hpread_read_array_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); static struct type *hpread_alloc_type PARAMS ((dnttpointer, struct objfile *)); @@ -158,12 +159,12 @@ static struct type *hpread_read_struct_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); void hpread_build_psymtabs - PARAMS ((struct objfile *, struct section_offsets *, int)); + PARAMS ((struct objfile *, int)); void hpread_symfile_finish PARAMS ((struct objfile *)); static struct partial_symtab *hpread_start_psymtab - PARAMS ((struct objfile *, struct section_offsets *, char *, CORE_ADDR, int, + PARAMS ((struct objfile *, char *, CORE_ADDR, int, struct partial_symbol **, struct partial_symbol **)); static struct partial_symtab *hpread_end_psymtab @@ -185,7 +186,7 @@ static sltpointer hpread_record_lines static struct type *hpread_read_function_type PARAMS ((dnttpointer, union dnttentry *, struct objfile *)); -static struct type * hpread_type_lookup +static struct type *hpread_type_lookup PARAMS ((dnttpointer, struct objfile *)); static unsigned long hpread_get_depth @@ -205,8 +206,8 @@ 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)); - + /* 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 @@ -243,11 +244,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. */ @@ -260,11 +261,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. */ @@ -277,7 +278,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. */ @@ -304,15 +305,12 @@ 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) +hpread_build_psymtabs (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { char *namestring; @@ -468,11 +466,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; @@ -482,17 +480,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; @@ -502,13 +500,13 @@ 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. */ - valu = dn_bufp->dfunc.hiaddr + ANOFFSET (section_offsets, - SECT_OFF_TEXT); + 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); + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); SET_NAMESTRING (dn_bufp, &namestring, objfile); add_psymbol_to_list (namestring, strlen (namestring), VAR_NAMESPACE, LOC_BLOCK, @@ -519,7 +517,7 @@ hpread_build_psymtabs (objfile, section_offsets, mainline) 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) { hpread_end_psymtab (pst, psymtab_include_list, includes_used, @@ -570,12 +568,12 @@ 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) { @@ -601,10 +599,10 @@ 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); } @@ -673,7 +671,7 @@ hpread_get_slt (index, objfile) 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 @@ -697,8 +695,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. */ @@ -824,10 +823,9 @@ hpread_has_name (kind) (normal). */ static struct partial_symtab * -hpread_start_psymtab (objfile, section_offsets, - filename, textlow, ldsymoff, global_syms, static_syms) +hpread_start_psymtab (objfile, filename, textlow, ldsymoff, global_syms, + static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; int ldsymoff; @@ -854,7 +852,7 @@ hpread_start_psymtab (objfile, section_offsets, static struct partial_symtab * hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, - capping_text, dependency_list, number_dependencies) + capping_text, dependency_list, number_dependencies) struct partial_symtab *pst; char **include_list; int num_includes; @@ -864,10 +862,10 @@ hpread_end_psymtab (pst, include_list, num_includes, capping_symbol_offset, 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 = @@ -880,9 +878,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; @@ -890,19 +888,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 *)); @@ -911,8 +909,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; @@ -932,17 +930,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. */ + 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. */ discard_psymtab (pst); /* Indicate that psymtab was thrown away. */ - pst = (struct partial_symtab *)NULL; + pst = (struct partial_symtab *) NULL; } return pst; } @@ -1209,15 +1207,15 @@ hpread_lookup_type (hp_type, objfile) { TYPE_VECTOR_LENGTH (objfile) = 100; TYPE_VECTOR (objfile) = (struct type **) - xmmalloc (objfile -> md, - 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 **) - xmrealloc (objfile -> md, + xmrealloc (objfile->md, (char *) TYPE_VECTOR (objfile), - (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); + (TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); memset (&TYPE_VECTOR (objfile)[old_len], 0, (TYPE_VECTOR_LENGTH (objfile) - old_len) * sizeof (struct type *)); @@ -1282,7 +1280,7 @@ 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) = obsavestring (name, strlen (name), + SYMBOL_NAME (sym) = obsavestring (name, strlen (name), &objfile->symbol_obstack); SYMBOL_CLASS (sym) = LOC_CONST; SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; @@ -1386,7 +1384,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)); @@ -1462,7 +1460,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) @@ -1566,9 +1564,9 @@ hpread_read_array_type (hp_type, dn_bufp, objfile) 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; @@ -1665,7 +1663,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; } @@ -1777,7 +1775,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, 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; @@ -1827,7 +1825,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, } start_subfile (name, NULL); break; - + case DNTT_TYPE_MODULE: /* No need to do anything with these DNTT_TYPE_MODULE symbols anymore. */ break; @@ -1840,7 +1838,7 @@ hpread_process_one_debug_symbol (dn_bufp, name, section_offsets, objfile, SL_INDEX (objfile), dn_bufp->dfunc.address, objfile, offset); - + WITHIN_FUNCTION (objfile) = 1; CURRENT_FUNCTION_VALUE (objfile) = valu; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 1064490dcf..6c7ddccf93 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -5,21 +5,22 @@ CMU. Major work by Per Bothner, John Gilmore and Ian Lance Taylor at Cygnus Support. -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. */ /* This module provides the function mdebug_build_psymtabs. It reads ECOFF debugging information into partial symbol tables. The @@ -59,10 +60,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ extern void ecoff_relocate_efi PARAMS ((struct symbol *, CORE_ADDR)); #include "coff/sym.h" #include "coff/symconst.h" -typedef struct mips_extra_func_info { - long numargs; - PDR pdr; -} *mips_extra_func_info_t; +typedef struct mips_extra_func_info + { + long numargs; + PDR pdr; + } + *mips_extra_func_info_t; #ifndef RA_REGNUM #define RA_REGNUM 0 #endif @@ -88,6 +91,7 @@ typedef struct mips_extra_func_info { #include "expression.h" #include "language.h" /* Needed inside partial-stab.h */ +extern void _initialize_mdebugread PARAMS ((void)); /* Provide a default mapping from a ecoff register number to a gdb REGNUM. */ #ifndef ECOFF_REG_TO_REGNUM @@ -100,26 +104,26 @@ typedef struct mips_extra_func_info { case the symbol's ELF section could not be represented in ECOFF. */ #define ECOFF_IN_ELF(bfd) (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ && bfd_get_section_by_name (bfd, ".mdebug") != NULL) - + /* We put a pointer to this structure in the read_symtab_private field of the psymtab. */ struct symloc -{ - /* Index of the FDR that this psymtab represents. */ - int fdr_idx; - /* The BFD that the psymtab was created from. */ - bfd *cur_bfd; - const struct ecoff_debug_swap *debug_swap; - struct ecoff_debug_info *debug_info; - struct mdebug_pending **pending_list; - /* Pointer to external symbols for this file. */ - EXTR *extern_tab; - /* Size of extern_tab. */ - int extern_count; - enum language pst_language; -}; + { + /* Index of the FDR that this psymtab represents. */ + int fdr_idx; + /* The BFD that the psymtab was created from. */ + bfd *cur_bfd; + const struct ecoff_debug_swap *debug_swap; + struct ecoff_debug_info *debug_info; + struct mdebug_pending **pending_list; + /* Pointer to external symbols for this file. */ + EXTR *extern_tab; + /* Size of extern_tab. */ + int extern_count; + enum language pst_language; + }; #define PST_PRIVATE(p) ((struct symloc *)(p)->read_symtab_private) #define FDR_IDX(p) (PST_PRIVATE(p)->fdr_idx) @@ -140,8 +144,8 @@ struct symloc #define SC_IS_COMMON(sc) ((sc) == scCommon || (sc) == scSCommon) #define SC_IS_BSS(sc) ((sc) == scBss || (sc) == scSBss) #define SC_IS_UNDEF(sc) ((sc) == scUndefined || (sc) == scSUndefined) - + /* Things we import explicitly from other modules */ extern int info_verbose; @@ -331,7 +335,7 @@ static void add_pending PARAMS ((FDR *, char *, struct type *)); static struct mdebug_pending * -is_pending_symbol PARAMS ((FDR *, char *)); + is_pending_symbol PARAMS ((FDR *, char *)); static void pop_parse_stack PARAMS ((void)); @@ -340,7 +344,7 @@ static void push_parse_stack PARAMS ((void)); static char * -fdr_name PARAMS ((FDR *)); + fdr_name PARAMS ((FDR *)); static void mdebug_psymtab_to_symtab PARAMS ((struct partial_symtab *)); @@ -349,11 +353,10 @@ static int upgrade_type PARAMS ((int, struct type **, int, union aux_ext *, int, char *)); static void -parse_partial_symbols PARAMS ((struct objfile *, - struct section_offsets *)); +parse_partial_symbols PARAMS ((struct objfile *)); static FDR -*get_rfd PARAMS ((int, int)); +* get_rfd PARAMS ((int, int)); static int has_opaque_xref PARAMS ((FDR *, SYMR *)); @@ -363,38 +366,38 @@ cross_ref PARAMS ((int, union aux_ext *, struct type **, enum type_code, char **, int, char *)); static struct symbol * -new_symbol PARAMS ((char *)); + new_symbol PARAMS ((char *)); static struct type * -new_type PARAMS ((char *)); + new_type PARAMS ((char *)); static struct block * -new_block PARAMS ((int)); + new_block PARAMS ((int)); static struct symtab * -new_symtab PARAMS ((char *, int, int, struct objfile *)); + new_symtab PARAMS ((char *, int, int, struct objfile *)); static struct linetable * -new_linetable PARAMS ((int)); + new_linetable PARAMS ((int)); static struct blockvector * -new_bvect PARAMS ((int)); + new_bvect PARAMS ((int)); static int -parse_symbol PARAMS ((SYMR *, union aux_ext *, char *, int, struct section_offsets *)); +parse_symbol PARAMS ((SYMR *, union aux_ext *, char *, int, struct section_offsets *, struct objfile *)); static struct type * -parse_type PARAMS ((int, union aux_ext *, unsigned int, int *, int, char *)); + parse_type PARAMS ((int, union aux_ext *, unsigned int, int *, int, char *)); static struct symbol * -mylookup_symbol PARAMS ((char *, struct block *, namespace_enum, - enum address_class)); + mylookup_symbol PARAMS ((char *, struct block *, namespace_enum, + enum address_class)); static struct block * -shrink_block PARAMS ((struct block *, struct symtab *)); + shrink_block PARAMS ((struct block *, struct symtab *)); static PTR -xzalloc PARAMS ((unsigned int)); + xzalloc PARAMS ((unsigned int)); static void sort_blocks PARAMS ((struct symtab *)); @@ -403,7 +406,7 @@ static int compare_blocks PARAMS ((const void *, const void *)); static struct partial_symtab * -new_psymtab PARAMS ((char *, struct objfile *, struct section_offsets *)); + new_psymtab PARAMS ((char *, struct objfile *)); static void psymtab_to_symtab_1 PARAMS ((struct partial_symtab *, char *)); @@ -418,13 +421,13 @@ static int add_line PARAMS ((struct linetable *, int, CORE_ADDR, int)); static struct linetable * -shrink_linetable PARAMS ((struct linetable *)); + shrink_linetable PARAMS ((struct linetable *)); static void handle_psymbol_enumerators PARAMS ((struct objfile *, FDR *, int, CORE_ADDR)); static char * -mdebug_next_symbol_text PARAMS ((struct objfile *)); + mdebug_next_symbol_text PARAMS ((struct objfile *)); /* Address bounds for the signal trampoline in inferior, if any */ @@ -491,10 +494,10 @@ get_rfd (cf, rf) if (f->rfdBase == 0) return fdrs + rf; (*debug_swap->swap_rfd_in) (cur_bfd, - ((char *) debug_info->external_rfd - + ((f->rfdBase + rf) - * debug_swap->external_rfd_size)), - &rfd); + ((char *) debug_info->external_rfd + + ((f->rfdBase + rf) + * debug_swap->external_rfd_size)), + &rfd); return fdrs + rfd; } @@ -516,11 +519,10 @@ fdr_name (f) different sections are relocated via the SECTION_OFFSETS. */ void -mdebug_build_psymtabs (objfile, swap, info, section_offsets) +mdebug_build_psymtabs (objfile, swap, info) struct objfile *objfile; const struct ecoff_debug_swap *swap; struct ecoff_debug_info *info; - struct section_offsets *section_offsets; { cur_bfd = objfile->obfd; debug_swap = swap; @@ -544,7 +546,7 @@ mdebug_build_psymtabs (objfile, swap, info, section_offsets) (*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr); } - parse_partial_symbols (objfile, section_offsets); + parse_partial_symbols (objfile); #if 0 /* Check to make sure file was compiled with -g. If not, warn the @@ -553,7 +555,7 @@ mdebug_build_psymtabs (objfile, swap, info, section_offsets) { if (max_gdbinfo == 0) printf_unfiltered ("\n%s not compiled with -g, debugging support is limited.\n", - objfile->name); + objfile->name); printf_unfiltered ("You should compile with -g2 or -g3 for best debugging support.\n"); gdb_flush (gdb_stdout); } @@ -578,25 +580,25 @@ struct pst_map after use. */ static struct parse_stack -{ - struct parse_stack *next, *prev; - struct symtab *cur_st; /* Current symtab. */ - struct block *cur_block; /* Block in it. */ - - /* What are we parsing. stFile, or stBlock are for files and - blocks. stProc or stStaticProc means we have seen the start of a - procedure, but not the start of the block within in. When we see - the start of that block, we change it to stNil, without pushing a - new block, i.e. stNil means both a procedure and a block. */ - - int blocktype; - - int maxsyms; /* Max symbols in this block. */ - struct type *cur_type; /* Type we parse fields for. */ - int cur_field; /* Field number in cur_type. */ - CORE_ADDR procadr; /* Start addres of this procedure */ - int numargs; /* Its argument count */ -} + { + struct parse_stack *next, *prev; + struct symtab *cur_st; /* Current symtab. */ + struct block *cur_block; /* Block in it. */ + + /* What are we parsing. stFile, or stBlock are for files and + blocks. stProc or stStaticProc means we have seen the start of a + procedure, but not the start of the block within in. When we see + the start of that block, we change it to stNil, without pushing a + new block, i.e. stNil means both a procedure and a block. */ + + int blocktype; + + int maxsyms; /* Max symbols in this block. */ + struct type *cur_type; /* Type we parse fields for. */ + int cur_field; /* Field number in cur_type. */ + CORE_ADDR procadr; /* Start addres of this procedure */ + int numargs; /* Its argument count */ + } *top_stack; /* Top stack ptr */ @@ -714,16 +716,17 @@ add_pending (fh, sh, t) SYMR's handled (normally one). */ static int -parse_symbol (sh, ax, ext_sh, bigend, section_offsets) +parse_symbol (sh, ax, ext_sh, bigend, section_offsets, objfile) SYMR *sh; union aux_ext *ax; char *ext_sh; int bigend; struct section_offsets *section_offsets; + struct objfile *objfile; { const bfd_size_type external_sym_size = debug_swap->external_sym_size; - void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) = - debug_swap->swap_sym_in; + void (*const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) = + debug_swap->swap_sym_in; char *name; struct symbol *s; struct block *b; @@ -746,23 +749,23 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) case scText: case scRConst: /* Do not relocate relative values. - The value of a stEnd symbol is the displacement from the - corresponding start symbol value. - The value of a stBlock symbol is the displacement from the - procedure address. */ + The value of a stEnd symbol is the displacement from the + corresponding start symbol value. + The value of a stBlock symbol is the displacement from the + procedure address. */ if (sh->st != stEnd && sh->st != stBlock) - sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT); + sh->value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); break; case scData: case scSData: case scRData: case scPData: case scXData: - sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA); + sh->value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile)); break; case scBss: case scSBss: - sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS); + sh->value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile)); break; } @@ -783,7 +786,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) class = LOC_STATIC; b = top_stack->cur_block; s = new_symbol (name); - if (SC_IS_COMMON(sh->sc)) + if (SC_IS_COMMON (sh->sc)) { /* It is a FORTRAN common block. At least for SGI Fortran the address is not in the symbol; we need to fix it later in @@ -814,7 +817,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) add_symbol (s, b); /* Type could be missing if file is compiled without debugging info. */ - if (SC_IS_UNDEF(sh->sc) + if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil || sh->index == indexNil) SYMBOL_TYPE (s) = nodebug_var_symbol_type; else @@ -837,21 +840,21 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) { case scRegister: /* Pass by value in register. */ - SYMBOL_CLASS(s) = LOC_REGPARM; + SYMBOL_CLASS (s) = LOC_REGPARM; svalue = ECOFF_REG_TO_REGNUM (svalue); break; case scVar: /* Pass by reference on stack. */ - SYMBOL_CLASS(s) = LOC_REF_ARG; + SYMBOL_CLASS (s) = LOC_REF_ARG; break; case scVarRegister: /* Pass by reference in register. */ - SYMBOL_CLASS(s) = LOC_REGPARM_ADDR; + SYMBOL_CLASS (s) = LOC_REGPARM_ADDR; svalue = ECOFF_REG_TO_REGNUM (svalue); break; default: /* Pass by value on stack. */ - SYMBOL_CLASS(s) = LOC_ARG; + SYMBOL_CLASS (s) = LOC_ARG; break; } SYMBOL_VALUE (s) = svalue; @@ -874,23 +877,23 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) SYMBOL_NAMESPACE (s) = VAR_NAMESPACE; SYMBOL_CLASS (s) = LOC_BLOCK; /* Type of the return value */ - if (SC_IS_UNDEF(sh->sc) || sh->sc == scNil) + if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil) t = mdebug_type_int; else { t = parse_type (cur_fd, ax, sh->index + 1, 0, bigend, name); - if (STREQ(name, "malloc") && t->code == TYPE_CODE_VOID) + if (STREQ (name, "malloc") && t->code == TYPE_CODE_VOID) { /* I don't know why, but, at least under Alpha GNU/Linux, - when linking against a malloc without debugging - symbols, its read as a function returning void---this - is bad because it means we cannot call functions with - string arguments interactively; i.e., "call - printf("howdy\n")" would fail with the error message - "program has no memory available". To avoid this, we - patch up the type and make it void* - instead. (davidm@azstarnet.com) - */ + when linking against a malloc without debugging + symbols, its read as a function returning void---this + is bad because it means we cannot call functions with + string arguments interactively; i.e., "call + printf("howdy\n")" would fail with the error message + "program has no memory available". To avoid this, we + patch up the type and make it void* + instead. (davidm@azstarnet.com) + */ t = make_pointer_type (t, NULL); } } @@ -923,7 +926,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) add_block (b, top_stack->cur_st); /* Not if we only have partial info */ - if (SC_IS_UNDEF(sh->sc) || sh->sc == scNil) + if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil) break; push_parse_stack (); @@ -936,7 +939,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) break; /* Beginning of code for structure, union, and enum definitions. - They all share a common set of local variables, defined here. */ + They all share a common set of local variables, defined here. */ { enum type_code type_code; char *ext_tsym; @@ -957,7 +960,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) goto structured_common; case stBlock: /* Either a lexical block, or some type */ - if (sh->sc != scInfo && !SC_IS_COMMON(sh->sc)) + if (sh->sc != scInfo && !SC_IS_COMMON (sh->sc)) goto case_stBlock_code; /* Lexical block */ type_code = TYPE_CODE_UNDEF; /* We have a type. */ @@ -988,26 +991,28 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) case stMember: if (nfields == 0 && type_code == TYPE_CODE_UNDEF) - /* If the type of the member is Nil (or Void), - without qualifiers, assume the tag is an - enumeration. - Alpha cc -migrate enums are recognized by a zero - index and a zero symbol value. - DU 4.0 cc enums are recognized by a member type of - btEnum without qualifiers and a zero symbol value. */ - if (tsym.index == indexNil - || (tsym.index == 0 && sh->value == 0)) - type_code = TYPE_CODE_ENUM; - else - { - (*debug_swap->swap_tir_in) (bigend, - &ax[tsym.index].a_ti, - &tir); - if ((tir.bt == btNil || tir.bt == btVoid - || (tir.bt == btEnum && sh->value == 0)) - && tir.tq0 == tqNil) - type_code = TYPE_CODE_ENUM; - } + { + /* If the type of the member is Nil (or Void), + without qualifiers, assume the tag is an + enumeration. + Alpha cc -migrate enums are recognized by a zero + index and a zero symbol value. + DU 4.0 cc enums are recognized by a member type of + btEnum without qualifiers and a zero symbol value. */ + if (tsym.index == indexNil + || (tsym.index == 0 && sh->value == 0)) + type_code = TYPE_CODE_ENUM; + else + { + (*debug_swap->swap_tir_in) (bigend, + &ax[tsym.index].a_ti, + &tir); + if ((tir.bt == btNil || tir.bt == btVoid + || (tir.bt == btEnum && sh->value == 0)) + && tir.tq0 == tqNil) + type_code = TYPE_CODE_ENUM; + } + } nfields++; if (tsym.value > max_value) max_value = tsym.value; @@ -1021,14 +1026,14 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) #if 0 /* This is a no-op; is it trying to tell us something we should be checking? */ - if (tsym.sc == scVariant); /*UNIMPLEMENTED*/ + if (tsym.sc == scVariant); /*UNIMPLEMENTED */ #endif if (tsym.index != 0) { /* This is something like a struct within a - struct. Skip over the fields of the inner - struct. The -1 is because the for loop will - increment ext_tsym. */ + struct. Skip over the fields of the inner + struct. The -1 is because the for loop will + increment ext_tsym. */ ext_tsym = ((char *) debug_info->external_sym + ((cur_fdr->isymBase + tsym.index - 1) * external_sym_size)); @@ -1090,10 +1095,12 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) here.) */ if (type_code == TYPE_CODE_UNDEF) - if (nfields > 1 && max_value == 0) - type_code = TYPE_CODE_UNION; - else - type_code = TYPE_CODE_STRUCT; + { + if (nfields > 1 && max_value == 0) + type_code = TYPE_CODE_UNION; + else + type_code = TYPE_CODE_STRUCT; + } /* Create a new type or use the pending type. */ pend = is_pending_symbol (cur_fdr, ext_sh); @@ -1208,12 +1215,12 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) case_stBlock_code: found_ecoff_debugging_info = 1; /* beginnning of (code) block. Value of symbol - is the displacement from procedure start */ + is the displacement from procedure start */ push_parse_stack (); /* Do not start a new block if this is the outermost block of a - procedure. This allows the LOC_BLOCK symbol to point to the - block with the local variables, so funcname::var works. */ + procedure. This allows the LOC_BLOCK symbol to point to the + block with the local variables, so funcname::var works. */ if (top_stack->blocktype == stProc || top_stack->blocktype == stStaticProc) { @@ -1230,7 +1237,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) break; case stEnd: /* end (of anything) */ - if (sh->sc == scInfo || SC_IS_COMMON(sh->sc)) + if (sh->sc == scInfo || SC_IS_COMMON (sh->sc)) { /* Finished with type */ top_stack->cur_type = 0; @@ -1282,7 +1289,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) if (TYPE_NFIELDS (ftype) <= 0) { /* No parameter type information is recorded with the function's - type. Set that from the type of the parameter symbols. */ + type. Set that from the type of the parameter symbols. */ int nparams = top_stack->numargs; int iparams; struct symbol *sym; @@ -1292,7 +1299,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) TYPE_NFIELDS (ftype) = nparams; TYPE_FIELDS (ftype) = (struct field *) TYPE_ALLOC (ftype, nparams * sizeof (struct field)); - + for (i = iparams = 0; iparams < nparams; i++) { sym = BLOCK_SYM (b, i); @@ -1349,14 +1356,14 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) case stIndirect: /* forward declaration on Irix5 */ /* Forward declarations from Irix5 cc are handled by cross_ref, - skip them. */ + skip them. */ break; case stTypedef: /* type definition */ found_ecoff_debugging_info = 1; /* Typedefs for forward declarations and opaque structs from alpha cc - are handled by cross_ref, skip them. */ + are handled by cross_ref, skip them. */ if (sh->iss == 0) break; @@ -1364,30 +1371,30 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) pend = is_pending_symbol (cur_fdr, ext_sh); if (pend == (struct mdebug_pending *) NULL) { - t = parse_type (cur_fd, ax, sh->index, (int *)NULL, bigend, name); + t = parse_type (cur_fd, ax, sh->index, (int *) NULL, bigend, name); add_pending (cur_fdr, ext_sh, t); } else t = pend->t; /* mips cc puts out a typedef with the name of the struct for forward - declarations. These should not go into the symbol table and - TYPE_NAME should not be set for them. - They can't be distinguished from an intentional typedef to - the same name however: - x.h: - struct x { int ix; int jx; }; - struct xx; - x.c: - typedef struct x x; - struct xx {int ixx; int jxx; }; - generates a cross referencing stTypedef for x and xx. - The user visible effect of this is that the type of a pointer - to struct foo sometimes is given as `foo *' instead of `struct foo *'. - The problem is fixed with alpha cc and Irix5 cc. */ + declarations. These should not go into the symbol table and + TYPE_NAME should not be set for them. + They can't be distinguished from an intentional typedef to + the same name however: + x.h: + struct x { int ix; int jx; }; + struct xx; + x.c: + typedef struct x x; + struct xx {int ixx; int jxx; }; + generates a cross referencing stTypedef for x and xx. + The user visible effect of this is that the type of a pointer + to struct foo sometimes is given as `foo *' instead of `struct foo *'. + The problem is fixed with alpha cc and Irix5 cc. */ /* However if the typedef cross references to an opaque aggregate, it - is safe to omit it from the symbol table. */ + is safe to omit it from the symbol table. */ if (has_opaque_xref (cur_fdr, sh)) break; @@ -1401,30 +1408,30 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets) /* Incomplete definitions of structs should not get a name. */ if (TYPE_NAME (SYMBOL_TYPE (s)) == NULL && (TYPE_NFIELDS (SYMBOL_TYPE (s)) != 0 - || (TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_STRUCT + || (TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_STRUCT && TYPE_CODE (SYMBOL_TYPE (s)) != TYPE_CODE_UNION))) { if (TYPE_CODE (SYMBOL_TYPE (s)) == TYPE_CODE_PTR || TYPE_CODE (SYMBOL_TYPE (s)) == TYPE_CODE_FUNC) { /* If we are giving a name to a type such as "pointer to - foo" or "function returning foo", we better not set - the TYPE_NAME. If the program contains "typedef char - *caddr_t;", we don't want all variables of type char - * to print as caddr_t. This is not just a - consequence of GDB's type management; CC and GCC (at - least through version 2.4) both output variables of - either type char * or caddr_t with the type - refering to the stTypedef symbol for caddr_t. If a future - compiler cleans this up it GDB is not ready for it - yet, but if it becomes ready we somehow need to - disable this check (without breaking the PCC/GCC2.4 - case). - - Sigh. - - Fortunately, this check seems not to be necessary - for anything except pointers or functions. */ + foo" or "function returning foo", we better not set + the TYPE_NAME. If the program contains "typedef char + *caddr_t;", we don't want all variables of type char + * to print as caddr_t. This is not just a + consequence of GDB's type management; CC and GCC (at + least through version 2.4) both output variables of + either type char * or caddr_t with the type + refering to the stTypedef symbol for caddr_t. If a future + compiler cleans this up it GDB is not ready for it + yet, but if it becomes ready we somehow need to + disable this check (without breaking the PCC/GCC2.4 + case). + + Sigh. + + Fortunately, this check seems not to be necessary + for anything except pointers or functions. */ } else TYPE_NAME (SYMBOL_TYPE (s)) = SYMBOL_NAME (s); @@ -1468,42 +1475,42 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) /* Null entries in this map are treated specially */ static struct type **map_bt[] = { - &mdebug_type_void, /* btNil */ - &mdebug_type_adr_32, /* btAdr */ - &mdebug_type_char, /* btChar */ - &mdebug_type_unsigned_char, /* btUChar */ - &mdebug_type_short, /* btShort */ + &mdebug_type_void, /* btNil */ + &mdebug_type_adr_32, /* btAdr */ + &mdebug_type_char, /* btChar */ + &mdebug_type_unsigned_char, /* btUChar */ + &mdebug_type_short, /* btShort */ &mdebug_type_unsigned_short, /* btUShort */ - &mdebug_type_int_32, /* btInt */ + &mdebug_type_int_32, /* btInt */ &mdebug_type_unsigned_int_32, /* btUInt */ - &mdebug_type_long_32, /* btLong */ + &mdebug_type_long_32, /* btLong */ &mdebug_type_unsigned_long_32, /* btULong */ - &mdebug_type_float, /* btFloat */ - &mdebug_type_double, /* btDouble */ - 0, /* btStruct */ - 0, /* btUnion */ - 0, /* btEnum */ - 0, /* btTypedef */ - 0, /* btRange */ - 0, /* btSet */ - &mdebug_type_complex, /* btComplex */ + &mdebug_type_float, /* btFloat */ + &mdebug_type_double, /* btDouble */ + 0, /* btStruct */ + 0, /* btUnion */ + 0, /* btEnum */ + 0, /* btTypedef */ + 0, /* btRange */ + 0, /* btSet */ + &mdebug_type_complex, /* btComplex */ &mdebug_type_double_complex, /* btDComplex */ - 0, /* btIndirect */ - &mdebug_type_fixed_dec, /* btFixedDec */ - &mdebug_type_float_dec, /* btFloatDec */ - &mdebug_type_string, /* btString */ - 0, /* btBit */ - 0, /* btPicture */ - &mdebug_type_void, /* btVoid */ - 0, /* DEC C++: Pointer to member */ - 0, /* DEC C++: Virtual function table */ - 0, /* DEC C++: Class (Record) */ - &mdebug_type_long_64, /* btLong64 */ + 0, /* btIndirect */ + &mdebug_type_fixed_dec, /* btFixedDec */ + &mdebug_type_float_dec, /* btFloatDec */ + &mdebug_type_string, /* btString */ + 0, /* btBit */ + 0, /* btPicture */ + &mdebug_type_void, /* btVoid */ + 0, /* DEC C++: Pointer to member */ + 0, /* DEC C++: Virtual function table */ + 0, /* DEC C++: Class (Record) */ + &mdebug_type_long_64, /* btLong64 */ &mdebug_type_unsigned_long_64, /* btULong64 */ - &mdebug_type_long_long_64, /* btLongLong64 */ - &mdebug_type_unsigned_long_long_64, /* btULongLong64 */ - &mdebug_type_adr_64, /* btAdr64 */ - &mdebug_type_int_64, /* btInt64 */ + &mdebug_type_long_long_64, /* btLongLong64 */ + &mdebug_type_unsigned_long_long_64, /* btULongLong64 */ + &mdebug_type_adr_64, /* btAdr64 */ + &mdebug_type_int_64, /* btInt64 */ &mdebug_type_unsigned_int_64, /* btUInt64 */ }; @@ -1579,8 +1586,8 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) int width = AUX_GET_WIDTH (bigend, ax); /* Inhibit core dumps with some cfront generated objects that - corrupt the TIR. */ - if (bs == (int *)NULL) + corrupt the TIR. */ + if (bs == (int *) NULL) { /* Alpha cc -migrate encodes char and unsigned char types as short and unsigned short types with a field width of 8. @@ -1595,7 +1602,7 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) complain (&bad_fbitfield_complaint, sym_name); } else - *bs = width; + *bs = width; ax++; } @@ -1626,7 +1633,7 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) xref_fh = get_rfd (fd, rf); xref_fd = xref_fh - debug_info->fdr; tp = parse_type (xref_fd, debug_info->external_aux + xref_fh->iauxBase, - rn->index, (int *) NULL, xref_fh->fBigendian, sym_name); + rn->index, (int *) NULL, xref_fh->fBigendian, sym_name); } /* All these types really point to some (common) MIPS type @@ -1636,8 +1643,8 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) t->bt == btUnion || t->bt == btEnum || - /* btSet (I think) implies that the name is a tag name, not a typedef - name. This apparently is a MIPS extension for C sets. */ + /* btSet (I think) implies that the name is a tag name, not a typedef + name. This apparently is a MIPS extension for C sets. */ t->bt == btSet) { char *name; @@ -1648,14 +1655,14 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) tp = init_type (type_code, 0, 0, (char *) NULL, current_objfile); /* DEC c89 produces cross references to qualified aggregate types, - dereference them. */ + dereference them. */ while (TYPE_CODE (tp) == TYPE_CODE_PTR || TYPE_CODE (tp) == TYPE_CODE_ARRAY) tp = tp->target_type; /* Make sure that TYPE_CODE(tp) has an expected type code. - Any type may be returned from cross_ref if file indirect entries - are corrupted. */ + Any type may be returned from cross_ref if file indirect entries + are corrupted. */ if (TYPE_CODE (tp) != TYPE_CODE_STRUCT && TYPE_CODE (tp) != TYPE_CODE_UNION && TYPE_CODE (tp) != TYPE_CODE_ENUM) @@ -1683,13 +1690,13 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) } /* Do not set the tag name if it is a compiler generated tag name - (.Fxx or .xxfake or empty) for unnamed struct/union/enums. */ + (.Fxx or .xxfake or empty) for unnamed struct/union/enums. */ if (name[0] == '.' || name[0] == '\0') TYPE_TAG_NAME (tp) = NULL; else if (TYPE_TAG_NAME (tp) == NULL || !STREQ (TYPE_TAG_NAME (tp), name)) TYPE_TAG_NAME (tp) = obsavestring (name, strlen (name), - ¤t_objfile->type_obstack); + ¤t_objfile->type_obstack); } } @@ -1707,8 +1714,8 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) tp = init_type (type_code, 0, 0, (char *) NULL, current_objfile); /* Make sure that TYPE_CODE(tp) has an expected type code. - Any type may be returned from cross_ref if file indirect entries - are corrupted. */ + Any type may be returned from cross_ref if file indirect entries + are corrupted. */ if (TYPE_CODE (tp) != TYPE_CODE_RANGE) { complain (&unexpected_type_code_complaint, sym_name); @@ -1747,11 +1754,11 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) TYPE_FIELDS (tp) = ((struct field *) TYPE_ALLOC (tp, 2 * sizeof (struct field))); TYPE_FIELD_NAME (tp, 0) = obsavestring ("Low", strlen ("Low"), - ¤t_objfile->type_obstack); + ¤t_objfile->type_obstack); TYPE_FIELD_BITPOS (tp, 0) = AUX_GET_DNLOW (bigend, ax); ax++; TYPE_FIELD_NAME (tp, 1) = obsavestring ("High", strlen ("High"), - ¤t_objfile->type_obstack); + ¤t_objfile->type_obstack); TYPE_FIELD_BITPOS (tp, 1) = AUX_GET_DNHIGH (bigend, ax); ax++; } @@ -1786,7 +1793,7 @@ parse_type (fd, ax, aux_index, bs, bigend, sym_name) /* Complain for illegal continuations due to corrupt aux entries. */ if (t->continued) complain (&bad_continued_complaint, sym_name); - + return tp; } @@ -1849,7 +1856,7 @@ upgrade_type (fd, tpp, tq, ax, bigend, sym_name) id, (int *) NULL, bigend, sym_name); /* The bounds type should be an integer type, but might be anything - else due to corrupt aux entries. */ + else due to corrupt aux entries. */ if (TYPE_CODE (indx) != TYPE_CODE_INT) { complain (&array_index_type_complaint, sym_name); @@ -1870,21 +1877,21 @@ upgrade_type (fd, tpp, tq, ax, bigend, sym_name) t = create_array_type ((struct type *) NULL, *tpp, range); /* We used to fill in the supplied array element bitsize - here if the TYPE_LENGTH of the target type was zero. - This happens for a `pointer to an array of anonymous structs', - but in this case the array element bitsize is also zero, - so nothing is gained. - And we used to check the TYPE_LENGTH of the target type against - the supplied array element bitsize. - gcc causes a mismatch for `pointer to array of object', - since the sdb directives it uses do not have a way of - specifying the bitsize, but it does no harm (the - TYPE_LENGTH should be correct) and we should be able to - ignore the erroneous bitsize from the auxiliary entry safely. - dbx seems to ignore it too. */ + here if the TYPE_LENGTH of the target type was zero. + This happens for a `pointer to an array of anonymous structs', + but in this case the array element bitsize is also zero, + so nothing is gained. + And we used to check the TYPE_LENGTH of the target type against + the supplied array element bitsize. + gcc causes a mismatch for `pointer to array of object', + since the sdb directives it uses do not have a way of + specifying the bitsize, but it does no harm (the + TYPE_LENGTH should be correct) and we should be able to + ignore the erroneous bitsize from the auxiliary entry safely. + dbx seems to ignore it too. */ /* TYPE_FLAG_TARGET_STUB now takes care of the zero TYPE_LENGTH - problem. */ + problem. */ if (TYPE_LENGTH (*tpp) == 0) { TYPE_FLAGS (t) |= TYPE_FLAG_TARGET_STUB; @@ -1947,7 +1954,7 @@ parse_procedure (pr, search_symtab, pst) { /* external */ EXTR she; - + (*debug_swap->swap_ext_in) (cur_bfd, ((char *) debug_info->external_ext + (pr->isym @@ -1973,12 +1980,12 @@ parse_procedure (pr, search_symtab, pst) { #if 0 /* This loses both in the case mentioned (want a static, find a global), - but also if we are looking up a non-mangled name which happens to - match the name of a mangled function. */ + but also if we are looking up a non-mangled name which happens to + match the name of a mangled function. */ /* We have to save the cur_fdr across the call to lookup_symbol. - If the pdr is for a static function and if a global function with - the same name exists, lookup_symbol will eventually read in the symtab - for the global function and clobber cur_fdr. */ + If the pdr is for a static function and if a global function with + the same name exists, lookup_symbol will eventually read in the symtab + for the global function and clobber cur_fdr. */ FDR *save_cur_fdr = cur_fdr; s = lookup_symbol (sh_name, NULL, VAR_NAMESPACE, 0, NULL); cur_fdr = save_cur_fdr; @@ -2017,7 +2024,7 @@ parse_procedure (pr, search_symtab, pst) BLOCK_FUNCTION (b) = s; BLOCK_START (b) = pr->adr; /* BOUND used to be the end of procedure's text, but the - argument is no longer passed in. */ + argument is no longer passed in. */ BLOCK_END (b) = bound; BLOCK_SUPERBLOCK (b) = top_stack->cur_block; add_block (b, top_stack->cur_st); @@ -2033,19 +2040,19 @@ parse_procedure (pr, search_symtab, pst) e->pdr.isym = (long) s; /* GDB expects the absolute function start address for the - procedure descriptor in e->pdr.adr. - As the address in the procedure descriptor is usually relative, - we would have to relocate e->pdr.adr with cur_fdr->adr and - ANOFFSET (pst->section_offsets, SECT_OFF_TEXT). - Unfortunately cur_fdr->adr and e->pdr.adr are both absolute - in shared libraries on some systems, and on other systems - e->pdr.adr is sometimes offset by a bogus value. - To work around these problems, we replace e->pdr.adr with - the start address of the function. */ + procedure descriptor in e->pdr.adr. + As the address in the procedure descriptor is usually relative, + we would have to relocate e->pdr.adr with cur_fdr->adr and + ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile)). + Unfortunately cur_fdr->adr and e->pdr.adr are both absolute + in shared libraries on some systems, and on other systems + e->pdr.adr is sometimes offset by a bogus value. + To work around these problems, we replace e->pdr.adr with + the start address of the function. */ e->pdr.adr = BLOCK_START (b); /* Correct incorrect setjmp procedure descriptor from the library - to make backtrace through setjmp work. */ + to make backtrace through setjmp work. */ if (e->pdr.pcreg == 0 && STREQ (sh_name, "setjmp")) { complain (&bad_setjmp_pdr_complaint, 0); @@ -2069,7 +2076,7 @@ parse_procedure (pr, search_symtab, pst) To work around these problems, the return value type of a TYPE_CODE_VOID function is adjusted accordingly if no debugging info was found in the compilation unit. */ - + if (processing_gcc_compilation == 0 && found_ecoff_debugging_info == 0 && TYPE_CODE (TYPE_TARGET_TYPE (SYMBOL_TYPE (s))) == TYPE_CODE_VOID) @@ -2086,7 +2093,7 @@ ecoff_relocate_efi (sym, delta) struct mips_extra_func_info *e; e = (struct mips_extra_func_info *) SYMBOL_VALUE (sym); - + e->pdr.adr += delta; } @@ -2096,13 +2103,14 @@ ecoff_relocate_efi (sym, delta) This routine clobbers top_stack->cur_block and ->cur_st. */ -static void parse_external PARAMS ((EXTR *, int, struct section_offsets *)); +static void parse_external PARAMS ((EXTR *, int, struct section_offsets *, struct objfile *)); static void -parse_external (es, bigend, section_offsets) +parse_external (es, bigend, section_offsets, objfile) EXTR *es; int bigend; struct section_offsets *section_offsets; + struct objfile *objfile; { union aux_ext *ax; @@ -2119,7 +2127,7 @@ parse_external (es, bigend, section_offsets) } /* Reading .o files */ - if (SC_IS_UNDEF(es->asym.sc) || es->asym.sc == scNil) + if (SC_IS_UNDEF (es->asym.sc) || es->asym.sc == scNil) { char *what; switch (es->asym.st) @@ -2159,25 +2167,25 @@ parse_external (es, bigend, section_offsets) case stProc: case stStaticProc: /* There is no need to parse the external procedure symbols. - If they are from objects compiled without -g, their index will - be indexNil, and the symbol definition from the minimal symbol - is preferrable (yielding a function returning int instead of int). - If the index points to a local procedure symbol, the local - symbol already provides the correct type. - Note that the index of the external procedure symbol points - to the local procedure symbol in the local symbol table, and - _not_ to the auxiliary symbol info. */ + If they are from objects compiled without -g, their index will + be indexNil, and the symbol definition from the minimal symbol + is preferrable (yielding a function returning int instead of int). + If the index points to a local procedure symbol, the local + symbol already provides the correct type. + Note that the index of the external procedure symbol points + to the local procedure symbol in the local symbol table, and + _not_ to the auxiliary symbol info. */ break; case stGlobal: case stLabel: /* Global common symbols are resolved by the runtime loader, - ignore them. */ - if (SC_IS_COMMON(es->asym.sc)) + ignore them. */ + if (SC_IS_COMMON (es->asym.sc)) break; /* Note that the case of a symbol with indexNil must be handled - anyways by parse_symbol(). */ - parse_symbol (&es->asym, ax, (char *) NULL, bigend, section_offsets); + anyways by parse_symbol(). */ + parse_symbol (&es->asym, ax, (char *) NULL, bigend, section_offsets, objfile); break; default: break; @@ -2223,18 +2231,18 @@ parse_lines (fh, pr, lt, maxlines, pst, lowest_pdr_addr) continue; /* Determine start and end address of compressed line bytes for - this procedure. */ + this procedure. */ base = debug_info->line + fh->cbLineOffset; if (j != (fh->cpd - 1)) - halt = base + pr[1].cbLineOffset; + halt = base + pr[1].cbLineOffset; else - halt = base + fh->cbLine; + halt = base + fh->cbLine; base += pr->cbLineOffset; adr = pst->textlow + pr->adr - lowest_pdr_addr; l = adr >> 2; /* in words */ - for (lineno = pr->lnLow; base < halt; ) + for (lineno = pr->lnLow; base < halt;) { count = *base & 0x0f; delta = *base++ >> 4; @@ -2266,19 +2274,18 @@ parse_lines (fh, pr, lt, maxlines, pst, lowest_pdr_addr) into a partial_symtab. */ static void -parse_partial_symbols (objfile, section_offsets) +parse_partial_symbols (objfile) struct objfile *objfile; - struct section_offsets *section_offsets; { const bfd_size_type external_sym_size = debug_swap->external_sym_size; const bfd_size_type external_rfd_size = debug_swap->external_rfd_size; const bfd_size_type external_ext_size = debug_swap->external_ext_size; - void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *)) - = debug_swap->swap_ext_in; - void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) - = debug_swap->swap_sym_in; - void (* const swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *)) - = debug_swap->swap_rfd_in; + void (*const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *)) + = debug_swap->swap_ext_in; + void (*const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) + = debug_swap->swap_sym_in; + void (*const swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *)) + = debug_swap->swap_rfd_in; int f_idx, s_idx; HDRR *hdr = &debug_info->symbolic_header; /* Running pointers */ @@ -2355,7 +2362,7 @@ parse_partial_symbols (objfile, section_offsets) old_chain = make_cleanup (free, fdr_to_pst); fdr_to_pst++; { - struct partial_symtab *pst = new_psymtab ("", objfile, section_offsets); + struct partial_symtab *pst = new_psymtab ("", objfile); fdr_to_pst[-1].pst = pst; FDR_IDX (pst) = -1; } @@ -2416,124 +2423,124 @@ parse_partial_symbols (objfile, section_offsets) To fix this, either : 1) don't create the duplicate symbol - (assumes ECOFF symtab is a subset of the ELF symtab; - assumes no side-effects result from ignoring ECOFF symbol) + (assumes ECOFF symtab is a subset of the ELF symtab; + assumes no side-effects result from ignoring ECOFF symbol) 2) create it, only if lookup for existing symbol in ELF's minimal - symbols fails - (inefficient; - assumes no side-effects result from ignoring ECOFF symbol) + symbols fails + (inefficient; + assumes no side-effects result from ignoring ECOFF symbol) 3) create it, but lookup ELF's minimal symbol and use it's section - during relocation, then modify "uniqify" phase to merge and - eliminate the duplicate symbol - (highly inefficient) + during relocation, then modify "uniqify" phase to merge and + eliminate the duplicate symbol + (highly inefficient) I've implemented #1 here... Skip the creation of the minimal symbols based on the ECOFF symbol table. */ - /* Pass 2 over external syms: fill in external symbols */ - ext_in = ext_block; - ext_in_end = ext_in + hdr->iextMax; - for (; ext_in < ext_in_end; ext_in++) - { - enum minimal_symbol_type ms_type = mst_text; - CORE_ADDR svalue = ext_in->asym.value; + /* Pass 2 over external syms: fill in external symbols */ + ext_in = ext_block; + ext_in_end = ext_in + hdr->iextMax; + for (; ext_in < ext_in_end; ext_in++) + { + enum minimal_symbol_type ms_type = mst_text; + CORE_ADDR svalue = ext_in->asym.value; - /* The Irix 5 native tools seem to sometimes generate bogus - external symbols. */ - if (ext_in->ifd < -1 || ext_in->ifd >= hdr->ifdMax) - { - complain (&bad_ext_ifd_complaint, ext_in->ifd, hdr->ifdMax); - continue; - } - if (ext_in->asym.iss < 0 || ext_in->asym.iss >= hdr->issExtMax) - { - complain (&bad_ext_iss_complaint, ext_in->asym.iss, - hdr->issExtMax); - continue; - } + /* The Irix 5 native tools seem to sometimes generate bogus + external symbols. */ + if (ext_in->ifd < -1 || ext_in->ifd >= hdr->ifdMax) + { + complain (&bad_ext_ifd_complaint, ext_in->ifd, hdr->ifdMax); + continue; + } + if (ext_in->asym.iss < 0 || ext_in->asym.iss >= hdr->issExtMax) + { + complain (&bad_ext_iss_complaint, ext_in->asym.iss, + hdr->issExtMax); + continue; + } - extern_tab[fdr_to_pst[ext_in->ifd].globals_offset - + fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in; + extern_tab[fdr_to_pst[ext_in->ifd].globals_offset + + fdr_to_pst[ext_in->ifd].n_globals++] = *ext_in; - if (SC_IS_UNDEF(ext_in->asym.sc) || ext_in->asym.sc == scNil) - continue; + if (SC_IS_UNDEF (ext_in->asym.sc) || ext_in->asym.sc == scNil) + continue; - - /* Pass 3 over files, over local syms: fill in static symbols */ - name = debug_info->ssext + ext_in->asym.iss; - /* Process ECOFF Symbol Types and Storage Classes */ - switch (ext_in->asym.st) - { - case stProc: - /* Beginnning of Procedure */ - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); - break; - case stStaticProc: - /* Load time only static procs */ - ms_type = mst_file_text; - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); - break; - case stGlobal: - /* External symbol */ - if (SC_IS_COMMON (ext_in->asym.sc)) - { - /* The value of a common symbol is its size, not its address. - Ignore it. */ - continue; - } - else if (SC_IS_DATA (ext_in->asym.sc)) - { - ms_type = mst_data; - svalue += ANOFFSET (section_offsets, SECT_OFF_DATA); - } - else if (SC_IS_BSS (ext_in->asym.sc)) - { - ms_type = mst_bss; - svalue += ANOFFSET (section_offsets, SECT_OFF_BSS); - } - else - ms_type = mst_abs; - break; - case stLabel: - /* Label */ - if (SC_IS_TEXT (ext_in->asym.sc)) - { - ms_type = mst_file_text; - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); - } - else if (SC_IS_DATA (ext_in->asym.sc)) - { - ms_type = mst_file_data; - svalue += ANOFFSET (section_offsets, SECT_OFF_DATA); - } - else if (SC_IS_BSS (ext_in->asym.sc)) - { - ms_type = mst_file_bss; - svalue += ANOFFSET (section_offsets, SECT_OFF_BSS); - } - else - ms_type = mst_abs; - break; - case stLocal: - case stNil: - /* The alpha has the section start addresses in stLocal symbols - whose name starts with a `.'. Skip those but complain for all - other stLocal symbols. - Irix6 puts the section start addresses in stNil symbols, skip - those too.*/ - if (name[0] == '.') + /* Pass 3 over files, over local syms: fill in static symbols */ + name = debug_info->ssext + ext_in->asym.iss; + + /* Process ECOFF Symbol Types and Storage Classes */ + switch (ext_in->asym.st) + { + case stProc: + /* Beginnning of Procedure */ + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + break; + case stStaticProc: + /* Load time only static procs */ + ms_type = mst_file_text; + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + break; + case stGlobal: + /* External symbol */ + if (SC_IS_COMMON (ext_in->asym.sc)) + { + /* The value of a common symbol is its size, not its address. + Ignore it. */ continue; - /* Fall through. */ - default: - ms_type = mst_unknown; - complain (&unknown_ext_complaint, name); - } - if (!ECOFF_IN_ELF(cur_bfd)) - prim_record_minimal_symbol (name, svalue, ms_type, objfile); - } + } + else if (SC_IS_DATA (ext_in->asym.sc)) + { + ms_type = mst_data; + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); + } + else if (SC_IS_BSS (ext_in->asym.sc)) + { + ms_type = mst_bss; + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); + } + else + ms_type = mst_abs; + break; + case stLabel: + /* Label */ + if (SC_IS_TEXT (ext_in->asym.sc)) + { + ms_type = mst_file_text; + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + } + else if (SC_IS_DATA (ext_in->asym.sc)) + { + ms_type = mst_file_data; + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); + } + else if (SC_IS_BSS (ext_in->asym.sc)) + { + ms_type = mst_file_bss; + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); + } + else + ms_type = mst_abs; + break; + case stLocal: + case stNil: + /* The alpha has the section start addresses in stLocal symbols + whose name starts with a `.'. Skip those but complain for all + other stLocal symbols. + Irix6 puts the section start addresses in stNil symbols, skip + those too. */ + if (name[0] == '.') + continue; + /* Fall through. */ + default: + ms_type = mst_unknown; + complain (&unknown_ext_complaint, name); + } + if (!ECOFF_IN_ELF (cur_bfd)) + prim_record_minimal_symbol (name, svalue, ms_type, objfile); + } /* Pass 3 over files, over local syms: fill in static symbols */ for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) @@ -2551,16 +2558,16 @@ parse_partial_symbols (objfile, section_offsets) } /* Determine the start address for this object file from the - file header and relocate it, except for Irix 5.2 zero fh->adr. */ + file header and relocate it, except for Irix 5.2 zero fh->adr. */ if (fh->cpd) { textlow = fh->adr; if (relocatable || textlow != 0) - textlow += ANOFFSET (section_offsets, SECT_OFF_TEXT); + textlow += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); } else textlow = 0; - pst = start_psymtab_common (objfile, section_offsets, + pst = start_psymtab_common (objfile, objfile->section_offsets, fdr_name (fh), textlow, objfile->global_psymbols.next, @@ -2582,15 +2589,15 @@ parse_partial_symbols (objfile, section_offsets) /* Set up language for the pst. The language from the FDR is used if it is unambigious (e.g. cfront - with native cc and g++ will set the language to C). - Otherwise we have to deduce the language from the filename. - Native ecoff has every header file in a separate FDR, so - deduce_language_from_filename will return language_unknown for - a header file, which is not what we want. - But the FDRs for the header files are after the FDR for the source - file, so we can assign the language of the source file to the - following header files. Then we save the language in the private - pst data so that we can reuse it when building symtabs. */ + with native cc and g++ will set the language to C). + Otherwise we have to deduce the language from the filename. + Native ecoff has every header file in a separate FDR, so + deduce_language_from_filename will return language_unknown for + a header file, which is not what we want. + But the FDRs for the header files are after the FDR for the source + file, so we can assign the language of the source file to the + following header files. Then we save the language in the private + pst data so that we can reuse it when building symtabs. */ prev_language = psymtab_language; switch (fh->lang) @@ -2609,11 +2616,11 @@ parse_partial_symbols (objfile, section_offsets) pst->texthigh = pst->textlow; /* For stabs-in-ecoff files, the second symbol must be @stab. - This symbol is emitted by mips-tfile to signal that the - current object file uses encapsulated stabs instead of mips - ecoff for local symbols. (It is the second symbol because - the first symbol is the stFile used to signal the start of a - file). */ + This symbol is emitted by mips-tfile to signal that the + current object file uses encapsulated stabs instead of mips + ecoff for local symbols. (It is the second symbol because + the first symbol is the stFile used to signal the start of a + file). */ processing_gcc_compilation = 0; if (fh->csym >= 2) { @@ -2634,7 +2641,7 @@ parse_partial_symbols (objfile, section_offsets) (*swap_sym_in) (cur_bfd, (((char *) debug_info->external_sym) - + (fh->isymBase + cur_sdx) * external_sym_size), + + (fh->isymBase + cur_sdx) * external_sym_size), &sh); type_code = ECOFF_UNMARK_STAB (sh.index); if (!ECOFF_IS_STAB (&sh)) @@ -2643,8 +2650,8 @@ parse_partial_symbols (objfile, section_offsets) { CORE_ADDR procaddr; long isym; - - sh.value += ANOFFSET (section_offsets, SECT_OFF_TEXT); + + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); if (sh.st == stStaticProc) { namestring = debug_info->ss + fh->issBase + sh.iss; @@ -2652,7 +2659,7 @@ parse_partial_symbols (objfile, section_offsets) sh.value, mst_file_text, NULL, - SECT_OFF_TEXT, + SECT_OFF_TEXT (objfile), NULL, objfile); } @@ -2671,9 +2678,9 @@ parse_partial_symbols (objfile, section_offsets) { CORE_ADDR high = procaddr + sh.value; - /* Kludge for Irix 5.2 zero fh->adr. */ + /* Kludge for Irix 5.2 zero fh->adr. */ if (!relocatable - && (pst->textlow == 0 || procaddr < pst->textlow)) + && (pst->textlow == 0 || procaddr < pst->textlow)) pst->textlow = procaddr; if (high > pst->texthigh) pst->texthigh = high; @@ -2695,12 +2702,12 @@ parse_partial_symbols (objfile, section_offsets) case scPData: case scXData: namestring = debug_info->ss + fh->issBase + sh.iss; - sh.value += ANOFFSET (section_offsets, SECT_OFF_DATA); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); prim_record_minimal_symbol_and_info (namestring, sh.value, mst_file_data, NULL, - SECT_OFF_DATA, + SECT_OFF_DATA (objfile), NULL, objfile); break; @@ -2709,12 +2716,12 @@ parse_partial_symbols (objfile, section_offsets) /* FIXME! Shouldn't this use cases for bss, then have the default be abs? */ namestring = debug_info->ss + fh->issBase + sh.iss; - sh.value += ANOFFSET (section_offsets, SECT_OFF_BSS); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); prim_record_minimal_symbol_and_info (namestring, sh.value, mst_file_bss, NULL, - SECT_OFF_BSS, + SECT_OFF_BSS (objfile), NULL, objfile); break; @@ -2726,7 +2733,7 @@ parse_partial_symbols (objfile, section_offsets) { char *stabstring = debug_info->ss + fh->issBase + sh.iss; int len = strlen (stabstring); - while (stabstring[len-1] == '\\') + while (stabstring[len - 1] == '\\') { SYMR sh2; char *stabstring1 = stabstring; @@ -2740,7 +2747,7 @@ parse_partial_symbols (objfile, section_offsets) cur_sdx++; (*swap_sym_in) (cur_bfd, (((char *) debug_info->external_sym) - + (fh->isymBase + cur_sdx) + + (fh->isymBase + cur_sdx) * external_sym_size), &sh2); stabstring2 = debug_info->ss + fh->issBase + sh2.iss; @@ -2748,7 +2755,7 @@ parse_partial_symbols (objfile, section_offsets) /* Concatinate stabstring2 with stabstring1 */ if (stabstring - && stabstring != debug_info->ss + fh->issBase + sh.iss) + && stabstring != debug_info->ss + fh->issBase + sh.iss) stabstring = xrealloc (stabstring, len + len2 + 1); else stabstring = xmalloc (len + len2 + 1); @@ -2761,18 +2768,18 @@ parse_partial_symbols (objfile, section_offsets) namestring = stabstring #define CUR_SYMBOL_TYPE type_code #define CUR_SYMBOL_VALUE sh.value -#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms)\ +#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms)\ pst = save_pst #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set) (void)0 #define HANDLE_RBRAC(val) \ if ((val) > save_pst->texthigh) save_pst->texthigh = (val); #include "partial-stab.h" - if (stabstring + if (stabstring && stabstring != debug_info->ss + fh->issBase + sh.iss) free (stabstring); } - /* end - Handle continuation */ + /* end - Handle continuation */ } } else @@ -2795,7 +2802,7 @@ parse_partial_symbols (objfile, section_offsets) } /* Non absolute static symbols go into the minimal table. */ - if (SC_IS_UNDEF(sh.sc) || sh.sc == scNil + if (SC_IS_UNDEF (sh.sc) || sh.sc == scNil || (sh.index == indexNil && (sh.st != stStatic || sh.sc == scAbs))) { @@ -2813,18 +2820,18 @@ parse_partial_symbols (objfile, section_offsets) /* The value of a stEnd symbol is the displacement from the corresponding start symbol value, do not relocate it. */ if (sh.st != stEnd) - sh.value += ANOFFSET (section_offsets, SECT_OFF_TEXT); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); break; case scData: case scSData: case scRData: case scPData: case scXData: - sh.value += ANOFFSET (section_offsets, SECT_OFF_DATA); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); break; case scBss: case scSBss: - sh.value += ANOFFSET (section_offsets, SECT_OFF_BSS); + sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); break; } @@ -2837,7 +2844,7 @@ parse_partial_symbols (objfile, section_offsets) case stStaticProc: prim_record_minimal_symbol_and_info (name, sh.value, mst_file_text, NULL, - SECT_OFF_TEXT, NULL, + SECT_OFF_TEXT (objfile), NULL, objfile); /* FALLTHROUGH */ @@ -2858,18 +2865,18 @@ parse_partial_symbols (objfile, section_offsets) add_psymbol_to_list (name, strlen (name), VAR_NAMESPACE, LOC_BLOCK, &objfile->global_psymbols, - 0, sh.value, psymtab_language, objfile); + 0, sh.value, psymtab_language, objfile); else add_psymbol_to_list (name, strlen (name), VAR_NAMESPACE, LOC_BLOCK, &objfile->static_psymbols, - 0, sh.value, psymtab_language, objfile); + 0, sh.value, psymtab_language, objfile); /* Skip over procedure to next one. */ if (sh.index >= hdr->iauxMax) { /* Should not happen, but does when cross-compiling - with the MIPS compiler. FIXME -- pull later. */ + with the MIPS compiler. FIXME -- pull later. */ complain (&index_complaint, name); new_sdx = cur_sdx + 1; /* Don't skip at all */ } @@ -2907,26 +2914,26 @@ parse_partial_symbols (objfile, section_offsets) continue; case stStatic: /* Variable */ - if (SC_IS_DATA (sh.sc)) + if (SC_IS_DATA (sh.sc)) prim_record_minimal_symbol_and_info (name, sh.value, mst_file_data, NULL, - SECT_OFF_DATA, + SECT_OFF_DATA (objfile), NULL, objfile); else prim_record_minimal_symbol_and_info (name, sh.value, mst_file_bss, NULL, - SECT_OFF_BSS, + SECT_OFF_BSS (objfile), NULL, objfile); class = LOC_STATIC; break; - case stIndirect:/* Irix5 forward declaration */ + case stIndirect: /* Irix5 forward declaration */ /* Skip forward declarations from Irix5 cc */ goto skip; - case stTypedef:/* Typedef */ + case stTypedef: /* Typedef */ /* Skip typedefs for forward declarations and opaque structs from alpha and mips cc. */ if (sh.iss == 0 || has_opaque_xref (fh, &sh)) @@ -2941,11 +2948,11 @@ parse_partial_symbols (objfile, section_offsets) case stUnion: case stStruct: case stEnum: - case stBlock: /* { }, str, un, enum*/ + case stBlock: /* { }, str, un, enum */ /* Do not create a partial symbol for cc unnamed aggregates and gcc empty aggregates. */ if ((sh.sc == scInfo - || SC_IS_COMMON(sh.sc)) + || SC_IS_COMMON (sh.sc)) && sh.iss != 0 && sh.index != cur_sdx + 2) { @@ -3013,7 +3020,7 @@ parse_partial_symbols (objfile, section_offsets) psh = &ext_ptr->asym; /* Do not add undefined symbols to the partial symbol table. */ - if (SC_IS_UNDEF(psh->sc) || psh->sc == scNil) + if (SC_IS_UNDEF (psh->sc) || psh->sc == scNil) continue; svalue = psh->value; @@ -3021,18 +3028,18 @@ parse_partial_symbols (objfile, section_offsets) { case scText: case scRConst: - svalue += ANOFFSET (section_offsets, SECT_OFF_TEXT); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); break; case scData: case scSData: case scRData: case scPData: case scXData: - svalue += ANOFFSET (section_offsets, SECT_OFF_DATA); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); break; case scBss: case scSBss: - svalue += ANOFFSET (section_offsets, SECT_OFF_BSS); + svalue += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); break; } @@ -3058,7 +3065,7 @@ parse_partial_symbols (objfile, section_offsets) case stGlobal: /* Global common symbols are resolved by the runtime loader, ignore them. */ - if (SC_IS_COMMON(psh->sc)) + if (SC_IS_COMMON (psh->sc)) continue; class = LOC_STATIC; @@ -3074,11 +3081,11 @@ parse_partial_symbols (objfile, section_offsets) } /* Link pst to FDR. end_psymtab returns NULL if the psymtab was - empty and put on the free list. */ + empty and put on the free list. */ fdr_to_pst[f_idx].pst = end_psymtab (save_pst, - psymtab_include_list, includes_used, + psymtab_include_list, includes_used, -1, save_pst->texthigh, - dependency_list, dependencies_used, textlow_not_set); + dependency_list, dependencies_used, textlow_not_set); includes_used = 0; dependencies_used = 0; @@ -3090,32 +3097,32 @@ parse_partial_symbols (objfile, section_offsets) } /* The objfile has its functions reordered if this partial symbol - table overlaps any other partial symbol table. - We cannot assume a reordered objfile if a partial symbol table - is contained within another partial symbol table, as partial symbol - tables for include files with executable code are contained - within the partial symbol table for the including source file, - and we do not want to flag the objfile reordered for these cases. - - This strategy works well for Irix-5.2 shared libraries, but we - might have to use a more elaborate (and slower) algorithm for - other cases. */ + table overlaps any other partial symbol table. + We cannot assume a reordered objfile if a partial symbol table + is contained within another partial symbol table, as partial symbol + tables for include files with executable code are contained + within the partial symbol table for the including source file, + and we do not want to flag the objfile reordered for these cases. + + This strategy works well for Irix-5.2 shared libraries, but we + might have to use a more elaborate (and slower) algorithm for + other cases. */ save_pst = fdr_to_pst[f_idx].pst; if (save_pst != NULL && save_pst->textlow != 0 && !(objfile->flags & OBJF_REORDERED)) { ALL_OBJFILE_PSYMTABS (objfile, pst) - { - if (save_pst != pst - && save_pst->textlow >= pst->textlow - && save_pst->textlow < pst->texthigh - && save_pst->texthigh > pst->texthigh) - { - objfile->flags |= OBJF_REORDERED; - break; - } - } + { + if (save_pst != pst + && save_pst->textlow >= pst->textlow + && save_pst->textlow < pst->texthigh + && save_pst->texthigh > pst->texthigh) + { + objfile->flags |= OBJF_REORDERED; + break; + } + } } } @@ -3125,7 +3132,7 @@ parse_partial_symbols (objfile, section_offsets) fh = f_idx + debug_info->fdr; pst = fdr_to_pst[f_idx].pst; - if (pst == (struct partial_symtab *)NULL) + if (pst == (struct partial_symtab *) NULL) continue; /* This should catch stabs-in-ecoff. */ @@ -3133,7 +3140,7 @@ parse_partial_symbols (objfile, section_offsets) continue; /* Skip the first file indirect entry as it is a self dependency - for source files or a reverse .h -> .c dependency for header files. */ + for source files or a reverse .h -> .c dependency for header files. */ pst->number_of_dependencies = 0; pst->dependencies = ((struct partial_symtab **) @@ -3159,7 +3166,7 @@ parse_partial_symbols (objfile, section_offsets) continue; /* Do not add to dependeny list if psymtab was empty. */ - if (fdr_to_pst[rh].pst == (struct partial_symtab *)NULL) + if (fdr_to_pst[rh].pst == (struct partial_symtab *) NULL) continue; pst->dependencies[pst->number_of_dependencies++] = fdr_to_pst[rh].pst; } @@ -3186,10 +3193,10 @@ handle_psymbol_enumerators (objfile, fh, stype, svalue) CORE_ADDR svalue; { const bfd_size_type external_sym_size = debug_swap->external_sym_size; - void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) - = debug_swap->swap_sym_in; + void (*const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) + = debug_swap->swap_sym_in; char *ext_sym = ((char *) debug_info->external_sym - + ((fh->isymBase + cur_sdx + 1) * external_sym_size)); + + ((fh->isymBase + cur_sdx + 1) * external_sym_size)); SYMR sh; TIR tir; @@ -3200,12 +3207,12 @@ handle_psymbol_enumerators (objfile, fh, stype, svalue) case stBlock: /* It is an enumerated type if the next symbol entry is a stMember - and its auxiliary index is indexNil or its auxiliary entry - is a plain btNil or btVoid. - Alpha cc -migrate enums are recognized by a zero index and - a zero symbol value. - DU 4.0 cc enums are recognized by a member type of btEnum without - qualifiers and a zero symbol value. */ + and its auxiliary index is indexNil or its auxiliary entry + is a plain btNil or btVoid. + Alpha cc -migrate enums are recognized by a zero index and + a zero symbol value. + DU 4.0 cc enums are recognized by a member type of btEnum without + qualifiers and a zero symbol value. */ (*swap_sym_in) (cur_bfd, ext_sym, &sh); if (sh.st != stMember) return; @@ -3238,7 +3245,7 @@ handle_psymbol_enumerators (objfile, fh, stype, svalue) name = debug_info->ss + cur_fdr->issBase + sh.iss; /* Note that the value doesn't matter for enum constants - in psymtabs, just in symtabs. */ + in psymtabs, just in symtabs. */ add_psymbol_to_list (name, strlen (name), VAR_NAMESPACE, LOC_CONST, &objfile->static_psymbols, 0, @@ -3387,8 +3394,8 @@ psymtab_to_symtab_1 (pst, filename) int type_code = ECOFF_UNMARK_STAB (sh.index); /* We should never get non N_STAB symbols here, but they - should be harmless, so keep process_one_symbol from - complaining about them. */ + should be harmless, so keep process_one_symbol from + complaining about them. */ if (type_code & N_STAB) { process_one_symbol (type_code, 0, valu, name, @@ -3405,9 +3412,9 @@ psymtab_to_symtab_1 (pst, filename) /* Make up special symbol to contain procedure specific info */ struct mips_extra_func_info *e = - ((struct mips_extra_func_info *) - obstack_alloc (¤t_objfile->symbol_obstack, - sizeof (struct mips_extra_func_info))); + ((struct mips_extra_func_info *) + obstack_alloc (¤t_objfile->symbol_obstack, + sizeof (struct mips_extra_func_info))); struct symbol *s = new_symbol (MIPS_EFI_SYMBOL_NAME); memset ((PTR) e, 0, sizeof (struct mips_extra_func_info)); @@ -3430,7 +3437,7 @@ psymtab_to_symtab_1 (pst, filename) else { /* Handle encoded stab line number. */ - valu += ANOFFSET (pst->section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (pst->section_offsets, SECT_OFF_TEXT (pst->objfile)); record_line (current_subfile, sh.index, valu); } } @@ -3441,18 +3448,18 @@ psymtab_to_symtab_1 (pst, filename) else complain (&stab_unknown_complaint, name); } - st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT); + st = end_symtab (pst->texthigh, pst->objfile, SECT_OFF_TEXT (pst->objfile)); end_stabs (); /* Sort the symbol table now, we are done adding symbols to it. - We must do this before parse_procedure calls lookup_symbol. */ + We must do this before parse_procedure calls lookup_symbol. */ sort_symtab_syms (st); /* There used to be a call to sort_blocks here, but this should not - be necessary for stabs symtabs. And as sort_blocks modifies the - start address of the GLOBAL_BLOCK to the FIRST_LOCAL_BLOCK, - it did the wrong thing if the first procedure in a file was - generated via asm statements. */ + be necessary for stabs symtabs. And as sort_blocks modifies the + start address of the GLOBAL_BLOCK to the FIRST_LOCAL_BLOCK, + it did the wrong thing if the first procedure in a file was + generated via asm statements. */ /* Fill in procedure info next. */ if (fh->cpd > 0) @@ -3478,7 +3485,7 @@ psymtab_to_symtab_1 (pst, filename) (*swap_pdr_in) (cur_bfd, pdr_ptr, pdr_in); /* Determine lowest PDR address, the PDRs are not always - sorted. */ + sorted. */ if (pdr_in == pr_block) lowest_pdr_addr = pdr_in->adr; else if (pdr_in->adr < lowest_pdr_addr) @@ -3556,7 +3563,7 @@ psymtab_to_symtab_1 (pst, filename) (*swap_sym_in) (cur_bfd, sym_ptr, &sh); c = parse_symbol (&sh, debug_info->external_aux + fh->iauxBase, - sym_ptr, fh->fBigendian, pst->section_offsets); + sym_ptr, fh->fBigendian, pst->section_offsets, pst->objfile); sym_ptr += c * external_sym_size; } @@ -3611,8 +3618,8 @@ psymtab_to_symtab_1 (pst, filename) LINETABLE (st) = lines; /* .. and our share of externals. - XXX use the global list to speed up things here. how? - FIXME, Maybe quit once we have found the right number of ext's? */ + XXX use the global list to speed up things here. how? + FIXME, Maybe quit once we have found the right number of ext's? */ top_stack->cur_st = st; top_stack->cur_block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (top_stack->cur_st), GLOBAL_BLOCK); @@ -3624,11 +3631,11 @@ psymtab_to_symtab_1 (pst, filename) ext_ptr = PST_PRIVATE (pst)->extern_tab; for (i = PST_PRIVATE (pst)->extern_count; --i >= 0; ext_ptr++) - parse_external (ext_ptr, fh->fBigendian, pst->section_offsets); + parse_external (ext_ptr, fh->fBigendian, pst->section_offsets, pst->objfile); /* If there are undefined symbols, tell the user. - The alpha has an undefined symbol for every symbol that is - from a shared library, so tell the user only if verbose is on. */ + The alpha has an undefined symbol for every symbol that is + from a shared library, so tell the user only if verbose is on. */ if (info_verbose && n_undef_symbols) { printf_filtered ("File %s contains %d unresolved references:", @@ -3642,7 +3649,7 @@ psymtab_to_symtab_1 (pst, filename) st->primary = 1; - /* Sort the symbol table now, we are done adding symbols to it.*/ + /* Sort the symbol table now, we are done adding symbols to it. */ sort_symtab_syms (st); sort_blocks (st); @@ -3712,7 +3719,7 @@ cross_ref (fd, ax, tpp, type_code, pname, bigend, sym_name) int xref_fd; struct mdebug_pending *pend; - *tpp = (struct type *)NULL; + *tpp = (struct type *) NULL; (*debug_swap->swap_rndx_in) (bigend, &ax->a_rndx, rn); @@ -3776,7 +3783,7 @@ cross_ref (fd, ax, tpp, type_code, pname, bigend, sym_name) || (sh.st != stBlock && sh.st != stTypedef && sh.st != stIndirect && sh.st != stStruct && sh.st != stUnion && sh.st != stEnum)) - && (sh.st != stBlock || !SC_IS_COMMON(sh.sc))) + && (sh.st != stBlock || !SC_IS_COMMON (sh.sc))) { /* File indirect entry is corrupt. */ *pname = ""; @@ -3801,14 +3808,14 @@ cross_ref (fd, ax, tpp, type_code, pname, bigend, sym_name) /* alpha cc puts out a stTypedef with a sh.iss of zero for two cases: a) forward declarations of structs/unions/enums which are not - defined in this compilation unit. - For these the type will be void. This is a bad design decision - as cross referencing across compilation units is impossible - due to the missing name. + defined in this compilation unit. + For these the type will be void. This is a bad design decision + as cross referencing across compilation units is impossible + due to the missing name. b) forward declarations of structs/unions/enums/typedefs which - are defined later in this file or in another file in the same - compilation unit. Irix5 cc uses a stIndirect symbol for this. - Simply cross reference those again to get the true type. + are defined later in this file or in another file in the same + compilation unit. Irix5 cc uses a stIndirect symbol for this. + Simply cross reference those again to get the true type. The forward references are not entered in the pending list and in the symbol table. */ @@ -3823,7 +3830,7 @@ cross_ref (fd, ax, tpp, type_code, pname, bigend, sym_name) case btVoid: *tpp = init_type (type_code, 0, 0, (char *) NULL, current_objfile); - *pname = ""; + *pname = ""; break; case btStruct: @@ -3838,16 +3845,16 @@ cross_ref (fd, ax, tpp, type_code, pname, bigend, sym_name) case btTypedef: /* Follow a forward typedef. This might recursively - call cross_ref till we get a non typedef'ed type. - FIXME: This is not correct behaviour, but gdb currently - cannot handle typedefs without type copying. Type - copying is impossible as we might have mutual forward - references between two files and the copied type would not - get filled in when we later parse its definition. */ + call cross_ref till we get a non typedef'ed type. + FIXME: This is not correct behaviour, but gdb currently + cannot handle typedefs without type copying. Type + copying is impossible as we might have mutual forward + references between two files and the copied type would not + get filled in when we later parse its definition. */ *tpp = parse_type (xref_fd, debug_info->external_aux + fh->iauxBase, sh.index, - (int *)NULL, + (int *) NULL, fh->fBigendian, debug_info->ss + fh->issBase + sh.iss); add_pending (fh, esh, *tpp); @@ -3873,7 +3880,7 @@ cross_ref (fd, ax, tpp, type_code, pname, bigend, sym_name) *tpp = parse_type (xref_fd, debug_info->external_aux + fh->iauxBase, sh.index, - (int *)NULL, + (int *) NULL, fh->fBigendian, debug_info->ss + fh->issBase + sh.iss); } @@ -3946,13 +3953,13 @@ add_symbol (s, b) { complain (&block_overflow_complaint, SYMBOL_NAME (s)); /* In this case shrink_block is actually grow_block, since - BLOCK_NSYMS(b) is larger than its current size. */ + BLOCK_NSYMS(b) is larger than its current size. */ origb = b; b = shrink_block (top_stack->cur_block, top_stack->cur_st); /* Now run through the stack replacing pointers to the - original block. shrink_block has already done this - for the blockvector and BLOCK_FUNCTION. */ + original block. shrink_block has already done this + for the blockvector and BLOCK_FUNCTION. */ for (stackp = top_stack; stackp; stackp = stackp->next) { if (stackp->cur_block == origb) @@ -4116,22 +4123,21 @@ new_symtab (name, maxsyms, maxlines, objfile) s->free_code = free_linetable; s->debugformat = obsavestring ("ECOFF", 5, - &objfile -> symbol_obstack); + &objfile->symbol_obstack); return (s); } /* Allocate a new partial_symtab NAME */ static struct partial_symtab * -new_psymtab (name, objfile, section_offsets) +new_psymtab (name, objfile) char *name; struct objfile *objfile; - struct section_offsets *section_offsets; { struct partial_symtab *psymtab; psymtab = allocate_psymtab (name, objfile); - psymtab->section_offsets = section_offsets; + psymtab->section_offsets = objfile->section_offsets; /* Keep a backpointer to the file's symbols */ @@ -4231,7 +4237,7 @@ shrink_block (b, s) * sizeof (struct symbol *)))); /* Should chase pointers to old one. Fortunately, that`s just - the block`s function and inferior blocks */ + the block`s function and inferior blocks */ if (BLOCK_FUNCTION (new) && SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) == b) SYMBOL_BLOCK_VALUE (BLOCK_FUNCTION (new)) = new; for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); i++) @@ -4280,11 +4286,10 @@ new_type (name) it as normal. */ void -elfmdebug_build_psymtabs (objfile, swap, sec, section_offsets) +elfmdebug_build_psymtabs (objfile, swap, sec) struct objfile *objfile; const struct ecoff_debug_swap *swap; asection *sec; - struct section_offsets *section_offsets; { bfd *abfd = objfile->obfd; struct ecoff_debug_info *info; @@ -4297,7 +4302,7 @@ elfmdebug_build_psymtabs (objfile, swap, sec, section_offsets) error ("Error reading ECOFF debugging information: %s", bfd_errmsg (bfd_get_error ())); - mdebug_build_psymtabs (objfile, swap, info, section_offsets); + mdebug_build_psymtabs (objfile, swap, info); } @@ -4384,8 +4389,8 @@ fixup_sigtramp () /* Make a MIPS_EFI_SYMBOL_NAME entry for it */ { struct mips_extra_func_info *e = - ((struct mips_extra_func_info *) - xzalloc (sizeof (struct mips_extra_func_info))); + ((struct mips_extra_func_info *) + xzalloc (sizeof (struct mips_extra_func_info))); e->numargs = 0; /* the kernel thinks otherwise */ e->pdr.frameoffset = 32; @@ -4418,7 +4423,7 @@ fixup_sigtramp () BLOCK_SYM (b, BLOCK_NSYMS (b)++) = s; } -#endif /* TM_MIPS_H */ +#endif /* TM_MIPS_H */ void _initialize_mdebugread () @@ -4479,7 +4484,7 @@ _initialize_mdebugread () init_type (TYPE_CODE_INT, 8, 0, "long long", (struct objfile *) NULL); - mdebug_type_unsigned_long_long_64 = + mdebug_type_unsigned_long_long_64 = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, "unsigned long long", (struct objfile *) NULL); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 2fd73cf74b..a032dd3511 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -609,15 +609,15 @@ prim_record_minimal_symbol (name, address, ms_type, objfile) case mst_text: case mst_file_text: case mst_solib_trampoline: - section = SECT_OFF_TEXT; + section = SECT_OFF_TEXT (objfile); break; case mst_data: case mst_file_data: - section = SECT_OFF_DATA; + section = SECT_OFF_DATA (objfile); break; case mst_bss: case mst_file_bss: - section = SECT_OFF_BSS; + section = SECT_OFF_BSS (objfile); break; default: section = -1; diff --git a/gdb/mipsread.c b/gdb/mipsread.c index 614c27ec91..9d8f0ff9ea 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -4,21 +4,22 @@ Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major work by Per Bothner, John Gilmore and Ian Lance Taylor at Cygnus Support. -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. */ /* Read symbols from an ECOFF file. Most of the work is done in mdebugread.c. */ @@ -41,6 +42,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "elf/common.h" #include "elf/mips.h" +extern void _initialize_mipsread PARAMS ((void)); + static void mipscoff_new_init PARAMS ((struct objfile *)); @@ -48,15 +51,14 @@ static void mipscoff_symfile_init PARAMS ((struct objfile *)); static void -mipscoff_symfile_read PARAMS ((struct objfile *, struct section_offsets *, - int)); +mipscoff_symfile_read PARAMS ((struct objfile *, int)); static void mipscoff_symfile_finish PARAMS ((struct objfile *)); static void read_alphacoff_dynamic_symtab PARAMS ((struct section_offsets *, - struct objfile *objfile)); + struct objfile * objfile)); /* Initialize anything that needs initializing when a completely new symbol file is specified (not just adding some symbols from another @@ -84,13 +86,12 @@ mipscoff_symfile_init (objfile) /* Read a symbol file from a file. */ static void -mipscoff_symfile_read (objfile, section_offsets, mainline) +mipscoff_symfile_read (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; int mainline; { bfd *abfd = objfile->obfd; - struct cleanup * back_to; + struct cleanup *back_to; init_minimal_symbol_collection (); back_to = make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0); @@ -103,11 +104,11 @@ mipscoff_symfile_read (objfile, section_offsets, mainline) error ("Error reading symbol table: %s", bfd_errmsg (bfd_get_error ())); mdebug_build_psymtabs (objfile, &ecoff_backend (abfd)->debug_swap, - &ecoff_data (abfd)->debug_info, section_offsets); + &ecoff_data (abfd)->debug_info); /* Add alpha coff dynamic symbols. */ - read_alphacoff_dynamic_symtab (section_offsets, objfile); + read_alphacoff_dynamic_symtab (objfile->section_offsets, objfile); /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ @@ -156,35 +157,42 @@ mipscoff_symfile_finish (objfile) /* Format of an alpha external ELF symbol. */ -typedef struct { - unsigned char st_name[4]; /* Symbol name, index in string tbl */ - unsigned char st_pad[4]; /* Pad to long word boundary */ - unsigned char st_value[8]; /* Value of the symbol */ - unsigned char st_size[4]; /* Associated symbol size */ - unsigned char st_info[1]; /* Type and binding attributes */ - unsigned char st_other[1]; /* No defined meaning, 0 */ - unsigned char st_shndx[2]; /* Associated section index */ -} Elfalpha_External_Sym; +typedef struct +{ + unsigned char st_name[4]; /* Symbol name, index in string tbl */ + unsigned char st_pad[4]; /* Pad to long word boundary */ + unsigned char st_value[8]; /* Value of the symbol */ + unsigned char st_size[4]; /* Associated symbol size */ + unsigned char st_info[1]; /* Type and binding attributes */ + unsigned char st_other[1]; /* No defined meaning, 0 */ + unsigned char st_shndx[2]; /* Associated section index */ +} +Elfalpha_External_Sym; /* Format of an alpha external ELF dynamic info structure. */ -typedef struct { - unsigned char d_tag[4]; /* Tag */ - unsigned char d_pad[4]; /* Pad to long word boundary */ - union { - unsigned char d_ptr[8]; /* Pointer value */ - unsigned char d_val[4]; /* Integer value */ - } d_un; -} Elfalpha_External_Dyn; +typedef struct + { + unsigned char d_tag[4]; /* Tag */ + unsigned char d_pad[4]; /* Pad to long word boundary */ + union + { + unsigned char d_ptr[8]; /* Pointer value */ + unsigned char d_val[4]; /* Integer value */ + } + d_un; + } +Elfalpha_External_Dyn; /* Struct to obtain the section pointers for alpha dynamic symbol info. */ -struct alphacoff_dynsecinfo { - asection *sym_sect; /* Section pointer for .dynsym section */ - asection *str_sect; /* Section pointer for .dynstr section */ - asection *dyninfo_sect; /* Section pointer for .dynamic section */ - asection *got_sect; /* Section pointer for .got section */ -}; +struct alphacoff_dynsecinfo + { + asection *sym_sect; /* Section pointer for .dynsym section */ + asection *str_sect; /* Section pointer for .dynstr section */ + asection *dyninfo_sect; /* Section pointer for .dynamic section */ + asection *got_sect; /* Section pointer for .got section */ + }; static void alphacoff_locate_sections PARAMS ((bfd *, asection *, void *)); @@ -257,7 +265,7 @@ read_alphacoff_dynamic_symtab (section_offsets, objfile) /* Locate the dynamic symbols sections and read them in. */ memset ((char *) &si, 0, sizeof (si)); - bfd_map_over_sections (abfd, alphacoff_locate_sections, (PTR) &si); + bfd_map_over_sections (abfd, alphacoff_locate_sections, (PTR) & si); if (si.sym_sect == NULL || si.str_sect == NULL || si.dyninfo_sect == NULL @@ -274,16 +282,16 @@ read_alphacoff_dynamic_symtab (section_offsets, objfile) got_secptr = alloca (got_secsize); if (!bfd_get_section_contents (abfd, si.sym_sect, sym_secptr, - (file_ptr)0, sym_secsize)) + (file_ptr) 0, sym_secsize)) return; if (!bfd_get_section_contents (abfd, si.str_sect, str_secptr, - (file_ptr)0, str_secsize)) + (file_ptr) 0, str_secsize)) return; if (!bfd_get_section_contents (abfd, si.dyninfo_sect, dyninfo_secptr, - (file_ptr)0, dyninfo_secsize)) + (file_ptr) 0, dyninfo_secsize)) return; if (!bfd_get_section_contents (abfd, si.got_sect, got_secptr, - (file_ptr)0, got_secsize)) + (file_ptr) 0, got_secsize)) return; /* Find the number of local GOT entries and the index for the @@ -292,7 +300,7 @@ read_alphacoff_dynamic_symtab (section_offsets, objfile) dyninfo_p < dyninfo_end; dyninfo_p += sizeof (Elfalpha_External_Dyn)) { - Elfalpha_External_Dyn *x_dynp = (Elfalpha_External_Dyn *)dyninfo_p; + Elfalpha_External_Dyn *x_dynp = (Elfalpha_External_Dyn *) dyninfo_p; long dyn_tag; dyn_tag = bfd_h_get_32 (abfd, (bfd_byte *) x_dynp->d_tag); @@ -369,7 +377,7 @@ read_alphacoff_dynamic_symtab (section_offsets, objfile) if (sym_value == 0) { int got_entry_offset = - (i - dt_mips_gotsym + dt_mips_local_gotno) * got_entry_size; + (i - dt_mips_gotsym + dt_mips_local_gotno) * got_entry_size; if (got_entry_offset < 0 || got_entry_offset >= got_secsize) continue; @@ -394,7 +402,7 @@ read_alphacoff_dynamic_symtab (section_offsets, objfile) ms_type = mst_text; else ms_type = mst_file_text; - sym_value += ANOFFSET (section_offsets, SECT_OFF_TEXT); + sym_value += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); } else if (sym_shndx == SHN_MIPS_DATA) { @@ -402,7 +410,7 @@ read_alphacoff_dynamic_symtab (section_offsets, objfile) ms_type = mst_data; else ms_type = mst_file_data; - sym_value += ANOFFSET (section_offsets, SECT_OFF_DATA); + sym_value += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile)); } else if (sym_shndx == SHN_MIPS_ACOMMON) { @@ -410,7 +418,7 @@ read_alphacoff_dynamic_symtab (section_offsets, objfile) ms_type = mst_bss; else ms_type = mst_file_bss; - sym_value += ANOFFSET (section_offsets, SECT_OFF_BSS); + sym_value += ANOFFSET (section_offsets, SECT_OFF_BSS (objfile)); } else if (sym_shndx == SHN_ABS) { diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 41ec317bc5..d307c2ab85 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -305,6 +305,14 @@ allocate_objfile (abfd, flags) } } + /* Initialize the section indexes for this objfile, so that we can + later detect if they are used w/o being properly assigned to. */ + + objfile->sect_index_text = -1; + objfile->sect_index_data = -1; + objfile->sect_index_bss = -1; + objfile->sect_index_rodata = -1; + /* Add this file onto the tail of the linked list of other such files. */ objfile->next = NULL; @@ -591,8 +599,8 @@ objfile_relocate (objfile, new_offsets) ALL_OBJFILE_PSYMTABS (objfile, p) { - p->textlow += ANOFFSET (delta, SECT_OFF_TEXT); - p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT); + p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); + p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); } } @@ -643,41 +651,41 @@ objfile_relocate (objfile, new_offsets) if (flags & SEC_CODE) { - s->addr += ANOFFSET (delta, SECT_OFF_TEXT); - s->endaddr += ANOFFSET (delta, SECT_OFF_TEXT); + s->addr += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); + s->endaddr += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); } else if (flags & (SEC_DATA | SEC_LOAD)) { - s->addr += ANOFFSET (delta, SECT_OFF_DATA); - s->endaddr += ANOFFSET (delta, SECT_OFF_DATA); + s->addr += ANOFFSET (delta, SECT_OFF_DATA (objfile)); + s->endaddr += ANOFFSET (delta, SECT_OFF_DATA (objfile)); } else if (flags & SEC_ALLOC) { - s->addr += ANOFFSET (delta, SECT_OFF_BSS); - s->endaddr += ANOFFSET (delta, SECT_OFF_BSS); + s->addr += ANOFFSET (delta, SECT_OFF_BSS (objfile)); + s->endaddr += ANOFFSET (delta, SECT_OFF_BSS (objfile)); } } } if (objfile->ei.entry_point != ~(CORE_ADDR) 0) - objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT); + objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); if (objfile->ei.entry_func_lowpc != INVALID_ENTRY_LOWPC) { - objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT); - objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT); + objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); + objfile->ei.entry_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); } if (objfile->ei.entry_file_lowpc != INVALID_ENTRY_LOWPC) { - objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT); - objfile->ei.entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT); + objfile->ei.entry_file_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); + objfile->ei.entry_file_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); } if (objfile->ei.main_func_lowpc != INVALID_ENTRY_LOWPC) { - objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT); - objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT); + objfile->ei.main_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); + objfile->ei.main_func_highpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile)); } /* Relocate breakpoints as necessary, after things are relocated. */ diff --git a/gdb/objfiles.h b/gdb/objfiles.h index d1bd4dad2a..b24894a6fd 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -372,6 +372,18 @@ struct objfile struct section_offsets *section_offsets; int num_sections; + /* Indexes in the section_offsets array. These are initialized by the + *_symfile_offsets() family of functions (som_symfile_offsets, + xcoff_symfile_offsets, default_symfile_offsets). In theory they + should correspond to the section indexes used by bfd for the + current objfile. The exception to this for the time being is the + SOM version. */ + + int sect_index_text; + int sect_index_data; + int sect_index_bss; + int sect_index_rodata; + /* These pointers are used to locate the section table, which among other things, is used to map pc addresses into sections. SECTIONS points to the first entry in the table, and @@ -584,4 +596,20 @@ is_in_import_list PARAMS ((char *, struct objfile *)); ALL_OBJFILES (objfile) \ ALL_OBJFILE_OSECTIONS (objfile, osect) +#define SECT_OFF_DATA(objfile) \ + ((objfile->sect_index_data == -1) ? \ + (internal_error ("sect_index_data not initialized"), -1) : objfile->sect_index_data) + +#define SECT_OFF_RODATA(objfile) \ + ((objfile->sect_index_rodata == -1) ? \ + (internal_error ("sect_index_rodata not initialized"), -1) : objfile->sect_index_rodata) + +#define SECT_OFF_TEXT(objfile) \ + ((objfile->sect_index_text == -1) ? \ + (internal_error ("sect_index_text not initialized"), -1) : objfile->sect_index_text) + +#define SECT_OFF_BSS(objfile) \ + ((objfile->sect_index_bss == -1) ? \ + (internal_error ("sect_index_bss not initialized"), -1) : objfile->sect_index_bss) + #endif /* !defined (OBJFILES_H) */ diff --git a/gdb/os9kread.c b/gdb/os9kread.c index 673d415c6e..cbc51a75e0 100644 --- a/gdb/os9kread.c +++ b/gdb/os9kread.c @@ -2,21 +2,22 @@ Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 96, 1998 Free Software Foundation, Inc. -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. */ /* This module provides three functions: os9k_symfile_init, which initializes to read a symbol file; os9k_new_init, which @@ -49,7 +50,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "command.h" #include "target.h" #include "gdbcore.h" /* for bfd stuff */ -#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ +#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ #include "symfile.h" #include "objfiles.h" #include "buildsym.h" @@ -60,6 +61,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "os9k.h" #include "stabsread.h" +extern void _initialize_os9kread PARAMS ((void)); + /* 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. @@ -76,10 +79,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) #define LDSYMCNT(p) (((struct symloc *)((p)->read_symtab_private))->ldsymnum) -struct symloc { - int ldsymoff; - int ldsymnum; -}; +struct symloc + { + int ldsymoff; + int ldsymnum; + }; /* Remember what we deduced to be the source language of this psymtab. */ static enum language psymtab_language = language_unknown; @@ -114,16 +118,16 @@ extern struct complaint repeated_header_name_complaint; #if 0 static struct complaint lbrac_unmatched_complaint = - {"unmatched Increment Block Entry before symtab pos %d", 0, 0}; +{"unmatched Increment Block Entry before symtab pos %d", 0, 0}; static struct complaint lbrac_mismatch_complaint = - {"IBE/IDE symbol mismatch at symtab pos %d", 0, 0}; +{"IBE/IDE symbol mismatch at symtab pos %d", 0, 0}; #endif /* Local function prototypes */ static void -read_minimal_symbols PARAMS ((struct objfile *, struct section_offsets *)); +read_minimal_symbols PARAMS ((struct objfile *)); static void os9k_read_ofile_symtab PARAMS ((struct partial_symtab *)); @@ -135,8 +139,7 @@ static void os9k_psymtab_to_symtab_1 PARAMS ((struct partial_symtab *)); static void -read_os9k_psymtab PARAMS ((struct section_offsets *, struct objfile *, - CORE_ADDR, int)); +read_os9k_psymtab PARAMS ((struct objfile *, CORE_ADDR, int)); static int fill_sym PARAMS ((FILE *, bfd *)); @@ -148,27 +151,26 @@ static void os9k_new_init PARAMS ((struct objfile *)); static void -os9k_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int)); +os9k_symfile_read PARAMS ((struct objfile *, int)); static void os9k_symfile_finish PARAMS ((struct objfile *)); static void -os9k_process_one_symbol PARAMS ((int, int, CORE_ADDR, char *, - struct section_offsets *, struct objfile *)); +os9k_process_one_symbol PARAMS ((int, int, CORE_ADDR, char *, + struct section_offsets *, struct objfile *)); static struct partial_symtab * -os9k_start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *, - CORE_ADDR, int, int, struct partial_symbol **, - struct partial_symbol **)); + os9k_start_psymtab PARAMS ((struct objfile *, char *, + CORE_ADDR, int, int, struct partial_symbol **, + struct partial_symbol **)); static struct partial_symtab * -os9k_end_psymtab PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR, - struct partial_symtab **, int)); + os9k_end_psymtab PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR, + struct partial_symtab **, int)); static void -record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *, - struct section_offsets *)); +record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *)); #define HANDLE_RBRAC(val) \ if ((val) > pst->texthigh) pst->texthigh = (val); @@ -194,115 +196,123 @@ record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *, #define N_ABS 6 static void -record_minimal_symbol (name, address, type, objfile, section_offsets) +record_minimal_symbol (name, address, type, objfile) char *name; CORE_ADDR address; int type; struct objfile *objfile; - struct section_offsets *section_offsets; { enum minimal_symbol_type ms_type; switch (type) { case N_TEXT: - ms_type = mst_text; - address += ANOFFSET(section_offsets, SECT_OFF_TEXT); - break; + ms_type = mst_text; + address += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + break; case N_DATA: - ms_type = mst_data; - break; + ms_type = mst_data; + break; case N_BSS: - ms_type = mst_bss; - break; + ms_type = mst_bss; + break; case N_RDATA: - ms_type = mst_bss; - break; - case N_IDATA: - ms_type = mst_data; - break; + ms_type = mst_bss; + break; + case N_IDATA: + ms_type = mst_data; + break; case N_ABS: - ms_type = mst_abs; - break; + ms_type = mst_abs; + break; default: - ms_type = mst_unknown; break; - } + ms_type = mst_unknown; + break; + } prim_record_minimal_symbol (name, address, ms_type, objfile); } /* read and process .stb file and store in minimal symbol table */ typedef char mhhdr[80]; -struct stbhdr { - mhhdr comhdr; - char * name; - short fmtno; - int crc; - int offset; - int nsym; - char *pad; -}; -struct stbsymbol { - int value; - short type; - int stroff; -}; +struct stbhdr + { + mhhdr comhdr; + char *name; + short fmtno; + int crc; + int offset; + int nsym; + char *pad; + }; +struct stbsymbol + { + int value; + short type; + int stroff; + }; #define STBSYMSIZE 10 static void -read_minimal_symbols(objfile, section_offsets) +read_minimal_symbols (objfile) struct objfile *objfile; - struct section_offsets *section_offsets; { -FILE *fp; -bfd *abfd; -struct stbhdr hdr; -struct stbsymbol sym; -int ch, i, j, off; -char buf[64], buf1[128]; - + FILE *fp; + bfd *abfd; + struct stbhdr hdr; + struct stbsymbol sym; + int ch, i, j, off; + char buf[64], buf1[128]; + fp = objfile->auxf1; - if (fp == NULL) return; + if (fp == NULL) + return; abfd = objfile->obfd; - fread(&hdr.comhdr[0], sizeof(mhhdr), 1, fp); + fread (&hdr.comhdr[0], sizeof (mhhdr), 1, fp); i = 0; - ch = getc(fp); - while (ch != -1) { - buf[i] = (char)ch; - i++; - if (ch == 0) break; - ch = getc(fp); - }; - if (i%2) ch=getc(fp); + ch = getc (fp); + while (ch != -1) + { + buf[i] = (char) ch; + i++; + if (ch == 0) + break; + ch = getc (fp); + }; + if (i % 2) + ch = getc (fp); hdr.name = &buf[0]; - fread(&hdr.fmtno, sizeof(hdr.fmtno), 1, fp); - fread(&hdr.crc, sizeof(hdr.crc), 1, fp); - fread(&hdr.offset, sizeof(hdr.offset), 1, fp); - fread(&hdr.nsym, sizeof(hdr.nsym), 1, fp); - SWAP_STBHDR(&hdr, abfd); - + fread (&hdr.fmtno, sizeof (hdr.fmtno), 1, fp); + fread (&hdr.crc, sizeof (hdr.crc), 1, fp); + fread (&hdr.offset, sizeof (hdr.offset), 1, fp); + fread (&hdr.nsym, sizeof (hdr.nsym), 1, fp); + SWAP_STBHDR (&hdr, abfd); + /* read symbols */ - init_minimal_symbol_collection(); + init_minimal_symbol_collection (); off = hdr.offset; - for (i = hdr.nsym; i > 0; i--) { - fseek(fp, (long)off, 0); - fread(&sym.value, sizeof(sym.value), 1, fp); - fread(&sym.type, sizeof(sym.type), 1, fp); - fread(&sym.stroff, sizeof(sym.stroff), 1, fp); - SWAP_STBSYM (&sym, abfd); - fseek(fp, (long)sym.stroff, 0); - j = 0; - ch = getc(fp); - while (ch != -1) { - buf1[j] = (char)ch; - j++; - if (ch == 0) break; - ch = getc(fp); + for (i = hdr.nsym; i > 0; i--) + { + fseek (fp, (long) off, 0); + fread (&sym.value, sizeof (sym.value), 1, fp); + fread (&sym.type, sizeof (sym.type), 1, fp); + fread (&sym.stroff, sizeof (sym.stroff), 1, fp); + SWAP_STBSYM (&sym, abfd); + fseek (fp, (long) sym.stroff, 0); + j = 0; + ch = getc (fp); + while (ch != -1) + { + buf1[j] = (char) ch; + j++; + if (ch == 0) + break; + ch = getc (fp); + }; + record_minimal_symbol (buf1, sym.value, sym.type & 7, objfile); + off += STBSYMSIZE; }; - record_minimal_symbol(buf1, sym.value, sym.type&7, objfile, section_offsets); - off += STBSYMSIZE; - }; install_minimal_symbols (objfile); return; } @@ -312,35 +322,32 @@ char buf[64], buf1[128]; put all the relevant info into a "struct os9k_symfile_info", hung off the objfile structure. - 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). */ static void -os9k_symfile_read (objfile, section_offsets, mainline) +os9k_symfile_read (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; - int mainline; /* FIXME comments above */ + int mainline; /* FIXME comments above */ { bfd *sym_bfd; struct cleanup *back_to; sym_bfd = objfile->obfd; /* If we are reinitializing, or if we have never loaded syms yet, init */ - 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, DBX_SYMCOUNT (objfile)); free_pending_blocks (); - back_to = make_cleanup ((make_cleanup_func) really_free_pendings, 0); + back_to = make_cleanup (really_free_pendings, 0); make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0); - read_minimal_symbols (objfile, section_offsets); + read_minimal_symbols (objfile); /* Now that the symbol table data of the executable file are all in core, process them and define symbols accordingly. */ - read_os9k_psymtab (section_offsets, objfile, + read_os9k_psymtab (objfile, DBX_TEXT_ADDR (objfile), DBX_TEXT_SIZE (objfile)); @@ -359,8 +366,8 @@ os9k_new_init (ignore) buildsym_new_init (); psymfile_depth = 0; /* - init_header_files (); -*/ + init_header_files (); + */ } /* os9k_symfile_init () @@ -384,24 +391,26 @@ os9k_symfile_init (objfile) FILE *minfile = 0; asection *text_sect; - strcpy(dbgname, name); - strcat(dbgname, ".dbg"); - strcpy(stbname, name); - strcat(stbname, ".stb"); + strcpy (dbgname, name); + strcat (dbgname, ".dbg"); + strcpy (stbname, name); + strcat (stbname, ".stb"); - if ((symfile = fopen(dbgname, "r")) == NULL) { - warning("Symbol file %s not found", dbgname); - } + if ((symfile = fopen (dbgname, "r")) == NULL) + { + warning ("Symbol file %s not found", dbgname); + } objfile->auxf2 = symfile; - if ((minfile = fopen(stbname, "r")) == NULL) { - warning("Symbol file %s not found", stbname); - } + if ((minfile = fopen (stbname, "r")) == NULL) + { + warning ("Symbol file %s not found", stbname); + } objfile->auxf1 = minfile; /* Allocate struct to keep track of the symfile */ objfile->sym_stab_info = (struct dbx_symfile_info *) - xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info)); + xmmalloc (objfile->md, sizeof (struct dbx_symfile_info)); DBX_SYMFILE_INFO (objfile)->stab_section_info = NULL; text_sect = bfd_get_section_by_name (sym_bfd, ".text"); @@ -410,9 +419,9 @@ os9k_symfile_init (objfile) DBX_TEXT_ADDR (objfile) = bfd_section_vma (sym_bfd, text_sect); DBX_TEXT_SIZE (objfile) = bfd_section_size (sym_bfd, text_sect); - DBX_SYMBOL_SIZE (objfile) = 0; /* variable size symbol */ - DBX_SYMCOUNT (objfile) = 0; /* used to be bfd_get_symcount(sym_bfd) */ - DBX_SYMTAB_OFFSET (objfile) = 0; /* used to be SYMBOL_TABLE_OFFSET */ + DBX_SYMBOL_SIZE (objfile) = 0; /* variable size symbol */ + DBX_SYMCOUNT (objfile) = 0; /* used to be bfd_get_symcount(sym_bfd) */ + DBX_SYMTAB_OFFSET (objfile) = 0; /* used to be SYMBOL_TABLE_OFFSET */ } /* Perform any local cleanups required when we are done with a particular @@ -426,15 +435,16 @@ os9k_symfile_finish (objfile) { if (objfile->sym_stab_info != NULL) { - mfree (objfile -> md, objfile->sym_stab_info); + mfree (objfile->md, objfile->sym_stab_info); } /* - free_header_files (); -*/ + free_header_files (); + */ } - -struct st_dbghdr { + +struct st_dbghdr +{ int sync; short rev; int crc; @@ -459,12 +469,13 @@ struct st_dbghdr { #define N_SYM_RBRAC 4 #define N_SYM_SE 5 -struct internal_symstruct { - short n_type; - short n_desc; - long n_value; - char * n_strx; -}; +struct internal_symstruct + { + short n_type; + short n_desc; + long n_value; + char *n_strx; + }; static struct internal_symstruct symbol; static struct internal_symstruct *symbuf = &symbol; static char strbuf[4096]; @@ -479,12 +490,12 @@ fill_sym (dbg_file, abfd) FILE *dbg_file; bfd *abfd; { -short si, nmask; -long li; -int ii; -char *p; + short si, nmask; + long li; + int ii; + char *p; - int nbytes = fread(&si, sizeof(si), 1, dbg_file); + int nbytes = fread (&si, sizeof (si), 1, dbg_file); if (nbytes == 0) return 0; if (nbytes < 0) @@ -492,71 +503,71 @@ char *p; symbuf->n_desc = 0; symbuf->n_value = 0; symbuf->n_strx = NULL; - symbuf->n_type = bfd_get_16 (abfd, (unsigned char *)&si); + symbuf->n_type = bfd_get_16 (abfd, (unsigned char *) &si); symbuf->n_type = 0xf & symbuf->n_type; switch (symbuf->n_type) { case N_SYM_CMPLR: - fread(&si, sizeof(si), 1, dbg_file); - symbuf->n_desc = bfd_get_16(abfd, (unsigned char *)&si); + fread (&si, sizeof (si), 1, dbg_file); + symbuf->n_desc = bfd_get_16 (abfd, (unsigned char *) &si); cmplrid = symbuf->n_desc & 0xff; break; case N_SYM_SLINE: - fread(&li, sizeof(li), 1, dbg_file); - symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li); - fread(&li, sizeof(li), 1, dbg_file); - li = bfd_get_32(abfd, (unsigned char *)&li); - symbuf->n_strx = (char *)(li >> 12); + fread (&li, sizeof (li), 1, dbg_file); + symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li); + fread (&li, sizeof (li), 1, dbg_file); + li = bfd_get_32 (abfd, (unsigned char *) &li); + symbuf->n_strx = (char *) (li >> 12); symbuf->n_desc = li & 0xfff; break; case N_SYM_SYM: - fread(&li, sizeof(li), 1, dbg_file); - symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li); + fread (&li, sizeof (li), 1, dbg_file); + symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li); si = 0; - do { - ii = getc(dbg_file); - strbuf[si++] = (char) ii; - } while (ii != 0 || si % 2 != 0); + do + { + ii = getc (dbg_file); + strbuf[si++] = (char) ii; + } + while (ii != 0 || si % 2 != 0); symbuf->n_strx = strbuf; p = (char *) strchr (strbuf, ':'); - if (!p) break; + if (!p) + break; if ((p[1] == 'F' || p[1] == 'f') && cmplrid == VER_PRE_ULTRAC) { - fread(&si, sizeof(si), 1, dbg_file); - nmask = bfd_get_16(abfd, (unsigned char *)&si); - for (ii=0; iin_value = bfd_get_32(abfd, (unsigned char *)&li); + fread (&li, sizeof (li), 1, dbg_file); + symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li); break; case N_SYM_RBRAC: - fread(&li, sizeof(li), 1, dbg_file); - symbuf->n_value = bfd_get_32(abfd, (unsigned char *)&li); + fread (&li, sizeof (li), 1, dbg_file); + symbuf->n_value = bfd_get_32 (abfd, (unsigned char *) &li); break; case N_SYM_SE: break; } - return 1; + return 1; } /* Given pointers to an a.out symbol table in core containing dbx style data, setup partial_symtab's describing each source file for which debugging information is available. - SYMFILE_NAME is the name of the file we are reading from - and SECTION_OFFSETS is the set of offsets for the various sections - of the file (a set of zeros if the mainline program). */ + SYMFILE_NAME is the name of the file we are reading from. */ static void -read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) - struct section_offsets *section_offsets; +read_os9k_psymtab (objfile, text_addr, text_size) struct objfile *objfile; CORE_ADDR text_addr; int text_size; { - register struct internal_symstruct *bufp = 0; /* =0 avoids gcc -Wall glitch*/ + register struct internal_symstruct *bufp = 0; /* =0 avoids gcc -Wall glitch */ register char *namestring; int past_first_source_file = 0; CORE_ADDR last_o_file_start = 0; @@ -597,67 +608,71 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) #ifdef END_OF_TEXT_DEFAULT end_of_text_addr = END_OF_TEXT_DEFAULT; #else - end_of_text_addr = text_addr + section_offsets->offsets[SECT_OFF_TEXT] - + text_size; /* Relocate */ + end_of_text_addr = text_addr + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)) + + text_size; /* Relocate */ #endif abfd = objfile->obfd; - fp = objfile->auxf2; - if (!fp) return; - - fread(&dbghdr.sync, sizeof(dbghdr.sync), 1, fp); - fread(&dbghdr.rev, sizeof(dbghdr.rev), 1, fp); - fread(&dbghdr.crc, sizeof(dbghdr.crc), 1, fp); - fread(&dbghdr.os, sizeof(dbghdr.os), 1, fp); - fread(&dbghdr.cpu, sizeof(dbghdr.cpu), 1, fp); - SWAP_DBGHDR(&dbghdr, abfd); + fp = objfile->auxf2; + if (!fp) + return; + + fread (&dbghdr.sync, sizeof (dbghdr.sync), 1, fp); + fread (&dbghdr.rev, sizeof (dbghdr.rev), 1, fp); + fread (&dbghdr.crc, sizeof (dbghdr.crc), 1, fp); + fread (&dbghdr.os, sizeof (dbghdr.os), 1, fp); + fread (&dbghdr.cpu, sizeof (dbghdr.cpu), 1, fp); + SWAP_DBGHDR (&dbghdr, abfd); symnum = 0; - while(1) + while (1) { - int ret; - long cursymoffset; + int ret; + long cursymoffset; /* Get the symbol for this run and pull out some info */ - QUIT; /* allow this to be interruptable */ - cursymoffset = ftell(objfile->auxf2); - ret = fill_sym(objfile->auxf2, abfd); - if (ret <= 0) break; - else symnum++; + QUIT; /* allow this to be interruptable */ + cursymoffset = ftell (objfile->auxf2); + ret = fill_sym (objfile->auxf2, abfd); + if (ret <= 0) + break; + else + symnum++; bufp = symbuf; /* Special case to speed up readin. */ - if (bufp->n_type == (short)N_SYM_SLINE) continue; + if (bufp->n_type == (short) N_SYM_SLINE) + continue; #define CUR_SYMBOL_VALUE bufp->n_value /* partial-stab.h */ switch (bufp->n_type) { - char *p; + char *p; case N_SYM_CMPLR: continue; case N_SYM_SE: - CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); if (psymfile_depth == 1 && pst) { os9k_end_psymtab (pst, psymtab_include_list, includes_used, - symnum, CUR_SYMBOL_VALUE, - dependency_list, dependencies_used); + symnum, CUR_SYMBOL_VALUE, + dependency_list, dependencies_used); pst = (struct partial_symtab *) 0; includes_used = 0; dependencies_used = 0; } - psymfile_depth--; + psymfile_depth--; continue; - case N_SYM_SYM: /* Typedef or automatic variable. */ + case N_SYM_SYM: /* Typedef or automatic variable. */ namestring = bufp->n_strx; - p = (char *) strchr (namestring, ':'); - if (!p) - continue; /* Not a debugging symbol. */ + p = (char *) strchr (namestring, ':'); + if (!p) + continue; /* Not a debugging symbol. */ /* Main processing section for debugging symbols which the initial read through the symbol tables needs to worry @@ -668,69 +683,74 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) switch (p[1]) { - case 'S' : + case 'S': { unsigned long valu; - enum language tmp_language; + enum language tmp_language; char *str, *p; int n; - + valu = CUR_SYMBOL_VALUE; if (valu) - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); past_first_source_file = 1; - p = strchr(namestring, ':'); - if (p) n = p-namestring; - else n = strlen(namestring); - str = alloca(n+1); - strncpy(str, namestring, n); - str[n] = '\0'; - - if (psymfile_depth == 0) { - if (!pst) - pst = os9k_start_psymtab (objfile, section_offsets, - str, valu, - cursymoffset, - symnum-1, - objfile -> global_psymbols.next, - objfile -> static_psymbols.next); - } else { /* this is a include file */ - tmp_language = deduce_language_from_filename (str); - if (tmp_language != language_unknown - && (tmp_language != language_c - || psymtab_language != language_cplus)) - psymtab_language = tmp_language; + p = strchr (namestring, ':'); + if (p) + n = p - namestring; + else + n = strlen (namestring); + str = alloca (n + 1); + strncpy (str, namestring, n); + str[n] = '\0'; -/* - if (pst && STREQ (str, pst->filename)) - continue; + if (psymfile_depth == 0) { - register int i; - for (i = 0; i < includes_used; i++) - if (STREQ (str, psymtab_include_list[i])) - { - i = -1; - break; - } - if (i == -1) - continue; + if (!pst) + pst = os9k_start_psymtab (objfile, + str, valu, + cursymoffset, + symnum - 1, + objfile->global_psymbols.next, + objfile->static_psymbols.next); } -*/ - - psymtab_include_list[includes_used++] = str; - if (includes_used >= includes_allocated) - { - char **orig = psymtab_include_list; + else + { /* this is a include file */ + tmp_language = deduce_language_from_filename (str); + if (tmp_language != language_unknown + && (tmp_language != language_c + || psymtab_language != language_cplus)) + psymtab_language = tmp_language; - psymtab_include_list = (char **) - alloca ((includes_allocated *= 2) * sizeof (char *)); - memcpy ((PTR)psymtab_include_list, (PTR)orig, - includes_used * sizeof (char *)); - } +/* + if (pst && STREQ (str, pst->filename)) + continue; + { + register int i; + for (i = 0; i < includes_used; i++) + if (STREQ (str, psymtab_include_list[i])) + { + i = -1; + break; + } + if (i == -1) + continue; + } + */ + + psymtab_include_list[includes_used++] = str; + if (includes_used >= includes_allocated) + { + char **orig = psymtab_include_list; + + psymtab_include_list = (char **) + alloca ((includes_allocated *= 2) * sizeof (char *)); + memcpy ((PTR) psymtab_include_list, (PTR) orig, + includes_used * sizeof (char *)); + } - } - psymfile_depth++; + } + psymfile_depth++; continue; } @@ -763,7 +783,7 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) add_psymbol_to_list (namestring, p - namestring, VAR_NAMESPACE, LOC_TYPEDEF, &objfile->static_psymbols, - CUR_SYMBOL_VALUE, 0, psymtab_language, + CUR_SYMBOL_VALUE, 0, psymtab_language, objfile); p += 1; } @@ -773,14 +793,14 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) We make the typedef here so that "ptype foo" works as expected for cfront translated code. */ else if (psymtab_language == language_cplus) - { + { /* Also a typedef with the same name. */ add_psymbol_to_list (namestring, p - namestring, VAR_NAMESPACE, LOC_TYPEDEF, &objfile->static_psymbols, - CUR_SYMBOL_VALUE, 0, psymtab_language, + CUR_SYMBOL_VALUE, 0, psymtab_language, objfile); - } + } } goto check_enum; case 't': @@ -794,22 +814,22 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) } check_enum: /* If this is an enumerated type, we need to - add all the enum constants to the partial symbol - table. This does not cover enums without names, e.g. - "enum {a, b} c;" in C, but fortunately those are - rare. There is no way for GDB to find those from the - enum type without spending too much time on it. Thus - to solve this problem, the compiler needs to put out the - enum in a nameless type. GCC2 does this. */ + add all the enum constants to the partial symbol + table. This does not cover enums without names, e.g. + "enum {a, b} c;" in C, but fortunately those are + rare. There is no way for GDB to find those from the + enum type without spending too much time on it. Thus + to solve this problem, the compiler needs to put out the + enum in a nameless type. GCC2 does this. */ /* We are looking for something of the form - ":" ("t" | "T") [ "="] "e" - { ":" ","} ";". */ + ":" ("t" | "T") [ "="] "e" + { ":" ","} ";". */ /* Skip over the colon and the 't' or 'T'. */ p += 2; /* This type may be given a number. Also, numbers can come - in pairs like (0,26). Skip over it. */ + in pairs like (0,26). Skip over it. */ while ((*p >= '0' && *p <= '9') || *p == '(' || *p == ',' || *p == ')' || *p == '=') @@ -818,7 +838,8 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) if (*p++ == 'e') { /* We have found an enumerated type. skip size */ - while (*p >= '0' && *p <= '9') p++; + while (*p >= '0' && *p <= '9') + p++; /* According to comments in read_enum_type a comma could end it instead of a semicolon. I don't know where that happens. @@ -828,17 +849,17 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) char *q; /* Check for and handle cretinous dbx symbol name - continuation! - if (*p == '\\') - p = next_symbol_text (objfile); - */ + continuation! + if (*p == '\\') + p = next_symbol_text (objfile); + */ /* Point to the character after the name - of the enum constant. */ + of the enum constant. */ for (q = p; *q && *q != ':'; q++) ; /* Note that the value doesn't matter for - enum constants in psymtabs, just in symtabs. */ + enum constants in psymtabs, just in symtabs. */ add_psymbol_to_list (p, q - p, VAR_NAMESPACE, LOC_CONST, &objfile->static_psymbols, 0, @@ -858,63 +879,63 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) /* Constant, e.g. from "const" in Pascal. */ add_psymbol_to_list (namestring, p - namestring, VAR_NAMESPACE, LOC_CONST, - &objfile->static_psymbols, CUR_SYMBOL_VALUE, + &objfile->static_psymbols, CUR_SYMBOL_VALUE, 0, psymtab_language, objfile); continue; case 'f': - CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); - if (pst && pst->textlow == 0) - pst->textlow = CUR_SYMBOL_VALUE; + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + if (pst && pst->textlow == 0) + pst->textlow = CUR_SYMBOL_VALUE; add_psymbol_to_list (namestring, p - namestring, VAR_NAMESPACE, LOC_BLOCK, - &objfile->static_psymbols, CUR_SYMBOL_VALUE, + &objfile->static_psymbols, CUR_SYMBOL_VALUE, 0, psymtab_language, objfile); continue; case 'F': - CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); - if (pst && pst->textlow == 0) - pst->textlow = CUR_SYMBOL_VALUE; + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + if (pst && pst->textlow == 0) + pst->textlow = CUR_SYMBOL_VALUE; add_psymbol_to_list (namestring, p - namestring, VAR_NAMESPACE, LOC_BLOCK, - &objfile->global_psymbols, CUR_SYMBOL_VALUE, + &objfile->global_psymbols, CUR_SYMBOL_VALUE, 0, psymtab_language, objfile); continue; case 'p': case 'l': - case 's': + case 's': continue; case ':': /* It is a C++ nested symbol. We don't need to record it - (I don't think); if we try to look up foo::bar::baz, - then symbols for the symtab containing foo should get - read in, I think. */ + (I don't think); if we try to look up foo::bar::baz, + then symbols for the symtab containing foo should get + read in, I think. */ /* Someone says sun cc puts out symbols like - /foo/baz/maclib::/usr/local/bin/maclib, - which would get here with a symbol type of ':'. */ + /foo/baz/maclib::/usr/local/bin/maclib, + which would get here with a symbol type of ':'. */ continue; default: /* Unexpected symbol descriptor. The second and subsequent stabs - of a continued stab can show up here. The question is - whether they ever can mimic a normal stab--it would be - nice if not, since we certainly don't want to spend the - time searching to the end of every string looking for - a backslash. */ + of a continued stab can show up here. The question is + whether they ever can mimic a normal stab--it would be + nice if not, since we certainly don't want to spend the + time searching to the end of every string looking for + a backslash. */ complain (&unknown_symchar_complaint, p[1]); continue; } case N_SYM_RBRAC: - CUR_SYMBOL_VALUE += ANOFFSET(section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); #ifdef HANDLE_RBRAC - HANDLE_RBRAC(CUR_SYMBOL_VALUE); + HANDLE_RBRAC (CUR_SYMBOL_VALUE); continue; #endif case N_SYM_LBRAC: @@ -935,22 +956,22 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) if (DBX_SYMCOUNT (objfile) > 0 /*FIXME, does this have a bug at start address 0? */ && last_o_file_start - && objfile -> ei.entry_point < bufp->n_value - && objfile -> ei.entry_point >= last_o_file_start) + && objfile->ei.entry_point < bufp->n_value + && objfile->ei.entry_point >= last_o_file_start) { - objfile -> ei.entry_file_lowpc = last_o_file_start; - objfile -> ei.entry_file_highpc = bufp->n_value; + objfile->ei.entry_file_lowpc = last_o_file_start; + objfile->ei.entry_file_highpc = bufp->n_value; } if (pst) { os9k_end_psymtab (pst, psymtab_include_list, includes_used, - symnum, end_of_text_addr, - dependency_list, dependencies_used); + symnum, end_of_text_addr, + dependency_list, dependencies_used); } /* - do_cleanups (back_to); -*/ + do_cleanups (back_to); + */ } /* Allocate and partially fill a partial symtab. It will be @@ -962,10 +983,9 @@ read_os9k_psymtab (section_offsets, objfile, text_addr, text_size) static struct partial_symtab * -os9k_start_psymtab (objfile, section_offsets, - filename, textlow, ldsymoff,ldsymcnt, global_syms, static_syms) +os9k_start_psymtab (objfile, + filename, textlow, ldsymoff, ldsymcnt, global_syms, static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; CORE_ADDR textlow; int ldsymoff; @@ -974,14 +994,14 @@ os9k_start_psymtab (objfile, section_offsets, struct partial_symbol **static_syms; { struct partial_symtab *result = - start_psymtab_common(objfile, section_offsets, - filename, textlow, global_syms, static_syms); + start_psymtab_common (objfile, objfile->section_offsets, + filename, textlow, global_syms, static_syms); result->read_symtab_private = (char *) - obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct symloc)); + obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc)); - LDSYMOFF(result) = ldsymoff; - LDSYMCNT(result) = ldsymcnt; + LDSYMOFF (result) = ldsymoff; + LDSYMCNT (result) = ldsymcnt; result->read_symtab = os9k_psymtab_to_symtab; /* Deduce the source language from the filename for this psymtab. */ @@ -995,7 +1015,7 @@ os9k_start_psymtab (objfile, section_offsets, static struct partial_symtab * os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, - capping_text, dependency_list, number_dependencies) + capping_text, dependency_list, number_dependencies) struct partial_symtab *pst; char **include_list; int num_includes; @@ -1007,10 +1027,10 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, { int i; struct partial_symtab *p1; - struct objfile *objfile = pst -> objfile; + struct objfile *objfile = pst->objfile; if (capping_symbol_cnt != -1) - LDSYMCNT(pst) = capping_symbol_cnt - LDSYMCNT(pst); + LDSYMCNT (pst) = capping_symbol_cnt - LDSYMCNT (pst); /* Under Solaris, the N_SO symbols always have a value of 0, instead of the usual address of the .o file. Therefore, @@ -1035,45 +1055,49 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, down the partial_symtab_list filling in previous texthighs that are still unknown. */ - if (pst->texthigh == 0 && last_function_name) { - char *p; - int n; - struct minimal_symbol *minsym; - - p = strchr (last_function_name, ':'); - if (p == NULL) - p = last_function_name; - n = p - last_function_name; - p = alloca (n + 1); - strncpy (p, last_function_name, n); - p[n] = 0; - - minsym = lookup_minimal_symbol (p, NULL, objfile); - - if (minsym) { - pst->texthigh = SYMBOL_VALUE_ADDRESS(minsym)+(long)MSYMBOL_INFO(minsym); - } else { - /* This file ends with a static function, and it's - difficult to imagine how hard it would be to track down - the elf symbol. Luckily, most of the time no one will notice, - since the next file will likely be compiled with -g, so - the code below will copy the first fuction's start address - back to our texthigh variable. (Also, if this file is the - last one in a dynamically linked program, texthigh already - has the right value.) If the next file isn't compiled - with -g, then the last function in this file winds up owning - all of the text space up to the next -g file, or the end (minus - shared libraries). This only matters for single stepping, - and even then it will still work, except that it will single - step through all of the covered functions, instead of setting - breakpoints around them as it usualy does. This makes it - pretty slow, but at least it doesn't fail. - - We can fix this with a fairly big change to bfd, but we need - to coordinate better with Cygnus if we want to do that. FIXME. */ + if (pst->texthigh == 0 && last_function_name) + { + char *p; + int n; + struct minimal_symbol *minsym; + + p = strchr (last_function_name, ':'); + if (p == NULL) + p = last_function_name; + n = p - last_function_name; + p = alloca (n + 1); + strncpy (p, last_function_name, n); + p[n] = 0; + + minsym = lookup_minimal_symbol (p, NULL, objfile); + + if (minsym) + { + pst->texthigh = SYMBOL_VALUE_ADDRESS (minsym) + (long) MSYMBOL_INFO (minsym); + } + else + { + /* This file ends with a static function, and it's + difficult to imagine how hard it would be to track down + the elf symbol. Luckily, most of the time no one will notice, + since the next file will likely be compiled with -g, so + the code below will copy the first fuction's start address + back to our texthigh variable. (Also, if this file is the + last one in a dynamically linked program, texthigh already + has the right value.) If the next file isn't compiled + with -g, then the last function in this file winds up owning + all of the text space up to the next -g file, or the end (minus + shared libraries). This only matters for single stepping, + and even then it will still work, except that it will single + step through all of the covered functions, instead of setting + breakpoints around them as it usualy does. This makes it + pretty slow, but at least it doesn't fail. + + We can fix this with a fairly big change to bfd, but we need + to coordinate better with Cygnus if we want to do that. FIXME. */ + } + last_function_name = NULL; } - last_function_name = NULL; - } /* this test will be true if the last .o file is only data */ if (pst->textlow == 0) @@ -1084,16 +1108,19 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, address, set it to our starting address. Take care to not set our own ending address to our starting address, nor to set addresses on `dependency' files that have both textlow and texthigh zero. */ - if (pst->textlow) { - ALL_OBJFILE_PSYMTABS (objfile, p1) { - if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst) { - p1->texthigh = pst->textlow; - /* if this file has only data, then make textlow match texthigh */ - if (p1->textlow == 0) - p1->textlow = p1->texthigh; + if (pst->textlow) + { + ALL_OBJFILE_PSYMTABS (objfile, p1) + { + if (p1->texthigh == 0 && p1->textlow != 0 && p1 != pst) + { + p1->texthigh = pst->textlow; + /* if this file has only data, then make textlow match texthigh */ + if (p1->textlow == 0) + p1->textlow = p1->texthigh; + } } } - } /* End of kludge for patching Solaris textlow and texthigh. */ @@ -1107,9 +1134,9 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, { 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; @@ -1117,19 +1144,19 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, 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) = - LDSYMCNT(subpst) = - subpst->textlow = - subpst->texthigh = 0; + (char *) obstack_alloc (&objfile->psymbol_obstack, + sizeof (struct symloc)); + LDSYMOFF (subpst) = + LDSYMCNT (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 *)); @@ -1138,8 +1165,8 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, 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; @@ -1155,17 +1182,18 @@ os9k_end_psymtab (pst, include_list, num_includes, capping_symbol_cnt, free_named_symtabs (pst->filename); if (num_includes == 0 - && number_dependencies == 0 - && pst->n_global_syms == 0 - && 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. */ - /* Indicate that psymtab was thrown away. */ + && number_dependencies == 0 + && pst->n_global_syms == 0 + && 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. */ + /* Indicate that psymtab was thrown away. */ - discard_psymtab (pst); + discard_psymtab (pst); - pst = (struct partial_symtab *)NULL; - } + pst = (struct partial_symtab *) NULL; + } return pst; } @@ -1175,14 +1203,14 @@ os9k_psymtab_to_symtab_1 (pst) { struct cleanup *old_chain; int i; - + if (!pst) return; if (pst->readin) { fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); + pst->filename); return; } @@ -1198,18 +1226,18 @@ os9k_psymtab_to_symtab_1 (pst) fputs_filtered ("and ", gdb_stdout); wrap_here (""); printf_filtered ("%s...", pst->dependencies[i]->filename); - wrap_here (""); /* Flush output */ + wrap_here (""); /* Flush output */ gdb_flush (gdb_stdout); } os9k_psymtab_to_symtab_1 (pst->dependencies[i]); } - if (LDSYMCNT(pst)) /* Otherwise it's a dummy */ + if (LDSYMCNT (pst)) /* Otherwise it's a dummy */ { /* Init stuff necessary for reading in symbols */ stabsread_init (); buildsym_init (); - old_chain = make_cleanup ((make_cleanup_func) really_free_pendings, 0); + old_chain = make_cleanup (really_free_pendings, 0); /* Read in this file's symbols */ os9k_read_ofile_symtab (pst); @@ -1235,14 +1263,14 @@ os9k_psymtab_to_symtab (pst) if (pst->readin) { fprintf_unfiltered (gdb_stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); + pst->filename); return; } - if (LDSYMCNT(pst) || pst->number_of_dependencies) + if (LDSYMCNT (pst) || pst->number_of_dependencies) { /* Print the message now, before reading the string table, - to avoid disconcerting pauses. */ + to avoid disconcerting pauses. */ if (info_verbose) { printf_filtered ("Reading in symbols for %s...", pst->filename); @@ -1275,15 +1303,13 @@ os9k_read_ofile_symtab (pst) int sym_offset; /* Offset to start of symbols to read */ CORE_ADDR text_offset; /* Start of text segment for symbols */ int text_size; /* Size of text segment for symbols */ - struct section_offsets *section_offsets; FILE *dbg_file; objfile = pst->objfile; - sym_offset = LDSYMOFF(pst); - max_symnum = LDSYMCNT(pst); + sym_offset = LDSYMOFF (pst); + max_symnum = LDSYMCNT (pst); text_offset = pst->textlow; text_size = pst->texthigh - pst->textlow; - section_offsets = pst->section_offsets; current_objfile = objfile; subfile_stack = NULL; @@ -1298,10 +1324,10 @@ os9k_read_ofile_symtab (pst) occurs before the N_SO symbol. Detecting this in read_dbx_symtab would slow down initial readin, so we look for it here instead. */ - if (!processing_acc_compilation && sym_offset >= (int)symbol_size) + if (!processing_acc_compilation && sym_offset >= (int) symbol_size) { fseek (objefile->auxf2, sym_offset, SEEK_CUR); - fill_sym(objfile->auxf2, abfd); + fill_sym (objfile->auxf2, abfd); bufp = symbuf; processing_gcc_compilation = 0; @@ -1314,7 +1340,7 @@ os9k_read_ofile_symtab (pst) } /* Try to select a C++ demangling based on the compilation unit - producer. */ + producer. */ if (processing_gcc_compilation) { @@ -1327,33 +1353,34 @@ os9k_read_ofile_symtab (pst) else { /* The N_SO starting this symtab is the first symbol, so we - better not check the symbol before it. I'm not this can - happen, but it doesn't hurt to check for it. */ + better not check the symbol before it. I'm not this can + happen, but it doesn't hurt to check for it. */ bfd_seek (symfile_bfd, sym_offset, SEEK_CUR); processing_gcc_compilation = 0; } #endif /* 0 */ - fseek(dbg_file, (long)sym_offset, 0); + fseek (dbg_file, (long) sym_offset, 0); /* - if (bufp->n_type != (unsigned char)N_SYM_SYM) - error("First symbol in segment of executable not a source symbol"); -*/ + if (bufp->n_type != (unsigned char)N_SYM_SYM) + error("First symbol in segment of executable not a source symbol"); + */ for (symnum = 0; symnum < max_symnum; symnum++) { QUIT; /* Allow this to be interruptable */ - fill_sym(dbg_file, abfd); + fill_sym (dbg_file, abfd); bufp = symbuf; type = bufp->n_type; - os9k_process_one_symbol ((int)type, (int)bufp->n_desc, - (CORE_ADDR)bufp->n_value, bufp->n_strx, section_offsets, objfile); + os9k_process_one_symbol ((int) type, (int) bufp->n_desc, + (CORE_ADDR) bufp->n_value, bufp->n_strx, pst->section_offsets, objfile); /* We skip checking for a new .o or -l file; that should never happen in this routine. */ #if 0 - else if (type == N_TEXT) + else + if (type == N_TEXT) { /* I don't think this code will ever be executed, because the GCC_COMPILED_FLAG_SYMBOL usually is right before @@ -1371,9 +1398,10 @@ os9k_read_ofile_symtab (pst) set_demangling_style (GNU_DEMANGLING_STYLE_STRING); } } - else if (type & N_EXT || type == (unsigned char)N_TEXT - || type == (unsigned char)N_NBTEXT - ) { + else if (type & N_EXT || type == (unsigned char) N_TEXT + || type == (unsigned char) N_NBTEXT + ) + { /* Global symbol: see if we came across a dbx defintion for a corresponding symbol. If so, store the value. Remove syms from the chain when their values are stored, but @@ -1384,7 +1412,7 @@ os9k_read_ofile_symtab (pst) be satisfied in each file as it appears. So we skip this section. */ ; - } + } #endif /* 0 */ } @@ -1395,11 +1423,11 @@ os9k_read_ofile_symtab (pst) which comes from pst->textlow is correct. */ if (last_source_start_addr == 0) last_source_start_addr = text_offset; - pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT); + pst->symtab = end_symtab (text_offset + text_size, objfile, SECT_OFF_TEXT (objfile)); end_stabs (); } - + /* This handles a single symbol from the symbol-file, building symbols into a GDB symtab. It takes these arguments and an implicit argument. @@ -1408,11 +1436,11 @@ os9k_read_ofile_symtab (pst) VALU is the value field of the ".stab" entry. NAME is the symbol name, in our address space. SECTION_OFFSETS is a set of amounts by which the sections of this object - file were relocated when it was loaded into memory. - All symbols that refer - to memory locations need to be offset by these amounts. + file were relocated when it was loaded into memory. + All symbols that refer + to memory locations need to be offset by these amounts. OBJFILE is the object file from which we are reading symbols. - It is used in end_symtab. */ + It is used in end_symtab. */ static void os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) @@ -1430,12 +1458,12 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) #if 0 /* Something is wrong if we see real data before seeing a source file name. */ - if (last_source_file == NULL && type != (unsigned char)N_SO) + if (last_source_file == NULL && type != (unsigned char) N_SO) { /* Ignore any symbols which appear before an N_SO symbol. - Currently no one puts symbols there, but we should deal - gracefully with the case. A complain()t might be in order, - but this should not be an error (). */ + Currently no one puts symbols there, but we should deal + gracefully with the case. A complain()t might be in order, + but this should not be an error (). */ return; } #endif /* 0 */ @@ -1444,20 +1472,20 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) { case N_SYM_LBRAC: /* On most machines, the block addresses are relative to the - N_SO, the linker did not relocate them (sigh). */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + N_SO, the linker did not relocate them (sigh). */ + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); new = push_context (desc, valu); break; case N_SYM_RBRAC: - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); - new = pop_context(); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); + new = pop_context (); #if !defined (OS9K_VARIABLES_INSIDE_BLOCK) #define OS9K_VARIABLES_INSIDE_BLOCK(desc, gcc_p) 1 #endif - if (!OS9K_VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) + if (!OS9K_VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation)) local_symbols = new->locals; if (context_stack_depth > 1) @@ -1471,7 +1499,7 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) if (local_symbols != NULL) { /* Muzzle a compiler bug that makes end < start. (which - compilers? Is this ever harmful?). */ + compilers? Is this ever harmful?). */ if (new->start_addr > valu) { complain (&lbrac_rbrac_complaint); @@ -1489,23 +1517,26 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) within_function = 0; /* Make a block for the local symbols within. */ finish_block (new->name, &local_symbols, new->old_blocks, - new->start_addr, valu, objfile); + new->start_addr, valu, objfile); } else { /* attach local_symbols to the end of new->locals */ - if (!new->locals) new->locals = local_symbols; - else { - struct pending *p; + if (!new->locals) + new->locals = local_symbols; + else + { + struct pending *p; - p = new->locals; - while (p->next) p = p->next; - p->next = local_symbols; - } + p = new->locals; + while (p->next) + p = p->next; + p->next = local_symbols; + } } } - if (OS9K_VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) + if (OS9K_VARIABLES_INSIDE_BLOCK (desc, processing_gcc_compilation)) /* Now pop locals of block just finished. */ local_symbols = new->locals; break; @@ -1513,16 +1544,16 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) case N_SYM_SLINE: /* This type of "symbol" really just records - one line-number -- core-address correspondence. - Enter it in the line list for this symbol table. */ + one line-number -- core-address correspondence. + Enter it in the line list for this symbol table. */ /* Relocate for dynamic loading and for ELF acc fn-relative syms. */ - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); /* FIXME: loses if sizeof (char *) > sizeof (int) */ - record_line (current_subfile, (int)name, valu); + record_line (current_subfile, (int) name, valu); break; - /* The following symbol types need to have the appropriate offset added - to their value; then we process symbol definitions in the name. */ + /* The following symbol types need to have the appropriate offset added + to their value; then we process symbol definitions in the name. */ case N_SYM_SYM: if (name) @@ -1539,35 +1570,42 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) switch (deftype) { case 'S': - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); - n = strrchr(name, '/'); - if (n != NULL) { - *n = '\0'; - n++; - dirn = name; - } else { - n = name; - dirn = NULL; - } + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); + n = strrchr (name, '/'); + if (n != NULL) + { + *n = '\0'; + n++; + dirn = name; + } + else + { + n = name; + dirn = NULL; + } *p = '\0'; - if (symfile_depth++ == 0) { - if (last_source_file) { - end_symtab (valu, objfile, SECT_OFF_TEXT); - end_stabs (); + if (symfile_depth++ == 0) + { + if (last_source_file) + { + end_symtab (valu, objfile, SECT_OFF_TEXT (objfile)); + end_stabs (); + } + start_stabs (); + os9k_stabs = 1; + start_symtab (n, dirn, valu); + record_debugformat ("OS9"); + } + else + { + push_subfile (); + start_subfile (n, dirn != NULL ? dirn : current_subfile->dirname); } - start_stabs (); - os9k_stabs = 1; - start_symtab (n, dirn, valu); - record_debugformat ("OS9"); - } else { - push_subfile(); - start_subfile (n, dirn!=NULL ? dirn : current_subfile->dirname); - } break; case 'f': case 'F': - valu += ANOFFSET (section_offsets, SECT_OFF_TEXT); + valu += ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile)); function_stab_type = type; within_function = 1; @@ -1577,7 +1615,7 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) case 'V': case 'v': - valu += ANOFFSET (section_offsets, SECT_OFF_DATA); + valu += ANOFFSET (section_offsets, SECT_OFF_DATA (objfile)); define_symbol (valu, name, desc, type, objfile); break; @@ -1589,13 +1627,13 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) break; case N_SYM_SE: - if (--symfile_depth != 0) - start_subfile(pop_subfile(), current_subfile->dirname); + if (--symfile_depth != 0) + start_subfile (pop_subfile (), current_subfile->dirname); break; default: complain (&unknown_symtype_complaint, - local_hex_string((unsigned long) type)); + local_hex_string ((unsigned long) type)); /* FALLTHROUGH */ break; @@ -1608,17 +1646,16 @@ os9k_process_one_symbol (type, desc, valu, name, section_offsets, objfile) static struct sym_fns os9k_sym_fns = { bfd_target_os9k_flavour, - os9k_new_init, /* sym_new_init: init anything gbl to entire symtab */ - os9k_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - os9k_symfile_read, /* sym_read: read a symbol file into symtab */ - os9k_symfile_finish, /* sym_finish: finished with file, cleanup */ - default_symfile_offsets, - /* sym_offsets: parse user's offsets to internal form*/ - NULL /* next: pointer to next struct sym_fns */ + os9k_new_init, /* sym_new_init: init anything gbl to entire symtab */ + os9k_symfile_init, /* sym_init: read initial info, setup for sym_read() */ + os9k_symfile_read, /* sym_read: read a symbol file into symtab */ + os9k_symfile_finish, /* sym_finish: finished with file, cleanup */ + default_symfile_offsets, /* sym_offsets: parse user's offsets to internal form */ + NULL /* next: pointer to next struct sym_fns */ }; void _initialize_os9kread () { - add_symtab_fns(&os9k_sym_fns); + add_symtab_fns (&os9k_sym_fns); } diff --git a/gdb/pa64solib.c b/gdb/pa64solib.c index cb991b2c09..ab568f5758 100644 --- a/gdb/pa64solib.c +++ b/gdb/pa64solib.c @@ -328,9 +328,9 @@ pa64_solib_load_symbols (so, name, from_tty, text_addr, target) return; } - ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT) + ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile)) = so->pa64_solib_desc.text_base; - ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA) + ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile)) = so->pa64_solib_desc.data_base; /* Relocate all the sections based on where they got loaded. */ @@ -338,13 +338,13 @@ pa64_solib_load_symbols (so, name, from_tty, text_addr, target) { if (p->the_bfd_section->flags & SEC_CODE) { - p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT); - p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT); + p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile)); + p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile)); } else if (p->the_bfd_section->flags & SEC_DATA) { - p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA); - p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA); + p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile)); + p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile)); } } diff --git a/gdb/partial-stab.h b/gdb/partial-stab.h index 9c4be680a2..b8c9de8d1f 100644 --- a/gdb/partial-stab.h +++ b/gdb/partial-stab.h @@ -46,19 +46,19 @@ switch (CUR_SYMBOL_TYPE) case N_TEXT | N_EXT: case N_NBTEXT | N_EXT: - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); goto record_it; case N_DATA | N_EXT: case N_NBDATA | N_EXT: - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); goto record_it; case N_BSS: case N_BSS | N_EXT: case N_NBBSS | N_EXT: case N_SETV | N_EXT: /* FIXME, is this in BSS? */ - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_BSS (objfile)); goto record_it; case N_ABS | N_EXT: @@ -85,7 +85,7 @@ switch (CUR_SYMBOL_TYPE) case N_FN_SEQ: case N_TEXT: #ifdef DBXREAD_ONLY - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); SET_NAMESTRING (); if ((namestring[0] == '-' && namestring[1] == 'l') || (namestring[(nsl = strlen (namestring)) - 1] == 'o' @@ -121,7 +121,7 @@ switch (CUR_SYMBOL_TYPE) continue; case N_DATA: - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); goto record_it; case N_UNDF | N_EXT: @@ -203,7 +203,7 @@ switch (CUR_SYMBOL_TYPE) char *p; int prev_textlow_not_set; - valu = CUR_SYMBOL_VALUE + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + valu = CUR_SYMBOL_VALUE + ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); prev_textlow_not_set = textlow_not_set; @@ -423,7 +423,7 @@ switch (CUR_SYMBOL_TYPE) switch (p[1]) { case 'S': - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); #ifdef STATIC_TRANSFORM_NAME namestring = STATIC_TRANSFORM_NAME (namestring); #endif @@ -434,7 +434,7 @@ switch (CUR_SYMBOL_TYPE) psymtab_language, objfile); continue; case 'G': - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)); /* The addresses in these entries are reported to be wrong. See the code that reads 'G's for symtabs. */ add_psymbol_to_list (namestring, p - namestring, @@ -575,7 +575,7 @@ switch (CUR_SYMBOL_TYPE) continue; case 'f': - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); #ifdef DBXREAD_ONLY /* Kludges for ELF/STABS with Sun ACC */ last_function_name = namestring; @@ -602,7 +602,7 @@ switch (CUR_SYMBOL_TYPE) if (textlow_not_set || (CUR_SYMBOL_VALUE < pst->textlow && CUR_SYMBOL_VALUE - != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT))) + != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))) { pst->textlow = CUR_SYMBOL_VALUE; textlow_not_set = 0; @@ -619,7 +619,7 @@ switch (CUR_SYMBOL_TYPE) are put into the global psymtab like one would expect. They're also in the minimal symbol table. */ case 'F': - CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT); + CUR_SYMBOL_VALUE += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); #ifdef DBXREAD_ONLY /* Kludges for ELF/STABS with Sun ACC */ last_function_name = namestring; @@ -627,7 +627,7 @@ switch (CUR_SYMBOL_TYPE) /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit value for the bottom of the text seg in those cases. */ if (CUR_SYMBOL_VALUE == ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT)) + SECT_OFF_TEXT (objfile))) CUR_SYMBOL_VALUE = find_stab_function_addr (namestring, pst->filename, objfile); if (pst && textlow_not_set) @@ -649,7 +649,7 @@ switch (CUR_SYMBOL_TYPE) if (textlow_not_set || (CUR_SYMBOL_VALUE < pst->textlow && CUR_SYMBOL_VALUE - != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT))) + != ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)))) { pst->textlow = CUR_SYMBOL_VALUE; textlow_not_set = 0; diff --git a/gdb/remote-os9k.c b/gdb/remote-os9k.c index dd821154e4..fd758b5a1b 100644 --- a/gdb/remote-os9k.c +++ b/gdb/remote-os9k.c @@ -514,8 +514,8 @@ rombug_wait (pid, status) new_symfile_objfile (obj_sec->objfile, 1, 0); offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS); - ANOFFSET (offs, SECT_OFF_DATA) = addr; - ANOFFSET (offs, SECT_OFF_BSS) = addr; + ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = addr; + ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = addr; objfile_relocate (symfile_objfile, offs); } diff --git a/gdb/remote-vx.c b/gdb/remote-vx.c index 06407041e6..d1a2582c27 100644 --- a/gdb/remote-vx.c +++ b/gdb/remote-vx.c @@ -717,9 +717,9 @@ vx_add_symbols (name, from_tty, text_addr, data_addr, bss_addr) bfd_map_over_sections (objfile->obfd, find_sect, &ss); /* Both COFF and b.out frontends use these SECT_OFF_* values. */ - ANOFFSET (offs, SECT_OFF_TEXT) = text_addr - ss.text_start; - ANOFFSET (offs, SECT_OFF_DATA) = data_addr - ss.data_start; - ANOFFSET (offs, SECT_OFF_BSS) = bss_addr - ss.bss_start; + ANOFFSET (offs, SECT_OFF_TEXT (so->objfile)) = text_addr - ss.text_start; + ANOFFSET (offs, SECT_OFF_DATA (so->objfile)) = data_addr - ss.data_start; + ANOFFSET (offs, SECT_OFF_BSS (so->objfile)) = bss_addr - ss.bss_start; objfile_relocate (objfile, offs); } diff --git a/gdb/remote.c b/gdb/remote.c index 00172b3fea..1087d9f014 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1803,14 +1803,14 @@ get_offsets () offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS); - ANOFFSET (offs, SECT_OFF_TEXT) = text_addr; + ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_addr; /* This is a temporary kludge to force data and bss to use the same offsets because that's what nlmconv does now. The real solution requires changes to the stub and remote.c that I don't have time to do right now. */ - ANOFFSET (offs, SECT_OFF_DATA) = data_addr; - ANOFFSET (offs, SECT_OFF_BSS) = data_addr; + ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_addr; + ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = data_addr; objfile_relocate (symfile_objfile, offs); } @@ -1918,9 +1918,9 @@ remote_cisco_objfile_relocate (text_off, data_off, bss_off) offs = (struct section_offsets *) alloca (SIZEOF_SECTION_OFFSETS); memcpy (offs, symfile_objfile->section_offsets, SIZEOF_SECTION_OFFSETS); - ANOFFSET (offs, SECT_OFF_TEXT) = text_off; - ANOFFSET (offs, SECT_OFF_DATA) = data_off; - ANOFFSET (offs, SECT_OFF_BSS) = bss_off; + ANOFFSET (offs, SECT_OFF_TEXT (symfile_objfile)) = text_off; + ANOFFSET (offs, SECT_OFF_DATA (symfile_objfile)) = data_off; + ANOFFSET (offs, SECT_OFF_BSS (symfile_objfile)) = bss_off; /* First call the standard objfile_relocate. */ objfile_relocate (symfile_objfile, offs); diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 49b481dcba..133269c826 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -357,9 +357,9 @@ vmap_symtab (vp) /* The symbols in the object file are linked to the VMA of the section, relocate them VMA relative. */ - ANOFFSET (new_offsets, SECT_OFF_TEXT) = vp->tstart - vp->tvma; - ANOFFSET (new_offsets, SECT_OFF_DATA) = vp->dstart - vp->dvma; - ANOFFSET (new_offsets, SECT_OFF_BSS) = vp->dstart - vp->dvma; + ANOFFSET (new_offsets, SECT_OFF_TEXT (objfile)) = vp->tstart - vp->tvma; + ANOFFSET (new_offsets, SECT_OFF_DATA (objfile)) = vp->dstart - vp->dvma; + ANOFFSET (new_offsets, SECT_OFF_BSS (objfile)) = vp->dstart - vp->dvma; objfile_relocate (objfile, new_offsets); } diff --git a/gdb/somread.c b/gdb/somread.c index bc9a3829ab..8dda58df9c 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -471,10 +471,24 @@ som_symfile_offsets (objfile, addrs) objfile->section_offsets = (struct section_offsets *) obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); + /* FIXME: ezannoni 2000-04-20 The section names in SOM are not + .text, .data, etc, but $TEXT$, $DATA$,... We should initialize + SET_OFF_* from bfd. (See default_symfile_offsets()). But I don't + know the correspondence between SOM sections and GDB's idea of + section names. So for now we default to what is was before these + changes.*/ + objfile->sect_index_text = 0; + objfile->sect_index_data = 1; + objfile->sect_index_bss = 2; + objfile->sect_index_rodata = 3; + /* First see if we're a shared library. If so, get the section offsets from the library, else get them from addrs. */ if (!som_solib_section_offsets (objfile, objfile->section_offsets)) { + /* Note: Here is OK to compare with ".text" because this is the + name that gdb itself gives to that section, not the SOM + name. */ for (i = 0; i < SECT_OFF_MAX && addrs->other[i].name; i++) if (strcmp (addrs->other[i].name, ".text") == 0) break; diff --git a/gdb/somsolib.c b/gdb/somsolib.c index 5d559a083c..fa7ecd09c0 100644 --- a/gdb/somsolib.c +++ b/gdb/somsolib.c @@ -355,13 +355,13 @@ som_solib_load_symbols (so, name, from_tty, text_addr, target) { if (p->the_bfd_section->flags & SEC_CODE) { - p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT); - p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT); + p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile)); + p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_TEXT (so->objfile)); } else if (p->the_bfd_section->flags & SEC_DATA) { - p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA); - p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA); + p->addr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile)); + p->endaddr += ANOFFSET (so->objfile->section_offsets, SECT_OFF_DATA (so->objfile)); } } @@ -1407,11 +1407,11 @@ som_solib_section_offsets (objfile, offsets) asection *private_section; /* The text offset is easy. */ - ANOFFSET (offsets, SECT_OFF_TEXT) + ANOFFSET (offsets, SECT_OFF_TEXT (objfile)) = (so_list->som_solib.text_addr - so_list->som_solib.text_link_addr); - ANOFFSET (offsets, SECT_OFF_RODATA) - = ANOFFSET (offsets, SECT_OFF_TEXT); + ANOFFSET (offsets, SECT_OFF_RODATA (objfile)) + = ANOFFSET (offsets, SECT_OFF_TEXT (objfile)); /* We should look at presumed_dp in the SOM header, but that's not easily available. This should be OK though. */ @@ -1420,14 +1420,14 @@ som_solib_section_offsets (objfile, offsets) if (!private_section) { warning ("Unable to find $PRIVATE$ in shared library!"); - ANOFFSET (offsets, SECT_OFF_DATA) = 0; - ANOFFSET (offsets, SECT_OFF_BSS) = 0; + ANOFFSET (offsets, SECT_OFF_DATA (objfile)) = 0; + ANOFFSET (offsets, SECT_OFF_BSS (objfile)) = 0; return 1; } - ANOFFSET (offsets, SECT_OFF_DATA) + ANOFFSET (offsets, SECT_OFF_DATA (objfile)) = (so_list->som_solib.data_start - private_section->vma); - ANOFFSET (offsets, SECT_OFF_BSS) - = ANOFFSET (offsets, SECT_OFF_DATA); + ANOFFSET (offsets, SECT_OFF_BSS (objfile)) + = ANOFFSET (offsets, SECT_OFF_DATA (objfile)); return 1; } so_list = so_list->next; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 7adf078e82..206310e4d4 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1351,13 +1351,13 @@ define_symbol (valu, string, desc, type, objfile) switch (type & N_TYPE) { case N_TEXT: - SYMBOL_SECTION (sym) = SECT_OFF_TEXT; + SYMBOL_SECTION (sym) = SECT_OFF_TEXT (objfile); break; case N_DATA: - SYMBOL_SECTION (sym) = SECT_OFF_DATA; + SYMBOL_SECTION (sym) = SECT_OFF_DATA (objfile); break; case N_BSS: - SYMBOL_SECTION (sym) = SECT_OFF_BSS; + SYMBOL_SECTION (sym) = SECT_OFF_BSS (objfile); break; } diff --git a/gdb/symfile.c b/gdb/symfile.c index 108695a338..b01fe33f71 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -518,33 +518,49 @@ default_symfile_offsets (objfile, addrs) struct section_addr_info *addrs; { int i; + asection *sect = NULL; objfile->num_sections = SECT_OFF_MAX; objfile->section_offsets = (struct section_offsets *) obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); memset (objfile->section_offsets, 0, SIZEOF_SECTION_OFFSETS); - /* Now calculate offsets for other sections. */ + /* Now calculate offsets for section that were specified by the + caller. */ for (i = 0; i < MAX_SECTIONS && addrs->other[i].name; i++) { struct other_sections *osp ; osp = &addrs->other[i] ; - if (addrs->other[i].addr == 0) + if (osp->addr == 0) continue; -#if 0 - if (strcmp (".text", osp->name) == 0) - SECT_OFF_TEXT = osp->sectindex ; - else if (strcmp (".data", osp->name) == 0) - SECT_OFF_DATA = osp->sectindex ; - else if (strcmp (".bss", osp->name) == 0) - SECT_OFF_BSS = osp->sectindex ; -#endif + /* Record all sections in offsets */ + /* The section_offsets in the objfile are here filled in using + the BFD index. */ ANOFFSET (objfile->section_offsets, osp->sectindex) = osp->addr; } -} + /* Remember the bfd indexes for the .text, .data, .bss and + .rodata sections. */ + + sect = bfd_get_section_by_name (objfile->obfd, ".text"); + if (sect) + objfile->sect_index_text = sect->index; + + sect = bfd_get_section_by_name (objfile->obfd, ".data"); + if (sect) + objfile->sect_index_data = sect->index; + + sect = bfd_get_section_by_name (objfile->obfd, ".bss"); + if (sect) + objfile->sect_index_bss = sect->index; + + sect = bfd_get_section_by_name (objfile->obfd, ".rodata"); + if (sect) + objfile->sect_index_rodata = sect->index; + +} /* Process a symbol file, as either the main file or as a dynamically loaded file. @@ -631,12 +647,12 @@ syms_from_objfile (objfile, addrs, mainline, verbo) if (lower_sect == NULL) warning ("no loadable sections found in added symbol-file %s", objfile->name); - else if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) - == 0) - warning ("Lowest section in %s is %s at %s", - objfile->name, - bfd_section_name (objfile->obfd, lower_sect), - paddr (bfd_section_vma (objfile->obfd, lower_sect))); + else + if ((bfd_get_section_flags (objfile->obfd, lower_sect) & SEC_CODE) == 0) + warning ("Lowest section in %s is %s at %s", + objfile->name, + bfd_section_name (objfile->obfd, lower_sect), + paddr (bfd_section_vma (objfile->obfd, lower_sect))); if (lower_sect != NULL) lower_offset = bfd_section_vma (objfile->obfd, lower_sect); else diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 0cf9371482..991c83a372 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1,24 +1,25 @@ /* Read AIX xcoff symbol tables and convert to internal format, for GDB. Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997 - Free Software Foundation, Inc. + Free Software Foundation, Inc. Derived from coffread.c, dbxread.c, and a lot of hacking. Contributed by IBM Corporation. -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. */ #include "defs.h" #include "bfd.h" @@ -54,19 +55,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "aout/stab_gnu.h" /* For interface with partial-stab.h. */ -#define N_UNDF 0 /* Undefined symbol */ +#define N_UNDF 0 /* Undefined symbol */ #undef N_ABS #define N_ABS 2 -#define N_TEXT 4 /* Text sym -- defined at offset in text seg */ -#define N_DATA 6 /* Data sym -- defined at offset in data seg */ -#define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */ -#define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */ -#define N_FN 0x1f /* File name of .o file */ -#define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */ +#define N_TEXT 4 /* Text sym -- defined at offset in text seg */ +#define N_DATA 6 /* Data sym -- defined at offset in data seg */ +#define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */ +#define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */ +#define N_FN 0x1f /* File name of .o file */ +#define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */ /* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT, N_DATA, or N_BSS. When the low-order bit of other types is set, (e.g. N_WARNING versus N_FN), they are two different types. */ -#define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */ +#define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */ #define N_INDR 0x0a /* The following symbols refer to set elements. @@ -92,40 +93,42 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* We put a pointer to this structure in the read_symtab_private field of the psymtab. */ -struct symloc { +struct symloc + { - /* First symbol number for this file. */ + /* First symbol number for this file. */ - int first_symnum; + int first_symnum; - /* Number of symbols in 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 numsyms is 0, the only - reason for this thing's existence is the dependency list. Nothing - else will happen when it is read in. */ + /* Number of symbols in 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 numsyms is 0, the only + reason for this thing's existence is the dependency list. Nothing + else will happen when it is read in. */ - int numsyms; + int numsyms; - /* Position of the start of the line number information for this psymtab. */ - unsigned int lineno_off; -}; + /* Position of the start of the line number information for this psymtab. */ + unsigned int lineno_off; + }; /* Remember what we deduced to be the source language of this psymtab. */ static enum language psymtab_language = language_unknown; - + /* Simplified internal version of coff symbol table information */ -struct coff_symbol { - char *c_name; - int c_symnum; /* symbol number of this entry */ - int c_naux; /* 0 if syment only, 1 if syment + auxent */ - long c_value; - unsigned char c_sclass; - int c_secnum; - unsigned int c_type; -}; +struct coff_symbol + { + char *c_name; + int c_symnum; /* symbol number of this entry */ + int c_naux; /* 0 if syment only, 1 if syment + auxent */ + long c_value; + unsigned char c_sclass; + int c_secnum; + unsigned int c_type; + }; /* last function's saved coff symbol `cs' */ @@ -157,48 +160,49 @@ int within_function; there is any reason not to just use a #define, but might as well ask BFD for the size and store it here, I guess. */ -static unsigned local_symesz; +static unsigned local_symesz; -struct coff_symfile_info { - file_ptr min_lineno_offset; /* Where in file lowest line#s are */ - file_ptr max_lineno_offset; /* 1+last byte of line#s in file */ +struct coff_symfile_info + { + file_ptr min_lineno_offset; /* Where in file lowest line#s are */ + file_ptr max_lineno_offset; /* 1+last byte of line#s in file */ - /* Pointer to the string table. */ - char *strtbl; + /* Pointer to the string table. */ + char *strtbl; - /* Pointer to debug section. */ - char *debugsec; + /* Pointer to debug section. */ + char *debugsec; - /* Pointer to the a.out symbol table. */ - char *symtbl; + /* Pointer to the a.out symbol table. */ + char *symtbl; - /* Number of symbols in symtbl. */ - int symtbl_num_syms; + /* Number of symbols in symtbl. */ + int symtbl_num_syms; - /* Offset in data section to TOC anchor. */ - CORE_ADDR toc_offset; -}; + /* Offset in data section to TOC anchor. */ + CORE_ADDR toc_offset; + }; static struct complaint storclass_complaint = - {"Unexpected storage class: %d", 0, 0}; +{"Unexpected storage class: %d", 0, 0}; static struct complaint bf_notfound_complaint = - {"line numbers off, `.bf' symbol not found", 0, 0}; +{"line numbers off, `.bf' symbol not found", 0, 0}; -static struct complaint ef_complaint = - {"Mismatched .ef symbol ignored starting at symnum %d", 0, 0}; +static struct complaint ef_complaint = +{"Mismatched .ef symbol ignored starting at symnum %d", 0, 0}; -static struct complaint eb_complaint = - {"Mismatched .eb symbol ignored starting at symnum %d", 0, 0}; +static struct complaint eb_complaint = +{"Mismatched .eb symbol ignored starting at symnum %d", 0, 0}; static void -xcoff_initial_scan PARAMS ((struct objfile *, struct section_offsets *, int)); +xcoff_initial_scan PARAMS ((struct objfile *, int)); static void -scan_xcoff_symtab PARAMS ((struct section_offsets *, struct objfile *)); +scan_xcoff_symtab PARAMS ((struct objfile *)); static char * -xcoff_next_symbol_text PARAMS ((struct objfile *)); + xcoff_next_symbol_text PARAMS ((struct objfile *)); static void record_include_begin PARAMS ((struct coff_symbol *)); @@ -219,14 +223,14 @@ xcoff_new_init PARAMS ((struct objfile *)); static void xcoff_symfile_finish PARAMS ((struct objfile *)); -static struct section_offsets * -xcoff_symfile_offsets PARAMS ((struct objfile *, CORE_ADDR)); +static void + xcoff_symfile_offsets PARAMS ((struct objfile *, struct section_addr_info *addrs)); static void find_linenos PARAMS ((bfd *, sec_ptr, PTR)); static char * -coff_getfilename PARAMS ((union internal_auxent *, struct objfile *)); + coff_getfilename PARAMS ((union internal_auxent *, struct objfile *)); static void read_symbol PARAMS ((struct internal_syment *, int)); @@ -238,7 +242,7 @@ static int read_symbol_nvalue PARAMS ((int)); static struct symbol * -process_xcoff_symbol PARAMS ((struct coff_symbol *, struct objfile *)); + process_xcoff_symbol PARAMS ((struct coff_symbol *, struct objfile *)); static void read_xcoff_symtab PARAMS ((struct partial_symtab *)); @@ -252,43 +256,47 @@ static int compare_lte PARAMS ((const void *, const void *)); static struct linetable * -arrange_linetable PARAMS ((struct linetable *)); + arrange_linetable PARAMS ((struct linetable *)); static void record_include_end PARAMS ((struct coff_symbol *)); static void process_linenos PARAMS ((CORE_ADDR, CORE_ADDR)); - + /* Translate from a COFF section number (target_index) to a SECT_OFF_* code. */ static int secnum_to_section PARAMS ((int, struct objfile *)); -static asection * secnum_to_bfd_section PARAMS ((int, struct objfile *)); +static asection *secnum_to_bfd_section PARAMS ((int, struct objfile *)); -struct find_targ_sec_arg { - int targ_index; - int *resultp; - asection **bfd_sect; -}; +struct find_targ_sec_arg + { + int targ_index; + int *resultp; + asection **bfd_sect; + struct objfile *objfile; + }; static void find_targ_sec PARAMS ((bfd *, asection *, void *)); -static void find_targ_sec (abfd, sect, obj) +static void +find_targ_sec (abfd, sect, obj) bfd *abfd; asection *sect; PTR obj; { - struct find_targ_sec_arg *args = (struct find_targ_sec_arg *)obj; + struct find_targ_sec_arg *args = (struct find_targ_sec_arg *) obj; + struct objfile *objfile = args->objfile; if (sect->target_index == args->targ_index) { /* This is the section. Figure out what SECT_OFF_* code it is. */ if (bfd_get_section_flags (abfd, sect) & SEC_CODE) - *args->resultp = SECT_OFF_TEXT; + *args->resultp = SECT_OFF_TEXT (objfile); else if (bfd_get_section_flags (abfd, sect) & SEC_LOAD) - *args->resultp = SECT_OFF_DATA; + *args->resultp = SECT_OFF_DATA (objfile); else - *args->resultp = SECT_OFF_BSS; + *args->resultp = SECT_OFF_BSS (objfile); *args->bfd_sect = sect; } } @@ -299,12 +307,13 @@ secnum_to_section (secnum, objfile) int secnum; struct objfile *objfile; { - int off = SECT_OFF_TEXT; + int off = SECT_OFF_TEXT (objfile); asection *sect = NULL; struct find_targ_sec_arg args; args.targ_index = secnum; args.resultp = &off; args.bfd_sect = § + args.objfile = objfile; bfd_map_over_sections (objfile->obfd, find_targ_sec, &args); return off; } @@ -315,7 +324,7 @@ secnum_to_bfd_section (secnum, objfile) int secnum; struct objfile *objfile; { - int off = SECT_OFF_TEXT; + int off = SECT_OFF_TEXT (objfile); asection *sect = NULL; struct find_targ_sec_arg args; args.targ_index = secnum; @@ -331,79 +340,83 @@ secnum_to_bfd_section (secnum, objfile) static void add_stab_to_list (stabname, stabvector) -char *stabname; -struct pending_stabs **stabvector; + char *stabname; + struct pending_stabs **stabvector; { - if ( *stabvector == NULL) { - *stabvector = (struct pending_stabs *) - xmalloc (sizeof (struct pending_stabs) + - INITIAL_STABVECTOR_LENGTH * sizeof (char*)); - (*stabvector)->count = 0; - (*stabvector)->length = INITIAL_STABVECTOR_LENGTH; - } - else if ((*stabvector)->count >= (*stabvector)->length) { - (*stabvector)->length += INITIAL_STABVECTOR_LENGTH; - *stabvector = (struct pending_stabs *) - xrealloc ((char *) *stabvector, sizeof (struct pending_stabs) + - (*stabvector)->length * sizeof (char*)); - } - (*stabvector)->stab [(*stabvector)->count++] = stabname; + if (*stabvector == NULL) + { + *stabvector = (struct pending_stabs *) + xmalloc (sizeof (struct pending_stabs) + + INITIAL_STABVECTOR_LENGTH * sizeof (char *)); + (*stabvector)->count = 0; + (*stabvector)->length = INITIAL_STABVECTOR_LENGTH; + } + else if ((*stabvector)->count >= (*stabvector)->length) + { + (*stabvector)->length += INITIAL_STABVECTOR_LENGTH; + *stabvector = (struct pending_stabs *) + xrealloc ((char *) *stabvector, sizeof (struct pending_stabs) + + (*stabvector)->length * sizeof (char *)); + } + (*stabvector)->stab[(*stabvector)->count++] = stabname; } #endif - - + /* *INDENT-OFF* */ /* Linenos are processed on a file-by-file basis. Two reasons: - 1) xlc (IBM's native c compiler) postpones static function code - emission to the end of a compilation unit. This way it can - determine if those functions (statics) are needed or not, and - can do some garbage collection (I think). This makes line - numbers and corresponding addresses unordered, and we end up - with a line table like: - - - lineno addr - foo() 10 0x100 - 20 0x200 - 30 0x300 - - foo3() 70 0x400 - 80 0x500 - 90 0x600 - - static foo2() - 40 0x700 - 50 0x800 - 60 0x900 - - and that breaks gdb's binary search on line numbers, if the - above table is not sorted on line numbers. And that sort - should be on function based, since gcc can emit line numbers - like: - - 10 0x100 - for the init/test part of a for stmt. - 20 0x200 - 30 0x300 - 10 0x400 - for the increment part of a for stmt. - - arrange_linetable() will do this sorting. - - 2) aix symbol table might look like: - - c_file // beginning of a new file - .bi // beginning of include file - .ei // end of include file - .bi - .ei - - basically, .bi/.ei pairs do not necessarily encapsulate - their scope. They need to be recorded, and processed later - on when we come the end of the compilation unit. - Include table (inclTable) and process_linenos() handle - that. */ + 1) xlc (IBM's native c compiler) postpones static function code + emission to the end of a compilation unit. This way it can + determine if those functions (statics) are needed or not, and + can do some garbage collection (I think). This makes line + numbers and corresponding addresses unordered, and we end up + with a line table like: + + + lineno addr + foo() 10 0x100 + 20 0x200 + 30 0x300 + + foo3() 70 0x400 + 80 0x500 + 90 0x600 + + static foo2() + 40 0x700 + 50 0x800 + 60 0x900 + + and that breaks gdb's binary search on line numbers, if the + above table is not sorted on line numbers. And that sort + should be on function based, since gcc can emit line numbers + like: + + 10 0x100 - for the init/test part of a for stmt. + 20 0x200 + 30 0x300 + 10 0x400 - for the increment part of a for stmt. + + arrange_linetable() will do this sorting. + + 2) aix symbol table might look like: + + c_file // beginning of a new file + .bi // beginning of include file + .ei // end of include file + .bi + .ei + + basically, .bi/.ei pairs do not necessarily encapsulate + their scope. They need to be recorded, and processed later + on when we come the end of the compilation unit. + Include table (inclTable) and process_linenos() handle + that. */ +/* *INDENT-ON* */ + + /* compare line table entry addresses. */ @@ -425,71 +438,75 @@ compare_lte (lte1p, lte2p) static struct linetable * arrange_linetable (oldLineTb) - struct linetable *oldLineTb; /* old linetable */ + struct linetable *oldLineTb; /* old linetable */ { - int ii, jj, - newline, /* new line count */ - function_count; /* # of functions */ + int ii, jj, newline, /* new line count */ + function_count; /* # of functions */ - struct linetable_entry *fentry; /* function entry vector */ - int fentry_size; /* # of function entries */ - struct linetable *newLineTb; /* new line table */ + struct linetable_entry *fentry; /* function entry vector */ + int fentry_size; /* # of function entries */ + struct linetable *newLineTb; /* new line table */ #define NUM_OF_FUNCTIONS 20 fentry_size = NUM_OF_FUNCTIONS; - fentry = (struct linetable_entry*) + fentry = (struct linetable_entry *) xmalloc (fentry_size * sizeof (struct linetable_entry)); - for (function_count=0, ii=0; ii nitems; ++ii) { + for (function_count = 0, ii = 0; ii < oldLineTb->nitems; ++ii) + { - if (oldLineTb->item[ii].line == 0) { /* function entry found. */ + if (oldLineTb->item[ii].line == 0) + { /* function entry found. */ - if (function_count >= fentry_size) { /* make sure you have room. */ - fentry_size *= 2; - fentry = (struct linetable_entry*) - xrealloc (fentry, fentry_size * sizeof (struct linetable_entry)); - } - fentry[function_count].line = ii; - fentry[function_count].pc = oldLineTb->item[ii].pc; - ++function_count; + if (function_count >= fentry_size) + { /* make sure you have room. */ + fentry_size *= 2; + fentry = (struct linetable_entry *) + xrealloc (fentry, fentry_size * sizeof (struct linetable_entry)); + } + fentry[function_count].line = ii; + fentry[function_count].pc = oldLineTb->item[ii].pc; + ++function_count; + } } - } - if (function_count == 0) { - free (fentry); - return oldLineTb; - } + if (function_count == 0) + { + free (fentry); + return oldLineTb; + } else if (function_count > 1) - qsort (fentry, function_count, sizeof(struct linetable_entry), compare_lte); + qsort (fentry, function_count, sizeof (struct linetable_entry), compare_lte); /* allocate a new line table. */ newLineTb = (struct linetable *) xmalloc - (sizeof (struct linetable) + - (oldLineTb->nitems - function_count) * sizeof (struct linetable_entry)); + (sizeof (struct linetable) + + (oldLineTb->nitems - function_count) * sizeof (struct linetable_entry)); /* if line table does not start with a function beginning, copy up until a function begin. */ newline = 0; if (oldLineTb->item[0].line != 0) - for (newline=0; - newline < oldLineTb->nitems && oldLineTb->item[newline].line; ++newline) + for (newline = 0; + newline < oldLineTb->nitems && oldLineTb->item[newline].line; ++newline) newLineTb->item[newline] = oldLineTb->item[newline]; /* Now copy function lines one by one. */ - for (ii=0; ii < function_count; ++ii) { - for (jj = fentry[ii].line + 1; - jj < oldLineTb->nitems && oldLineTb->item[jj].line != 0; - ++jj, ++newline) - newLineTb->item[newline] = oldLineTb->item[jj]; - } + for (ii = 0; ii < function_count; ++ii) + { + for (jj = fentry[ii].line + 1; + jj < oldLineTb->nitems && oldLineTb->item[jj].line != 0; + ++jj, ++newline) + newLineTb->item[newline] = oldLineTb->item[jj]; + } free (fentry); newLineTb->nitems = oldLineTb->nitems - function_count; - return newLineTb; -} + return newLineTb; +} /* include file support: C_BINCL/C_EINCL pairs will be kept in the following `IncludeChain'. At the end of each symtab (end_symtab), @@ -497,63 +514,67 @@ arrange_linetable (oldLineTb) represent if (the include files. */ -typedef struct _inclTable { - char *name; /* include filename */ +typedef struct _inclTable +{ + char *name; /* include filename */ /* Offsets to the line table. end points to the last entry which is part of this include file. */ - int begin, end; - + int begin, end; + struct subfile *subfile; - unsigned funStartLine; /* start line # of its function */ -} InclTable; + unsigned funStartLine; /* start line # of its function */ +} +InclTable; #define INITIAL_INCLUDE_TABLE_LENGTH 20 -static InclTable *inclTable; /* global include table */ -static int inclIndx; /* last entry to table */ -static int inclLength; /* table length */ -static int inclDepth; /* nested include depth */ +static InclTable *inclTable; /* global include table */ +static int inclIndx; /* last entry to table */ +static int inclLength; /* table length */ +static int inclDepth; /* nested include depth */ static void allocate_include_entry PARAMS ((void)); static void record_include_begin (cs) -struct coff_symbol *cs; + struct coff_symbol *cs; { if (inclDepth) { /* In xcoff, we assume include files cannot be nested (not in .c files - of course, but in corresponding .s files.). */ + of course, but in corresponding .s files.). */ /* This can happen with old versions of GCC. - GCC 2.3.3-930426 does not exhibit this on a test case which - a user said produced the message for him. */ - static struct complaint msg = {"Nested C_BINCL symbols", 0, 0}; + GCC 2.3.3-930426 does not exhibit this on a test case which + a user said produced the message for him. */ + static struct complaint msg = + {"Nested C_BINCL symbols", 0, 0}; complain (&msg); } ++inclDepth; allocate_include_entry (); - inclTable [inclIndx].name = cs->c_name; - inclTable [inclIndx].begin = cs->c_value; + inclTable[inclIndx].name = cs->c_name; + inclTable[inclIndx].begin = cs->c_value; } static void record_include_end (cs) -struct coff_symbol *cs; + struct coff_symbol *cs; { - InclTable *pTbl; + InclTable *pTbl; if (inclDepth == 0) { - static struct complaint msg = {"Mismatched C_BINCL/C_EINCL pair", 0, 0}; + static struct complaint msg = + {"Mismatched C_BINCL/C_EINCL pair", 0, 0}; complain (&msg); } allocate_include_entry (); - pTbl = &inclTable [inclIndx]; + pTbl = &inclTable[inclIndx]; pTbl->end = cs->c_value; --inclDepth; @@ -565,7 +586,7 @@ allocate_include_entry () { if (inclTable == NULL) { - inclTable = (InclTable *) + inclTable = (InclTable *) xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH); memset (inclTable, '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH); @@ -575,10 +596,10 @@ allocate_include_entry () else if (inclIndx >= inclLength) { inclLength += INITIAL_INCLUDE_TABLE_LENGTH; - inclTable = (InclTable *) + inclTable = (InclTable *) xrealloc (inclTable, sizeof (InclTable) * inclLength); - memset (inclTable + inclLength - INITIAL_INCLUDE_TABLE_LENGTH, - '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH); + memset (inclTable + inclLength - INITIAL_INCLUDE_TABLE_LENGTH, + '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH); } } @@ -595,8 +616,8 @@ process_linenos (start, end) { int offset, ii; file_ptr max_offset = - ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private) - ->max_lineno_offset; + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->sym_private) + ->max_lineno_offset; /* subfile structure for the main compilation unit. */ struct subfile main_subfile; @@ -611,7 +632,7 @@ process_linenos (start, end) unsigned *firstLine; offset = - ((struct symloc *)this_symtab_psymtab->read_symtab_private)->lineno_off; + ((struct symloc *) this_symtab_psymtab->read_symtab_private)->lineno_off; if (offset == 0) goto return_after_cleanup; @@ -620,14 +641,14 @@ process_linenos (start, end) if (inclIndx == 0) /* All source lines were in the main source file. None in include files. */ - enter_line_range (&main_subfile, offset, 0, start, end, - &main_source_baseline); + enter_line_range (&main_subfile, offset, 0, start, end, + &main_source_baseline); else { /* There was source with line numbers in include files. */ main_source_baseline = 0; - for (ii=0; ii < inclIndx; ++ii) + for (ii = 0; ii < inclIndx; ++ii) { struct subfile *tmpSubfile; @@ -648,7 +669,7 @@ process_linenos (start, end) firstLine = &(inclTable[ii].funStartLine); /* Enter include file's lines now. */ - enter_line_range (tmpSubfile, inclTable[ii].begin, + enter_line_range (tmpSubfile, inclTable[ii].begin, inclTable[ii].end, start, 0, firstLine); if (offset <= inclTable[ii].end) @@ -656,10 +677,10 @@ process_linenos (start, end) } /* All the include files' line have been processed at this point. Now, - enter remaining lines of the main file, if any left. */ + enter remaining lines of the main file, if any left. */ if (offset < max_offset + 1 - LINESZ) { - enter_line_range (&main_subfile, offset, 0, start, end, + enter_line_range (&main_subfile, offset, 0, start, end, &main_source_baseline); } } @@ -672,7 +693,7 @@ process_linenos (start, end) lv = main_subfile.line_vector; /* Line numbers are not necessarily ordered. xlc compilation will - put static function to the end. */ + put static function to the end. */ lineTb = arrange_linetable (lv); if (lv == lineTb) @@ -687,15 +708,15 @@ process_linenos (start, end) current_subfile->line_vector = lineTb; } - current_subfile->line_vector_length = + current_subfile->line_vector_length = current_subfile->line_vector->nitems; } /* Now, process included files' line numbers. */ - for (ii=0; ii < inclIndx; ++ii) + for (ii = 0; ii < inclIndx; ++ii) { - if ((inclTable[ii].subfile)->line_vector) /* Useless if!!! FIXMEmgo */ + if ((inclTable[ii].subfile)->line_vector) /* Useless if!!! FIXMEmgo */ { struct linetable *lineTb, *lv; @@ -711,11 +732,11 @@ process_linenos (start, end) /* For the same include file, we might want to have more than one subfile. This happens if we have something like: - ...... - #include "foo.h" - ...... - #include "foo.h" - ...... + ...... + #include "foo.h" + ...... + #include "foo.h" + ...... while foo.h including code in it. (stupid but possible) Since start_subfile() looks at the name and uses an @@ -723,7 +744,7 @@ process_linenos (start, end) fool it. */ #if 0 - start_subfile (inclTable[ii].name, (char*)0); + start_subfile (inclTable[ii].name, (char *) 0); #else { /* Pick a fake name that will produce the same results as this @@ -732,18 +753,18 @@ process_linenos (start, end) char *fakename = strrchr (inclTable[ii].name, '.'); if (fakename == NULL) fakename = " ?"; - start_subfile (fakename, (char*)0); + start_subfile (fakename, (char *) 0); free (current_subfile->name); } - current_subfile->name = strdup (inclTable[ii].name); + current_subfile->name = xstrdup (inclTable[ii].name); #endif if (lv == lineTb) { current_subfile->line_vector = (struct linetable *) xrealloc - (lv, (sizeof (struct linetable) - + lv->nitems * sizeof (struct linetable_entry))); + (lv, (sizeof (struct linetable) + + lv->nitems * sizeof (struct linetable_entry))); } else @@ -752,13 +773,13 @@ process_linenos (start, end) current_subfile->line_vector = lineTb; } - current_subfile->line_vector_length = + current_subfile->line_vector_length = current_subfile->line_vector->nitems; - start_subfile (pop_subfile (), (char*)0); + start_subfile (pop_subfile (), (char *) 0); } } - return_after_cleanup: +return_after_cleanup: /* We don't want to keep alloc/free'ing the global include file table. */ inclIndx = 0; @@ -777,8 +798,8 @@ aix_process_linenos () /* Enter a given range of lines into the line vector. can be called in the following two ways: - enter_line_range (subfile, beginoffset, endoffset, startaddr, 0, firstLine) or - enter_line_range (subfile, beginoffset, 0, startaddr, endaddr, firstLine) + enter_line_range (subfile, beginoffset, endoffset, startaddr, 0, firstLine) or + enter_line_range (subfile, beginoffset, 0, startaddr, endaddr, firstLine) endoffset points to the last line table entry that we should pay attention to. */ @@ -787,9 +808,9 @@ static void enter_line_range (subfile, beginoffset, endoffset, startaddr, endaddr, firstLine) struct subfile *subfile; - unsigned beginoffset, endoffset; /* offsets to line table */ - CORE_ADDR startaddr, endaddr; - unsigned *firstLine; + unsigned beginoffset, endoffset; /* offsets to line table */ + CORE_ADDR startaddr, endaddr; + unsigned *firstLine; { unsigned int curoffset; CORE_ADDR addr; @@ -802,15 +823,15 @@ enter_line_range (subfile, beginoffset, endoffset, startaddr, endaddr, return; curoffset = beginoffset; limit_offset = - ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private) - ->max_lineno_offset; + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->sym_private) + ->max_lineno_offset; if (endoffset != 0) { if (endoffset >= limit_offset) { static struct complaint msg = - {"Bad line table offset in C_EINCL directive", 0, 0}; + {"Bad line table offset in C_EINCL directive", 0, 0}; complain (&msg); return; } @@ -831,7 +852,7 @@ enter_line_range (subfile, beginoffset, endoffset, startaddr, endaddr, ? int_lnno.l_addr.l_paddr : read_symbol_nvalue (int_lnno.l_addr.l_symndx)); addr += ANOFFSET (this_symtab_psymtab->objfile->section_offsets, - SECT_OFF_TEXT); + SECT_OFF_TEXT (this_symtab_psymtab->objfile)); if (addr < startaddr || (endaddr && addr >= endaddr)) return; @@ -882,7 +903,7 @@ enter_line_range (subfile, beginoffset, endoffset, startaddr, endaddr, /* xcoff has static blocks marked in `.bs', `.es' pairs. They cannot be nested. At any given time, a symbol can only be in one static block. This is the base address of current static block, zero if non exists. */ - + static int static_block_base = 0; /* Section number for the current static block. */ @@ -906,7 +927,7 @@ xcoff_next_symbol_text (objfile) { struct internal_syment symbol; static struct complaint msg = - {"Unexpected symbol continuation", 0, 0}; + {"Unexpected symbol continuation", 0, 0}; char *retval; /* FIXME: is this the same as the passed arg? */ objfile = this_symtab_psymtab->objfile; @@ -917,14 +938,14 @@ xcoff_next_symbol_text (objfile) complain (&msg); /* Return something which points to '\0' and hope the symbol reading - code does something reasonable. */ + code does something reasonable. */ retval = ""; } else if (symbol.n_sclass & 0x80) { retval = - ((struct coff_symfile_info *)objfile->sym_private)->debugsec - + symbol.n_offset; + ((struct coff_symfile_info *) objfile->sym_private)->debugsec + + symbol.n_offset; raw_symbol += coff_data (objfile->obfd)->local_symesz; ++symnum; @@ -934,7 +955,7 @@ xcoff_next_symbol_text (objfile) complain (&msg); /* Return something which points to '\0' and hope the symbol reading - code does something reasonable. */ + code does something reasonable. */ retval = ""; } return retval; @@ -949,9 +970,9 @@ read_xcoff_symtab (pst) struct objfile *objfile = pst->objfile; bfd *abfd = objfile->obfd; char *raw_auxptr; /* Pointer to first raw aux entry for sym */ - char *strtbl = ((struct coff_symfile_info *)objfile->sym_private)->strtbl; + char *strtbl = ((struct coff_symfile_info *) objfile->sym_private)->strtbl; char *debugsec = - ((struct coff_symfile_info *)objfile->sym_private)->debugsec; + ((struct coff_symfile_info *) objfile->sym_private)->debugsec; struct internal_syment symbol[1]; union internal_auxent main_aux; @@ -973,7 +994,7 @@ read_xcoff_symtab (pst) char *filestring = " _start_ "; /* Name of the current file. */ - char *last_csect_name; /* last seen csect's name and value */ + char *last_csect_name; /* last seen csect's name and value */ CORE_ADDR last_csect_val; int last_csect_sec; @@ -988,16 +1009,16 @@ read_xcoff_symtab (pst) last_csect_val = 0; start_stabs (); - start_symtab (filestring, (char *)NULL, file_start_addr); + start_symtab (filestring, (char *) NULL, file_start_addr); record_debugformat ("XCOFF"); - symnum = ((struct symloc *)pst->read_symtab_private)->first_symnum; + symnum = ((struct symloc *) pst->read_symtab_private)->first_symnum; max_symnum = - symnum + ((struct symloc *)pst->read_symtab_private)->numsyms; + symnum + ((struct symloc *) pst->read_symtab_private)->numsyms; first_object_file_end = 0; raw_symbol = ((struct coff_symfile_info *) objfile->sym_private)->symtbl - + symnum * local_symesz; + + symnum * local_symesz; while (symnum < max_symnum) { @@ -1006,10 +1027,10 @@ read_xcoff_symtab (pst) /* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */ /* read one symbol into `cs' structure. After processing the - whole symbol table, only string table will be kept in memory, - symbol table and debug section of xcoff will be freed. Thus - we can mark symbols with names in string table as - `alloced'. */ + whole symbol table, only string table will be kept in memory, + symbol table and debug section of xcoff will be freed. Thus + we can mark symbols with names in string table as + `alloced'. */ { int ii; @@ -1024,7 +1045,7 @@ read_xcoff_symtab (pst) /* We must use the original, unswapped, name here so the name field pointed to by cs->c_name will persist throughout xcoffread. If we use the new field, it gets overwritten for each symbol. */ - cs->c_name = ((struct external_syment *)raw_symbol)->e.e_name; + cs->c_name = ((struct external_syment *) raw_symbol)->e.e_name; /* If it's exactly E_SYMNMLEN characters long it isn't '\0'-terminated. */ if (cs->c_name[E_SYMNMLEN - 1] != '\0') @@ -1045,13 +1066,13 @@ read_xcoff_symtab (pst) else { /* in string table */ - cs->c_name = strtbl + (int)symbol->n_offset; + cs->c_name = strtbl + (int) symbol->n_offset; symname_alloced = 1; } cs->c_value = symbol->n_value; cs->c_sclass = symbol->n_sclass; cs->c_secnum = symbol->n_scnum; - cs->c_type = (unsigned)symbol->n_type; + cs->c_type = (unsigned) symbol->n_type; raw_symbol += coff_data (abfd)->local_symesz; ++symnum; @@ -1077,19 +1098,19 @@ read_xcoff_symtab (pst) if (last_source_file) { pst->symtab = - end_symtab (cur_src_end_addr, objfile, SECT_OFF_TEXT); + end_symtab (cur_src_end_addr, objfile, SECT_OFF_TEXT (objfile)); end_stabs (); } start_stabs (); - start_symtab ("_globals_", (char *)NULL, (CORE_ADDR)0); + start_symtab ("_globals_", (char *) NULL, (CORE_ADDR) 0); record_debugformat ("XCOFF"); cur_src_end_addr = first_object_file_end; /* done with all files, everything from here on is globals */ } /* if explicitly specified as a function, treat is as one. */ - if (ISFCN(cs->c_type) && cs->c_sclass != C_TPDEF) + if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF) { bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, 0, cs->c_naux, &main_aux); @@ -1128,31 +1149,31 @@ read_xcoff_symtab (pst) { /* A program csect is seen. We have to allocate one - symbol table for each program csect. Normally gdb - prefers one symtab for each source file. In case - of AIX, one source file might include more than one - [PR] csect, and they don't have to be adjacent in - terms of the space they occupy in memory. Thus, one - single source file might get fragmented in the - memory and gdb's file start and end address - approach does not work! GCC (and I think xlc) seem - to put all the code in the unnamed program csect. */ + symbol table for each program csect. Normally gdb + prefers one symtab for each source file. In case + of AIX, one source file might include more than one + [PR] csect, and they don't have to be adjacent in + terms of the space they occupy in memory. Thus, one + single source file might get fragmented in the + memory and gdb's file start and end address + approach does not work! GCC (and I think xlc) seem + to put all the code in the unnamed program csect. */ if (last_csect_name) { complete_symtab (filestring, file_start_addr); cur_src_end_addr = file_end_addr; - end_symtab (file_end_addr, objfile, SECT_OFF_TEXT); + end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile)); end_stabs (); start_stabs (); /* Give all csects for this source file the same name. */ - start_symtab (filestring, NULL, (CORE_ADDR)0); + start_symtab (filestring, NULL, (CORE_ADDR) 0); record_debugformat ("XCOFF"); } /* If this is the very first csect seen, - basically `__start'. */ + basically `__start'. */ if (just_started) { first_object_file_end @@ -1162,7 +1183,7 @@ read_xcoff_symtab (pst) file_start_addr = cs->c_value + ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT); + SECT_OFF_TEXT (objfile)); file_end_addr = file_start_addr + CSECT_LEN (&main_aux); if (cs->c_name && cs->c_name[0] == '.') @@ -1258,7 +1279,7 @@ read_xcoff_symtab (pst) complete_symtab (filestring, file_start_addr); cur_src_end_addr = file_end_addr; - end_symtab (file_end_addr, objfile, SECT_OFF_TEXT); + end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile)); end_stabs (); /* XCOFF, according to the AIX 3.2 documentation, puts the filename @@ -1276,7 +1297,7 @@ read_xcoff_symtab (pst) filestring = cs->c_name; start_stabs (); - start_symtab (filestring, (char *)NULL, (CORE_ADDR)0); + start_symtab (filestring, (char *) NULL, (CORE_ADDR) 0); record_debugformat ("XCOFF"); last_csect_name = 0; @@ -1293,7 +1314,7 @@ read_xcoff_symtab (pst) if (STREQ (cs->c_name, ".bf")) { CORE_ADDR off = ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT); + SECT_OFF_TEXT (objfile)); bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, 0, cs->c_naux, &main_aux); @@ -1301,11 +1322,11 @@ read_xcoff_symtab (pst) new = push_context (0, fcn_start_addr + off); - new->name = define_symbol + new->name = define_symbol (fcn_cs_saved.c_value + off, fcn_stab_saved.c_name, 0, 0, objfile); if (new->name != NULL) - SYMBOL_SECTION (new->name) = SECT_OFF_TEXT; + SYMBOL_SECTION (new->name) = SECT_OFF_TEXT (objfile); } else if (STREQ (cs->c_name, ".ef")) { @@ -1314,9 +1335,9 @@ read_xcoff_symtab (pst) 0, cs->c_naux, &main_aux); /* The value of .ef is the address of epilogue code; - not useful for gdb. */ + not useful for gdb. */ /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno - contains number of lines to '}' */ + contains number of lines to '}' */ if (context_stack_depth <= 0) { /* We attempted to pop an empty context stack */ @@ -1338,7 +1359,7 @@ read_xcoff_symtab (pst) (fcn_cs_saved.c_value + fcn_aux_saved.x_sym.x_misc.x_fsize + ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT)), + SECT_OFF_TEXT (objfile))), objfile); within_function = 0; } @@ -1371,7 +1392,7 @@ read_xcoff_symtab (pst) case C_ENTAG: { static struct complaint msg = - {"Unrecognized storage class %d.", 0, 0}; + {"Unrecognized storage class %d.", 0, 0}; complain (&msg, cs->c_sclass); } break; @@ -1408,7 +1429,7 @@ read_xcoff_symtab (pst) new = push_context (depth, (cs->c_value + ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT))); + SECT_OFF_TEXT (objfile)))); } else if (STREQ (cs->c_name, ".eb")) { @@ -1430,7 +1451,7 @@ read_xcoff_symtab (pst) new->start_addr, (cs->c_value + ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT)), + SECT_OFF_TEXT (objfile))), objfile); } local_symbols = new->locals; @@ -1449,7 +1470,7 @@ read_xcoff_symtab (pst) complete_symtab (filestring, file_start_addr); cur_src_end_addr = file_end_addr; - s = end_symtab (file_end_addr, objfile, SECT_OFF_TEXT); + s = end_symtab (file_end_addr, objfile, SECT_OFF_TEXT (objfile)); /* When reading symbols for the last C_FILE of the objfile, try to make sure that we set pst->symtab to the symtab for the file, not to the _globals_ symtab. I'm not sure whether this @@ -1464,8 +1485,8 @@ read_xcoff_symtab (pst) (SYMBOL2) = (struct symbol *) \ obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); \ *(SYMBOL2) = *(SYMBOL1); - - + + #define SYMNAME_ALLOC(NAME, ALLOCED) \ (ALLOCED) ? (NAME) : obsavestring ((NAME), strlen (NAME), &objfile->symbol_obstack); @@ -1477,8 +1498,8 @@ static struct type *var_symbol_type; static struct symbol * process_xcoff_symbol (cs, objfile) - register struct coff_symbol *cs; - struct objfile *objfile; + register struct coff_symbol *cs; + struct objfile *objfile; { struct symbol onesymbol; register struct symbol *sym = &onesymbol; @@ -1491,7 +1512,7 @@ process_xcoff_symbol (cs, objfile) if (cs->c_secnum < 0) { /* The value is a register number, offset within a frame, etc., - and does not get relocated. */ + and does not get relocated. */ off = 0; sec = -1; } @@ -1515,8 +1536,8 @@ process_xcoff_symbol (cs, objfile) if (ISFCN (cs->c_type)) { /* At this point, we don't know the type of the function. This - will be patched with the type from its stab entry later on in - patch_block_stabs (), unless the file was compiled without -g. */ + will be patched with the type from its stab entry later on in + patch_block_stabs (), unless the file was compiled without -g. */ SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); SYMBOL_TYPE (sym) = func_symbol_type; @@ -1537,8 +1558,8 @@ process_xcoff_symbol (cs, objfile) switch (cs->c_sclass) { #if 0 - /* The values of functions and global symbols are now resolved - via the global_sym_chain in stabsread.c. */ + /* The values of functions and global symbols are now resolved + via the global_sym_chain in stabsread.c. */ case C_FUN: if (fcn_cs_saved.c_sclass == C_EXT) add_stab_to_list (name, &global_stabs); @@ -1589,7 +1610,7 @@ process_xcoff_symbol (cs, objfile) where we need to, which is not necessarily super-clean, but seems workable enough. */ - if (*name == ':' || (pp = (char *) strchr(name, ':')) == NULL) + if (*name == ':' || (pp = (char *) strchr (name, ':')) == NULL) return NULL; ++pp; @@ -1623,7 +1644,7 @@ coff_getfilename (aux_entry, objfile) if (aux_entry->x_file.x_n.x_zeroes == 0) strcpy (buffer, - ((struct coff_symfile_info *)objfile->sym_private)->strtbl + ((struct coff_symfile_info *) objfile->sym_private)->strtbl + aux_entry->x_file.x_n.x_offset); else { @@ -1640,25 +1661,25 @@ read_symbol (symbol, symno) int symno; { int nsyms = - ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private) - ->symtbl_num_syms; - char *stbl = - ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private) - ->symtbl; + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->sym_private) + ->symtbl_num_syms; + char *stbl = + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->sym_private) + ->symtbl; if (symno < 0 || symno >= nsyms) { static struct complaint msg = - {"Invalid symbol offset", 0, 0}; + {"Invalid symbol offset", 0, 0}; complain (&msg); symbol->n_value = 0; symbol->n_scnum = -1; return; } bfd_coff_swap_sym_in (this_symtab_psymtab->objfile->obfd, - stbl + (symno*local_symesz), + stbl + (symno * local_symesz), symbol); } - + /* Get value corresponding to symbol number symno in symtbl. */ static int @@ -1668,7 +1689,7 @@ read_symbol_nvalue (symno) struct internal_syment symbol[1]; read_symbol (symbol, symno); - return symbol->n_value; + return symbol->n_value; } @@ -1680,11 +1701,11 @@ read_symbol_lineno (symno) int symno; { int nsyms = - ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private) - ->symtbl_num_syms; - char *stbl = - ((struct coff_symfile_info *)this_symtab_psymtab->objfile->sym_private) - ->symtbl; + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->sym_private) + ->symtbl_num_syms; + char *stbl = + ((struct coff_symfile_info *) this_symtab_psymtab->objfile->sym_private) + ->symtbl; struct internal_syment symbol[1]; union internal_auxent main_aux[1]; @@ -1743,7 +1764,7 @@ static void find_linenos (abfd, asect, vpinfo) bfd *abfd; sec_ptr asect; - PTR vpinfo; + PTR vpinfo; { struct coff_symfile_info *info; int size, count; @@ -1755,7 +1776,7 @@ find_linenos (abfd, asect, vpinfo) return; size = count * coff_data (abfd)->local_linesz; - info = (struct coff_symfile_info *)vpinfo; + info = (struct coff_symfile_info *) vpinfo; offset = asect->line_filepos; maxoff = offset + size; @@ -1774,7 +1795,7 @@ xcoff_psymtab_to_symtab_1 (pst) { struct cleanup *old_chain; int i; - + if (!pst) return; @@ -1798,18 +1819,18 @@ xcoff_psymtab_to_symtab_1 (pst) fputs_filtered ("and ", gdb_stdout); wrap_here (""); printf_filtered ("%s...", pst->dependencies[i]->filename); - wrap_here (""); /* Flush output */ + wrap_here (""); /* Flush output */ gdb_flush (gdb_stdout); } xcoff_psymtab_to_symtab_1 (pst->dependencies[i]); } - if (((struct symloc *)pst->read_symtab_private)->numsyms != 0) + if (((struct symloc *) pst->read_symtab_private)->numsyms != 0) { /* Init stuff necessary for reading in symbols. */ stabsread_init (); buildsym_init (); - old_chain = make_cleanup ((make_cleanup_func) really_free_pendings, 0); + old_chain = make_cleanup (really_free_pendings, 0); read_xcoff_symtab (pst); sort_symtab_syms (pst->symtab); @@ -1842,11 +1863,11 @@ xcoff_psymtab_to_symtab (pst) return; } - if (((struct symloc *)pst->read_symtab_private)->numsyms != 0 + if (((struct symloc *) pst->read_symtab_private)->numsyms != 0 || pst->number_of_dependencies) { /* Print the message now, before reading the string table, - to avoid disconcerting pauses. */ + to avoid disconcerting pauses. */ if (info_verbose) { printf_filtered ("Reading in symbols for %s...", pst->filename); @@ -1878,7 +1899,7 @@ xcoff_new_init (objfile) } /* Do initialization in preparation for reading symbols from OBJFILE. - + We will only be called if this is an XCOFF or XCOFF-like file. BFD handles figuring out the format of the file, and code in symfile.c uses BFD's determination to vector to us. */ @@ -1888,8 +1909,8 @@ xcoff_symfile_init (objfile) struct objfile *objfile; { /* Allocate struct to keep track of the symfile */ - objfile -> sym_private = xmmalloc (objfile -> md, - sizeof (struct coff_symfile_info)); + objfile->sym_private = xmmalloc (objfile->md, + sizeof (struct coff_symfile_info)); /* XCOFF objects may be reordered, so set OBJF_REORDERED. If we find this causes a significant slowdown in gdb then we could @@ -1908,9 +1929,9 @@ static void xcoff_symfile_finish (objfile) struct objfile *objfile; { - if (objfile -> sym_private != NULL) + if (objfile->sym_private != NULL) { - mfree (objfile -> md, objfile -> sym_private); + mfree (objfile->md, objfile->sym_private); } /* Start with a fresh include table for the next objfile. */ @@ -1934,13 +1955,13 @@ init_stringtab (abfd, offset, objfile) unsigned char lengthbuf[4]; char *strtbl; - ((struct coff_symfile_info *)objfile->sym_private)->strtbl = NULL; + ((struct coff_symfile_info *) objfile->sym_private)->strtbl = NULL; if (bfd_seek (abfd, offset, SEEK_SET) < 0) error ("cannot seek to string table in %s: %s", bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ())); - val = bfd_read ((char *)lengthbuf, 1, sizeof lengthbuf, abfd); + val = bfd_read ((char *) lengthbuf, 1, sizeof lengthbuf, abfd); length = bfd_h_get_32 (abfd, lengthbuf); /* If no string table is needed, then the file may end immediately @@ -1953,7 +1974,7 @@ init_stringtab (abfd, offset, objfile) as long as we have its symbol table around. */ strtbl = (char *) obstack_alloc (&objfile->symbol_obstack, length); - ((struct coff_symfile_info *)objfile->sym_private)->strtbl = strtbl; + ((struct coff_symfile_info *) objfile->sym_private)->strtbl = strtbl; /* Copy length buffer, the first byte is usually zero and is used for stabs with a name length of zero. */ @@ -1979,7 +2000,7 @@ init_stringtab (abfd, offset, objfile) static unsigned int first_fun_line_offset; static struct partial_symtab *xcoff_start_psymtab - PARAMS ((struct objfile *, struct section_offsets *, char *, int, + PARAMS ((struct objfile *, char *, int, struct partial_symbol **, struct partial_symbol **)); /* Allocate and partially fill a partial symtab. It will be @@ -1990,25 +2011,24 @@ static struct partial_symtab *xcoff_start_psymtab (normal). */ static struct partial_symtab * -xcoff_start_psymtab (objfile, section_offsets, - filename, first_symnum, global_syms, static_syms) +xcoff_start_psymtab (objfile, filename, first_symnum, global_syms, + static_syms) struct objfile *objfile; - struct section_offsets *section_offsets; char *filename; int first_symnum; struct partial_symbol **global_syms; struct partial_symbol **static_syms; { struct partial_symtab *result = - start_psymtab_common (objfile, section_offsets, - filename, - /* We fill in textlow later. */ - 0, - global_syms, static_syms); + start_psymtab_common (objfile, objfile->section_offsets, + filename, + /* We fill in textlow later. */ + 0, + global_syms, static_syms); result->read_symtab_private = (char *) - obstack_alloc (&objfile -> psymbol_obstack, sizeof (struct symloc)); - ((struct symloc *)result->read_symtab_private)->first_symnum = first_symnum; + obstack_alloc (&objfile->psymbol_obstack, sizeof (struct symloc)); + ((struct symloc *) result->read_symtab_private)->first_symnum = first_symnum; result->read_symtab = xcoff_psymtab_to_symtab; /* Deduce the source language from the filename for this psymtab. */ @@ -2041,13 +2061,13 @@ xcoff_end_psymtab (pst, include_list, num_includes, capping_symbol_number, int textlow_not_set; { int i; - struct objfile *objfile = pst -> objfile; + struct objfile *objfile = pst->objfile; if (capping_symbol_number != -1) - ((struct symloc *)pst->read_symtab_private)->numsyms = + ((struct symloc *) pst->read_symtab_private)->numsyms = capping_symbol_number - - ((struct symloc *)pst->read_symtab_private)->first_symnum; - ((struct symloc *)pst->read_symtab_private)->lineno_off = + - ((struct symloc *) pst->read_symtab_private)->first_symnum; + ((struct symloc *) pst->read_symtab_private)->lineno_off = first_fun_line_offset; first_fun_line_offset = 0; pst->n_global_syms = @@ -2060,9 +2080,9 @@ xcoff_end_psymtab (pst, include_list, num_includes, capping_symbol_number, { 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; @@ -2070,19 +2090,19 @@ xcoff_end_psymtab (pst, include_list, num_includes, capping_symbol_number, 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)); - ((struct symloc *)subpst->read_symtab_private)->first_symnum = 0; - ((struct symloc *)subpst->read_symtab_private)->numsyms = 0; + (char *) obstack_alloc (&objfile->psymbol_obstack, + sizeof (struct symloc)); + ((struct symloc *) subpst->read_symtab_private)->first_symnum = 0; + ((struct symloc *) subpst->read_symtab_private)->numsyms = 0; subpst->textlow = 0; 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 *)); @@ -2091,8 +2111,8 @@ xcoff_end_psymtab (pst, include_list, num_includes, capping_symbol_number, 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; @@ -2112,14 +2132,14 @@ xcoff_end_psymtab (pst, include_list, num_includes, capping_symbol_number, && 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. */ + any symbols in them. There can be a lot of them. */ discard_psymtab (pst); /* Indicate that psymtab was thrown away. */ - pst = (struct partial_symtab *)NULL; + pst = (struct partial_symtab *) NULL; } return pst; } @@ -2146,7 +2166,7 @@ swap_sym (symbol, aux, name, raw, symnump, objfile) if (symbol->n_zeroes) { /* If it's exactly E_SYMNMLEN characters long it isn't - '\0'-terminated. */ + '\0'-terminated. */ if (symbol->n_name[E_SYMNMLEN - 1] != '\0') { /* FIXME: wastes memory for symbols which we don't end up putting @@ -2160,16 +2180,16 @@ swap_sym (symbol, aux, name, raw, symnump, objfile) else /* Point to the unswapped name as that persists as long as the objfile does. */ - *name = ((struct external_syment *)*raw)->e.e_name; + *name = ((struct external_syment *) *raw)->e.e_name; } else if (symbol->n_sclass & 0x80) { - *name = ((struct coff_symfile_info *)objfile->sym_private)->debugsec + *name = ((struct coff_symfile_info *) objfile->sym_private)->debugsec + symbol->n_offset; } else { - *name = ((struct coff_symfile_info *)objfile->sym_private)->strtbl + *name = ((struct coff_symfile_info *) objfile->sym_private)->strtbl + symbol->n_offset; } ++*symnump; @@ -2185,11 +2205,10 @@ swap_sym (symbol, aux, name, raw, symnump, objfile) } static void -scan_xcoff_symtab (section_offsets, objfile) - struct section_offsets *section_offsets; +scan_xcoff_symtab (objfile) struct objfile *objfile; { - CORE_ADDR toc_offset = 0; /* toc offset value in data section. */ + CORE_ADDR toc_offset = 0; /* toc offset value in data section. */ char *filestring = NULL; char *namestring; @@ -2212,13 +2231,13 @@ scan_xcoff_symtab (section_offsets, objfile) char *sraw_symbol; struct internal_syment symbol; - union internal_auxent main_aux; + union internal_auxent main_aux[5]; unsigned int ssymnum; - char *last_csect_name = NULL; /* last seen csect's name and value */ + char *last_csect_name = NULL; /* last seen csect's name and value */ CORE_ADDR last_csect_val = 0; int last_csect_sec = 0; - int misc_func_recorded = 0; /* true if any misc. function */ + int misc_func_recorded = 0; /* true if any misc. function */ int textlow_not_set = 1; pst = (struct partial_symtab *) 0; @@ -2238,16 +2257,16 @@ scan_xcoff_symtab (section_offsets, objfile) abfd = objfile->obfd; - sraw_symbol = ((struct coff_symfile_info *)objfile->sym_private)->symtbl; - nsyms = ((struct coff_symfile_info *)objfile->sym_private)->symtbl_num_syms; + sraw_symbol = ((struct coff_symfile_info *) objfile->sym_private)->symtbl; + nsyms = ((struct coff_symfile_info *) objfile->sym_private)->symtbl_num_syms; ssymnum = 0; while (ssymnum < nsyms) { - int sclass = ((struct external_syment *)sraw_symbol)->e_sclass[0] & 0xff; + int sclass = ((struct external_syment *) sraw_symbol)->e_sclass[0] & 0xff; /* This is the type we pass to partial-stab.h. A less kludgy solution - would be to break out partial-stab.h into its various parts--shuffle - off the DBXREAD_ONLY stuff to dbxread.c, and make separate - pstab-norm.h (for most types), pstab-sol.h (for N_SOL), etc. */ + would be to break out partial-stab.h into its various parts--shuffle + off the DBXREAD_ONLY stuff to dbxread.c, and make separate + pstab-norm.h (for most types), pstab-sol.h (for N_SOL), etc. */ int stype; QUIT; @@ -2261,13 +2280,13 @@ scan_xcoff_symtab (section_offsets, objfile) union internal_auxent csect_aux; unsigned int symnum_before = ssymnum; - swap_sym (&symbol, &main_aux, &namestring, &sraw_symbol, + swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol, &ssymnum, objfile); if (symbol.n_numaux > 1) { bfd_coff_swap_aux_in (objfile->obfd, - sraw_symbol - coff_data(abfd)->local_symesz, + sraw_symbol - coff_data (abfd)->local_symesz, symbol.n_type, symbol.n_sclass, symbol.n_numaux - 1, @@ -2275,7 +2294,7 @@ scan_xcoff_symtab (section_offsets, objfile) &csect_aux); } else - csect_aux = main_aux; + csect_aux = main_aux[0]; /* If symbol name starts with ".$" or "$", ignore it. */ if (namestring[0] == '$' @@ -2317,7 +2336,7 @@ scan_xcoff_symtab (section_offsets, objfile) /* Give all psymtabs for this source file the same name. */ pst = xcoff_start_psymtab - (objfile, section_offsets, + (objfile, filestring, symnum_before, objfile->global_psymbols.next, @@ -2334,7 +2353,7 @@ scan_xcoff_symtab (section_offsets, objfile) if (pst != NULL) { CORE_ADDR highval = - symbol.n_value + csect_aux.x_csect.x_scnlen.l; + symbol.n_value + csect_aux.x_csect.x_scnlen.l; if (highval > pst->texthigh) pst->texthigh = highval; if (pst->textlow == 0 || symbol.n_value < pst->textlow) @@ -2383,7 +2402,7 @@ scan_xcoff_symtab (section_offsets, objfile) if (first_fun_line_offset == 0 && symbol.n_numaux > 1) first_fun_line_offset = - main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr; + main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr; RECORD_MINIMAL_SYMBOL (namestring, symbol.n_value, sclass == C_HIDEXT ? mst_file_text : mst_text, @@ -2458,7 +2477,7 @@ scan_xcoff_symtab (section_offsets, objfile) unsigned int symnum_before; symnum_before = ssymnum; - swap_sym (&symbol, &main_aux, &namestring, &sraw_symbol, + swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol, &ssymnum, objfile); /* See if the last csect needs to be recorded. */ @@ -2492,12 +2511,12 @@ scan_xcoff_symtab (section_offsets, objfile) exists, otherwise use the symbol itself. */ if (!strcmp (namestring, ".file") && symbol.n_numaux > 0) { - filestring = coff_getfilename (&main_aux, objfile); + filestring = coff_getfilename (&main_aux[0], objfile); } else filestring = namestring; - pst = xcoff_start_psymtab (objfile, section_offsets, + pst = xcoff_start_psymtab (objfile, filestring, symnum_before, objfile->global_psymbols.next, @@ -2509,7 +2528,7 @@ scan_xcoff_symtab (section_offsets, objfile) default: { static struct complaint msg = - {"Storage class %d not recognized during scan", 0, 0}; + {"Storage class %d not recognized during scan", 0, 0}; complain (&msg, sclass); } /* FALLTHROUGH */ @@ -2560,7 +2579,7 @@ scan_xcoff_symtab (section_offsets, objfile) /* We probably could save a few instructions by assuming that C_LSYM, C_PSYM, etc., never have auxents. */ int naux1 = - ((struct external_syment *)sraw_symbol)->e_numaux[0] + 1; + ((struct external_syment *) sraw_symbol)->e_numaux[0] + 1; ssymnum += naux1; sraw_symbol += sizeof (struct external_syment) * naux1; } @@ -2582,7 +2601,7 @@ scan_xcoff_symtab (section_offsets, objfile) case C_STSYM: stype = N_LSYM; pstab:; - swap_sym (&symbol, &main_aux, &namestring, &sraw_symbol, + swap_sym (&symbol, &main_aux[0], &namestring, &sraw_symbol, &ssymnum, objfile); #define CUR_SYMBOL_TYPE stype #define CUR_SYMBOL_VALUE symbol.n_value @@ -2590,11 +2609,11 @@ scan_xcoff_symtab (section_offsets, objfile) /* START_PSYMTAB and END_PSYMTAB are never used, because they are only called from DBXREAD_ONLY or N_SO code. Likewise for the symnum variable. */ -#define START_PSYMTAB(ofile,secoff,fname,low,symoff,global_syms,static_syms) 0 +#define START_PSYMTAB(ofile,fname,low,symoff,global_syms,static_syms) 0 #define END_PSYMTAB(pst,ilist,ninc,c_off,c_text,dep_list,n_deps,textlow_not_set)\ do {} while (0) /* We have already set the namestring. */ -#define SET_NAMESTRING() /* */ +#define SET_NAMESTRING() /* */ #include "partial-stab.h" } @@ -2636,29 +2655,28 @@ get_toc_offset (objfile) table (as opposed to a shared lib or dynamically loaded file). */ static void -xcoff_initial_scan (objfile, section_offsets, mainline) +xcoff_initial_scan (objfile, mainline) struct objfile *objfile; - struct section_offsets *section_offsets; - int mainline; /* FIXME comments above */ + int mainline; /* FIXME comments above */ { bfd *abfd; int val; struct cleanup *back_to; - int num_symbols; /* # of symbols */ - file_ptr symtab_offset; /* symbol table and */ - file_ptr stringtab_offset; /* string table file offsets */ + int num_symbols; /* # of symbols */ + file_ptr symtab_offset; /* symbol table and */ + file_ptr stringtab_offset; /* string table file offsets */ struct coff_symfile_info *info; char *name; unsigned int size; - info = (struct coff_symfile_info *) objfile -> sym_private; + info = (struct coff_symfile_info *) objfile->sym_private; symfile_bfd = abfd = objfile->obfd; name = objfile->name; num_symbols = bfd_get_symcount (abfd); /* # of symbols */ symtab_offset = obj_sym_filepos (abfd); /* symbol table file offset */ stringtab_offset = symtab_offset + - num_symbols * coff_data(abfd)->local_symesz; + num_symbols * coff_data (abfd)->local_symesz; info->min_lineno_offset = 0; info->max_lineno_offset = 0; @@ -2692,7 +2710,7 @@ xcoff_initial_scan (objfile, section_offsets, mainline) } } } - ((struct coff_symfile_info *)objfile->sym_private)->debugsec = + ((struct coff_symfile_info *) objfile->sym_private)->debugsec = debugsec; } } @@ -2704,12 +2722,12 @@ xcoff_initial_scan (objfile, section_offsets, mainline) error ("Error reading symbols from %s: %s", name, bfd_errmsg (bfd_get_error ())); size = coff_data (abfd)->local_symesz * num_symbols; - ((struct coff_symfile_info *)objfile->sym_private)->symtbl = + ((struct coff_symfile_info *) objfile->sym_private)->symtbl = obstack_alloc (&objfile->symbol_obstack, size); - ((struct coff_symfile_info *)objfile->sym_private)->symtbl_num_syms = + ((struct coff_symfile_info *) objfile->sym_private)->symtbl_num_syms = num_symbols; - val = bfd_read (((struct coff_symfile_info *)objfile->sym_private)->symtbl, + val = bfd_read (((struct coff_symfile_info *) objfile->sym_private)->symtbl, size, 1, abfd); if (val != size) perror_with_name ("reading symbol table"); @@ -2725,7 +2743,7 @@ xcoff_initial_scan (objfile, section_offsets, mainline) init_psymbol_list (objfile, num_symbols); free_pending_blocks (); - back_to = make_cleanup ((make_cleanup_func) really_free_pendings, 0); + back_to = make_cleanup (really_free_pendings, 0); init_minimal_symbol_collection (); make_cleanup ((make_cleanup_func) discard_minimal_symbols, 0); @@ -2733,7 +2751,7 @@ xcoff_initial_scan (objfile, section_offsets, mainline) /* Now that the symbol table data of the executable file are all in core, process them and define symbols accordingly. */ - scan_xcoff_symtab (section_offsets, objfile); + scan_xcoff_symtab (objfile); /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ @@ -2743,33 +2761,48 @@ xcoff_initial_scan (objfile, section_offsets, mainline) do_cleanups (back_to); } -static struct section_offsets * -xcoff_symfile_offsets (objfile, addr) +static void +xcoff_symfile_offsets (objfile, addrs) struct objfile *objfile; - CORE_ADDR addr; + struct section_addr_info *addrs; { - struct section_offsets *section_offsets; + asection *sect = NULL; int i; objfile->num_sections = SECT_OFF_MAX; - section_offsets = (struct section_offsets *) - obstack_alloc - (&objfile -> psymbol_obstack, - sizeof (struct section_offsets) - + sizeof (section_offsets->offsets) * objfile->num_sections); - - /* syms_from_objfile kindly subtracts from addr the bfd_section_vma - of the .text section. This strikes me as wrong--whether the - offset to be applied to symbol reading is relative to the start - address of the section depends on the symbol format. In any - event, this whole "addr" concept is pretty broken (it doesn't - handle any section but .text sensibly), so just ignore the addr - parameter and use 0. rs6000-nat.c will set the correct section - offsets via objfile_relocate. */ - for (i = 0; i < objfile->num_sections; ++i) - ANOFFSET (section_offsets, i) = 0; + objfile->section_offsets = (struct section_offsets *) + obstack_alloc (&objfile->psymbol_obstack, SIZEOF_SECTION_OFFSETS); - return section_offsets; + /* Initialize the section indexes for future use. */ + sect = bfd_get_section_by_name (objfile->obfd, ".text"); + if (sect) + objfile->sect_index_text = sect->index; + + sect = bfd_get_section_by_name (objfile->obfd, ".data"); + if (sect) + objfile->sect_index_data = sect->index; + + sect = bfd_get_section_by_name (objfile->obfd, ".bss"); + if (sect) + objfile->sect_index_bss = sect->index; + + sect = bfd_get_section_by_name (objfile->obfd, ".rodata"); + if (sect) + objfile->sect_index_rodata = sect->index; + + for (i = 0; i < objfile->num_sections; ++i) + { + /* syms_from_objfile kindly subtracts from addr the + bfd_section_vma of the .text section. This strikes me as + wrong--whether the offset to be applied to symbol reading is + relative to the start address of the section depends on the + symbol format. In any event, this whole "addr" concept is + pretty broken (it doesn't handle any section but .text + sensibly), so just ignore the addr parameter and use 0. + rs6000-nat.c will set the correct section offsets via + objfile_relocate. */ + ANOFFSET (objfile->section_offsets, i) = 0; + } } /* Register our ability to parse symbols for xcoff BFD files. */ @@ -2787,20 +2820,20 @@ static struct sym_fns xcoff_sym_fns = xcoffread.c reads all the symbols and does in fact randomly access them (in C_BSTAT and line number processing). */ - (enum bfd_flavour)-1, + (enum bfd_flavour) -1, - xcoff_new_init, /* sym_new_init: init anything gbl to entire symtab */ - xcoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - xcoff_initial_scan, /* sym_read: read a symbol file into symtab */ - xcoff_symfile_finish, /* sym_finish: finished with file, cleanup */ - xcoff_symfile_offsets, /* sym_offsets: xlate offsets ext->int form */ - NULL /* next: pointer to next struct sym_fns */ + xcoff_new_init, /* sym_new_init: init anything gbl to entire symtab */ + xcoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */ + xcoff_initial_scan, /* sym_read: read a symbol file into symtab */ + xcoff_symfile_finish, /* sym_finish: finished with file, cleanup */ + xcoff_symfile_offsets, /* sym_offsets: xlate offsets ext->int form */ + NULL /* next: pointer to next struct sym_fns */ }; void _initialize_xcoffread () { - add_symtab_fns(&xcoff_sym_fns); + add_symtab_fns (&xcoff_sym_fns); func_symbol_type = init_type (TYPE_CODE_FUNC, 1, 0, "", NULL); -- 2.11.0