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. */
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 ();
}
/* Flag of whether we're printing the first one. */
int first;
-};
-/* Slave routine for sources_info. Force line breaks at ,'s.
- NAME is the name to print.
- DATA contains the state for printing and watching for duplicates. */
+ /* Worker for sources_info. Force line breaks at ,'s.
+ NAME is the name to print. */
+ void output (const char *name);
-static void
-output_source_filename (const char *name,
- struct output_source_filename_data *data)
+ /* An overload suitable for use as a callback to
+ quick_symbol_functions::map_symbol_filenames. */
+ void operator() (const char *filename, const char *fullname)
+ {
+ output (fullname != nullptr ? fullname : filename);
+ }
+};
+
+void
+output_source_filename_data::output (const char *name)
{
/* Since a single source file can result in several partial symbol
tables, we need to avoid printing it more than once. Note: if
symtabs; it doesn't hurt to check. */
/* Was NAME already seen? */
- if (data->filename_seen_cache->seen (name))
+ if (filename_seen_cache->seen (name))
{
/* Yes; don't print it again. */
return;
}
- /* Does it match data->regexp? */
- if (data->c_regexp.has_value ())
+ /* Does it match regexp? */
+ if (c_regexp.has_value ())
{
const char *to_match;
std::string dirname;
- if (data->partial_match.dirname)
+ if (partial_match.dirname)
{
dirname = ldirname (name);
to_match = dirname.c_str ();
}
- else if (data->partial_match.basename)
+ else if (partial_match.basename)
to_match = lbasename (name);
else
to_match = name;
- if (data->c_regexp->exec (to_match, 0, NULL, 0) != 0)
+ if (c_regexp->exec (to_match, 0, NULL, 0) != 0)
return;
}
/* Print it and reset *FIRST. */
- if (! data->first)
+ if (! first)
printf_filtered (", ");
- data->first = 0;
+ first = 0;
wrap_here ("");
fputs_styled (name, file_name_style.style (), gdb_stdout);
}
-/* A callback for map_partial_symbol_filenames. */
-
-static void
-output_partial_symbol_filename (const char *filename, const char *fullname,
- void *data)
-{
- output_source_filename (fullname ? fullname : filename,
- (struct output_source_filename_data *) data);
-}
-
using isrc_flag_option_def
= gdb::option::flag_option_def<filename_partial_match_opts>;
{
const char *fullname = symtab_to_fullname (s);
- output_source_filename (fullname, &data);
+ data.output (fullname);
}
}
}
filenames_seen.clear ();
data.first = 1;
- map_symbol_filenames (output_partial_symbol_filename, &data,
- 1 /*need_fullname*/);
+ map_symbol_filenames (data, true /*need_fullname*/);
printf_filtered ("\n");
}
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,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ UNDEF_DOMAIN,
+ 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)
{
add_symtab_completions (symtab,
tracker, mode, lookup_name,
sym_text, word, code);
+ return true;
},
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
ALL_DOMAIN);
/* Search upwards from currently selected frame (so that we can
return 0;
}
-/* An object of this type is passed as the user_data argument to
+/* An object of this type is passed as the callback argument to
map_partial_symbol_filenames. */
struct add_partial_filename_data
{
const char *word;
int text_len;
completion_list *list;
+
+ void operator() (const char *filename, const char *fullname);
};
/* A callback for map_partial_symbol_filenames. */
-static void
-maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
- void *user_data)
+void
+add_partial_filename_data::operator() (const char *filename,
+ const char *fullname)
{
- struct add_partial_filename_data *data
- = (struct add_partial_filename_data *) user_data;
-
if (not_interesting_fname (filename))
return;
- if (!data->filename_seen_cache->seen (filename)
- && filename_ncmp (filename, data->text, data->text_len) == 0)
+ if (!filename_seen_cache->seen (filename)
+ && filename_ncmp (filename, text, text_len) == 0)
{
/* This file matches for a completion; add it to the
current list of matches. */
- add_filename_to_list (filename, data->text, data->word, data->list);
+ add_filename_to_list (filename, text, word, list);
}
else
{
const char *base_name = lbasename (filename);
if (base_name != filename
- && !data->filename_seen_cache->seen (base_name)
- && filename_ncmp (base_name, data->text, data->text_len) == 0)
- add_filename_to_list (base_name, data->text, data->word, data->list);
+ && !filename_seen_cache->seen (base_name)
+ && filename_ncmp (base_name, text, text_len) == 0)
+ add_filename_to_list (base_name, text, word, list);
}
}
datum.word = word;
datum.text_len = text_len;
datum.list = &list;
- map_symbol_filenames (maybe_add_partial_symtab_filename, &datum,
- 0 /*need_fullname*/);
+ map_symbol_filenames (datum, false /*need_fullname*/);
return list;
}
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