aboutsummaryrefslogtreecommitdiff
path: root/gdb/quick-symbol.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-20 17:23:40 -0600
committerTom Tromey <tom@tromey.com>2021-03-20 17:23:42 -0600
commit39298a5d973d5822ed7d09230f67cc83f72a06c2 (patch)
tree468409018aab2f1b1856aec397eee5bd38d19f51 /gdb/quick-symbol.h
parent5c3f1e5bfc0cf45d8bc734aabaf0225b72a31096 (diff)
downloadfsf-binutils-gdb-39298a5d973d5822ed7d09230f67cc83f72a06c2.zip
fsf-binutils-gdb-39298a5d973d5822ed7d09230f67cc83f72a06c2.tar.gz
fsf-binutils-gdb-39298a5d973d5822ed7d09230f67cc83f72a06c2.tar.bz2
Convert quick_symbol_functions to use methods
This changes quick_symbol_functions to be a base class with pure virtual methods, rather than a struct holding function pointers. Then, objfile is changed to hold a unique_ptr to an instance of this class. struct psymbol_functions is put into psympriv.h, and not psymtab.c, because that is convenient later in the series. gdb/ChangeLog 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.
Diffstat (limited to 'gdb/quick-symbol.h')
-rw-r--r--gdb/quick-symbol.h71
1 files changed, 39 insertions, 32 deletions
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index fa5f501..85e7a32 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -66,16 +66,20 @@ typedef void (expand_symtabs_exp_notify_ftype) (compunit_symtab *symtab);
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.
@@ -89,9 +93,9 @@ struct quick_symbol_functions
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,
@@ -103,10 +107,10 @@ struct quick_symbol_functions
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
@@ -114,35 +118,36 @@ struct quick_symbol_functions
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
@@ -161,13 +166,13 @@ struct quick_symbol_functions
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.
@@ -190,13 +195,13 @@ struct quick_symbol_functions
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
@@ -204,25 +209,27 @@ struct quick_symbol_functions
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 */