From dcc355360e4b039cbe4fb56339d6f490d26b917e Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Wed, 29 May 1991 00:13:44 +0000 Subject: Update bfd_h_get{short,long} to bfd_h_get{_16,_32} for basic type size independence. --- gdb/coffread.c | 92 +++++++++++++++++++++++++++++----------------------------- gdb/dbxread.c | 46 ++++++++++++++++++++--------- 2 files changed, 78 insertions(+), 60 deletions(-) diff --git a/gdb/coffread.c b/gdb/coffread.c index debf04b..b118985 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License along with GDB; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include #include "defs.h" #include "param.h" @@ -29,8 +28,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "bfd.h" #include "symfile.h" -#ifndef NO_COFF - #if defined (TDESC) /* Need to get C_VERSION and friends. */ #include @@ -75,6 +72,11 @@ extern void free_all_psymtabs (); /* external routines from the BFD library -- undocumented interface used by GDB to read symbols. Move to libcoff.h. FIXME-SOMEDAY! */ +extern void bfd_coff_swap_sym_in (/* symfile_bfd, &sym */); +extern void bfd_coff_swap_aux_in (/* symfile_bfd, &aux, type, sclass */); +extern void bfd_coff_swap_lineno_in (/* symfile_bfd, &lineno */); +extern void bfd_coff_swap_scnhdr_in (/* bfd, scnhdr_ext, scnhdr_int */); + extern void bfd_coff_swap_sym (/* symfile_bfd, &sym */); extern void bfd_coff_swap_aux (/* symfile_bfd, &aux, type, sclass */); extern void bfd_coff_swap_lineno (/* symfile_bfd, &lineno */); @@ -812,11 +814,11 @@ read_coff_symtab (desc, nsyms) register struct context_stack *new; struct coff_symbol coff_symbol; register struct coff_symbol *cs = &coff_symbol; - static SYMENT main_sym; - static AUXENT main_aux; + static struct internal_syment main_sym; + static union internal_auxent main_aux; struct coff_symbol fcn_cs_saved; - static SYMENT fcn_sym_saved; - static AUXENT fcn_aux_saved; + static struct internal_syment fcn_sym_saved; + static union internal_auxent fcn_aux_saved; /* A .file is open. */ int in_source_file = 0; @@ -1168,28 +1170,32 @@ read_file_hdr (chan, file_hdr) } #endif +/* Read the next symbol, swap it, and return it in both internal_syment + form, and coff_symbol form. Also return its first auxent, if any, + in internal_auxent form, and skip any other auxents. */ static void read_one_sym (cs, sym, aux) register struct coff_symbol *cs; - register SYMENT *sym; - register AUXENT *aux; + register struct internal_syment *sym; + register union internal_auxent *aux; { - AUXENT temp_aux; + struct external_syment temp_sym[1]; + union external_auxent temp_aux[1]; int i; cs->c_symnum = symnum; - fread ((char *)sym, SYMESZ, 1, nlist_stream_global); - bfd_coff_swap_sym (symfile_bfd, sym); + fread ((char *)temp_sym, SYMESZ, 1, nlist_stream_global); + bfd_coff_swap_sym_in (symfile_bfd, temp_sym, sym); cs->c_nsyms = (sym->n_numaux & 0xff) + 1; if (cs->c_nsyms >= 2) { - fread ((char *)aux, AUXESZ, 1, nlist_stream_global); - bfd_coff_swap_aux (symfile_bfd, aux, sym->n_type, sym->n_sclass); + fread ((char *)temp_aux, AUXESZ, 1, nlist_stream_global); + bfd_coff_swap_aux_in (symfile_bfd, temp_aux, sym->n_type, sym->n_sclass, aux); /* If more than one aux entry, read past it (only the first aux is important). */ for (i = 2; i < cs->c_nsyms; i++) - fread ((char *)&temp_aux, AUXESZ, 1, nlist_stream_global); + fread ((char *)temp_aux, AUXESZ, 1, nlist_stream_global); } cs->c_name = getsymname (sym); cs->c_value = sym->n_value; @@ -1225,7 +1231,7 @@ init_stringtab (chan, offset) return -1; val = myread (chan, (char *)lengthbuf, sizeof lengthbuf); - length = bfd_h_getlong (symfile_bfd, lengthbuf); + length = bfd_h_get_32 (symfile_bfd, lengthbuf); /* If no string table is needed, then the file may end immediately after the symbols. Just return with `stringtab' set to null. */ @@ -1257,18 +1263,18 @@ free_stringtab () static char * getsymname (symbol_entry) - SYMENT *symbol_entry; + struct internal_syment *symbol_entry; { static char buffer[SYMNMLEN+1]; char *result; - if (symbol_entry->n_zeroes == 0) + if (symbol_entry->_n._n_n._n_zeroes == 0) { - result = stringtab + symbol_entry->n_offset; + result = stringtab + symbol_entry->_n._n_n._n_offset; } else { - strncpy (buffer, symbol_entry->n_name, SYMNMLEN); + strncpy (buffer, symbol_entry->_n._n_name, SYMNMLEN); buffer[SYMNMLEN] = '\0'; result = buffer; } @@ -1277,7 +1283,7 @@ getsymname (symbol_entry) static char * getfilename (aux_entry) - AUXENT *aux_entry; + union internal_auxent *aux_entry; { static char buffer[BUFSIZ]; register char *temp; @@ -1315,7 +1321,9 @@ static char *linetab = NULL; static long linetab_offset; static unsigned long linetab_size; -/* Read in all the line numbers for fast lookups later. */ +/* Read in all the line numbers for fast lookups later. Leave them in + external (unswapped) format in memory; we'll swap them as we enter + them into GDB's data structures. */ static int init_lineno (chan, offset, size) @@ -1324,7 +1332,6 @@ init_lineno (chan, offset, size) int size; { int val; - register char *p, *q; if (lseek (chan, offset, 0) < 0) return -1; @@ -1335,11 +1342,6 @@ init_lineno (chan, offset, size) if (val != size) return -1; - /* Swap all entries */ - q = linetab + size; - for (p = linetab; p < q; p += LINESZ) - bfd_coff_swap_lineno (symfile_bfd, (LINENO *)p); - linetab_offset = offset; linetab_size = size; make_cleanup (free, linetab); /* Be sure it gets de-allocated. */ @@ -1357,7 +1359,7 @@ enter_linenos (file_offset, first_line, last_line) register int last_line; { register char *rawptr; - struct lineno lptr; + struct internal_lineno lptr; if (file_offset < linetab_offset) { @@ -1374,14 +1376,14 @@ enter_linenos (file_offset, first_line, last_line) /* line numbers start at one for the first line of the function */ first_line--; - /* Bcopy since occaisionally rawptr isn't pointing at long - boundaries. */ - for (bcopy (rawptr, &lptr, LINESZ); - L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line; - rawptr += LINESZ, bcopy (rawptr, &lptr, LINESZ)) - { + for (;;) { + bfd_coff_swap_lineno_in (symfile_bfd, (LINENO *)rawptr, &lptr); + rawptr += LINESZ; + if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line) record_line (first_line + L_LNNO32 (&lptr), lptr.l_addr.l_paddr); - } + else + break; + } } static int @@ -1499,7 +1501,7 @@ patch_opaque_types () static struct symbol * process_coff_symbol (cs, aux) register struct coff_symbol *cs; - register AUXENT *aux; + register union internal_auxent *aux; { register struct symbol *sym = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); @@ -1654,7 +1656,7 @@ struct type * decode_type (cs, c_type, aux) register struct coff_symbol *cs; unsigned int c_type; - register AUXENT *aux; + register union internal_auxent *aux; { register struct type *type = 0; unsigned int new_c_type; @@ -1722,7 +1724,7 @@ struct type * decode_function_type (cs, c_type, aux) register struct coff_symbol *cs; unsigned int c_type; - register AUXENT *aux; + register union internal_auxent *aux; { if (aux->x_sym.x_tagndx == 0) cs->c_nsyms = 1; /* auxent refers to function, not base type */ @@ -1737,7 +1739,7 @@ struct type * decode_base_type (cs, c_type, aux) register struct coff_symbol *cs; unsigned int c_type; - register AUXENT *aux; + register union internal_auxent *aux; { struct type *type; @@ -1873,8 +1875,8 @@ read_struct_type (index, length, lastsym) #endif struct coff_symbol member_sym; register struct coff_symbol *ms = &member_sym; - SYMENT sub_sym; - AUXENT sub_aux; + struct internal_syment sub_sym; + union internal_auxent sub_aux; int done = 0; type = coff_alloc_type (index); @@ -1957,8 +1959,8 @@ read_enum_type (index, length, lastsym) struct pending **symlist; struct coff_symbol member_sym; register struct coff_symbol *ms = &member_sym; - SYMENT sub_sym; - AUXENT sub_aux; + struct internal_syment sub_sym; + union internal_auxent sub_aux; struct pending *osyms, *syms; register int n; char *name; @@ -2051,5 +2053,3 @@ _initialize_coffread () { add_symtab_fns(&coff_sym_fns); } - -#endif /* NO_COFF */ diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 6c79982..cd87db4 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1423,7 +1423,7 @@ dbx_symfile_init (sf) val = myread (desc, size_temp, sizeof (long)); if (val < 0) perror_with_name (name); - info->stringtab_size = bfd_h_getlong (sym_bfd, size_temp); + info->stringtab_size = bfd_h_get_32 (sym_bfd, size_temp); if (info->stringtab_size >= 0 && info->stringtab_size < statbuf.st_size) { @@ -1485,11 +1485,11 @@ fill_symbuf () #define SWAP_SYMBOL(symp) \ { \ - (symp)->n_un.n_strx = bfd_h_getlong(symfile_bfd, \ + (symp)->n_un.n_strx = bfd_h_get_32(symfile_bfd, \ (unsigned char *)&(symp)->n_un.n_strx); \ - (symp)->n_desc = bfd_h_getshort (symfile_bfd, \ + (symp)->n_desc = bfd_h_get_16 (symfile_bfd, \ (unsigned char *)&(symp)->n_desc); \ - (symp)->n_value = bfd_h_getlong (symfile_bfd, \ + (symp)->n_value = bfd_h_get_32 (symfile_bfd, \ (unsigned char *)&(symp)->n_value); \ } @@ -2661,7 +2661,7 @@ dbx_psymtab_to_symtab (pst) val = myread (desc, &st_temp, sizeof st_temp); if (val < 0) perror_with_name (pst->symfile_name); - stsize = bfd_h_getlong (sym_bfd, (unsigned char *)&st_temp); + stsize = bfd_h_get_32 (sym_bfd, (unsigned char *)&st_temp); if (fstat (desc, &statbuf) < 0) perror_with_name (pst->symfile_name); @@ -4535,6 +4535,7 @@ read_struct_type (pp, type) { int i; struct next_fnfield *sublist = 0; + struct type *look_ahead_type = NULL; int length = 0; struct next_fnfieldlist *new_mainlist = (struct next_fnfieldlist *)alloca (sizeof (struct next_fnfieldlist)); @@ -4575,12 +4576,20 @@ read_struct_type (pp, type) (struct next_fnfield *)alloca (sizeof (struct next_fnfield)); /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') *pp = next_symbol_text (); + if (look_ahead_type == NULL) /* Normal case. */ + { + if (**pp == '\\') *pp = next_symbol_text (); - new_sublist->fn_field.type = read_type (pp); - if (**pp != ':') - /* Invalid symtab info for method. */ - return error_type (pp); + new_sublist->fn_field.type = read_type (pp); + if (**pp != ':') + /* Invalid symtab info for method. */ + return error_type (pp); + } + else + { /* g++ version 1 kludge */ + new_sublist->fn_field.type = look_ahead_type; + look_ahead_type = NULL; + } *pp += 1; p = *pp; @@ -4621,6 +4630,8 @@ read_struct_type (pp, type) new_sublist->fn_field.voffset = (0x7fffffff & read_number (pp, ';')) + 1; + if (**pp == '\\') *pp = next_symbol_text (); + if (**pp == ';' || **pp == '\0') /* Must be g++ version 1. */ new_sublist->fn_field.fcontext = 0; @@ -4629,11 +4640,18 @@ read_struct_type (pp, type) /* Figure out from whence this virtual function came. It may belong to virtual function table of one of its baseclasses. */ - new_sublist->fn_field.fcontext = read_type (pp); - if (**pp != ';') - return error_type (pp); + look_ahead_type = read_type (pp); + if (**pp == ':') + { /* g++ version 1 overloaded methods. */ } else - ++*pp; + { + new_sublist->fn_field.fcontext = look_ahead_type; + if (**pp != ';') + return error_type (pp); + else + ++*pp; + look_ahead_type = NULL; + } } break; -- cgit v1.1