diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-02-05 22:01:48 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-02-10 14:38:08 +0000 |
commit | ebbc3a7d56f82f68bbeece3d7daf1823c9d98170 (patch) | |
tree | 07d4658bb23d7c55f074c9a2cf7fb0141f389948 | |
parent | 52ff20fe7ba8e8de2660339fff5308ed932e2b32 (diff) | |
download | gdb-ebbc3a7d56f82f68bbeece3d7daf1823c9d98170.zip gdb-ebbc3a7d56f82f68bbeece3d7daf1823c9d98170.tar.gz gdb-ebbc3a7d56f82f68bbeece3d7daf1823c9d98170.tar.bz2 |
gdb: Delete SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION
Replace the two macros SYMBOL_OBJ_SECTION and MSYMBOL_OBJ_SECTION with
a member function on general_symbol_info.
There should be no user visible change after this commit.
gdb/ChangeLog:
* breakpoint.c (resolve_sal_pc): Replace SYMBOL_OBJ_SECTION and
MSYMBOL_OBJ_SECTION.
* findvar.c (language_defn::read_var_value): Likewise.
* infcmd.c (jump_command): Likewise.
* linespec.c (minsym_found): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minsyms.c (lookup_minimal_symbol_by_pc_section): Likewise.
(minimal_symbol_upper_bound): Likewise.
* parse.c (find_minsym_type_and_address): Likewise.
(operator_check_standard): Likewise.
* printcmd.c (info_address_command): Likewise.
* symmisc.c (dump_msymbols): Likewise.
(print_symbol): Likewise.
* symtab.c (general_symbol_info::obj_section): Define new
function.
(fixup_symbol_section): Replace SYMBOL_OBJ_SECTION.
(find_pc_sect_compunit_symtab): Likewise.
(find_function_start_sal): Likewise.
(skip_prologue_sal): Replace SYMBOL_OBJ_SECTION and
MSYMBOL_OBJ_SECTION.
* symtab.h (struct general_symbol_info) <obj_section>: Declare new
function.
(SYMBOL_OBJ_SECTION): Delete.
(MSYMBOL_OBJ_SECTION): Delete.
-rw-r--r-- | gdb/ChangeLog | 27 | ||||
-rw-r--r-- | gdb/breakpoint.c | 5 | ||||
-rw-r--r-- | gdb/findvar.c | 18 | ||||
-rw-r--r-- | gdb/infcmd.c | 2 | ||||
-rw-r--r-- | gdb/linespec.c | 2 | ||||
-rw-r--r-- | gdb/maint.c | 2 | ||||
-rw-r--r-- | gdb/minsyms.c | 10 | ||||
-rw-r--r-- | gdb/parse.c | 5 | ||||
-rw-r--r-- | gdb/printcmd.c | 6 | ||||
-rw-r--r-- | gdb/symmisc.c | 4 | ||||
-rw-r--r-- | gdb/symtab.c | 21 | ||||
-rw-r--r-- | gdb/symtab.h | 14 |
12 files changed, 73 insertions, 43 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 120dee8..67c9980 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,30 @@ +2021-02-10 Andrew Burgess <andrew.burgess@embecosm.com> + + * breakpoint.c (resolve_sal_pc): Replace SYMBOL_OBJ_SECTION and + MSYMBOL_OBJ_SECTION. + * findvar.c (language_defn::read_var_value): Likewise. + * infcmd.c (jump_command): Likewise. + * linespec.c (minsym_found): Likewise. + * maint.c (maintenance_translate_address): Likewise. + * minsyms.c (lookup_minimal_symbol_by_pc_section): Likewise. + (minimal_symbol_upper_bound): Likewise. + * parse.c (find_minsym_type_and_address): Likewise. + (operator_check_standard): Likewise. + * printcmd.c (info_address_command): Likewise. + * symmisc.c (dump_msymbols): Likewise. + (print_symbol): Likewise. + * symtab.c (general_symbol_info::obj_section): Define new + function. + (fixup_symbol_section): Replace SYMBOL_OBJ_SECTION. + (find_pc_sect_compunit_symtab): Likewise. + (find_function_start_sal): Likewise. + (skip_prologue_sal): Replace SYMBOL_OBJ_SECTION and + MSYMBOL_OBJ_SECTION. + * symtab.h (struct general_symbol_info) <obj_section>: Declare new + function. + (SYMBOL_OBJ_SECTION): Delete. + (MSYMBOL_OBJ_SECTION): Delete. + 2021-02-09 Tom Tromey <tom@tromey.com> * stap-probe.c (stap_parse_argument_conditionally): Fix typo. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c20c0d7..5f1914e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -9677,8 +9677,7 @@ resolve_sal_pc (struct symtab_and_line *sal) if (sym != NULL) { fixup_symbol_section (sym, SYMTAB_OBJFILE (sal->symtab)); - sal->section = SYMBOL_OBJ_SECTION (SYMTAB_OBJFILE (sal->symtab), - sym); + sal->section = sym->obj_section (SYMTAB_OBJFILE (sal->symtab)); } else { @@ -9692,7 +9691,7 @@ resolve_sal_pc (struct symtab_and_line *sal) bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (sal->pc); if (msym.minsym) - sal->section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym); + sal->section = msym.minsym->obj_section (msym.objfile); } } } diff --git a/gdb/findvar.c b/gdb/findvar.c index 6abcd3a..fcd9719 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -638,11 +638,9 @@ language_defn::read_var_value (struct symbol *var, v = allocate_value (type); if (overlay_debugging) { - addr - = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), - SYMBOL_OBJ_SECTION (symbol_objfile (var), - var)); - + struct objfile *var_objfile = symbol_objfile (var); + addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), + var->obj_section (var_objfile)); store_typed_address (value_contents_raw (v), type, addr); } else @@ -665,9 +663,9 @@ language_defn::read_var_value (struct symbol *var, case LOC_STATIC: if (overlay_debugging) - addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), - SYMBOL_OBJ_SECTION (symbol_objfile (var), - var)); + addr + = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var), + var->obj_section (symbol_objfile (var))); else addr = SYMBOL_VALUE_ADDRESS (var); break; @@ -709,7 +707,7 @@ language_defn::read_var_value (struct symbol *var, if (overlay_debugging) addr = symbol_overlayed_address (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var)), - SYMBOL_OBJ_SECTION (symbol_objfile (var), var)); + var->obj_section (symbol_objfile (var))); else addr = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (var)); break; @@ -777,7 +775,7 @@ language_defn::read_var_value (struct symbol *var, error (_("Missing %s symbol \"%s\"."), flavour_name, var->linkage_name ()); } - obj_section = MSYMBOL_OBJ_SECTION (lookup_data.result.objfile, msym); + obj_section = msym->obj_section (lookup_data.result.objfile); /* Relocate address, unless there is no section or the variable is a TLS variable. */ if (obj_section == NULL diff --git a/gdb/infcmd.c b/gdb/infcmd.c index ebaf575..80e6ad3 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1110,7 +1110,7 @@ jump_command (const char *arg, int from_tty) struct obj_section *section; fixup_symbol_section (sfn, 0); - section = SYMBOL_OBJ_SECTION (symbol_objfile (sfn), sfn); + section = sfn->obj_section (symbol_objfile (sfn)); if (section_is_overlay (section) && !section_is_mapped (section)) { diff --git a/gdb/linespec.c b/gdb/linespec.c index a9809a5..9bfa159 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -4258,7 +4258,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, sal.pspace = current_program_space; } - sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol); + sal.section = msymbol->obj_section (objfile); if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc)) add_sal_to_sals (self, result, &sal, msymbol->natural_name (), 0); diff --git a/gdb/maint.c b/gdb/maint.c index d718d70..7495cab 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -509,7 +509,7 @@ maintenance_translate_address (const char *arg, int from_tty) const char *symbol_offset = pulongest (address - BMSYMBOL_VALUE_ADDRESS (sym)); - sect = MSYMBOL_OBJ_SECTION(sym.objfile, sym.minsym); + sect = sym.minsym->obj_section (sym.objfile); if (sect != NULL) { const char *section_name; diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 5c719f9..b861f93 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -800,9 +800,9 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio /* Some types of debug info, such as COFF, don't fill the bfd_section member, so don't throw away symbols on those platforms. */ - && MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]) != NULL + && msymbol[hi].obj_section (objfile) != nullptr && (!matching_obj_sections - (MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]), + (msymbol[hi].obj_section (objfile), section))) { hi--; @@ -820,8 +820,8 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio == MSYMBOL_SIZE (&msymbol[hi - 1])) && (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi]) == MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi - 1])) - && (MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]) - == MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi - 1]))) + && (msymbol[hi].obj_section (objfile) + == msymbol[hi - 1].obj_section (objfile))) { hi--; continue; @@ -1560,7 +1560,7 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym) break; } - obj_section = MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym); + obj_section = minsym.minsym->obj_section (minsym.objfile); if (iter != past_the_end && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter) < obj_section_endaddr (obj_section))) diff --git a/gdb/parse.c b/gdb/parse.c index 08fde89..d634a4f 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -416,7 +416,7 @@ find_minsym_type_and_address (minimal_symbol *msymbol, CORE_ADDR *address_p) { bound_minimal_symbol bound_msym = {msymbol, objfile}; - struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol); + struct obj_section *section = msymbol->obj_section (objfile); enum minimal_symbol_type type = MSYMBOL_TYPE (msymbol); bool is_tls = (section != NULL @@ -1359,8 +1359,7 @@ operator_check_standard (struct expression *exp, int pos, const struct block *const block = elts[pos + 1].block; const struct symbol *const symbol = elts[pos + 2].symbol; - /* Check objfile where the variable itself is placed. - SYMBOL_OBJ_SECTION (symbol) may be NULL. */ + /* Check objfile where the variable itself is placed. */ if ((*objfile_func) (symbol_objfile (symbol), data)) return 1; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 332d971..1e328a7 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1534,7 +1534,7 @@ info_address_command (const char *exp, int from_tty) fputs_styled (paddress (gdbarch, load_addr), address_style.style (), gdb_stdout); printf_filtered (" in a file compiled without debugging"); - section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym); + section = msymbol.minsym->obj_section (objfile); if (section_is_overlay (section)) { load_addr = overlay_unmapped_address (load_addr, section); @@ -1558,7 +1558,7 @@ info_address_command (const char *exp, int from_tty) printf_filtered ("\" is "); val = SYMBOL_VALUE (sym); if (SYMBOL_OBJFILE_OWNED (sym)) - section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym); + section = sym->obj_section (symbol_objfile (sym)); else section = NULL; gdbarch = symbol_arch (sym); @@ -1678,7 +1678,7 @@ info_address_command (const char *exp, int from_tty) printf_filtered ("unresolved"); else { - section = MSYMBOL_OBJ_SECTION (msym.objfile, msym.minsym); + section = msym.minsym->obj_section (msym.objfile); if (section && (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0) diff --git a/gdb/symmisc.c b/gdb/symmisc.c index fe353bc..ec4758c 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -196,7 +196,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) index = 0; for (minimal_symbol *msymbol : objfile->msymbols ()) { - struct obj_section *section = MSYMBOL_OBJ_SECTION (objfile, msymbol); + struct obj_section *section = msymbol->obj_section (objfile); switch (MSYMBOL_TYPE (msymbol)) { @@ -543,7 +543,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, struct obj_section *section; if (SYMBOL_OBJFILE_OWNED (symbol)) - section = SYMBOL_OBJ_SECTION (symbol_objfile (symbol), symbol); + section = symbol->obj_section (symbol_objfile (symbol)); else section = NULL; diff --git a/gdb/symtab.c b/gdb/symtab.c index 7ffb52a..9ad7c1f 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1012,6 +1012,16 @@ general_symbol_info::search_name () const /* See symtab.h. */ +struct obj_section * +general_symbol_info::obj_section (const struct objfile *objfile) const +{ + if (section >= 0) + return &objfile->sections[section]; + return nullptr; +} + +/* See symtab.h. */ + bool symbol_matches_search_name (const struct general_symbol_info *gsymbol, const lookup_name_info &name) @@ -1730,7 +1740,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile) if (objfile == NULL) objfile = symbol_objfile (sym); - if (SYMBOL_OBJ_SECTION (objfile, sym)) + if (sym->obj_section (objfile) != nullptr) return sym; /* We should have an objfile by now. */ @@ -2972,8 +2982,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) ALL_BLOCK_SYMBOLS (b, iter, sym) { fixup_symbol_section (sym, obj_file); - if (matching_obj_sections (SYMBOL_OBJ_SECTION (obj_file, - sym), + if (matching_obj_sections (sym->obj_section (obj_file), section)) break; } @@ -3732,7 +3741,7 @@ find_function_start_sal (symbol *sym, bool funfirstline) fixup_symbol_section (sym, NULL); symtab_and_line sal = find_function_start_sal_1 (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)), - SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym), + sym->obj_section (symbol_objfile (sym)), funfirstline); sal.symbol = sym; return sal; @@ -3823,7 +3832,7 @@ skip_prologue_sal (struct symtab_and_line *sal) objfile = symbol_objfile (sym); pc = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)); - section = SYMBOL_OBJ_SECTION (objfile, sym); + section = sym->obj_section (objfile); name = sym->linkage_name (); } else @@ -3836,7 +3845,7 @@ skip_prologue_sal (struct symtab_and_line *sal) objfile = msymbol.objfile; pc = BMSYMBOL_VALUE_ADDRESS (msymbol); - section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym); + section = msymbol.minsym->obj_section (objfile); name = msymbol.minsym->linkage_name (); } diff --git a/gdb/symtab.h b/gdb/symtab.h index f060e0e..e85ae68 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -540,6 +540,12 @@ struct general_symbol_info does not get relocated relative to a section. */ short section; + + /* Return the obj_section from OBJFILE for this symbol. The symbol + returned is based on the SECTION member variable, and can be nullptr + if SECTION is negative. */ + + struct obj_section *obj_section (const struct objfile *objfile) const; }; extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *); @@ -565,10 +571,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym); #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain #define SYMBOL_SECTION(symbol) (symbol)->section -#define SYMBOL_OBJ_SECTION(objfile, symbol) \ - (((symbol)->section >= 0) \ - ? (&(((objfile)->sections)[(symbol)->section])) \ - : NULL) /* Try to determine the demangled name for a symbol, based on the language of that symbol. If the language is set to language_auto, @@ -763,10 +765,6 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf, #define MSYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block #define MSYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain #define MSYMBOL_SECTION(symbol) (symbol)->section -#define MSYMBOL_OBJ_SECTION(objfile, symbol) \ - (((symbol)->section >= 0) \ - ? (&(((objfile)->sections)[(symbol)->section])) \ - : NULL) #include "minsyms.h" |