aboutsummaryrefslogtreecommitdiff
path: root/gdb/quick-symbol.h
AgeCommit message (Collapse)AuthorFilesLines
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-12-19Remove quick_symbol_functions::relocatedTom Tromey1-7/+0
quick_symbol_functions::relocated is only needed for psymtabs, and there it is only needed for Rust. However, because we've switched the DWARF reader away from psymtabs, this means there's no longer a need for this method at all.
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-07-16Document quick_symbol_functions::expand_symtabs_matching invariantTom Tromey1-0/+2
While working on my series to replace the DWARF psymbol reader, I noticed that the expand_symtabs_matching has an undocumented invariant. I think that, if this invariant is not followed, then GDB will crash. So, this patch documents this in the relevant spots and introduces some asserts to make it clear. Regression tested on x86-64 Fedora 32.
2021-06-25gdb: add new function quick_symbol_functions::has_unexpanded_symbolsAndrew Burgess1-0/+6
Adds a new function to the quick_symbol_functions API to let us know if there are any unexpanded symbols. This functionality is required by a later commit. After this commit the functionality is unused, and untested. The new function objfile::has_unexpanded_symtabs is added to the symfile-debug.c file which is a little strange, but this is (currently) where many of the other objfile::* functions (that call onto the quick_symbol_functions) are defined, so I'm reluctant to break this pattern. There should be no user visible changes after this commit. gdb/ChangeLog: * dwarf2/read.c (struct dwarf2_base_index_functions) <has_unexpanded_symtabs>: Declare. (dwarf2_base_index_functions::has_unexpanded_symtabs): Define new function. * objfiles.h (struct objfile) <has_unexpanded_symtabs>: Declare. * psympriv.h (struct psymbol_functions) <has_unexpanded_symtabs>: Declare. * psymtab.c (psymbol_functions::has_unexpanded_symtabs): Define new function. * quick-symbol.h (struct quick_symbol_functions) <has_unexpanded_symtabs>: Declare. * symfile-debug.c (objfile::has_unexpanded_symtabs): Define new function.
2021-04-17Simplify quick_symbol_functions::map_matching_symbolsTom Tromey1-9/+6
quick_symbol_functions::map_matching_symbols is only used by the Ada code. Currently, it both expands certain psymtabs and then walks over the full symtabs -- including any already-expanded ones -- calling a callback. It appears to work lazily as well, in that if the callback returns false, iteration stops. However, only the psymtab implementation does this; the DWARF index implementations are not lazy. It turns out, though, that the only callback that is ever passed here never returns false. This patch simplifies this method by removing the callback. The method is also renamed. In the new scheme, the caller is responsible for walking the full symtabs, which removes some redundancy as well. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * psymtab.c (psymbol_functions::expand_matching_symbols): Rename from map_matching_symbols. Change parameters. * psympriv.h (struct psymbol_functions) <expand_matching_symbols>: Rename from map_matching_symbols. Change parameters. * dwarf2/read.c (struct dwarf2_gdb_index) <expand_matching_symbols>: Rename from map_matching_symbols. Change parameters. (struct dwarf2_debug_names_index) <expand_matching_symbols>: Rename from map_matching_symbols. Change parameters. (dwarf2_gdb_index::expand_matching_symbols): Rename from dw2_map_matching_symbols. Change parameters. (dwarf2_gdb_index::expand_matching_symbols): Remove old implementation. (dwarf2_debug_names_index::expand_matching_symbols): Rename from map_matching_symbols. Change parameters. * objfiles.h (struct objfile) <expand_matching_symbols>: Rename from map_matching_symbols. Change parameters. * symfile-debug.c (objfile::expand_matching_symbols): Rename from map_matching_symbols. Change parameters. * ada-lang.c (map_matching_symbols): New function. (add_nonlocal_symbols): Update.
2021-04-17Remove quick_symbol_functions::expand_symtabs_with_fullnameTom Tromey1-8/+0
This removes quick_symbol_functions::expand_symtabs_with_fullname, replacing it with a call to expand_symtabs_matching. As with the previous patches, the implementation is consolidated in the objfile method. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * quick-symbol.h (struct quick_symbol_functions) <expand_symtabs_with_fullname>: Remove. * psymtab.c (psymbol_functions::expand_symtabs_with_fullname): Remove. * psympriv.h (struct psymbol_functions) <expand_symtabs_with_fullname>: Remove. * dwarf2/read.c (struct dwarf2_base_index_functions) <expand_symtabs_with_fullname>: Remove. (dwarf2_base_index_functions::expand_symtabs_with_fullname): Remove. * objfiles.h (struct objfile) <expand_symtabs_with_fullname>: Update comment. * symfile-debug.c (objfile::expand_symtabs_with_fullname): Rewrite.
2021-04-17Remove quick_symbol_functions::expand_symtabs_for_functionTom Tromey1-5/+0
This removes quick_symbol_functions::expand_symtabs_for_function, replacing it with a call to expand_symtabs_matching. As with the previous patches, the implementation is consolidated in the objfile method. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * symfile-debug.c (objfile::expand_symtabs_for_function): Rewrite. * quick-symbol.h (struct quick_symbol_functions) <expand_symtabs_for_function>: Remove. * psymtab.c (psymbol_functions::expand_symtabs_for_function): Remove. * psympriv.h (struct psymbol_functions) <expand_symtabs_for_function>: Remove. * objfiles.h (struct objfile) <expand_symtabs_for_function>: Update comment. * dwarf2/read.c (struct dwarf2_gdb_index) <expand_symtabs_for_function>: Remove. (struct dwarf2_debug_names_index) <expand_symtabs_for_function>: Remove. (find_slot_in_mapped_hash): Remove. (dw2_symtab_iter_init_common): Merge with dw2_symtab_iter_init. (dw2_symtab_iter_init): Remove one overload. (dwarf2_gdb_index::expand_symtabs_for_function) (dwarf2_debug_names_index::expand_symtabs_for_function): Remove.
2021-04-17Remove quick_symbol_functions::map_symtabs_matching_filenameTom Tromey1-16/+0
This replaces quick_symbol_functions::map_symtabs_matching_filename with a call to expand_symtabs_matching. As with the previous patch, rather than update all callers, the implementation is consolidated in objfile::map_symtabs_matching_filename. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * symfile-debug.c (objfile::map_symtabs_matching_filename): Rewrite. * quick-symbol.h (struct quick_symbol_functions) <map_symtabs_matching_filename>: Remove. * psymtab.c (partial_map_expand_apply) (psymbol_functions::map_symtabs_matching_filename): Remove. * psympriv.h (struct psymbol_functions) <map_symtabs_matching_filename>: Remove. * objfiles.h (struct objfile) <map_symtabs_matching_filename>: Update comment. * dwarf2/read.c (struct dwarf2_base_index_functions) <map_symtabs_matching_filename>: Remove. (dw2_map_expand_apply) (dwarf2_base_index_functions::map_symtabs_matching_filename): Remove.
2021-04-17Remove quick_symbol_functions::lookup_symbolTom Tromey1-15/+0
This removes quick_symbol_functions, replacing it with calls to expand_symtabs_matching. Because the replacement is somewhat verbose, objfile::lookup_symbol is not removed. This consolidates some duplicated code into this one spot. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * symfile-debug.c (objfile::lookup_symbol): Rewrite. * quick-symbol.h (struct quick_symbol_functions) <lookup_symbol>: Remove. * psymtab.c (psymbol_functions::lookup_symbol): Remove. * psympriv.h (struct psymbol_functions) <lookup_symbol>: Remove. * objfiles.h (struct objfile) <lookup_symbol>: Add comment. * dwarf2/read.c (struct dwarf2_gdb_index) <lookup_symbol>: Remove. (struct dwarf2_debug_names_index) <lookup_symbol>: Remove. (dwarf2_gdb_index::lookup_symbol) (dwarf2_debug_names_index::lookup_symbol): Remove.
2021-04-17Add 'domain' parameter to expand_symtabs_matchingTom Tromey1-1/+3
Currently, expand_symtabs_matching only accepts a search_domain parameter. However, lookup_symbol uses a domain_enum instead, and the two, confusingly, do quite different things -- one cannot emulate the other. So, this patch adds a domain_enum parameter to expand_symtabs_matching, with UNDEF_DOMAIN used as a wildcard. This is another step toward replacing lookup_symbol with expand_symtabs_matching. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * symtab.c (global_symbol_searcher::expand_symtabs): Update. * symmisc.c (maintenance_expand_symtabs): Update. * symfile.c (expand_symtabs_matching): Update. * symfile-debug.c (objfile::expand_symtabs_matching): Add 'domain' parameter. * quick-symbol.h (struct quick_symbol_functions) <expand_symtabs_matching>: Add 'domain' parameter. * psymtab.c (recursively_search_psymtabs) (psymbol_functions::expand_symtabs_matching): Add 'domain' parameter. * psympriv.h (struct psymbol_functions) <expand_symtabs_matching>: Add 'domain' parameter. * objfiles.h (struct objfile) <expand_symtabs_matching>: Add 'domain' parameter. * linespec.c (iterate_over_all_matching_symtabs): Update. * dwarf2/read.c (struct dwarf2_gdb_index) <expand_symtabs_matching>: Add 'domain' parameter. (struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add 'domain' parameter. (dw2_expand_symtabs_matching) (dwarf2_gdb_index::expand_symtabs_matching) (dw2_debug_names_iterator) (dwarf2_debug_names_index::expand_symtabs_matching): Add 'domain' parameter.
2021-04-17Add search_flags to expand_symtabs_matchingTom Tromey1-0/+1
This adds a block search flags parameter to expand_symtabs_matching. All callers are updated to search both the static and global blocks, as that was the implied behavior before this patch. This is a step toward replacing lookup_symbol with expand_symtabs_matching. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * symtab.c (global_symbol_searcher::expand_symtabs) (default_collect_symbol_completion_matches_break_on): Update. * symmisc.c (maintenance_expand_symtabs): Update. * symfile.h (expand_symtabs_matching): Add search_flags parameter. * symfile.c (expand_symtabs_matching): Add search_flags parameter. * symfile-debug.c (objfile::expand_symtabs_matching): Add search_flags parameter. * quick-symbol.h (struct quick_symbol_functions) <expand_symtabs_matching>: Add search_flags parameter. * python/py-symbol.c (gdbpy_lookup_static_symbols): Update. * psymtab.c (recursively_search_psymtabs) (psymbol_functions::expand_symtabs_matching): Add search_flags parameter. * psympriv.h (struct psymbol_functions) <expand_symtabs_matching>: Add search_flags parameter. * objfiles.h (struct objfile) <expand_symtabs_matching>: Add search_flags parameter. * linespec.c (iterate_over_all_matching_symtabs): Update. * dwarf2/read.c (struct dwarf2_gdb_index) <expand_symtabs_matching>: Add search_flags parameter. (struct dwarf2_debug_names_index) <expand_symtabs_matching>: Add search_flags parameter. (dw2_map_matching_symbols): Update. (dw2_expand_marked_cus, dw2_expand_symtabs_matching) (dwarf2_gdb_index::expand_symtabs_matching): Add search_flags parameter. (dw2_debug_names_iterator): Change block_index to search flags. <m_block_index>: Likewise. (dw2_debug_names_iterator::next) (dwarf2_debug_names_index::lookup_symbol) (dwarf2_debug_names_index::expand_symtabs_for_function) (dwarf2_debug_names_index::map_matching_symbols) (dwarf2_debug_names_index::map_matching_symbols): Update. (dwarf2_debug_names_index::expand_symtabs_matching): Add search_flags parameter. * ada-lang.c (ada_add_global_exceptions) (collect_symbol_completion_matches): Update.
2021-04-17Let expand_symtabs_matching short-circuitTom Tromey1-4/+10
This changes expand_symtabs_exp_notify_ftype to return bool, and updates all the uses. Now, if the notification function returns false, the call is short-circuited and stops examining symtabs. This is a step toward replacing map_symtabs_matching_filename with expand_symtabs_matching. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * symtab.c (default_collect_symbol_completion_matches_break_on): Update. * symfile.h (expand_symtabs_matching): Return bool. * symfile.c (expand_symtabs_matching): Return bool. * symfile-debug.c (objfile::expand_symtabs_matching): Return bool. * quick-symbol.h (expand_symtabs_exp_notify_ftype): Return bool. (struct quick_symbol_functions) <expand_symtabs_matching>: Return bool. * psymtab.c (psymbol_functions::expand_symtabs_matching): Return bool. * psympriv.h (struct psymbol_functions) <expand_symtabs_matching>: Return bool. * objfiles.h (struct objfile) <expand_symtabs_matching>: Return bool. * dwarf2/read.c (struct dwarf2_gdb_index) <expand_symtabs_matching>: Return bool. (struct dwarf2_debug_names_index) <expand_symtabs_matching>: Return bool. (dw2_expand_symtabs_matching_symbol): Return bool. (dw2_expand_symtabs_matching_one, dw2_expand_marked_cus) (dw2_expand_symtabs_matching) (dwarf2_gdb_index::expand_symtabs_matching) (dwarf2_debug_names_index::expand_symtabs_matching) (dwarf2_debug_names_index::expand_symtabs_matching): Return bool.
2021-04-17Add block_search_flagsTom Tromey1-0/+10
This adds block_search_flags, a flag enum. This will be used to by certain search functions so that the caller can control which blocks are searched more precisely. gdb/ChangeLog 2021-04-17 Tom Tromey <tom@tromey.com> * quick-symbol.h (enum block_search_flag_values): New. (block_search_flags): New enum flags type.
2021-03-26Use function view in quick_symbol_functions::map_symbol_filenamesTom Tromey1-7/+8
This changes quick_symbol_functions::map_symbol_filenames to use a function_view, and updates all the uses. It also changes the final parameter to 'bool'. A couple of spots are further updated to use operator() rather than a lambda. gdb/ChangeLog 2021-03-26 Tom Tromey <tom@tromey.com> * symtab.c (struct output_source_filename_data): Add 'output' method and operator(). (output_source_filename_data::output): Rename from output_source_filename. (output_partial_symbol_filename): Remove. (info_sources_command): Update. (struct add_partial_filename_data): Add operator(). (add_partial_filename_data::operator()): Rename from maybe_add_partial_symtab_filename. (make_source_files_completion_list): Update. * symfile.c (quick_symbol_functions): Update. * symfile-debug.c (objfile::map_symbol_filenames): Update. * quick-symbol.h (symbol_filename_ftype): Change type of 'fun' and 'need_fullname'. Remove 'data' parameter. (struct quick_symbol_functions) <map_symbol_filenames>: Likewise. * psymtab.c (psymbol_functions::map_symbol_filenames): Update. * psympriv.h (struct psymbol_functions) <map_symbol_filenames>: Change type of 'fun' and 'need_fullname'. Remove 'data' parameter. * objfiles.h (struct objfile) <map_symbol_filenames>: Change type of 'fun' and 'need_fullname'. Remove 'data' parameter. * mi/mi-cmd-file.c (print_partial_file_name): Remove 'ignore' parameter. (mi_cmd_file_list_exec_source_files): Update. * dwarf2/read.c (dwarf2_base_index_functions::map_symbol_filenames): Update.
2021-03-20Remove sym_fns::sym_read_psymbolsTom Tromey1-0/+14
Partial symbols are read via the sym_fns::sym_read_psymbols function pointer. In order to separate the partial symbols from the objfile, this must instead be done via a virtual method on quick_symbol_functions. This patch implements this change. gdb/ChangeLog 2021-03-20 Tom Tromey <tom@tromey.com> * xcoffread.c (xcoff_sym_fns): Update. * symfile.h (struct sym_fns) <sym_read_psymbols>: Remove. * symfile-debug.c (objfile::has_partial_symbols): Use can_lazily_read_symbols. (debug_sym_read_psymbols): Remove. (debug_sym_fns, install_symfile_debug_logging): Update. * quick-symbol.h (struct quick_symbol_functions) <can_lazily_read_symbols, read_partial_symbols>: New methods. * psymtab.c (require_partial_symbols): Use new 'qf' methods. * mipsread.c (ecoff_sym_fns): Update. * machoread.c (macho_sym_fns): Update. * elfread.c (struct lazy_dwarf_reader): New. (elf_symfile_read): Update. (read_psyms): Now a method of lazy_dwarf_reader. (elf_sym_fns): Update. (elf_sym_fns_lazy_psyms): Remove. * dbxread.c (aout_sym_fns): Update. * coffread.c (coff_sym_fns): Update.
2021-03-20Move psymtab statistics printing to psymtab.cTom Tromey1-2/+4
This moves all the psymtab statistics printing code form symmisc.c to psymtab.c. This changes the formatting of the output a little, but considering that it is a maint command (and, I assume, a rarely used one), this seems fine to me. This change helps further dissociate the psymtab from the objfile. In the end there will be no direct connect -- only via the quick_symbol_functions interface. gdb/ChangeLog 2021-03-20 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf2_base_index_functions::print_stats): Add print_bcache parameter. * symfile-debug.c (objfile::print_stats): Add print_bcache parameter. * quick-symbol.h (struct quick_symbol_functions) <print_stats>: Add print_bcache parameter. * symmisc.c (print_symbol_bcache_statistics, count_psyms): Move code to psymtab.c. (print_objfile_statistics): Move psymtab code to psymtab.c. * psymtab.c (count_psyms): Move from symmisc.c. (psymbol_functions::print_stats): Print partial symbol and bcache statistics. Add print_bcache parameter. * objfiles.h (print_symbol_bcache_statistics): Don't declare. (struct objfile) <print_stats>: Add print_bcache parameter. * maint.c (maintenance_print_statistics): Update. gdb/testsuite/ChangeLog 2021-03-20 Tom Tromey <tom@tromey.com> * gdb.base/maint.exp: Update "maint print statistics" output.
2021-03-20Move psymbol_map out of objfileTom Tromey1-0/+7
objfile::psymbol_map is used to implement a Rust feature. It is currently specific to partial symbols -- it isn't used by the DWARF indices. This patch moves it out of objfile and into psymbol_functions, adding a new method to quick_symbol_functions to handle the clearing case. This is needed because the map holds unrelocated addresses. gdb/ChangeLog 2021-03-20 Tom Tromey <tom@tromey.com> * quick-symbol.h (struct quick_symbol_functions) <relocated>: New method. * psymtab.h (struct psymbol_functions) <relocated>: New method. <fill_psymbol_map>: Declare method. <m_psymbol_map>: New member. * psymtab.c (psymbol_functions::fill_psymbol_map): Rename. (psymbol_functions::find_compunit_symtab_by_address): Update. * objfiles.h (reset_psymtabs): Don't clear psymbol_map. (struct objfile) <psymbol_map>: Remove. * objfiles.c (objfile_relocate1): Update.
2021-03-20Convert quick_symbol_functions to use methodsTom Tromey1-32/+39
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.
2021-03-20Move quick_symbol_functions to a new headerTom Tromey1-0/+228
This introduces a new header, quick-symbol.h, and moves quick_symbol_functions and related typedefs into it. gdb/ChangeLog 2021-03-20 Tom Tromey <tom@tromey.com> * symfile.h (symbol_compare_ftype, symbol_filename_ftype) (expand_symtabs_file_matcher_ftype) (expand_symtabs_symbol_matcher_ftype) (expand_symtabs_exp_notify_ftype, struct quick_symbol_functions): Move to quick-symbol.h. * quick-symbol.h: New file.