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.
This commit is contained in:
parent
52ff20fe7b
commit
ebbc3a7d56
12 changed files with 73 additions and 43 deletions
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
21
gdb/symtab.c
21
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 ();
|
||||
}
|
||||
|
||||
|
|
14
gdb/symtab.h
14
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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue