X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fmdebugread.c;h=2e9608b1202aa311a9361cd84c875a312f07c21f;hb=346d1dfebdbc5b7c8ce7d84f9250cbb8f4ec3e6c;hp=2fed944a79c324022a8a3aaa2544556edaa5058a;hpb=05cba821addfe83535ad36f7487d1d2bbac48ba2;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 2fed944a79..2e9608b120 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1,6 +1,6 @@ /* Read a symbol table in ECOFF format (Third-Eye). - Copyright (C) 1986-2013 Free Software Foundation, Inc. + Copyright (C) 1986-2014 Free Software Foundation, Inc. Original version contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major work by Per Bothner, John Gilmore and Ian Lance Taylor @@ -55,8 +55,8 @@ #include "block.h" #include "dictionary.h" #include "mdebugread.h" -#include "gdb_stat.h" -#include "gdb_string.h" +#include +#include #include "psympriv.h" #include "source.h" @@ -248,8 +248,8 @@ static struct blockvector *new_bvect (int); static struct type *parse_type (int, union aux_ext *, unsigned int, int *, int, char *); -static struct symbol *mylookup_symbol (char *, struct block *, domain_enum, - enum address_class); +static struct symbol *mylookup_symbol (char *, const struct block *, + domain_enum, enum address_class); static void sort_blocks (struct symtab *); @@ -542,6 +542,11 @@ static const struct symbol_register_ops mdebug_register_funcs = { mdebug_reg_to_regnum }; +/* The "aclass" indices for computed symbols. */ + +static int mdebug_register_index; +static int mdebug_regparm_index; + static int parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, struct section_offsets *section_offsets, struct objfile *objfile) @@ -626,16 +631,13 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, s = new_symbol (name); SYMBOL_VALUE (s) = svalue; if (sh->sc == scRegister) - { - class = LOC_REGISTER; - SYMBOL_REGISTER_OPS (s) = &mdebug_register_funcs; - } + class = mdebug_register_index; else class = LOC_LOCAL; data: /* Common code for symbols describing data. */ SYMBOL_DOMAIN (s) = VAR_DOMAIN; - SYMBOL_CLASS (s) = class; + SYMBOL_ACLASS_INDEX (s) = class; add_symbol (s, top_stack->cur_st, b); /* Type could be missing if file is compiled without debugging info. */ @@ -664,21 +666,19 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, { case scRegister: /* Pass by value in register. */ - SYMBOL_CLASS (s) = LOC_REGISTER; - SYMBOL_REGISTER_OPS (s) = &mdebug_register_funcs; + SYMBOL_ACLASS_INDEX (s) = mdebug_register_index; break; case scVar: /* Pass by reference on stack. */ - SYMBOL_CLASS (s) = LOC_REF_ARG; + SYMBOL_ACLASS_INDEX (s) = LOC_REF_ARG; break; case scVarRegister: /* Pass by reference in register. */ - SYMBOL_CLASS (s) = LOC_REGPARM_ADDR; - SYMBOL_REGISTER_OPS (s) = &mdebug_register_funcs; + SYMBOL_ACLASS_INDEX (s) = mdebug_regparm_index; break; default: /* Pass by value on stack. */ - SYMBOL_CLASS (s) = LOC_ARG; + SYMBOL_ACLASS_INDEX (s) = LOC_ARG; break; } SYMBOL_VALUE (s) = svalue; @@ -689,7 +689,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, case stLabel: /* label, goes into current block. */ s = new_symbol (name); SYMBOL_DOMAIN (s) = VAR_DOMAIN; /* So that it can be used */ - SYMBOL_CLASS (s) = LOC_LABEL; /* but not misused. */ + SYMBOL_ACLASS_INDEX (s) = LOC_LABEL; /* but not misused. */ SYMBOL_VALUE_ADDRESS (s) = (CORE_ADDR) sh->value; SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_int; add_symbol (s, top_stack->cur_st, top_stack->cur_block); @@ -731,7 +731,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, } s = new_symbol (name); SYMBOL_DOMAIN (s) = VAR_DOMAIN; - SYMBOL_CLASS (s) = LOC_BLOCK; + SYMBOL_ACLASS_INDEX (s) = LOC_BLOCK; /* Type of the return value. */ if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil) t = objfile_type (objfile)->builtin_int; @@ -756,7 +756,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, b = top_stack->cur_block; if (sh->st == stProc) { - struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st); + const struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st); /* The next test should normally be true, but provides a hook for nested functions (which we don't want to make @@ -1048,15 +1048,12 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss; FIELD_BITSIZE (*f) = 0; - enum_sym = ((struct symbol *) - obstack_alloc (&mdebugread_objfile->objfile_obstack, - sizeof (struct symbol))); - memset (enum_sym, 0, sizeof (struct symbol)); + enum_sym = allocate_symbol (mdebugread_objfile); SYMBOL_SET_LINKAGE_NAME (enum_sym, obstack_copy0 (&mdebugread_objfile->objfile_obstack, f->name, strlen (f->name))); - SYMBOL_CLASS (enum_sym) = LOC_CONST; + SYMBOL_ACLASS_INDEX (enum_sym) = LOC_CONST; SYMBOL_TYPE (enum_sym) = t; SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN; SYMBOL_VALUE (enum_sym) = tsym.value; @@ -1089,7 +1086,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, s = new_symbol (name); SYMBOL_DOMAIN (s) = STRUCT_DOMAIN; - SYMBOL_CLASS (s) = LOC_TYPEDEF; + SYMBOL_ACLASS_INDEX (s) = LOC_TYPEDEF; SYMBOL_VALUE (s) = 0; SYMBOL_TYPE (s) = t; add_symbol (s, top_stack->cur_st, top_stack->cur_block); @@ -1134,7 +1131,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, top_stack->blocktype == stStaticProc)) { /* Finished with procedure */ - struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st); + const struct blockvector *bv = BLOCKVECTOR (top_stack->cur_st); struct mdebug_extra_func_info *e; struct block *b = top_stack->cur_block; struct type *ftype = top_stack->cur_type; @@ -1145,7 +1142,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, /* Make up special symbol to contain procedure specific info. */ s = new_symbol (MDEBUG_EFI_SYMBOL_NAME); SYMBOL_DOMAIN (s) = LABEL_DOMAIN; - SYMBOL_CLASS (s) = LOC_CONST; + SYMBOL_ACLASS_INDEX (s) = LOC_CONST; SYMBOL_TYPE (s) = objfile_type (mdebugread_objfile)->builtin_void; e = ((struct mdebug_extra_func_info *) obstack_alloc (&mdebugread_objfile->objfile_obstack, @@ -1285,7 +1282,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, break; s = new_symbol (name); SYMBOL_DOMAIN (s) = VAR_DOMAIN; - SYMBOL_CLASS (s) = LOC_TYPEDEF; + SYMBOL_ACLASS_INDEX (s) = LOC_TYPEDEF; SYMBOL_BLOCK_VALUE (s) = top_stack->cur_block; SYMBOL_TYPE (s) = t; add_symbol (s, top_stack->cur_st, top_stack->cur_block); @@ -1872,8 +1869,8 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend, ax++; rf = AUX_GET_WIDTH (bigend, ax); /* bit size of array element */ - range = create_range_type ((struct type *) NULL, indx, - lower, upper); + range = create_static_range_type ((struct type *) NULL, indx, + lower, upper); t = create_array_type ((struct type *) NULL, *tpp, range); @@ -1931,7 +1928,7 @@ parse_procedure (PDR *pr, struct symtab *search_symtab, struct partial_symtab *pst) { struct symbol *s, *i; - struct block *b; + const struct block *b; char *sh_name; /* Simple rule to find files linked "-x". */ @@ -2259,74 +2256,59 @@ record_minimal_symbol (const char *name, const CORE_ADDR address, struct objfile *objfile) { int section; - asection *bfd_section; switch (storage_class) { case scText: section = SECT_OFF_TEXT (objfile); - bfd_section = bfd_get_section_by_name (cur_bfd, ".text"); break; case scData: section = SECT_OFF_DATA (objfile); - bfd_section = bfd_get_section_by_name (cur_bfd, ".data"); break; case scBss: section = SECT_OFF_BSS (objfile); - bfd_section = bfd_get_section_by_name (cur_bfd, ".bss"); break; case scSData: section = get_section_index (objfile, ".sdata"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".sdata"); break; case scSBss: section = get_section_index (objfile, ".sbss"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".sbss"); break; case scRData: section = get_section_index (objfile, ".rdata"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".rdata"); break; case scInit: section = get_section_index (objfile, ".init"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".init"); break; case scXData: section = get_section_index (objfile, ".xdata"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".xdata"); break; case scPData: section = get_section_index (objfile, ".pdata"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".pdata"); break; case scFini: section = get_section_index (objfile, ".fini"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".fini"); break; case scRConst: section = get_section_index (objfile, ".rconst"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".rconst"); break; #ifdef scTlsData case scTlsData: section = get_section_index (objfile, ".tlsdata"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsdata"); break; #endif #ifdef scTlsBss case scTlsBss: section = get_section_index (objfile, ".tlsbss"); - bfd_section = bfd_get_section_by_name (cur_bfd, ".tlsbss"); break; #endif default: /* This kind of symbol is not associated to a section. */ section = -1; - bfd_section = NULL; } prim_record_minimal_symbol_and_info (name, address, ms_type, - section, bfd_section, objfile); + section, objfile); } /* Master parsing procedure for first-pass reading of file symbols @@ -2537,14 +2519,10 @@ parse_partial_symbols (struct objfile *objfile) { 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 */ @@ -2557,20 +2535,14 @@ parse_partial_symbols (struct objfile *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 if (SC_IS_SBSS (ext_in->asym.sc)) { ms_type = mst_bss; - svalue += ANOFFSET (objfile->section_offsets, - get_section_index (objfile, ".sbss")); } else ms_type = mst_abs; @@ -2603,8 +2575,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_text; - svalue += ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); } else if (SC_IS_DATA (ext_in->asym.sc)) { @@ -2612,8 +2582,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_data; - svalue += ANOFFSET (objfile->section_offsets, - SECT_OFF_DATA (objfile)); } else if (SC_IS_BSS (ext_in->asym.sc)) { @@ -2621,8 +2589,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_bss; - svalue += ANOFFSET (objfile->section_offsets, - SECT_OFF_BSS (objfile)); } else if (SC_IS_SBSS (ext_in->asym.sc)) { @@ -2632,7 +2598,6 @@ parse_partial_symbols (struct objfile *objfile) continue; ms_type = mst_file_bss; - svalue += ANOFFSET (objfile->section_offsets, sbss_sect_index); } else ms_type = mst_abs; @@ -2766,8 +2731,6 @@ parse_partial_symbols (struct objfile *objfile) CORE_ADDR procaddr; long isym; - sh.value += ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); if (sh.st == stStaticProc) { namestring = debug_info->ss + fh->issBase + sh.iss; @@ -2775,6 +2738,8 @@ parse_partial_symbols (struct objfile *objfile) mst_file_text, sh.sc, objfile); } + sh.value += ANOFFSET (objfile->section_offsets, + SECT_OFF_TEXT (objfile)); procaddr = sh.value; isym = AUX_GET_ISYM (fh->fBigendian, @@ -2814,22 +2779,22 @@ parse_partial_symbols (struct objfile *objfile) case scPData: case scXData: namestring = debug_info->ss + fh->issBase + sh.iss; - sh.value += ANOFFSET (objfile->section_offsets, - SECT_OFF_DATA (objfile)); record_minimal_symbol (namestring, sh.value, mst_file_data, sh.sc, objfile); + sh.value += ANOFFSET (objfile->section_offsets, + SECT_OFF_DATA (objfile)); break; default: /* 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 (objfile->section_offsets, - SECT_OFF_BSS (objfile)); record_minimal_symbol (namestring, sh.value, mst_file_bss, sh.sc, objfile); + sh.value += ANOFFSET (objfile->section_offsets, + SECT_OFF_BSS (objfile)); break; } } @@ -3453,6 +3418,7 @@ parse_partial_symbols (struct objfile *objfile) { char *name; enum address_class class; + CORE_ADDR minsym_value; (*swap_sym_in) (cur_bfd, ((char *) debug_info->external_sym @@ -3478,6 +3444,8 @@ parse_partial_symbols (struct objfile *objfile) name = debug_info->ss + fh->issBase + sh.iss; + minsym_value = sh.value; + switch (sh.sc) { case scText: @@ -3510,10 +3478,10 @@ parse_partial_symbols (struct objfile *objfile) int new_sdx; case stStaticProc: - prim_record_minimal_symbol_and_info (name, sh.value, + prim_record_minimal_symbol_and_info (name, minsym_value, mst_file_text, SECT_OFF_TEXT (objfile), - NULL, objfile); + objfile); /* FALLTHROUGH */ @@ -3596,16 +3564,14 @@ parse_partial_symbols (struct objfile *objfile) case stStatic: /* Variable */ if (SC_IS_DATA (sh.sc)) - prim_record_minimal_symbol_and_info (name, sh.value, + prim_record_minimal_symbol_and_info (name, minsym_value, mst_file_data, SECT_OFF_DATA (objfile), - NULL, objfile); else - prim_record_minimal_symbol_and_info (name, sh.value, + prim_record_minimal_symbol_and_info (name, minsym_value, mst_file_bss, SECT_OFF_BSS (objfile), - NULL, objfile); class = LOC_STATIC; break; @@ -4119,7 +4085,7 @@ psymtab_to_symtab_1 (struct objfile *objfile, memset (e, 0, sizeof (struct mdebug_extra_func_info)); SYMBOL_DOMAIN (s) = LABEL_DOMAIN; - SYMBOL_CLASS (s) = LOC_CONST; + SYMBOL_ACLASS_INDEX (s) = LOC_CONST; SYMBOL_TYPE (s) = objfile_type (objfile)->builtin_void; SYMBOL_VALUE_BYTES (s) = (gdb_byte *) e; e->pdr.framereg = -1; @@ -4354,7 +4320,7 @@ psymtab_to_symtab_1 (struct objfile *objfile, } pop_parse_stack (); - st->primary = 1; + set_symtab_primary (st, 1); sort_blocks (st); } @@ -4604,7 +4570,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp, keeping the symtab sorted. */ static struct symbol * -mylookup_symbol (char *name, struct block *block, +mylookup_symbol (char *name, const struct block *block, domain_enum domain, enum address_class class) { struct block_iterator iter; @@ -4642,7 +4608,9 @@ add_symbol (struct symbol *s, struct symtab *symtab, struct block *b) static void add_block (struct block *b, struct symtab *s) { - struct blockvector *bv = BLOCKVECTOR (s); + /* Cast away "const", but that's ok because we're building the + symtab and blockvector here. */ + struct blockvector *bv = (struct blockvector *) BLOCKVECTOR (s); bv = (struct blockvector *) xrealloc ((void *) bv, (sizeof (struct blockvector) @@ -4711,7 +4679,9 @@ compare_blocks (const void *arg1, const void *arg2) static void sort_blocks (struct symtab *s) { - struct blockvector *bv = BLOCKVECTOR (s); + /* We have to cast away const here, but this is ok because we're + constructing the blockvector in this code. */ + struct blockvector *bv = (struct blockvector *) BLOCKVECTOR (s); if (BLOCKVECTOR_NBLOCKS (bv) <= FIRST_LOCAL_BLOCK) { @@ -4763,17 +4733,17 @@ static struct symtab * new_symtab (const char *name, int maxlines, struct objfile *objfile) { struct symtab *s = allocate_symtab (name, objfile); + struct blockvector *bv; LINETABLE (s) = new_linetable (maxlines); /* All symtabs must have at least two blocks. */ - BLOCKVECTOR (s) = new_bvect (2); - BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK) - = new_block (NON_FUNCTION_BLOCK); - BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) - = new_block (NON_FUNCTION_BLOCK); - BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK)) = - BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); + bv = new_bvect (2); + BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = new_block (NON_FUNCTION_BLOCK); + BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK); + BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) = + BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); + BLOCKVECTOR (s) = bv; s->debugformat = "ECOFF"; return (s); @@ -4879,12 +4849,10 @@ new_block (enum block_type type) static struct symbol * new_symbol (char *name) { - struct symbol *s = ((struct symbol *) - obstack_alloc (&mdebugread_objfile->objfile_obstack, - sizeof (struct symbol))); + struct symbol *s = allocate_symbol (mdebugread_objfile); - memset (s, 0, sizeof (*s)); - SYMBOL_SET_LANGUAGE (s, psymtab_language); + SYMBOL_SET_LANGUAGE (s, psymtab_language, + &mdebugread_objfile->objfile_obstack); SYMBOL_SET_NAMES (s, name, strlen (name), 1, mdebugread_objfile); return s; } @@ -4940,4 +4908,9 @@ void _initialize_mdebugread (void) { basic_type_data = register_objfile_data (); + + mdebug_register_index + = register_symbol_register_impl (LOC_REGISTER, &mdebug_register_funcs); + mdebug_regparm_index + = register_symbol_register_impl (LOC_REGPARM_ADDR, &mdebug_register_funcs); }