+2021-03-20 Tom Tromey <tom@tromey.com>
+
+ * psympriv.h (struct psymbol_functions): New.
+ * symfile.c (syms_from_objfile_1, reread_symbols): Update.
+ * symfile-debug.c (objfile::find_compunit_symtab_by_address)
+ (objfile::lookup_global_symbol_language): Update.
+ * quick-symbol.h (struct quick_symbol_functions): Convert function
+ pointers to methods. Add virtual destructor.
+ (quick_symbol_functions_up): New typedef.
+ * psymtab.h (psym_functions, dwarf2_gdb_index_functions)
+ (dwarf2_debug_names_functions): Don't declare.
+ (make_psymbol_functions): Declare.
+ * psymtab.c (psymbol_functions::map_symtabs_matching_filename)
+ (psymbol_functions::find_pc_sect_compunit_symtab)
+ (psymbol_functions::lookup_symbol)
+ (psymbol_functions::lookup_global_symbol_language)
+ (psymbol_functions::find_last_source_symtab)
+ (psymbol_functions::forget_cached_source_info)
+ (psymbol_functions::print_stats, psymbol_functions::dump)
+ (psymbol_functions::expand_symtabs_for_function)
+ (psymbol_functions::expand_all_symtabs)
+ (psymbol_functions::expand_symtabs_with_fullname)
+ (psymbol_functions::map_symbol_filenames)
+ (psymbol_functions::map_matching_symbols)
+ (psymbol_functions::expand_symtabs_matching)
+ (psymbol_functions::has_symbols)
+ (psymbol_functions::find_compunit_symtab_by_address): Rename.
+ (psym_functions): Remove.
+ (make_psymbol_functions): New function.
+ * objfiles.h (struct objfile) <qf>: Change type.
+ * elfread.c (elf_symfile_read): Update.
+ * dwarf2/read.c (struct dwarf2_base_index_functions)
+ (struct dwarf2_gdb_index, struct dwarf2_debug_names_index): New.
+ (make_dwarf_gdb_index, make_dwarf_debug_names): New functions.
+ (dwarf2_base_index_functions::find_last_source_symtab)
+ (dwarf2_base_index_functions::forget_cached_source_info)
+ (dwarf2_base_index_functions::map_symtabs_matching_filename)
+ (dwarf2_gdb_index::lookup_symbol)
+ (dwarf2_base_index_functions::print_stats)
+ (dwarf2_gdb_index::dump)
+ (dwarf2_gdb_index::expand_symtabs_for_function)
+ (dwarf2_base_index_functions::expand_all_symtabs)
+ (dwarf2_base_index_functions::expand_symtabs_with_fullname):
+ Rename.
+ (dwarf2_gdb_index::map_matching_symbols): New method.
+ (dwarf2_gdb_index::expand_symtabs_matching): New method.
+ (dwarf2_base_index_functions::find_pc_sect_compunit_symtab)
+ (dwarf2_base_index_functions::map_symbol_filenames)
+ (dwarf2_base_index_functions::has_symbols): Rename.
+ (dwarf2_gdb_index_functions): Remove.
+ (dwarf2_debug_names_index::lookup_symbol)
+ (dwarf2_debug_names_index::dump)
+ (dwarf2_debug_names_index::expand_symtabs_for_function)
+ (dwarf2_debug_names_index::map_matching_symbols)
+ (dwarf2_debug_names_index::expand_symtabs_matching): Rename.
+ (dwarf2_debug_names_functions): Remove.
+ * dwarf2/public.h (make_dwarf_gdb_index, make_dwarf_debug_names):
+ Declare.
+
2021-03-20 Tom Tromey <tom@tromey.com>
* psymtab.c (require_partial_symbols): Check that 'sf' is not
extern void dwarf2_build_psymtabs (struct objfile *);
extern void dwarf2_build_frame_info (struct objfile *);
+extern quick_symbol_functions_up make_dwarf_gdb_index ();
+extern quick_symbol_functions_up make_dwarf_debug_names ();
+
#endif /* DWARF2_PUBLIC_H */
}
\f
-/* DWARF quick_symbols_functions support. */
+/* DWARF quick_symbol_functions support. */
/* TUs can share .debug_line entries, and there can be a lot more TUs than
unique line tables, so we maintain a separate table of all .debug_line
unsigned int no_file_data : 1;
};
+struct dwarf2_base_index_functions : public quick_symbol_functions
+{
+ bool has_symbols (struct objfile *objfile) override;
+
+ struct symtab *find_last_source_symtab (struct objfile *objfile) override;
+
+ void forget_cached_source_info (struct objfile *objfile) override;
+
+ bool map_symtabs_matching_filename
+ (struct objfile *objfile, const char *name, const char *real_path,
+ gdb::function_view<bool (symtab *)> callback) override;
+
+ enum language lookup_global_symbol_language (struct objfile *objfile,
+ const char *name,
+ domain_enum domain,
+ bool *symbol_found_p) override
+ {
+ *symbol_found_p = false;
+ return language_unknown;
+ }
+
+ void print_stats (struct objfile *objfile) override;
+
+ void expand_all_symtabs (struct objfile *objfile) override;
+
+ void expand_symtabs_with_fullname (struct objfile *objfile,
+ const char *fullname) override;
+
+ struct compunit_symtab *find_pc_sect_compunit_symtab
+ (struct objfile *objfile, struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc, struct obj_section *section, int warn_if_readin) override;
+
+ struct compunit_symtab *find_compunit_symtab_by_address
+ (struct objfile *objfile, CORE_ADDR address) override
+ {
+ return nullptr;
+ }
+
+ void map_symbol_filenames (struct objfile *objfile,
+ symbol_filename_ftype *fun, void *data,
+ int need_fullname) override;
+};
+
+struct dwarf2_gdb_index : public dwarf2_base_index_functions
+{
+ struct compunit_symtab *lookup_symbol (struct objfile *objfile,
+ block_enum block_index,
+ const char *name,
+ domain_enum domain) override;
+
+ void dump (struct objfile *objfile) override;
+
+ void expand_symtabs_for_function (struct objfile *objfile,
+ const char *func_name) override;
+
+ void map_matching_symbols
+ (struct objfile *,
+ const lookup_name_info &lookup_name,
+ domain_enum domain,
+ int global,
+ gdb::function_view<symbol_found_callback_ftype> callback,
+ symbol_compare_ftype *ordered_compare) override;
+
+ void expand_symtabs_matching
+ (struct objfile *objfile,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ const lookup_name_info *lookup_name,
+ gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ enum search_domain kind) override;
+};
+
+struct dwarf2_debug_names_index : public dwarf2_base_index_functions
+{
+ struct compunit_symtab *lookup_symbol (struct objfile *objfile,
+ block_enum block_index,
+ const char *name,
+ domain_enum domain) override;
+
+ void dump (struct objfile *objfile) override;
+
+ void expand_symtabs_for_function (struct objfile *objfile,
+ const char *func_name) override;
+
+ void map_matching_symbols
+ (struct objfile *,
+ const lookup_name_info &lookup_name,
+ domain_enum domain,
+ int global,
+ gdb::function_view<symbol_found_callback_ftype> callback,
+ symbol_compare_ftype *ordered_compare) override;
+
+ void expand_symtabs_matching
+ (struct objfile *objfile,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ const lookup_name_info *lookup_name,
+ gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ enum search_domain kind) override;
+};
+
+quick_symbol_functions_up
+make_dwarf_gdb_index ()
+{
+ return quick_symbol_functions_up (new dwarf2_gdb_index);
+}
+
+quick_symbol_functions_up
+make_dwarf_debug_names ()
+{
+ return quick_symbol_functions_up (new dwarf2_debug_names_index);
+}
+
/* Utility hash function for a stmt_list_hash. */
static hashval_t
return qfn->real_names[index];
}
-static struct symtab *
-dw2_find_last_source_symtab (struct objfile *objfile)
+struct symtab *
+dwarf2_base_index_functions::find_last_source_symtab (struct objfile *objfile)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
dwarf2_per_cu_data *dwarf_cu = per_objfile->per_bfd->all_comp_units.back ();
return 1;
}
-static void
-dw2_forget_cached_source_info (struct objfile *objfile)
+void
+dwarf2_base_index_functions::forget_cached_source_info
+ (struct objfile *objfile)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
/* Implementation of the map_symtabs_matching_filename method. */
-static bool
-dw2_map_symtabs_matching_filename
+bool
+dwarf2_base_index_functions::map_symtabs_matching_filename
(struct objfile *objfile, const char *name, const char *real_path,
gdb::function_view<bool (symtab *)> callback)
{
return NULL;
}
-static struct compunit_symtab *
-dw2_lookup_symbol (struct objfile *objfile, block_enum block_index,
- const char *name, domain_enum domain)
+struct compunit_symtab *
+dwarf2_gdb_index::lookup_symbol (struct objfile *objfile,
+ block_enum block_index,
+ const char *name, domain_enum domain)
{
struct compunit_symtab *stab_best = NULL;
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
return stab_best;
}
-static void
-dw2_print_stats (struct objfile *objfile)
+void
+dwarf2_base_index_functions::print_stats (struct objfile *objfile)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
int total = (per_objfile->per_bfd->all_comp_units.size ()
One use is to verify .gdb_index has been loaded by the
gdb.dwarf2/gdb-index.exp testcase. */
-static void
-dw2_dump (struct objfile *objfile)
+void
+dwarf2_gdb_index::dump (struct objfile *objfile)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
printf_filtered ("\n");
}
-static void
-dw2_expand_symtabs_for_function (struct objfile *objfile,
- const char *func_name)
+void
+dwarf2_gdb_index::expand_symtabs_for_function (struct objfile *objfile,
+ const char *func_name)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
}
-static void
-dw2_expand_all_symtabs (struct objfile *objfile)
+void
+dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
int total_units = (per_objfile->per_bfd->all_comp_units.size ()
}
}
-static void
-dw2_expand_symtabs_with_fullname (struct objfile *objfile,
- const char *fullname)
+void
+dwarf2_base_index_functions::expand_symtabs_with_fullname
+ (struct objfile *objfile, const char *fullname)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
}
}
+void
+dwarf2_gdb_index::map_matching_symbols
+ (struct objfile *objfile,
+ const lookup_name_info &name, domain_enum domain,
+ int global,
+ gdb::function_view<symbol_found_callback_ftype> callback,
+ symbol_compare_ftype *ordered_compare)
+{
+ dw2_map_matching_symbols (objfile, name, domain, global, callback,
+ ordered_compare);
+}
+
/* Starting from a search name, return the string that finds the upper
bound of all strings that start with SEARCH_NAME in a sorted name
list. Returns the empty string to indicate that the upper bound is
}, per_objfile);
}
+void
+dwarf2_gdb_index::expand_symtabs_matching
+ (struct objfile *objfile,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ const lookup_name_info *lookup_name,
+ gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ enum search_domain kind)
+{
+ dw2_expand_symtabs_matching (objfile, file_matcher, lookup_name,
+ symbol_matcher, expansion_notify, kind);
+}
+
/* A helper for dw2_find_pc_sect_compunit_symtab which finds the most specific
symtab. */
return NULL;
}
-static struct compunit_symtab *
-dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
- struct bound_minimal_symbol msymbol,
- CORE_ADDR pc,
- struct obj_section *section,
- int warn_if_readin)
+struct compunit_symtab *
+dwarf2_base_index_functions::find_pc_sect_compunit_symtab
+ (struct objfile *objfile,
+ struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc,
+ struct obj_section *section,
+ int warn_if_readin)
{
struct dwarf2_per_cu_data *data;
struct compunit_symtab *result;
return result;
}
-static void
-dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
- void *data, int need_fullname)
+void
+dwarf2_base_index_functions::map_symbol_filenames (struct objfile *objfile,
+ symbol_filename_ftype *fun,
+ void *data,
+ int need_fullname)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
});
}
-static bool
-dw2_has_symbols (struct objfile *objfile)
+bool
+dwarf2_base_index_functions::has_symbols (struct objfile *objfile)
{
return true;
}
-const struct quick_symbol_functions dwarf2_gdb_index_functions =
-{
- dw2_has_symbols,
- dw2_find_last_source_symtab,
- dw2_forget_cached_source_info,
- dw2_map_symtabs_matching_filename,
- dw2_lookup_symbol,
- NULL,
- dw2_print_stats,
- dw2_dump,
- dw2_expand_symtabs_for_function,
- dw2_expand_all_symtabs,
- dw2_expand_symtabs_with_fullname,
- dw2_map_matching_symbols,
- dw2_expand_symtabs_matching,
- dw2_find_pc_sect_compunit_symtab,
- NULL,
- dw2_map_symbol_filenames
-};
-
/* DWARF-5 debug_names reader. */
/* DWARF-5 augmentation string for GDB's DW_IDX_GNU_* extension. */
return per_cu;
}
-static struct compunit_symtab *
-dw2_debug_names_lookup_symbol (struct objfile *objfile, block_enum block_index,
- const char *name, domain_enum domain)
+struct compunit_symtab *
+dwarf2_debug_names_index::lookup_symbol
+ (struct objfile *objfile, block_enum block_index,
+ const char *name, domain_enum domain)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
via "mt print objfiles". The gdb.dwarf2/gdb-index.exp testcase
uses this to verify that .debug_names has been loaded. */
-static void
-dw2_debug_names_dump (struct objfile *objfile)
+void
+dwarf2_debug_names_index::dump (struct objfile *objfile)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
printf_filtered ("\n");
}
-static void
-dw2_debug_names_expand_symtabs_for_function (struct objfile *objfile,
- const char *func_name)
+void
+dwarf2_debug_names_index::expand_symtabs_for_function
+ (struct objfile *objfile, const char *func_name)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
}
}
-static void
-dw2_debug_names_map_matching_symbols
+void
+dwarf2_debug_names_index::map_matching_symbols
(struct objfile *objfile,
const lookup_name_info &name, domain_enum domain,
int global,
}
}
-static void
-dw2_debug_names_expand_symtabs_matching
+void
+dwarf2_debug_names_index::expand_symtabs_matching
(struct objfile *objfile,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
const lookup_name_info *lookup_name,
}, per_objfile);
}
-const struct quick_symbol_functions dwarf2_debug_names_functions =
-{
- dw2_has_symbols,
- dw2_find_last_source_symtab,
- dw2_forget_cached_source_info,
- dw2_map_symtabs_matching_filename,
- dw2_debug_names_lookup_symbol,
- NULL,
- dw2_print_stats,
- dw2_debug_names_dump,
- dw2_debug_names_expand_symtabs_for_function,
- dw2_expand_all_symtabs,
- dw2_expand_symtabs_with_fullname,
- dw2_debug_names_map_matching_symbols,
- dw2_debug_names_expand_symtabs_matching,
- dw2_find_pc_sect_compunit_symtab,
- NULL,
- dw2_map_symbol_filenames
-};
-
/* Get the content of the .gdb_index section of OBJ. SECTION_OWNER should point
to either a dwarf2_per_bfd or dwz_file object. */
switch (index_kind)
{
case dw_index_kind::GDB_INDEX:
- objfile->qf = &dwarf2_gdb_index_functions;
+ objfile->qf = make_dwarf_gdb_index ();
break;
case dw_index_kind::DEBUG_NAMES:
- objfile->qf = &dwarf2_debug_names_functions;
+ objfile->qf = make_dwarf_debug_names ();
break;
}
}
#include "gdbarch.h"
#include "gdbsupport/refcounted-object.h"
#include "jit.h"
+#include "quick-symbol.h"
struct htab;
struct objfile_data;
/* The "quick" (aka partial) symbol functions for this symbol
reader. */
- const struct quick_symbol_functions *qf = nullptr;
+ quick_symbol_functions_up qf;
/* Per objfile data-pointers required by other GDB modules. */
struct partial_symtab *m_psymtab;
};
+/* An implementation of quick_symbol_functions, specialized for
+ partial symbols. */
+struct psymbol_functions : public quick_symbol_functions
+{
+ bool has_symbols (struct objfile *objfile) override;
+
+ struct symtab *find_last_source_symtab (struct objfile *objfile) override;
+
+ void forget_cached_source_info (struct objfile *objfile) override;
+
+ bool map_symtabs_matching_filename
+ (struct objfile *objfile, const char *name, const char *real_path,
+ gdb::function_view<bool (symtab *)> callback) override;
+
+ struct compunit_symtab *lookup_symbol (struct objfile *objfile,
+ block_enum block_index,
+ const char *name,
+ domain_enum domain) override;
+
+ enum language lookup_global_symbol_language (struct objfile *objfile,
+ const char *name,
+ domain_enum domain,
+ bool *symbol_found_p) override;
+
+ void print_stats (struct objfile *objfile) override;
+
+ void dump (struct objfile *objfile) override;
+
+ void expand_symtabs_for_function (struct objfile *objfile,
+ const char *func_name) override;
+
+ void expand_all_symtabs (struct objfile *objfile) override;
+
+ void expand_symtabs_with_fullname (struct objfile *objfile,
+ const char *fullname) override;
+
+ void map_matching_symbols
+ (struct objfile *,
+ const lookup_name_info &lookup_name,
+ domain_enum domain,
+ int global,
+ gdb::function_view<symbol_found_callback_ftype> callback,
+ symbol_compare_ftype *ordered_compare) override;
+
+ void expand_symtabs_matching
+ (struct objfile *objfile,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ const lookup_name_info *lookup_name,
+ gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ enum search_domain kind) override;
+
+ struct compunit_symtab *find_pc_sect_compunit_symtab
+ (struct objfile *objfile, struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc, struct obj_section *section, int warn_if_readin) override;
+
+ struct compunit_symtab *find_compunit_symtab_by_address
+ (struct objfile *objfile, CORE_ADDR address) override;
+
+ void map_symbol_filenames (struct objfile *objfile,
+ symbol_filename_ftype *fun, void *data,
+ int need_fullname) override;
+};
+
#endif /* PSYMPRIV_H */
/* Psymtab version of map_symtabs_matching_filename. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static bool
-psym_map_symtabs_matching_filename
+bool
+psymbol_functions::map_symtabs_matching_filename
(struct objfile *objfile,
const char *name,
const char *real_path,
/* Psymtab version of find_pc_sect_compunit_symtab. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static struct compunit_symtab *
-psym_find_pc_sect_compunit_symtab (struct objfile *objfile,
- struct bound_minimal_symbol msymbol,
- CORE_ADDR pc,
- struct obj_section *section,
- int warn_if_readin)
+struct compunit_symtab *
+psymbol_functions::find_pc_sect_compunit_symtab
+ (struct objfile *objfile,
+ struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc,
+ struct obj_section *section,
+ int warn_if_readin)
{
struct partial_symtab *ps = find_pc_sect_psymtab (objfile, pc, section,
msymbol);
/* Psymtab version of lookup_symbol. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static struct compunit_symtab *
-psym_lookup_symbol (struct objfile *objfile,
- block_enum block_index, const char *name,
- const domain_enum domain)
+struct compunit_symtab *
+psymbol_functions::lookup_symbol (struct objfile *objfile,
+ block_enum block_index, const char *name,
+ const domain_enum domain)
{
const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
struct compunit_symtab *stab_best = NULL;
/* Psymtab version of lookup_global_symbol_language. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static enum language
-psym_lookup_global_symbol_language (struct objfile *objfile, const char *name,
- domain_enum domain, bool *symbol_found_p)
+enum language
+psymbol_functions::lookup_global_symbol_language (struct objfile *objfile,
+ const char *name,
+ domain_enum domain,
+ bool *symbol_found_p)
{
*symbol_found_p = false;
if (objfile->sf == NULL)
/* Psymtab version of find_last_source_symtab. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static struct symtab *
-psym_find_last_source_symtab (struct objfile *ofp)
+struct symtab *
+psymbol_functions::find_last_source_symtab (struct objfile *ofp)
{
struct partial_symtab *cs_pst = NULL;
/* Psymtab version of forget_cached_source_info. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_forget_cached_source_info (struct objfile *objfile)
+void
+psymbol_functions::forget_cached_source_info (struct objfile *objfile)
{
for (partial_symtab *pst : require_partial_symbols (objfile, true))
{
/* Psymtab version of print_stats. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_print_stats (struct objfile *objfile)
+void
+psymbol_functions::print_stats (struct objfile *objfile)
{
int i;
/* Psymtab version of dump. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_dump (struct objfile *objfile)
+void
+psymbol_functions::dump (struct objfile *objfile)
{
struct partial_symtab *psymtab;
/* Psymtab version of expand_symtabs_for_function. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_expand_symtabs_for_function (struct objfile *objfile,
- const char *func_name)
+void
+psymbol_functions::expand_symtabs_for_function (struct objfile *objfile,
+ const char *func_name)
{
lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
lookup_name_info lookup_name = base_lookup.make_ignore_params ();
/* Psymtab version of expand_all_symtabs. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_expand_all_symtabs (struct objfile *objfile)
+void
+psymbol_functions::expand_all_symtabs (struct objfile *objfile)
{
for (partial_symtab *psymtab : require_partial_symbols (objfile, true))
psymtab_to_symtab (objfile, psymtab);
/* Psymtab version of expand_symtabs_with_fullname. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_expand_symtabs_with_fullname (struct objfile *objfile,
- const char *fullname)
+void
+psymbol_functions::expand_symtabs_with_fullname (struct objfile *objfile,
+ const char *fullname)
{
for (partial_symtab *p : require_partial_symbols (objfile, true))
{
/* Psymtab version of map_symbol_filenames. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_map_symbol_filenames (struct objfile *objfile,
- symbol_filename_ftype *fun, void *data,
- int need_fullname)
+void
+psymbol_functions::map_symbol_filenames (struct objfile *objfile,
+ symbol_filename_ftype *fun,
+ void *data,
+ int need_fullname)
{
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
/* Psymtab version of map_matching_symbols. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_map_matching_symbols
+void
+psymbol_functions::map_matching_symbols
(struct objfile *objfile,
const lookup_name_info &name, domain_enum domain,
int global,
/* Psymtab version of expand_symtabs_matching. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static void
-psym_expand_symtabs_matching
+void
+psymbol_functions::expand_symtabs_matching
(struct objfile *objfile,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
const lookup_name_info *lookup_name,
/* Psymtab version of has_symbols. See its definition in
the definition of quick_symbol_functions in symfile.h. */
-static bool
-psym_has_symbols (struct objfile *objfile)
+bool
+psymbol_functions::has_symbols (struct objfile *objfile)
{
return objfile->partial_symtabs->psymtabs != NULL;
}
/* See find_compunit_symtab_by_address in quick_symbol_functions, in
symfile.h. */
-static compunit_symtab *
-psym_find_compunit_symtab_by_address (struct objfile *objfile,
- CORE_ADDR address)
+compunit_symtab *
+psymbol_functions::find_compunit_symtab_by_address (struct objfile *objfile,
+ CORE_ADDR address)
{
if (objfile->psymbol_map.empty ())
{
return psymtab_to_symtab (objfile, iter->second);
}
-const struct quick_symbol_functions psym_functions =
+quick_symbol_functions_up
+make_psymbol_functions ()
{
- psym_has_symbols,
- psym_find_last_source_symtab,
- psym_forget_cached_source_info,
- psym_map_symtabs_matching_filename,
- psym_lookup_symbol,
- psym_lookup_global_symbol_language,
- psym_print_stats,
- psym_dump,
- psym_expand_symtabs_for_function,
- psym_expand_all_symtabs,
- psym_expand_symtabs_with_fullname,
- psym_map_matching_symbols,
- psym_expand_symtabs_matching,
- psym_find_pc_sect_compunit_symtab,
- psym_find_compunit_symtab_by_address,
- psym_map_symbol_filenames
-};
+ return quick_symbol_functions_up (new psymbol_functions);
+}
\f
};
-extern const struct quick_symbol_functions psym_functions;
-
-extern const struct quick_symbol_functions dwarf2_gdb_index_functions;
-extern const struct quick_symbol_functions dwarf2_debug_names_functions;
-
/* Ensure that the partial symbols for OBJFILE have been loaded. If
VERBOSE is true, then this will print a message when symbols
are loaded. This function returns a range adapter suitable for
extern psymtab_storage::partial_symtab_range require_partial_symbols
(struct objfile *objfile, bool verbose);
+extern quick_symbol_functions_up make_psymbol_functions ();
+
#endif /* PSYMTAB_H */
struct quick_symbol_functions
{
+ virtual ~quick_symbol_functions ()
+ {
+ }
+
/* Return true if this objfile has any "partial" symbols
available. */
- bool (*has_symbols) (struct objfile *objfile);
+ virtual bool has_symbols (struct objfile *objfile) = 0;
/* Return the symbol table for the "last" file appearing in
OBJFILE. */
- struct symtab *(*find_last_source_symtab) (struct objfile *objfile);
+ virtual struct symtab *find_last_source_symtab (struct objfile *objfile) = 0;
/* Forget all cached full file names for OBJFILE. */
- void (*forget_cached_source_info) (struct objfile *objfile);
+ virtual void forget_cached_source_info (struct objfile *objfile) = 0;
/* Expand and iterate over each "partial" symbol table in OBJFILE
where the source file is named NAME.
Then, this calls iterate_over_some_symtabs (or equivalent) over
all newly-created symbol tables, passing CALLBACK to it.
The result of this call is returned. */
- bool (*map_symtabs_matching_filename)
+ virtual bool map_symtabs_matching_filename
(struct objfile *objfile, const char *name, const char *real_path,
- gdb::function_view<bool (symtab *)> callback);
+ gdb::function_view<bool (symtab *)> callback) = 0;
/* Check to see if the symbol is defined in a "partial" symbol table
of OBJFILE. BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK,
defined, or NULL if no such symbol table exists. If OBJFILE
contains !TYPE_OPAQUE symbol prefer its compunit. If it contains
only TYPE_OPAQUE symbol(s), return at least that compunit. */
- struct compunit_symtab *(*lookup_symbol) (struct objfile *objfile,
- block_enum block_index,
- const char *name,
- domain_enum domain);
+ virtual struct compunit_symtab *lookup_symbol (struct objfile *objfile,
+ block_enum block_index,
+ const char *name,
+ domain_enum domain) = 0;
/* Check to see if the global symbol is defined in a "partial" symbol table
of OBJFILE. NAME is the name of the symbol to look for. DOMAIN
If found, sets *symbol_found_p to true and returns the symbol language.
defined, or NULL if no such symbol table exists. */
- enum language (*lookup_global_symbol_language) (struct objfile *objfile,
- const char *name,
- domain_enum domain,
- bool *symbol_found_p);
+ virtual enum language lookup_global_symbol_language
+ (struct objfile *objfile,
+ const char *name,
+ domain_enum domain,
+ bool *symbol_found_p) = 0;
/* Print statistics about any indices loaded for OBJFILE. The
statistics should be printed to gdb_stdout. This is used for
"maint print statistics". */
- void (*print_stats) (struct objfile *objfile);
+ virtual void print_stats (struct objfile *objfile) = 0;
/* Dump any indices loaded for OBJFILE. The dump should go to
gdb_stdout. This is used for "maint print objfiles". */
- void (*dump) (struct objfile *objfile);
+ virtual void dump (struct objfile *objfile) = 0;
/* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
the corresponding symbol tables are loaded. */
- void (*expand_symtabs_for_function) (struct objfile *objfile,
- const char *func_name);
+ virtual void expand_symtabs_for_function (struct objfile *objfile,
+ const char *func_name) = 0;
/* Read all symbol tables associated with OBJFILE. */
- void (*expand_all_symtabs) (struct objfile *objfile);
+ virtual void expand_all_symtabs (struct objfile *objfile) = 0;
/* Read all symbol tables associated with OBJFILE which have
symtab_to_fullname equal to FULLNAME.
This is for the purposes of examining code only, e.g., expand_line_sal.
The routine may ignore debug info that is known to not be useful with
code, e.g., DW_TAG_type_unit for dwarf debug info. */
- void (*expand_symtabs_with_fullname) (struct objfile *objfile,
- const char *fullname);
+ virtual void expand_symtabs_with_fullname (struct objfile *objfile,
+ const char *fullname) = 0;
/* Find global or static symbols in all tables that are in DOMAIN
and for which MATCH (symbol name, NAME) == 0, passing each to
CALLBACK returns true to indicate that the scan should continue, or
false to indicate that the scan should be terminated. */
- void (*map_matching_symbols)
+ virtual void map_matching_symbols
(struct objfile *,
const lookup_name_info &lookup_name,
domain_enum domain,
int global,
gdb::function_view<symbol_found_callback_ftype> callback,
- symbol_compare_ftype *ordered_compare);
+ symbol_compare_ftype *ordered_compare) = 0;
/* Expand all symbol tables in OBJFILE matching some criteria.
If SYMBOL_MATCHER returns false, then the symbol is skipped.
Otherwise, the symbol's symbol table is expanded. */
- void (*expand_symtabs_matching)
+ virtual void expand_symtabs_matching
(struct objfile *objfile,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
- enum search_domain kind);
+ enum search_domain kind) = 0;
/* Return the comp unit from OBJFILE that contains PC and
SECTION. Return NULL if there is no such compunit. This
address exactly matches PC, or, if there is no exact match, the
compunit that contains a symbol whose address is closest to
PC. */
- struct compunit_symtab *(*find_pc_sect_compunit_symtab)
+ virtual struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, struct bound_minimal_symbol msymbol,
- CORE_ADDR pc, struct obj_section *section, int warn_if_readin);
+ CORE_ADDR pc, struct obj_section *section, int warn_if_readin) = 0;
/* Return the comp unit from OBJFILE that contains a symbol at
ADDRESS. Return NULL if there is no such comp unit. Unlike
find_pc_sect_compunit_symtab, any sort of symbol (not just text
symbols) can be considered, and only exact address matches are
- considered. This pointer may be NULL. */
- struct compunit_symtab *(*find_compunit_symtab_by_address)
- (struct objfile *objfile, CORE_ADDR address);
+ considered. */
+ virtual struct compunit_symtab *find_compunit_symtab_by_address
+ (struct objfile *objfile, CORE_ADDR address) = 0;
/* Call a callback for every file defined in OBJFILE whose symtab is
not already read in. FUN is the callback. It is passed the file's
FILENAME, the file's FULLNAME (if need_fullname is non-zero), and
the DATA passed to this function. */
- void (*map_symbol_filenames) (struct objfile *objfile,
- symbol_filename_ftype *fun, void *data,
- int need_fullname);
+ virtual void map_symbol_filenames (struct objfile *objfile,
+ symbol_filename_ftype *fun, void *data,
+ int need_fullname) = 0;
};
+typedef std::unique_ptr<quick_symbol_functions> quick_symbol_functions_up;
+
#endif /* GDB_QUICK_SYMBOL_H */
hex_string (address));
struct compunit_symtab *result = NULL;
- if (qf != nullptr && qf->find_compunit_symtab_by_address != NULL)
+ if (qf != nullptr)
result = qf->find_compunit_symtab_by_address (this, address);
if (debug_symfile)
{
enum language result = language_unknown;
- if (qf != nullptr && qf->lookup_global_symbol_language != nullptr)
+ if (qf != nullptr)
result = qf->lookup_global_symbol_language (this, name, domain,
symbol_found_p);
else
const int mainline = add_flags & SYMFILE_MAINLINE;
objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
- objfile->qf = &psym_functions;
+ objfile->qf = make_psymbol_functions ();
if (objfile->sf == NULL)
{
based on whether .gdb_index is present, and we need it to
start over. PR symtab/15885 */
objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd));
- objfile->qf = &psym_functions;
+ objfile->qf = make_psymbol_functions ();
build_objfile_section_table (objfile);