/* Symbol table lookup for the GNU debugger, GDB.
- Copyright (C) 1986-2020 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
This file is part of GDB.
#include "addrmap.h"
#include "cli/cli-utils.h"
#include "cli/cli-style.h"
+#include "cli/cli-cmds.h"
#include "fnmatch.h"
#include "hashtab.h"
#include "typeprint.h"
for (objfile *objfile : current_program_space->objfiles ())
{
- if (objfile->sf
- && objfile->sf->qf->map_symtabs_matching_filename (objfile,
- name,
- real_path.get (),
- callback))
+ if (objfile->map_symtabs_matching_filename (name, real_path.get (),
+ callback))
return;
}
}
/* See symtab.h. */
+struct obj_section *
+general_symbol_info::obj_section (const struct objfile *objfile) const
+{
+ if (section_index () >= 0)
+ return &objfile->sections[section_index ()];
+ return nullptr;
+}
+
+/* See symtab.h. */
+
bool
symbol_matches_search_name (const struct general_symbol_info *gsymbol,
const lookup_name_info &name)
for (objfile *objfile : current_program_space->objfiles ())
{
- struct compunit_symtab *cust = NULL;
-
- if (objfile->sf)
- cust = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
- pc, section, 0);
+ struct compunit_symtab *cust
+ = objfile->find_pc_sect_compunit_symtab (msymbol, pc, section, 0);
if (cust)
return;
}
msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->linkage_name (),
objfile);
if (msym)
- ginfo->section = MSYMBOL_SECTION (msym);
+ ginfo->set_section_index (msym->section_index ());
else
{
/* Static, function-local variables do appear in the linker
if (obj_section_addr (s) - offset <= addr
&& addr < obj_section_endaddr (s) - offset)
{
- ginfo->section = idx;
+ ginfo->set_section_index (idx);
return;
}
}
section. If there is no allocated section, then it hardly
matters what we pick, so just pick zero. */
if (fallback == -1)
- ginfo->section = 0;
+ ginfo->set_section_index (0);
else
- ginfo->section = fallback;
+ ginfo->set_section_index (fallback);
}
}
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. */
}
else if (lang == language_go)
{
- char *demangled_name = go_demangle (name, 0);
+ char *demangled_name
+ = language_def (language_go)->demangle_symbol (name, 0);
if (demangled_name != NULL)
return storage.set_malloc_ptr (demangled_name);
}
const struct block *block;
struct block_symbol result;
- if (!objfile->sf)
- return {};
-
if (symbol_lookup_debug > 1)
{
fprintf_unfiltered (gdb_stdlog,
name, domain_name (domain));
}
- cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name, domain);
+ cust = objfile->lookup_symbol (block_index, name, domain);
if (cust == NULL)
{
if (symbol_lookup_debug > 1)
static enum language
find_quick_global_symbol_language (const char *name, const domain_enum domain)
{
- for (objfile *objfile : current_program_space->objfiles ())
- {
- if (objfile->sf && objfile->sf->qf
- && objfile->sf->qf->lookup_global_symbol_language)
- continue;
- return language_unknown;
- }
-
for (objfile *objfile : current_program_space->objfiles ())
{
bool symbol_found_p;
enum language lang
- = objfile->sf->qf->lookup_global_symbol_language (objfile, name, domain,
- &symbol_found_p);
- if (!symbol_found_p)
- continue;
- return lang;
+ = objfile->lookup_global_symbol_language (name, domain, &symbol_found_p);
+ if (symbol_found_p)
+ return lang;
}
return language_unknown;
const struct block *block;
struct symbol *sym;
- if (!objfile->sf)
- return NULL;
- cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name,
- STRUCT_DOMAIN);
+ cust = objfile->lookup_symbol (block_index, name, STRUCT_DOMAIN);
if (cust == NULL)
return NULL;
/* In order to better support objfiles that contain both
stabs and coff debugging info, we continue on if a psymtab
can't be found. */
- if ((obj_file->flags & OBJF_REORDERED) && obj_file->sf)
+ if ((obj_file->flags & OBJF_REORDERED) != 0)
{
struct compunit_symtab *result;
result
- = obj_file->sf->qf->find_pc_sect_compunit_symtab (obj_file,
- msymbol,
- pc,
- section,
- 0);
+ = obj_file->find_pc_sect_compunit_symtab (msymbol,
+ pc,
+ section,
+ 0);
if (result != NULL)
return result;
}
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;
}
for (objfile *objf : current_program_space->objfiles ())
{
- struct compunit_symtab *result;
-
- if (!objf->sf)
- continue;
- result = objf->sf->qf->find_pc_sect_compunit_symtab (objf,
- msymbol,
- pc, section,
- 1);
+ struct compunit_symtab *result
+ = objf->find_pc_sect_compunit_symtab (msymbol, pc, section, 1);
if (result != NULL)
return result;
}
for (objfile *objfile : current_program_space->objfiles ())
{
- /* If this objfile doesn't have "quick" functions, then it may
- have been read with -readnow, in which case we need to search
- the symtabs directly. */
- if (objfile->sf == NULL
- || objfile->sf->qf->find_compunit_symtab_by_address == NULL)
+ /* If this objfile was read with -readnow, then we need to
+ search the symtabs directly. */
+ if ((objfile->flags & OBJF_READNOW) != 0)
{
for (compunit_symtab *symtab : objfile->compunits ())
{
else
{
struct compunit_symtab *symtab
- = objfile->sf->qf->find_compunit_symtab_by_address (objfile,
- address);
+ = objfile->find_compunit_symtab_by_address (address);
if (symtab != NULL)
{
struct symbol *sym = search_symtab (symtab, address);
best = 0;
for (objfile *objfile : current_program_space->objfiles ())
- {
- if (objfile->sf)
- objfile->sf->qf->expand_symtabs_with_fullname
- (objfile, symtab_to_fullname (sym_tab));
- }
+ objfile->expand_symtabs_with_fullname (symtab_to_fullname (sym_tab));
for (objfile *objfile : current_program_space->objfiles ())
{
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 ();
}
enum search_domain kind = m_kind;
bool found_msymbol = false;
- if (objfile->sf)
- objfile->sf->qf->expand_symtabs_matching
- (objfile,
- [&] (const char *filename, bool basenames)
- {
- return file_matches (filename, filenames, basenames);
- },
- &lookup_name_info::match_any (),
- [&] (const char *symname)
- {
- return (!preg.has_value ()
- || preg->exec (symname, 0, NULL, 0) == 0);
- },
- NULL,
- kind);
+ objfile->expand_symtabs_matching
+ ([&] (const char *filename, bool basenames)
+ {
+ return file_matches (filename, filenames, basenames);
+ },
+ &lookup_name_info::match_any (),
+ [&] (const char *symname)
+ {
+ return (!preg.has_value ()
+ || preg->exec (symname, 0, NULL, 0) == 0);
+ },
+ NULL,
+ kind);
/* Here, we search through the minimal symbol tables for functions and
variables that match, and force their symbols to be read. This is in
if (MSYMBOL_TYPE (minsym) == mst_data_gnu_ifunc)
{
struct gdbarch *gdbarch = objfile->arch ();
- msym_addr
- = gdbarch_convert_from_func_ptr_addr (gdbarch,
- msym_addr,
- current_top_target ());
+ msym_addr = gdbarch_convert_from_func_ptr_addr
+ (gdbarch, msym_addr, current_inferior ()->top_target ());
}
if (msym_addr == address)
{
return BMSYMBOL_VALUE_ADDRESS (found);
}
}
- return minsym->value.address + objf->section_offsets[minsym->section];
+ return (minsym->value.address
+ + objf->section_offsets[minsym->section_index ()]);
}
\f
_("Print symbol cache statistics for each program space."),
&maintenanceprintlist);
- add_cmd ("flush-symbol-cache", class_maintenance,
+ add_cmd ("symbol-cache", class_maintenance,
maintenance_flush_symbol_cache,
_("Flush the symbol cache for each program space."),
- &maintenancelist);
+ &maintenanceflushlist);
+ c = add_alias_cmd ("flush-symbol-cache", "flush symbol-cache",
+ class_maintenance, 0, &maintenancelist);
+ deprecate_cmd (c, "maintenancelist flush symbol-cache");
gdb::observers::executable_changed.attach (symtab_observer_executable_changed);
gdb::observers::new_objfile.attach (symtab_new_objfile_observer);