+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.
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
{
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);
}
}
}
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
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;
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;
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
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))
{
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);
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;
/* 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--;
== 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;
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)))
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
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;
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);
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);
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)
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))
{
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;
/* 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)
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. */
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;
}
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;
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
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 ();
}
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 *);
#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,
#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"