2013-09-26 07:17:12 +08:00
|
|
|
|
/* Debug logging for the symbol file functions for the GNU debugger, GDB.
|
|
|
|
|
|
2024-01-12 23:30:44 +08:00
|
|
|
|
Copyright (C) 2013-2024 Free Software Foundation, Inc.
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
Contributed by Cygnus Support, using pieces from other GDB modules.
|
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
|
|
/* Note: Be careful with functions that can throw errors.
|
|
|
|
|
We want to see a logging message regardless of whether an error was thrown.
|
|
|
|
|
This typically means printing a message before calling the real function
|
|
|
|
|
and then if the function returns a result printing a message after it
|
|
|
|
|
returns. */
|
|
|
|
|
|
2024-04-24 03:22:44 +08:00
|
|
|
|
#include "cli/cli-cmds.h"
|
2013-09-26 07:17:12 +08:00
|
|
|
|
#include "objfiles.h"
|
Convert observers to C++
This converts observers from using a special source-generating script
to be plain C++. This version of the patch takes advantage of C++11
by using std::function and variadic templates; incorporates Pedro's
patches; and renames the header file to "observable.h" (this change
eliminates the need for a clean rebuild).
Note that Pedro's patches used a template lambda in tui-hooks.c, but
this failed to compile on some buildbot instances (presumably due to
differing C++ versions); I replaced this with an ordinary template
function.
Regression tested on the buildbot.
gdb/ChangeLog
2018-03-19 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* unittests/observable-selftests.c: New file.
* common/observable.h: New file.
* observable.h: New file.
* ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c,
arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c,
breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c,
corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c,
extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c,
infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c,
linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c,
mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c,
ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c,
python/py-breakpoint.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c,
record-btrace.c, record-full.c, record.c, regcache.c, remote.c,
riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c,
spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c,
symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c,
tui/tui-interp.c, valops.c: Update all users.
* tui/tui-hooks.c (tui_bp_created_observer)
(tui_bp_deleted_observer, tui_bp_modified_observer)
(tui_inferior_exit_observer, tui_before_prompt_observer)
(tui_normal_stop_observer, tui_register_changed_observer):
Remove.
(tui_observers_token): New global.
(attach_or_detach, tui_attach_detach_observers): New functions.
(tui_install_hooks, tui_remove_hooks): Use
tui_attach_detach_observers.
* record-btrace.c (record_btrace_thread_observer): Remove.
(record_btrace_thread_observer_token): New global.
* observer.sh: Remove.
* observer.c: Rename to observable.c.
* observable.c (namespace gdb_observers): Define new objects.
(observer_debug): Move into gdb_observers namespace.
(struct observer, struct observer_list, xalloc_observer_list_node)
(xfree_observer_list_node, generic_observer_attach)
(generic_observer_detach, generic_observer_notify): Remove.
(_initialize_observer): Update.
Don't include observer.inc.
* Makefile.in (generated_files): Remove observer.h, observer.inc.
(clean mostlyclean): Likewise.
(observer.h, observer.inc): Remove targets.
(SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c.
(COMMON_SFILES): Use observable.c, not observer.c.
* .gitignore: Remove observer.h.
gdb/doc/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* observer.texi: Remove.
gdb/testsuite/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* gdb.gdb/observer.exp: Remove.
2016-10-03 00:50:20 +08:00
|
|
|
|
#include "observable.h"
|
2013-09-26 07:17:12 +08:00
|
|
|
|
#include "source.h"
|
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "symfile.h"
|
2021-04-17 23:35:04 +08:00
|
|
|
|
#include "block.h"
|
2021-04-17 23:35:04 +08:00
|
|
|
|
#include "filenames.h"
|
2023-08-29 21:48:56 +08:00
|
|
|
|
#include "cli/cli-style.h"
|
gdb: merge debug symbol file lookup code from coffread & elfread paths
This commit merges the code that looks for and loads the separate
debug symbol files from coffread.c and elfread.c. The factored out
code is moved into a new objfile::find_and_add_separate_symbol_file()
method.
For the elfread.c path there should be no user visible changes after
this commit.
For the coffread.c path GDB will now attempt to perform a debuginfod
lookup for the missing debug information, assuming that GDB can find a
build-id in the COFF file.
I don't know if COFF files can include a build-id, but I the existing
coffread.c code already includes a call to
find_separate_debug_file_by_build-id, so I know that it is at least OK
for GDB to ask a COFF file for a build-id. If the COFF file doesn't
include a build-id then the debuginfod lookup code will not trigger
and the new code is harmless.
If the COFF file does include a build-id, then we're going to end up
asking debuginfod for the debug file. As build-ids should be unique,
this should be harmless, even if debuginfod doesn't contain any
suitable debug data, it just costs us one debuginfod lookup, so I'm
not too worried about this for now.
As with the previous commit, I've done some minimal testing using the
mingw toolchain on a Linux machine, GDB seems to still access the
split debug information just fine.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 16:50:33 +08:00
|
|
|
|
#include "build-id.h"
|
|
|
|
|
#include "debuginfod-support.h"
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
/* We need to save a pointer to the real symbol functions.
|
|
|
|
|
Plus, the debug versions are malloc'd because we have to NULL out the
|
|
|
|
|
ones that are NULL in the real copy. */
|
|
|
|
|
|
|
|
|
|
struct debug_sym_fns_data
|
|
|
|
|
{
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
const struct sym_fns *real_sf = nullptr;
|
|
|
|
|
struct sym_fns debug_sf {};
|
2013-09-26 07:17:12 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* We need to record a pointer to the real set of functions for each
|
|
|
|
|
objfile. */
|
2020-10-19 01:38:10 +08:00
|
|
|
|
static const registry<objfile>::key<debug_sym_fns_data>
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
symfile_debug_objfile_data_key;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Change boolean options to bool instead of int
This is for add_setshow_boolean_cmd as well as the gdb::option interface.
gdb/ChangeLog:
2019-09-17 Christian Biesinger <cbiesinger@google.com>
* ada-lang.c (ada_ignore_descriptive_types_p): Change to bool.
(print_signatures): Likewise.
(trust_pad_over_xvs): Likewise.
* arch/aarch64-insn.c (aarch64_debug): Likewise.
* arch/aarch64-insn.h (aarch64_debug): Likewise.
* arm-linux-nat.c (arm_apcs_32): Likewise.
* arm-linux-tdep.c (arm_apcs_32): Likewise.
* arm-nbsd-nat.c (arm_apcs_32): Likewise.
* arm-tdep.c (arm_debug): Likewise.
(arm_apcs_32): Likewise.
* auto-load.c (debug_auto_load): Likewise.
(auto_load_gdb_scripts): Likewise.
(global_auto_load): Likewise.
(auto_load_local_gdbinit): Likewise.
(auto_load_local_gdbinit_loaded): Likewise.
* auto-load.h (global_auto_load): Likewise.
(auto_load_local_gdbinit): Likewise.
(auto_load_local_gdbinit_loaded): Likewise.
* breakpoint.c (disconnected_dprintf): Likewise.
(breakpoint_proceeded): Likewise.
(automatic_hardware_breakpoints): Likewise.
(always_inserted_mode): Likewise.
(target_exact_watchpoints): Likewise.
(_initialize_breakpoint): Update.
* breakpoint.h (target_exact_watchpoints): Change to bool.
* btrace.c (maint_btrace_pt_skip_pad): Likewise.
* cli/cli-cmds.c (trace_commands): Likewise.
* cli/cli-cmds.h (trace_commands): Likewise.
* cli/cli-decode.c (add_setshow_boolean_cmd): Change int* argument
to bool*.
* cli/cli-logging.c (logging_overwrite): Change to bool.
(logging_redirect): Likewise.
(debug_redirect): Likewise.
* cli/cli-option.h (option_def) <boolean>: Change return type to bool*.
(struct boolean_option_def) <get_var_address_cb_>: Change return type
to bool.
<boolean_option_def>: Update.
(struct flag_option_def): Change default type of Context to bool
from int.
<flag_option_def>: Change return type of var_address_cb_ to bool*.
* cli/cli-setshow.c (do_set_command): Cast to bool* instead of int*.
(get_setshow_command_value_string): Likewise.
* cli/cli-style.c (cli_styling): Change to bool.
(source_styling): Likewise.
* cli/cli-style.h (source_styling): Likewise.
(cli_styling): Likewise.
* cli/cli-utils.h (struct qcs_flags) <quiet, cont, silent>: Change
to bool.
* command.h (var_types): Update comment.
(add_setshow_boolean_cmd): Change int* var argument to bool*.
* compile/compile-cplus-types.c (debug_compile_cplus_types): Change to
bool.
(debug_compile_cplus_scopes): Likewise.
* compile/compile-internal.h (compile_debug): Likewise.
* compile/compile.c (compile_debug): Likewise.
(struct compile_options) <raw>: Likewise.
* cp-support.c (catch_demangler_crashes): Likewise.
* cris-tdep.c (usr_cmd_cris_version_valid): Likewise.
(usr_cmd_cris_dwarf2_cfi): Likewise.
* csky-tdep.c (csky_debug): Likewise.
* darwin-nat.c (enable_mach_exceptions): Likewise.
* dcache.c (dcache_enabled_p): Likewise.
* defs.h (info_verbose): Likewise.
* demangle.c (demangle): Likewise.
(asm_demangle): Likewise.
* dwarf-index-cache.c (debug_index_cache): Likewise.
* dwarf2-frame.c (dwarf2_frame_unwinders_enabled_p): Likewise.
* dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Likewise.
* dwarf2read.c (check_physname): Likewise.
(use_deprecated_index_sections): Likewise.
(dwarf_always_disassemble): Likewise.
* eval.c (overload_resolution): Likewise.
* event-top.c (set_editing_cmd_var): Likewise.
(exec_done_display_p): Likewise.
* event-top.h (set_editing_cmd_var): Likewise.
(exec_done_display_p): Likewise.
* exec.c (write_files): Likewise.
* fbsd-nat.c (debug_fbsd_lwp): Likewise
(debug_fbsd_nat): Likewise.
* frame.h (struct frame_print_options) <print_raw_frame_arguments>:
Likewise.
(struct set_backtrace_options) <backtrace_past_main>: Likewise.
<backtrace_past_entry> Likewise.
* gdb-demangle.h (demangle): Likewise.
(asm_demangle): Likewise.
* gdb_bfd.c (bfd_sharing): Likewise.
* gdbcore.h (write_files): Likewise.
* gdbsupport/common-debug.c (show_debug_regs): Likewise.
* gdbsupport/common-debug.h (show_debug_regs): Likewise.
* gdbthread.h (print_thread_events): Likewise.
* gdbtypes.c (opaque_type_resolution): Likewise.
(strict_type_checking): Likewise.
* gnu-nat.c (gnu_debug_flag): Likewise.
* guile/scm-auto-load.c (auto_load_guile_scripts): Likewise.
* guile/scm-param.c (pascm_variable): Add boolval.
(add_setshow_generic): Update.
(pascm_param_value): Update.
(pascm_set_param_value_x): Update.
* hppa-tdep.c (hppa_debug): Change to bool..
* infcall.c (may_call_functions_p): Likewise.
(coerce_float_to_double_p): Likewise.
(unwind_on_signal_p): Likewise.
(unwind_on_terminating_exception_p): Likewise.
* infcmd.c (startup_with_shell): Likewise.
* inferior.c (print_inferior_events): Likewise.
* inferior.h (startup_with_shell): Likewise.
(print_inferior_events): Likewise.
* infrun.c (step_stop_if_no_debug): Likewise.
(detach_fork): Likewise.
(debug_displaced): Likewise.
(disable_randomization): Likewise.
(non_stop): Likewise.
(non_stop_1): Likewise.
(observer_mode): Likewise.
(observer_mode_1): Likewise.
(set_observer_mode): Update.
(sched_multi): Change to bool.
* infrun.h (debug_displaced): Likewise.
(sched_multi): Likewise.
(step_stop_if_no_debug): Likewise.
(non_stop): Likewise.
(disable_randomization): Likewise.
* linux-tdep.c (use_coredump_filter): Likewise.
(dump_excluded_mappings): Likewise.
* linux-thread-db.c (auto_load_thread_db): Likewise.
(check_thread_db_on_load): Likewise.
* main.c (captured_main_1): Update.
* maint-test-options.c (struct test_options_opts) <flag_opt, xx1_opt,
xx2_opt, boolean_opt>: Change to bool.
* maint-test-settings.c (maintenance_test_settings_boolean): Likewise.
* maint.c (maintenance_profile_p): Likewise.
(per_command_time): Likewise.
(per_command_space): Likewise.
(per_command_symtab): Likewise.
* memattr.c (inaccessible_by_default): Likewise.
* mi/mi-main.c (mi_async): Likewise.
(mi_async_1): Likewise.
* mips-tdep.c (mips64_transfers_32bit_regs_p): Likewise.
* nat/fork-inferior.h (startup_with_shell): Likewise.
* nat/linux-namespaces.c (debug_linux_namespaces): Likewise.
* nat/linux-namespaces.h (debug_linux_namespaces): Likewise.
* nios2-tdep.c (nios2_debug): Likewise.
* or1k-tdep.c (or1k_debug): Likewise.
* parse.c (parser_debug): Likewise.
* parser-defs.h (parser_debug): Likewise.
* printcmd.c (print_symbol_filename): Likewise.
* proc-api.c (procfs_trace): Likewise.
* python/py-auto-load.c (auto_load_python_scripts): Likewise.
* python/py-param.c (union parmpy_variable): Add "bool boolval" field.
(set_parameter_value): Update.
(add_setshow_generic): Update.
* python/py-value.c (copy_py_bool_obj): Change argument from int*
to bool*.
* python/python.c (gdbpy_parameter_value): Cast to bool* instead of
int*.
* ravenscar-thread.c (ravenscar_task_support): Change to bool.
* record-btrace.c (record_btrace_target::store_registers): Update.
* record-full.c (record_full_memory_query): Change to bool.
(record_full_stop_at_limit): Likewise.
* record-full.h (record_full_memory_query): Likewise.
* remote-notif.c (notif_debug): Likewise.
* remote-notif.h (notif_debug): Likewise.
* remote.c (use_range_stepping): Likewise.
(interrupt_on_connect): Likewise.
(remote_break): Likewise.
* ser-tcp.c (tcp_auto_retry): Likewise.
* ser-unix.c (serial_hwflow): Likewise.
* skip.c (debug_skip): Likewise.
* solib-aix.c (solib_aix_debug): Likewise.
* spu-tdep.c (spu_stop_on_load_p): Likewise.
(spu_auto_flush_cache_p): Likewise.
* stack.c (struct backtrace_cmd_options) <full, no_filters, hide>:
Likewise.
(struct info_print_options) <quiet>: Likewise.
* symfile-debug.c (debug_symfile): Likewise.
* symfile.c (auto_solib_add): Likewise.
(separate_debug_file_debug): Likewise.
* symfile.h (auto_solib_add): Likewise.
(separate_debug_file_debug): Likewise.
* symtab.c (basenames_may_differ): Likewise.
(struct filename_partial_match_opts) <dirname, basename>: Likewise.
(struct info_print_options) <quiet, exclude_minsyms>: Likewise.
(struct info_types_options) <quiet>: Likewise.
* symtab.h (demangle): Likewise.
(basenames_may_differ): Likewise.
* target-dcache.c (stack_cache_enabled_1): Likewise.
(code_cache_enabled_1): Likewise.
* target.c (trust_readonly): Likewise.
(may_write_registers): Likewise.
(may_write_memory): Likewise.
(may_insert_breakpoints): Likewise.
(may_insert_tracepoints): Likewise.
(may_insert_fast_tracepoints): Likewise.
(may_stop): Likewise.
(auto_connect_native_target): Likewise.
(target_stop_and_wait): Update.
(target_async_permitted): Change to bool.
(target_async_permitted_1): Likewise.
(may_write_registers_1): Likewise.
(may_write_memory_1): Likewise.
(may_insert_breakpoints_1): Likewise.
(may_insert_tracepoints_1): Likewise.
(may_insert_fast_tracepoints_1): Likewise.
(may_stop_1): Likewise.
* target.h (target_async_permitted): Likewise.
(may_write_registers): Likewise.
(may_write_memory): Likewise.
(may_insert_breakpoints): Likewise.
(may_insert_tracepoints): Likewise.
(may_insert_fast_tracepoints): Likewise.
(may_stop): Likewise.
* thread.c (struct info_threads_opts) <show_global_ids>: Likewise.
(make_thread_apply_all_options_def_group): Change argument from int*
to bool*.
(thread_apply_all_command): Update.
(print_thread_events): Change to bool.
* top.c (confirm): Likewise.
(command_editing_p): Likewise.
(history_expansion_p): Likewise.
(write_history_p): Likewise.
(info_verbose): Likewise.
* top.h (confirm): Likewise.
(history_expansion_p): Likewise.
* tracepoint.c (disconnected_tracing): Likewise.
(circular_trace_buffer): Likewise.
* typeprint.c (print_methods): Likewise.
(print_typedefs): Likewise.
* utils.c (debug_timestamp): Likewise.
(sevenbit_strings): Likewise.
(pagination_enabled): Likewise.
* utils.h (sevenbit_strings): Likewise.
(pagination_enabled): Likewise.
* valops.c (overload_resolution): Likewise.
* valprint.h (struct value_print_options) <prettyformat_arrays,
prettyformat_structs, vtblprint, unionprint, addressprint, objectprint,
stop_print_at_null, print_array_indexes, deref_ref, static_field_print,
pascal_static_field_print, raw, summary, symbol_print, finish_print>:
Likewise.
* windows-nat.c (new_console): Likewise.
(cygwin_exceptions): Likewise.
(new_group): Likewise.
(debug_exec): Likewise.
(debug_events): Likewise.
(debug_memory): Likewise.
(debug_exceptions): Likewise.
(useshell): Likewise.
* windows-tdep.c (maint_display_all_tib): Likewise.
* xml-support.c (debug_xml): Likewise.
2019-09-15 03:36:58 +08:00
|
|
|
|
/* If true all calls to the symfile functions are logged. */
|
|
|
|
|
static bool debug_symfile = false;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
/* Return non-zero if symfile debug logging is installed. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
symfile_debug_installed (struct objfile *objfile)
|
|
|
|
|
{
|
|
|
|
|
return (objfile->sf != NULL
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
&& symfile_debug_objfile_data_key.get (objfile) != NULL);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Utility return the name to print for SYMTAB. */
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
|
debug_symtab_name (struct symtab *symtab)
|
|
|
|
|
{
|
|
|
|
|
return symtab_to_filename_for_display (symtab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
/* See objfiles.h. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
objfile::has_partial_symbols ()
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
bool retval = false;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
/* If we have not read psymbols, but we have a function capable of reading
|
|
|
|
|
them, then that is an indication that they are in fact available. Without
|
|
|
|
|
this function the symbols may have been already read in but they also may
|
|
|
|
|
not be present in this objfile. */
|
2021-03-21 07:23:40 +08:00
|
|
|
|
for (const auto &iter : qf)
|
|
|
|
|
{
|
2023-01-02 03:14:21 +08:00
|
|
|
|
retval = iter->has_symbols (this);
|
2021-03-21 07:23:40 +08:00
|
|
|
|
if (retval)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->has_symbols (%s) = %d\n",
|
|
|
|
|
objfile_debug_name (this), retval);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 18:29:55 +08:00
|
|
|
|
/* See objfiles.h. */
|
|
|
|
|
bool
|
|
|
|
|
objfile::has_unexpanded_symtabs ()
|
|
|
|
|
{
|
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->has_unexpanded_symtabs (%s)\n",
|
|
|
|
|
objfile_debug_name (this));
|
2021-04-15 18:29:55 +08:00
|
|
|
|
|
|
|
|
|
bool result = false;
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-04-15 18:29:55 +08:00
|
|
|
|
{
|
|
|
|
|
if (iter->has_unexpanded_symtabs (this))
|
|
|
|
|
{
|
|
|
|
|
result = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->has_unexpanded_symtabs (%s) = %d\n",
|
|
|
|
|
objfile_debug_name (this), (result ? 1 : 0));
|
2021-04-15 18:29:55 +08:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
struct symtab *
|
|
|
|
|
objfile::find_last_source_symtab ()
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
struct symtab *retval = nullptr;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
|
|
|
|
|
objfile_debug_name (this));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
{
|
|
|
|
|
retval = iter->find_last_source_symtab (this);
|
|
|
|
|
if (retval != nullptr)
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n",
|
|
|
|
|
retval ? debug_symtab_name (retval) : "NULL");
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
void
|
|
|
|
|
objfile::forget_cached_source_info ()
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
|
|
|
|
|
objfile_debug_name (this));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2023-02-22 06:03:38 +08:00
|
|
|
|
for (compunit_symtab *cu : compunits ())
|
2024-06-05 23:06:30 +08:00
|
|
|
|
cu->forget_cached_source_info ();
|
2023-02-22 06:03:38 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
iter->forget_cached_source_info (this);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
bool
|
|
|
|
|
objfile::map_symtabs_matching_filename
|
|
|
|
|
(const char *name, const char *real_path,
|
Use gdb::function_view in iterate_over_symtabs & co
I wanted to pass a lambda to iterate_over_symtabs (see following
patch), so I converted it to function_view, and then the rest is
cascaded from that.
This gets rid of a bunch of single-use callback functions and
corresponding manually managed callback capture types
(add_partial_datum, search_symbols_data, etc.) in favor of letting the
compiler generate them for us by using lambdas with a capture. In a
couple cases, it was more natural to convert the existing function
callbacks to function objects (i.e., operator(), e.g.,
decode_compound_collector).
gdb/ChangeLog:
2017-02-23 Pedro Alves <palves@redhat.com>
* ada-lang.c: Include "common/function-view.h".
(ada_iterate_over_symbols): Adjust to use function_view as
callback type.
(struct add_partial_datum, ada_complete_symbol_matcher): Delete.
(ada_make_symbol_completion_list): Use a lambda.
(ada_exc_search_name_matches): Delete.
(name_matches_regex): New.
(ada_add_global_exceptions): Use a lambda and name_matches_regex.
* compile/compile-c-support.c: Include "common/function-view.h".
(print_one_macro): Change prototype to accept a ui_file pointer.
(write_macro_definitions): Use a lambda.
* dwarf2read.c: Include "common/function-view.h".
(dw2_map_expand_apply, dw2_map_symtabs_matching_filename)
(dw2_expand_symtabs_matching): Adjust to use function_view as
callback type.
* language.h: Include "common/function-view.h".
(struct language_defn) <la_iterate_over_symbols>: Adjust to use
function_view as callback type.
(LA_ITERATE_OVER_SYMBOLS): Remove DATA parameter.
* linespec.c: Include "common/function-view.h".
(collect_info::add_symbol): New method.
(struct symbol_and_data_callback, iterate_inline_only, struct
symbol_matcher_data, iterate_name_matcher): Delete.
(iterate_over_all_matching_symtabs): Adjust to use function_view
as callback type and lambdas.
(iterate_over_file_blocks): Adjust to use function_view as
callback type.
(decode_compound_collector): Now a class with private fields.
(decode_compound_collector::release_symbols): New method.
(collect_one_symbol): Rename to...
(decode_compound_collector::operator()): ... this and adjust.
(lookup_prefix_sym): decode_compound_collector construction bits
move to decode_compound_collector ctor. Pass the
decode_compound_collector object directly as callback. Remove
cleanups and use decode_compound_collector::release_symbols
instead.
(symtab_collector): Now a class with private fields.
(symtab_collector::release_symtabs): New method.
(add_symtabs_to_list): Rename to...
(symtab_collector::operator()): ... this and adjust.
(collect_symtabs_from_filename): symtab_collector construction
bits move to symtab_collector ctor. Pass the symtab_collector
object directly as callback. Remove cleanups and use
symtab_collector::release_symtabs instead.
(collect_symbols): Delete.
(add_matching_symbols_to_info): Use lambdas.
* macrocmd.c (print_macro_callback): Delete.
(info_macro_command): Use a lambda.
(info_macros_command): Pass print_macro_definition as callable
directly.
(print_one_macro): Remove 'ignore' parameter.
(macro_list_command): Adjust.
* macrotab.c (macro_for_each_data::fn): Now a function_view.
(macro_for_each_data::user_data): Delete field.
(foreach_macro): Adjust to call the function_view.
(macro_for_each): Adjust to use function_view as callback type.
(foreach_macro_in_scope): Adjust to call the function_view.
(macro_for_each_in_scope): Adjust to use function_view as callback
type.
* macrotab.h: Include "common/function-view.h".
(macro_callback_fn): Declare a prototype instead of a pointer.
Remove "user_data" parameter.
(macro_for_each, macro_for_each_in_scope): Adjust to use
function_view as callback type.
* psymtab.c (partial_map_expand_apply)
(psym_map_symtabs_matching_filename, recursively_search_psymtabs):
Adjust to use function_view as callback type and to return bool.
(psym_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile-debug.c (debug_qf_map_symtabs_matching_filename): Adjust
to use function_view as callback type and to return bool.
(debug_qf_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile.c (expand_symtabs_matching): Adjust to use function_view
as callback types.
* symfile.h: Include "common/function-view.h".
(expand_symtabs_file_matcher_ftype)
(expand_symtabs_symbol_matcher_ftype)
(expand_symtabs_exp_notify_ftype): Remove "data" parameter and
return bool.
(quick_symbol_functions::map_symtabs_matching_filename)
(quick_symbol_functions::expand_symtabs_matching): Adjust to use
function_view as callback type and return bool.
(expand_symtabs_matching): Adjust to use function_view as callback
type.
(maintenance_expand_name_matcher)
(maintenance_expand_file_matcher): Delete.
(maintenance_expand_symtabs): Use lambdas.
* symtab.c (iterate_over_some_symtabs): Adjust to use
function_view as callback types and return bool.
(iterate_over_symtabs): Likewise. Use unique_xmalloc_ptr instead
of a cleanup.
(lookup_symtab_callback): Delete.
(lookup_symtab): Use a lambda.
(iterate_over_symbols): Adjust to use function_view as callback
type.
(struct search_symbols_data, search_symbols_file_matches)
(search_symbols_name_matches): Delete.
(search_symbols): Use a pair of lambdas.
(struct add_name_data, add_macro_name, symbol_completion_matcher)
(symtab_expansion_callback): Delete.
(default_make_symbol_completion_list_break_on_1): Use lambdas.
* symtab.h: Include "common/function-view.h".
(iterate_over_some_symtabs): Adjust to use function_view as
callback type and return bool.
(iterate_over_symtabs): Adjust to use function_view as callback
type.
(symbol_found_callback_ftype): Remove 'data' parameter and return
bool.
(iterate_over_symbols): Adjust to use function_view as callback
type.
2017-02-22 22:43:35 +08:00
|
|
|
|
gdb::function_view<bool (symtab *)> callback)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->map_symtabs_matching_filename (%s, \"%s\", "
|
|
|
|
|
"\"%s\", %s)\n",
|
|
|
|
|
objfile_debug_name (this), name,
|
|
|
|
|
real_path ? real_path : NULL,
|
|
|
|
|
host_address_to_string (&callback));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2021-04-17 23:35:04 +08:00
|
|
|
|
bool retval = true;
|
|
|
|
|
const char *name_basename = lbasename (name);
|
|
|
|
|
|
|
|
|
|
auto match_one_filename = [&] (const char *filename, bool basenames)
|
|
|
|
|
{
|
|
|
|
|
if (compare_filenames_for_search (filename, name))
|
|
|
|
|
return true;
|
|
|
|
|
if (basenames && FILENAME_CMP (name_basename, filename) == 0)
|
|
|
|
|
return true;
|
|
|
|
|
if (real_path != nullptr && IS_ABSOLUTE_PATH (filename)
|
|
|
|
|
&& IS_ABSOLUTE_PATH (real_path))
|
|
|
|
|
return filename_cmp (filename, real_path) == 0;
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
compunit_symtab *last_made = this->compunit_symtabs;
|
|
|
|
|
|
|
|
|
|
auto on_expansion = [&] (compunit_symtab *symtab)
|
|
|
|
|
{
|
|
|
|
|
/* The callback to iterate_over_some_symtabs returns false to keep
|
|
|
|
|
going and true to continue, so we have to invert the result
|
|
|
|
|
here, for expand_symtabs_matching. */
|
|
|
|
|
bool result = !iterate_over_some_symtabs (name, real_path,
|
|
|
|
|
this->compunit_symtabs,
|
|
|
|
|
last_made,
|
|
|
|
|
callback);
|
|
|
|
|
last_made = this->compunit_symtabs;
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
{
|
2021-04-17 23:35:04 +08:00
|
|
|
|
if (!iter->expand_symtabs_matching (this,
|
|
|
|
|
match_one_filename,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
on_expansion,
|
|
|
|
|
(SEARCH_GLOBAL_BLOCK
|
|
|
|
|
| SEARCH_STATIC_BLOCK),
|
2024-01-30 00:45:35 +08:00
|
|
|
|
SEARCH_ALL_DOMAINS))
|
2021-04-17 23:35:04 +08:00
|
|
|
|
{
|
|
|
|
|
retval = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-03-21 07:23:40 +08:00
|
|
|
|
}
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->map_symtabs_matching_filename (...) = %d\n",
|
|
|
|
|
retval);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2021-04-17 23:35:04 +08:00
|
|
|
|
/* We must re-invert the return value here to match the caller's
|
|
|
|
|
expectations. */
|
|
|
|
|
return !retval;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
struct compunit_symtab *
|
2024-01-26 02:17:24 +08:00
|
|
|
|
objfile::lookup_symbol (block_enum kind, const lookup_name_info &name,
|
2023-03-31 13:00:26 +08:00
|
|
|
|
domain_search_flags domain)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
struct compunit_symtab *retval = nullptr;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
|
2024-01-26 02:17:24 +08:00
|
|
|
|
objfile_debug_name (this), kind, name.c_str (),
|
2023-03-31 13:00:26 +08:00
|
|
|
|
domain_name (domain).c_str ());
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2021-04-17 23:35:04 +08:00
|
|
|
|
auto search_one_symtab = [&] (compunit_symtab *stab)
|
|
|
|
|
{
|
|
|
|
|
struct symbol *sym, *with_opaque = NULL;
|
2021-11-20 11:25:23 +08:00
|
|
|
|
const struct blockvector *bv = stab->blockvector ();
|
2022-02-07 11:54:03 +08:00
|
|
|
|
const struct block *block = bv->block (kind);
|
2021-04-17 23:35:04 +08:00
|
|
|
|
|
2024-01-26 02:17:24 +08:00
|
|
|
|
sym = block_find_symbol (block, name, domain, &with_opaque);
|
2021-04-17 23:35:04 +08:00
|
|
|
|
|
|
|
|
|
/* Some caution must be observed with overloaded functions
|
|
|
|
|
and methods, since the index will not contain any overload
|
|
|
|
|
information (but NAME might contain it). */
|
|
|
|
|
|
2023-03-30 22:41:17 +08:00
|
|
|
|
if (sym != nullptr)
|
2021-04-17 23:35:04 +08:00
|
|
|
|
{
|
|
|
|
|
retval = stab;
|
|
|
|
|
/* Found it. */
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-03-30 22:41:17 +08:00
|
|
|
|
if (with_opaque != nullptr)
|
2021-04-17 23:35:04 +08:00
|
|
|
|
retval = stab;
|
|
|
|
|
|
|
|
|
|
/* Keep looking through other psymtabs. */
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
{
|
2021-04-17 23:35:04 +08:00
|
|
|
|
if (!iter->expand_symtabs_matching (this,
|
|
|
|
|
nullptr,
|
2024-01-26 02:17:24 +08:00
|
|
|
|
&name,
|
2021-04-17 23:35:04 +08:00
|
|
|
|
nullptr,
|
|
|
|
|
search_one_symtab,
|
|
|
|
|
kind == GLOBAL_BLOCK
|
|
|
|
|
? SEARCH_GLOBAL_BLOCK
|
|
|
|
|
: SEARCH_STATIC_BLOCK,
|
2023-03-31 13:00:26 +08:00
|
|
|
|
domain))
|
2021-03-21 07:23:40 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
|
|
|
|
|
retval
|
|
|
|
|
? debug_symtab_name (retval->primary_filetab ())
|
|
|
|
|
: "NULL");
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
void
|
2021-03-21 07:23:40 +08:00
|
|
|
|
objfile::print_stats (bool print_bcache)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->print_stats (%s, %d)\n",
|
|
|
|
|
objfile_debug_name (this), print_bcache);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
iter->print_stats (this, print_bcache);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
void
|
|
|
|
|
objfile::dump ()
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->dump (%s)\n",
|
|
|
|
|
objfile_debug_name (this));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2021-03-21 07:23:40 +08:00
|
|
|
|
for (const auto &iter : qf)
|
|
|
|
|
iter->dump (this);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
void
|
|
|
|
|
objfile::expand_symtabs_for_function (const char *func_name)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->expand_symtabs_for_function (%s, \"%s\")\n",
|
|
|
|
|
objfile_debug_name (this), func_name);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2021-04-17 23:35:04 +08:00
|
|
|
|
lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
|
|
|
|
|
lookup_name_info lookup_name = base_lookup.make_ignore_params ();
|
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-04-17 23:35:04 +08:00
|
|
|
|
iter->expand_symtabs_matching (this,
|
|
|
|
|
nullptr,
|
|
|
|
|
&lookup_name,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
(SEARCH_GLOBAL_BLOCK
|
|
|
|
|
| SEARCH_STATIC_BLOCK),
|
2023-09-02 23:42:44 +08:00
|
|
|
|
SEARCH_FUNCTION_DOMAIN);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
void
|
|
|
|
|
objfile::expand_all_symtabs ()
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
|
|
|
|
|
objfile_debug_name (this));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
iter->expand_all_symtabs (this);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
void
|
|
|
|
|
objfile::expand_symtabs_with_fullname (const char *fullname)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
|
|
|
|
|
objfile_debug_name (this), fullname);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2021-04-17 23:35:04 +08:00
|
|
|
|
const char *basename = lbasename (fullname);
|
|
|
|
|
auto file_matcher = [&] (const char *filename, bool basenames)
|
|
|
|
|
{
|
|
|
|
|
return filename_cmp (basenames ? basename : fullname, filename) == 0;
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-04-17 23:35:04 +08:00
|
|
|
|
iter->expand_symtabs_matching (this,
|
|
|
|
|
file_matcher,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
(SEARCH_GLOBAL_BLOCK
|
|
|
|
|
| SEARCH_STATIC_BLOCK),
|
2024-01-30 00:45:35 +08:00
|
|
|
|
SEARCH_ALL_DOMAINS);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-17 23:35:04 +08:00
|
|
|
|
bool
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
objfile::expand_symtabs_matching
|
|
|
|
|
(gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
|
[gdb] Expand symbolless symtabs using maint expand-symtabs
Consider this test-case, consisting of header file hello.h:
...
inline static const char*
foo (void)
{
return "foo";
}
...
and source file hello.c:
...
int
main (void)
{
printf ("hello: %s\n", foo ());
return 0;
}
...
compiled with -g:
...
$ gcc hello.c -g
...
When trying to expand the partial symtab for hello.h:
...
$ gdb -batch \
-iex "set language c" \
a.out \
-ex "maint expand-symtabs hello.h" \
-ex "maint info psymtabs"
...
we in fact find that the partial symtab for hello.h (and corresponding
includer partial symtab hello.c) have not been expanded:
...
{ psymtab hello.h ((struct partial_symtab *) 0x27cf070)
readin no
...
{ psymtab hello.c ((struct partial_symtab *) 0x2cf09e0)
readin no
...
This is due to the recursively_search_psymtabs call in
psym_expand_symtabs_matching:
...
if (recursively_search_psymtabs (ps, objfile, domain,
lookup_name, symbol_matcher))
...
which always returns false for symbolless partial symtabs.
The same problem occurs with CUs where the dwarf is generated by gas
--gdwarf-2 for a foo.S: if we read such a test-case with -readnow, we'll have
a symbolless symtab for foo.S. But if we read the test-case with partial
symtabs, and expand those using "maint expand-symtabs", the foo.S psymtab
remains unexpanded.
Fix this by passing a NULL symbol_matcher and lookup_name to
expand_symtabs_matching in maintenance_expand_symtabs, and skipping the call
to recursively_search_psymtabs if symbol_matcher == NULL and
lookup_name == NULL.
Build and tested on x86_64-linux, with native.
In addition, tested test-case with target boards cc-with-gdb-index.exp,
cc-with-debug-names.exp and readnow.exp.
gdb/ChangeLog:
2020-04-14 Tom de Vries <tdevries@suse.de>
PR symtab/25720
* symmisc.c (maintenance_expand_symtabs): Call expand_symtabs_matching
with NULL symbol_matcher and lookup_name.
* psymtab.c (psym_expand_symtabs_matching): Handle NULL symbol_matcher
and lookup_name.
* dwarf2/read.c (dw2_expand_symtabs_matching)
(dw2_debug_names_expand_symtabs_matching): Same.
* symfile.h (struct quick_symbol_functions::expand_symtabs_matching):
Make lookup_name a pointer. Update comment.
* symtab.c (global_symbol_searcher::expand_symtabs): Handle
lookup_name being a pointer.
* symfile.c (expand_symtabs_matching): Same.
* symfile-debug.c (debug_qf_expand_symtabs_matching): Same.
* linespec.c (iterate_over_all_matching_symtabs): Same.
gdb/testsuite/ChangeLog:
2020-04-14 Tom de Vries <tdevries@suse.de>
PR symtab/25720
* gdb.base/maint-expand-symbols-header-file.c: New test.
* gdb.base/maint-expand-symbols-header-file.exp: New file.
* gdb.base/maint-expand-symbols-header-file.h: New test.
2020-04-14 21:08:42 +08:00
|
|
|
|
const lookup_name_info *lookup_name,
|
Use gdb::function_view in iterate_over_symtabs & co
I wanted to pass a lambda to iterate_over_symtabs (see following
patch), so I converted it to function_view, and then the rest is
cascaded from that.
This gets rid of a bunch of single-use callback functions and
corresponding manually managed callback capture types
(add_partial_datum, search_symbols_data, etc.) in favor of letting the
compiler generate them for us by using lambdas with a capture. In a
couple cases, it was more natural to convert the existing function
callbacks to function objects (i.e., operator(), e.g.,
decode_compound_collector).
gdb/ChangeLog:
2017-02-23 Pedro Alves <palves@redhat.com>
* ada-lang.c: Include "common/function-view.h".
(ada_iterate_over_symbols): Adjust to use function_view as
callback type.
(struct add_partial_datum, ada_complete_symbol_matcher): Delete.
(ada_make_symbol_completion_list): Use a lambda.
(ada_exc_search_name_matches): Delete.
(name_matches_regex): New.
(ada_add_global_exceptions): Use a lambda and name_matches_regex.
* compile/compile-c-support.c: Include "common/function-view.h".
(print_one_macro): Change prototype to accept a ui_file pointer.
(write_macro_definitions): Use a lambda.
* dwarf2read.c: Include "common/function-view.h".
(dw2_map_expand_apply, dw2_map_symtabs_matching_filename)
(dw2_expand_symtabs_matching): Adjust to use function_view as
callback type.
* language.h: Include "common/function-view.h".
(struct language_defn) <la_iterate_over_symbols>: Adjust to use
function_view as callback type.
(LA_ITERATE_OVER_SYMBOLS): Remove DATA parameter.
* linespec.c: Include "common/function-view.h".
(collect_info::add_symbol): New method.
(struct symbol_and_data_callback, iterate_inline_only, struct
symbol_matcher_data, iterate_name_matcher): Delete.
(iterate_over_all_matching_symtabs): Adjust to use function_view
as callback type and lambdas.
(iterate_over_file_blocks): Adjust to use function_view as
callback type.
(decode_compound_collector): Now a class with private fields.
(decode_compound_collector::release_symbols): New method.
(collect_one_symbol): Rename to...
(decode_compound_collector::operator()): ... this and adjust.
(lookup_prefix_sym): decode_compound_collector construction bits
move to decode_compound_collector ctor. Pass the
decode_compound_collector object directly as callback. Remove
cleanups and use decode_compound_collector::release_symbols
instead.
(symtab_collector): Now a class with private fields.
(symtab_collector::release_symtabs): New method.
(add_symtabs_to_list): Rename to...
(symtab_collector::operator()): ... this and adjust.
(collect_symtabs_from_filename): symtab_collector construction
bits move to symtab_collector ctor. Pass the symtab_collector
object directly as callback. Remove cleanups and use
symtab_collector::release_symtabs instead.
(collect_symbols): Delete.
(add_matching_symbols_to_info): Use lambdas.
* macrocmd.c (print_macro_callback): Delete.
(info_macro_command): Use a lambda.
(info_macros_command): Pass print_macro_definition as callable
directly.
(print_one_macro): Remove 'ignore' parameter.
(macro_list_command): Adjust.
* macrotab.c (macro_for_each_data::fn): Now a function_view.
(macro_for_each_data::user_data): Delete field.
(foreach_macro): Adjust to call the function_view.
(macro_for_each): Adjust to use function_view as callback type.
(foreach_macro_in_scope): Adjust to call the function_view.
(macro_for_each_in_scope): Adjust to use function_view as callback
type.
* macrotab.h: Include "common/function-view.h".
(macro_callback_fn): Declare a prototype instead of a pointer.
Remove "user_data" parameter.
(macro_for_each, macro_for_each_in_scope): Adjust to use
function_view as callback type.
* psymtab.c (partial_map_expand_apply)
(psym_map_symtabs_matching_filename, recursively_search_psymtabs):
Adjust to use function_view as callback type and to return bool.
(psym_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile-debug.c (debug_qf_map_symtabs_matching_filename): Adjust
to use function_view as callback type and to return bool.
(debug_qf_expand_symtabs_matching): Adjust to use function_view as
callback types.
* symfile.c (expand_symtabs_matching): Adjust to use function_view
as callback types.
* symfile.h: Include "common/function-view.h".
(expand_symtabs_file_matcher_ftype)
(expand_symtabs_symbol_matcher_ftype)
(expand_symtabs_exp_notify_ftype): Remove "data" parameter and
return bool.
(quick_symbol_functions::map_symtabs_matching_filename)
(quick_symbol_functions::expand_symtabs_matching): Adjust to use
function_view as callback type and return bool.
(expand_symtabs_matching): Adjust to use function_view as callback
type.
(maintenance_expand_name_matcher)
(maintenance_expand_file_matcher): Delete.
(maintenance_expand_symtabs): Use lambdas.
* symtab.c (iterate_over_some_symtabs): Adjust to use
function_view as callback types and return bool.
(iterate_over_symtabs): Likewise. Use unique_xmalloc_ptr instead
of a cleanup.
(lookup_symtab_callback): Delete.
(lookup_symtab): Use a lambda.
(iterate_over_symbols): Adjust to use function_view as callback
type.
(struct search_symbols_data, search_symbols_file_matches)
(search_symbols_name_matches): Delete.
(search_symbols): Use a pair of lambdas.
(struct add_name_data, add_macro_name, symbol_completion_matcher)
(symtab_expansion_callback): Delete.
(default_make_symbol_completion_list_break_on_1): Use lambdas.
* symtab.h: Include "common/function-view.h".
(iterate_over_some_symtabs): Adjust to use function_view as
callback type and return bool.
(iterate_over_symtabs): Adjust to use function_view as callback
type.
(symbol_found_callback_ftype): Remove 'data' parameter and return
bool.
(iterate_over_symbols): Adjust to use function_view as callback
type.
2017-02-22 22:43:35 +08:00
|
|
|
|
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
|
|
|
|
|
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
|
2021-04-17 23:35:04 +08:00
|
|
|
|
block_search_flags search_flags,
|
[gdb/symtab] Don't expand non-Ada CUs for info exceptions
I noticed when running test-case gdb.ada/info_exc.exp with glibc debug info
installed, that the "info exceptions" command that lists all Ada exceptions
also expands non-Ada CUs, which includes CUs in
/lib64/ld-linux-x86-64.so.2 and /lib64/libc.so.6.
Fix this by:
- adding a new lang_matcher parameter to the expand_symtabs_matching
function, and
- using that new parameter in the expand_symtabs_matching call in
ada_add_global_exceptions.
The new parameter is a hint, meaning implementations are free to ignore it and
expand CUs with any language. This is the case for partial symtabs, I'm not
sure whether it makes sense to implement support for this there.
Conversely, when processing a CU with language C and name "<artificial>"
(as produced by GCC LTO), the CU may not really have a single language and we
should ignore the lang_matcher. See also commit d2f67711730
("Fix 'catch exception' with -flto").
Now that we have lang_matcher available, also use it to limit name splitting
styles and symbol matchers to those applicable to the matched languages.
Without this patch we have (with a gdb build with -O0):
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real 0m1.866s
user 0m2.089s
sys 0m0.120s
...
and with this patch we have:
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real 0m0.469s
user 0m0.777s
sys 0m0.051s
...
Or, to put it in terms of number of CUs, we have 1853 CUs:
...
$ gdb -q -batch -readnow outputs/gdb.ada/info_exc/foo \
-ex start \
-ex "maint info symtabs" \
| grep -c " name "
1853
...
Without this patch, we have:
...
$ gdb -q -batch outputs/gdb.ada/info_exc/foo \
-ex start \
-ex "info exceptions" \
-ex "maint info symtabs" \
| grep -c " name "
1393
...
so ~75% of the CUs is expanded, and with this patch we have:
...
$ gdb <same-as-above>
20
...
so ~1% of the CUs is expanded.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/32182
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32182
2024-09-24 16:24:22 +08:00
|
|
|
|
domain_search_flags domain,
|
|
|
|
|
gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
2021-06-22 04:10:41 +08:00
|
|
|
|
/* This invariant is documented in quick-functions.h. */
|
|
|
|
|
gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
|
|
|
|
|
objfile_debug_name (this),
|
|
|
|
|
host_address_to_string (&file_matcher),
|
|
|
|
|
host_address_to_string (&symbol_matcher),
|
|
|
|
|
host_address_to_string (&expansion_notify),
|
2023-03-11 22:55:42 +08:00
|
|
|
|
domain_name (domain).c_str ());
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-04-17 23:35:04 +08:00
|
|
|
|
if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
|
|
|
|
|
symbol_matcher, expansion_notify,
|
[gdb/symtab] Don't expand non-Ada CUs for info exceptions
I noticed when running test-case gdb.ada/info_exc.exp with glibc debug info
installed, that the "info exceptions" command that lists all Ada exceptions
also expands non-Ada CUs, which includes CUs in
/lib64/ld-linux-x86-64.so.2 and /lib64/libc.so.6.
Fix this by:
- adding a new lang_matcher parameter to the expand_symtabs_matching
function, and
- using that new parameter in the expand_symtabs_matching call in
ada_add_global_exceptions.
The new parameter is a hint, meaning implementations are free to ignore it and
expand CUs with any language. This is the case for partial symtabs, I'm not
sure whether it makes sense to implement support for this there.
Conversely, when processing a CU with language C and name "<artificial>"
(as produced by GCC LTO), the CU may not really have a single language and we
should ignore the lang_matcher. See also commit d2f67711730
("Fix 'catch exception' with -flto").
Now that we have lang_matcher available, also use it to limit name splitting
styles and symbol matchers to those applicable to the matched languages.
Without this patch we have (with a gdb build with -O0):
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real 0m1.866s
user 0m2.089s
sys 0m0.120s
...
and with this patch we have:
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real 0m0.469s
user 0m0.777s
sys 0m0.051s
...
Or, to put it in terms of number of CUs, we have 1853 CUs:
...
$ gdb -q -batch -readnow outputs/gdb.ada/info_exc/foo \
-ex start \
-ex "maint info symtabs" \
| grep -c " name "
1853
...
Without this patch, we have:
...
$ gdb -q -batch outputs/gdb.ada/info_exc/foo \
-ex start \
-ex "info exceptions" \
-ex "maint info symtabs" \
| grep -c " name "
1393
...
so ~75% of the CUs is expanded, and with this patch we have:
...
$ gdb <same-as-above>
20
...
so ~1% of the CUs is expanded.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/32182
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32182
2024-09-24 16:24:22 +08:00
|
|
|
|
search_flags, domain,
|
|
|
|
|
lang_matcher))
|
2021-04-17 23:35:04 +08:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
struct compunit_symtab *
|
2024-07-17 11:51:59 +08:00
|
|
|
|
objfile::find_pc_sect_compunit_symtab (bound_minimal_symbol msymbol,
|
Split struct symtab into two: struct symtab and compunit_symtab.
Currently "symtabs" in gdb are stored as a single linked list of
struct symtab that contains both symbol symtabs (the blockvectors)
and file symtabs (the linetables).
This has led to confusion, bugs, and performance issues.
This patch is conceptually very simple: split struct symtab into
two pieces: one part containing things common across the entire
compilation unit, and one part containing things specific to each
source file.
Example.
For the case of a program built out of these files:
foo.c
foo1.h
foo2.h
bar.c
foo1.h
bar.h
Today we have a single list of struct symtabs:
objfile -> foo.c -> foo1.h -> foo2.h -> bar.c -> foo1.h -> bar.h -> NULL
where "->" means the "next" pointer in struct symtab.
With this patch, that turns into:
objfile -> foo.c(cu) -> bar.c(cu) -> NULL
| |
v v
foo.c bar.c
| |
v v
foo1.h foo1.h
| |
v v
foo2.h bar.h
| |
v v
NULL NULL
where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects,
and the files foo.c, etc. are struct symtab objects.
So now, for example, when we want to iterate over all blockvectors
we can now just iterate over the compunit_symtab list.
Plus a lot of the data that was either unused or replicated for each
symtab in a compilation unit now lives in struct compunit_symtab.
E.g., the objfile pointer, the producer string, etc.
I thought of moving "language" out of struct symtab but there is
logic to try to compute the language based on previously seen files,
and I think that's best left as is for now.
With my standard monster benchmark with -readnow (which I can't actually
do, but based on my calculations), whereas today the list requires
77MB to store all the struct symtabs, it now only requires 37MB.
A modest space savings given the gigabytes needed for all the debug info,
etc. Still, it's nice. Plus, whereas today we create a copy of dirname
for each source file symtab in a compilation unit, we now only create one
for the compunit.
So this patch is basically just a data structure reorg,
I don't expect significant performance improvements from it.
Notes:
1) A followup patch can do a similar split for struct partial_symtab.
I have left that until after I get the changes I want in to
better utilize .gdb_index (it may affect how we do partial syms).
2) Another followup patch *could* rename struct symtab.
The term "symtab" is ambiguous and has been a source of confusion.
In this patch I'm leaving it alone, calling it the "historical" name
of "filetabs", which is what they are now: just the file-name + line-table.
gdb/ChangeLog:
Split struct symtab into two: struct symtab and compunit_symtab.
* amd64-tdep.c (amd64_skip_xmm_prologue): Fetch producer from compunit.
* block.c (blockvector_for_pc_sect): Change "struct symtab *" argument
to "struct compunit_symtab *". All callers updated.
(set_block_compunit_symtab): Renamed from set_block_symtab. Change
"struct symtab *" argument to "struct compunit_symtab *".
All callers updated.
(get_block_compunit_symtab): Renamed from get_block_symtab. Change
result to "struct compunit_symtab *". All callers updated.
(find_iterator_compunit_symtab): Renamed from find_iterator_symtab.
Change result to "struct compunit_symtab *". All callers updated.
* block.h (struct global_block) <compunit_symtab>: Renamed from symtab.
hange type to "struct compunit_symtab *". All uses updated.
(struct block_iterator) <d.compunit_symtab>: Renamed from "d.symtab".
Change type to "struct compunit_symtab *". All uses updated.
* buildsym.c (struct buildsym_compunit): New struct.
(subfiles, buildsym_compdir, buildsym_objfile, main_subfile): Delete.
(buildsym_compunit): New static global.
(finish_block_internal): Update to fetch objfile from
buildsym_compunit.
(make_blockvector): Delete objfile argument.
(start_subfile): Rewrite to use buildsym_compunit. Don't initialize
debugformat, producer.
(start_buildsym_compunit): New function.
(free_buildsym_compunit): Renamed from free_subfiles_list.
All callers updated.
(patch_subfile_names): Rewrite to use buildsym_compunit.
(get_compunit_symtab): New function.
(get_macro_table): Delete argument comp_dir. All callers updated.
(start_symtab): Change result to "struct compunit_symtab *".
All callers updated. Create the subfile of the main source file.
(watch_main_source_file_lossage): Rewrite to use buildsym_compunit.
(reset_symtab_globals): Update.
(end_symtab_get_static_block): Update to use buildsym_compunit.
(end_symtab_without_blockvector): Rewrite.
(end_symtab_with_blockvector): Change result to
"struct compunit_symtab *". All callers updated.
Update to use buildsym_compunit. Don't set symtab->dirname,
instead set it in the compunit.
Explicitly make sure main symtab is first in its list.
Set debugformat, producer, blockvector, block_line_section, and
macrotable in the compunit.
(end_symtab_from_static_block): Change result to
"struct compunit_symtab *". All callers updated.
(end_symtab, end_expandable_symtab): Ditto.
(set_missing_symtab): Change symtab argument to
"struct compunit_symtab *". All callers updated.
(augment_type_symtab): Ditto.
(record_debugformat): Update to use buildsym_compunit.
(record_producer): Update to use buildsym_compunit.
* buildsym.h (struct subfile) <dirname>: Delete.
<producer, debugformat>: Delete.
<buildsym_compunit>: New member.
(get_compunit_symtab): Declare.
* dwarf2read.c (struct type_unit_group) <compunit_symtab>: Renamed
from primary_symtab. Change type to "struct compunit_symtab *".
All uses updated.
(dwarf2_start_symtab): Change result to "struct compunit_symtab *".
All callers updated.
(dwarf_decode_macros): Delete comp_dir argument. All callers updated.
(struct dwarf2_per_cu_quick_data) <compunit_symtab>: Renamed from
symtab. Change type to "struct compunit_symtab *". All uses updated.
(dw2_instantiate_symtab): Change result to "struct compunit_symtab *".
All callers updated.
(dw2_find_last_source_symtab): Ditto.
(dw2_lookup_symbol): Ditto.
(recursively_find_pc_sect_compunit_symtab): Renamed from
recursively_find_pc_sect_symtab. Change result to
"struct compunit_symtab *". All callers updated.
(dw2_find_pc_sect_compunit_symtab): Renamed from
dw2_find_pc_sect_symtab. Change result to
"struct compunit_symtab *". All callers updated.
(get_compunit_symtab): Renamed from get_symtab. Change result to
"struct compunit_symtab *". All callers updated.
(recursively_compute_inclusions): Change type of immediate_parent
argument to "struct compunit_symtab *". All callers updated.
(compute_compunit_symtab_includes): Renamed from
compute_symtab_includes. All callers updated. Rewrite to compute
includes of compunit_symtabs and not symtabs.
(process_full_comp_unit): Update to work with struct compunit_symtab.
(process_full_type_unit): Ditto.
(dwarf_decode_lines_1): Delete argument comp_dir. All callers updated.
(dwarf_decode_lines): Remove special case handling of main subfile.
(macro_start_file): Delete argument comp_dir. All callers updated.
(dwarf_decode_macro_bytes): Ditto.
* guile/scm-block.c (bkscm_print_block_syms_progress_smob): Update to
use struct compunit_symtab.
* i386-tdep.c (i386_skip_prologue): Fetch producer from compunit.
* jit.c (finalize_symtab): Build compunit_symtab.
* jv-lang.c (get_java_class_symtab): Change result to
"struct compunit_symtab *". All callers updated.
* macroscope.c (sal_macro_scope): Fetch macro table from compunit.
* macrotab.c (struct macro_table) <compunit_symtab>: Renamed from
comp_dir. Change type to "struct compunit_symtab *".
All uses updated.
(new_macro_table): Change comp_dir argument to cust,
"struct compunit_symtab *". All callers updated.
* maint.c (struct cmd_stats) <nr_compunit_symtabs>: Renamed from
nr_primary_symtabs. All uses updated.
(count_symtabs_and_blocks): Update to handle compunits.
(report_command_stats): Update output, "primary symtabs" renamed to
"compunits".
* mdebugread.c (new_symtab): Change result to
"struct compunit_symtab *". All callers updated.
(parse_procedure): Change type of search_symtab argument to
"struct compunit_symtab *". All callers updated.
* objfiles.c (objfile_relocate1): Loop over blockvectors in a
separate loop.
* objfiles.h (struct objfile) <compunit_symtabs>: Renamed from
symtabs. Change type to "struct compunit_symtab *". All uses updated.
(ALL_OBJFILE_FILETABS): Renamed from ALL_OBJFILE_SYMTABS.
All uses updated.
(ALL_OBJFILE_COMPUNITS): Renamed from ALL_OBJFILE_PRIMARY_SYMTABS.
All uses updated.
(ALL_FILETABS): Renamed from ALL_SYMTABS. All uses updated.
(ALL_COMPUNITS): Renamed from ALL_PRIMARY_SYMTABS. All uses updated.
* psympriv.h (struct partial_symtab) <compunit_symtab>: Renamed from
symtab. Change type to "struct compunit_symtab *". All uses updated.
* psymtab.c (psymtab_to_symtab): Change result type to
"struct compunit_symtab *". All callers updated.
(find_pc_sect_compunit_symtab_from_partial): Renamed from
find_pc_sect_symtab_from_partial. Change result type to
"struct compunit_symtab *". All callers updated.
(lookup_symbol_aux_psymtabs): Change result type to
"struct compunit_symtab *". All callers updated.
(find_last_source_symtab_from_partial): Ditto.
* python/py-symtab.c (stpy_get_producer): Fetch producer from compunit.
* source.c (forget_cached_source_info_for_objfile): Fetch debugformat
and macro_table from compunit.
* symfile-debug.c (debug_qf_find_last_source_symtab): Change result
type to "struct compunit_symtab *". All callers updated.
(debug_qf_lookup_symbol): Ditto.
(debug_qf_find_pc_sect_compunit_symtab): Renamed from
debug_qf_find_pc_sect_symtab, change result type to
"struct compunit_symtab *". All callers updated.
* symfile.c (allocate_symtab): Delete objfile argument.
New argument cust.
(allocate_compunit_symtab): New function.
(add_compunit_symtab_to_objfile): New function.
* symfile.h (struct quick_symbol_functions) <lookup_symbol>:
Change result type to "struct compunit_symtab *". All uses updated.
<find_pc_sect_compunit_symtab>: Renamed from find_pc_sect_symtab.
Change result type to "struct compunit_symtab *". All uses updated.
* symmisc.c (print_objfile_statistics): Compute blockvector count in
separate loop.
(dump_symtab_1): Update test for primary source symtab.
(maintenance_info_symtabs): Update to handle compunit symtabs.
(maintenance_check_symtabs): Ditto.
* symtab.c (set_primary_symtab): Delete.
(compunit_primary_filetab): New function.
(compunit_language): New function.
(iterate_over_some_symtabs): Change type of arguments "first",
"after_last" to "struct compunit_symtab *". All callers updated.
Update to loop over symtabs in each compunit.
(error_in_psymtab_expansion): Rename symtab argument to cust,
and change type to "struct compunit_symtab *". All callers updated.
(find_pc_sect_compunit_symtab): Renamed from find_pc_sect_symtab.
Change result type to "struct compunit_symtab *". All callers updated.
(find_pc_compunit_symtab): Renamed from find_pc_symtab.
Change result type to "struct compunit_symtab *". All callers updated.
(find_pc_sect_line): Only loop over symtabs within selected compunit
instead of all symtabs in the objfile.
* symtab.h (struct symtab) <blockvector>: Moved to compunit_symtab.
<compunit_symtab> New member.
<block_line_section>: Moved to compunit_symtab.
<locations_valid>: Ditto.
<epilogue_unwind_valid>: Ditto.
<macro_table>: Ditto.
<dirname>: Ditto.
<debugformat>: Ditto.
<producer>: Ditto.
<objfile>: Ditto.
<call_site_htab>: Ditto.
<includes>: Ditto.
<user>: Ditto.
<primary>: Delete
(SYMTAB_COMPUNIT): New macro.
(SYMTAB_BLOCKVECTOR): Update definition.
(SYMTAB_OBJFILE): Update definition.
(SYMTAB_DIRNAME): Update definition.
(struct compunit_symtab): New type. Common members among all source
symtabs within a compilation unit moved here. All uses updated.
(COMPUNIT_OBJFILE): New macro.
(COMPUNIT_FILETABS): New macro.
(COMPUNIT_DEBUGFORMAT): New macro.
(COMPUNIT_PRODUCER): New macro.
(COMPUNIT_DIRNAME): New macro.
(COMPUNIT_BLOCKVECTOR): New macro.
(COMPUNIT_BLOCK_LINE_SECTION): New macro.
(COMPUNIT_LOCATIONS_VALID): New macro.
(COMPUNIT_EPILOGUE_UNWIND_VALID): New macro.
(COMPUNIT_CALL_SITE_HTAB): New macro.
(COMPUNIT_MACRO_TABLE): New macro.
(ALL_COMPUNIT_FILETABS): New macro.
(compunit_symtab_ptr): New typedef.
(DEF_VEC_P (compunit_symtab_ptr)): New vector type.
gdb/testsuite/ChangeLog:
* gdb.base/maint.exp: Update expected output.
2014-11-20 23:42:48 +08:00
|
|
|
|
CORE_ADDR pc,
|
|
|
|
|
struct obj_section *section,
|
|
|
|
|
int warn_if_readin)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
struct compunit_symtab *retval = nullptr;
|
|
|
|
|
|
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
|
|
|
|
|
objfile_debug_name (this),
|
|
|
|
|
host_address_to_string (msymbol.minsym),
|
|
|
|
|
hex_string (pc),
|
|
|
|
|
host_address_to_string (section),
|
|
|
|
|
warn_if_readin);
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
{
|
|
|
|
|
retval = iter->find_pc_sect_compunit_symtab (this, msymbol, pc, section,
|
|
|
|
|
warn_if_readin);
|
|
|
|
|
if (retval != nullptr)
|
|
|
|
|
break;
|
|
|
|
|
}
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
|
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->find_pc_sect_compunit_symtab (...) = %s\n",
|
|
|
|
|
retval
|
|
|
|
|
? debug_symtab_name (retval->primary_filetab ())
|
|
|
|
|
: "NULL");
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
void
|
2021-03-27 03:44:24 +08:00
|
|
|
|
objfile::map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
|
|
|
|
|
bool need_fullname)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->map_symbol_filenames (%s, ..., %d)\n",
|
|
|
|
|
objfile_debug_name (this),
|
|
|
|
|
need_fullname);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-27 03:44:24 +08:00
|
|
|
|
iter->map_symbol_filenames (this, fun, need_fullname);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-31 02:29:12 +08:00
|
|
|
|
void
|
|
|
|
|
objfile::compute_main_name ()
|
|
|
|
|
{
|
|
|
|
|
if (debug_symfile)
|
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->compute_main_name (%s)\n",
|
|
|
|
|
objfile_debug_name (this));
|
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2022-12-31 02:29:12 +08:00
|
|
|
|
iter->compute_main_name (this);
|
|
|
|
|
}
|
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
struct compunit_symtab *
|
|
|
|
|
objfile::find_compunit_symtab_by_address (CORE_ADDR address)
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
{
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->find_compunit_symtab_by_address (%s, %s)\n",
|
|
|
|
|
objfile_debug_name (this),
|
|
|
|
|
hex_string (address));
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
|
|
|
|
|
struct compunit_symtab *result = NULL;
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
{
|
|
|
|
|
result = iter->find_compunit_symtab_by_address (this, address);
|
|
|
|
|
if (result != nullptr)
|
|
|
|
|
break;
|
|
|
|
|
}
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
if (debug_symfile)
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"qf->find_compunit_symtab_by_address (...) = %s\n",
|
|
|
|
|
result
|
|
|
|
|
? debug_symtab_name (result->primary_filetab ())
|
|
|
|
|
: "NULL");
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum language
|
|
|
|
|
objfile::lookup_global_symbol_language (const char *name,
|
2023-03-11 22:55:42 +08:00
|
|
|
|
domain_search_flags domain,
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
bool *symbol_found_p)
|
|
|
|
|
{
|
|
|
|
|
enum language result = language_unknown;
|
2021-03-21 07:23:40 +08:00
|
|
|
|
*symbol_found_p = false;
|
Introduce method wrappers for quick_symbol_functions
This introduces wrappers for each function in quick_symbol_functions.
The wrappers are methods on objfile, and are defined in
symfile-debug.c, so that they can use the symfile_debug variable.
Places that call the quick functions are all updated to call these new
wrapper methods.
gdb/ChangeLog
2021-03-20 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, expand_symtab_containing_pc)
(lookup_symbol_via_quick_fns, find_quick_global_symbol_language)
(basic_lookup_transparent_type_quick)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, global_symbol_searcher::expand_symtabs):
Update.
* symmisc.c (print_objfile_statistics, dump_objfile)
(maintenance_expand_symtabs): Update.
* symfile.c (symbol_file_add_with_addrs)
(expand_symtabs_matching, map_symbol_filenames): Update.
* symfile-debug.c (objfile::has_partial_symbols)
(objfile::find_last_source_symtab)
(objfile::forget_cached_source_info)
(objfile::map_symtabs_matching_filename, objfile::lookup_symbol)
(objfile::print_stats, objfile::dump)
(objfile::expand_symtabs_for_function)
(objfile::expand_all_symtabs)
(objfile::expand_symtabs_with_fullname)
(objfile::map_matching_symbols)
(objfile::expand_symtabs_matching)
(objfile::find_pc_sect_compunit_symtab)
(objfile::map_symbol_filenames)
(objfile::find_compunit_symtab_by_address)
(objfile::lookup_global_symbol_language): New methods.
(debug_sym_quick_functions): Remove.
(debug_sym_fns, install_symfile_debug_logging): Update.
* source.c (forget_cached_source_info_for_objfile)
(select_source_symtab): Update.
* objfiles.h (struct objfile): Add methods corresponding to
quick_symbol_functions.
* objfiles.c (objfile::has_partial_symbols): Move to
symfile-debug.c.
* linespec.c (iterate_over_all_matching_symtabs): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* ada-lang.c (add_nonlocal_symbols): Update.
2021-03-21 07:23:40 +08:00
|
|
|
|
|
2023-01-02 03:14:21 +08:00
|
|
|
|
for (const auto &iter : qf)
|
2021-03-21 07:23:40 +08:00
|
|
|
|
{
|
|
|
|
|
result = iter->lookup_global_symbol_language (this, name, domain,
|
|
|
|
|
symbol_found_p);
|
|
|
|
|
if (*symbol_found_p)
|
|
|
|
|
break;
|
|
|
|
|
}
|
Handle dereferencing Rust trait objects
In Rust, virtual tables work a bit differently than they do in C++. In
C++, as you know, they are connected to a particular class hierarchy.
Rust, instead, can generate a virtual table for potentially any type --
in fact, one such virtual table for each trait (a trait is similar to an
abstract class or to a Java interface) that a type implements.
Objects that are referenced via a trait can't currently be inspected by
gdb. This patch implements the Rust equivalent of "set print object".
gdb relies heavily on the C++ ABI to decode virtual tables; primarily to
make "set print object" work; but also "info vtbl". However, Rust does
not currently have a specified ABI, so this approach seems unwise to
emulate.
Instead, I've changed the Rust compiler to emit some DWARF that
describes trait objects (previously their internal structure was
opaque), vtables (currently just a size -- but I hope to expand this in
the future), and the concrete type for which a vtable was emitted.
The concrete type is expressed as a DW_AT_containing_type on the
vtable's type. This is a small extension to DWARF.
This patch adds a new entry to quick_symbol_functions to return the
symtab that holds a data address. Previously there was no way in gdb to
look up a full (only minimal) non-text symbol by address. The psymbol
implementation of this method works by lazily filling in a map that is
added to the objfile. This avoids slowing down psymbol reading for a
feature that is likely to not be used too frequently.
I did not update .gdb_index. My thinking here is that the DWARF 5
indices will obsolete .gdb_index soon-ish, meaning that adding a new
feature to them is probably wasted work. If necessary I can update the
DWARF 5 index code when it lands in gdb.
Regression tested on x86-64 Fedora 25.
2017-11-17 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol) <is_rust_vtable>: New member.
(struct rust_vtable_symbol): New.
(find_symbol_at_address): Declare.
* symtab.c (find_symbol_at_address): New function.
* symfile.h (struct quick_symbol_functions)
<find_compunit_symtab_by_address>: New member.
* symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New
function.
(debug_sym_quick_functions): Link to
debug_qf_find_compunit_symtab_by_address.
* rust-lang.c (rust_get_trait_object_pointer): New function.
(rust_evaluate_subexp) <case UNOP_IND>: New case. Call
rust_get_trait_object_pointer.
* psymtab.c (psym_relocate): Clear psymbol_map.
(psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New
functions.
(psym_functions): Link to psym_find_compunit_symtab_by_address.
* objfiles.h (struct objfile) <psymbol_map>: New member.
* dwarf2read.c (dwarf2_gdb_index_functions): Update.
(process_die) <DW_TAG_variable>: New case. Call read_variable.
(rust_containing_type, read_variable): New functions.
2017-11-17 Tom Tromey <tom@tromey.com>
* gdb.rust/traits.rs: New file.
* gdb.rust/traits.exp: New file.
2017-07-06 20:44:38 +08:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-13 23:17:20 +08:00
|
|
|
|
/* Call LOOKUP_FUNC to find the filename of a file containing the separate
|
|
|
|
|
debug information matching OBJFILE. If LOOKUP_FUNC does return a
|
|
|
|
|
filename then open this file and return a std::pair containing the
|
|
|
|
|
gdb_bfd_ref_ptr of the open file and the filename returned by
|
|
|
|
|
LOOKUP_FUNC, otherwise this function returns an empty pair; the first
|
|
|
|
|
item will be nullptr, and the second will be an empty string.
|
|
|
|
|
|
|
|
|
|
Any warnings generated by this function, or by calling LOOKUP_FUNC are
|
|
|
|
|
placed into WARNINGS, these warnings are only displayed to the user if
|
|
|
|
|
GDB is unable to find the separate debug information via any route. */
|
|
|
|
|
static std::pair<gdb_bfd_ref_ptr, std::string>
|
|
|
|
|
simple_find_and_open_separate_symbol_file
|
|
|
|
|
(struct objfile *objfile,
|
|
|
|
|
std::string (*lookup_func) (struct objfile *, deferred_warnings *),
|
|
|
|
|
deferred_warnings *warnings)
|
|
|
|
|
{
|
|
|
|
|
std::string filename = lookup_func (objfile, warnings);
|
|
|
|
|
|
|
|
|
|
if (!filename.empty ())
|
|
|
|
|
{
|
|
|
|
|
gdb_bfd_ref_ptr symfile_bfd
|
|
|
|
|
= symfile_bfd_open_no_error (filename.c_str ());
|
|
|
|
|
if (symfile_bfd != nullptr)
|
|
|
|
|
return { symfile_bfd, filename };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lookup separate debug information for OBJFILE via debuginfod. If
|
|
|
|
|
successful the debug information will be have been downloaded into the
|
|
|
|
|
debuginfod cache and this function will return a std::pair containing a
|
|
|
|
|
gdb_bfd_ref_ptr of the open debug information file and the filename for
|
|
|
|
|
the file within the debuginfod cache. If no debug information could be
|
|
|
|
|
found then this function returns an empty pair; the first item will be
|
|
|
|
|
nullptr, and the second will be an empty string. */
|
|
|
|
|
|
|
|
|
|
static std::pair<gdb_bfd_ref_ptr, std::string>
|
|
|
|
|
debuginfod_find_and_open_separate_symbol_file (struct objfile * objfile)
|
|
|
|
|
{
|
|
|
|
|
const struct bfd_build_id *build_id
|
|
|
|
|
= build_id_bfd_get (objfile->obfd.get ());
|
|
|
|
|
const char *filename = bfd_get_filename (objfile->obfd.get ());
|
|
|
|
|
|
|
|
|
|
if (build_id != nullptr)
|
|
|
|
|
{
|
|
|
|
|
gdb::unique_xmalloc_ptr<char> symfile_path;
|
|
|
|
|
scoped_fd fd (debuginfod_debuginfo_query (build_id->data, build_id->size,
|
|
|
|
|
filename, &symfile_path));
|
|
|
|
|
|
|
|
|
|
if (fd.get () >= 0)
|
|
|
|
|
{
|
|
|
|
|
/* File successfully retrieved from server. */
|
|
|
|
|
gdb_bfd_ref_ptr debug_bfd
|
|
|
|
|
(symfile_bfd_open_no_error (symfile_path.get ()));
|
|
|
|
|
|
|
|
|
|
if (debug_bfd != nullptr
|
|
|
|
|
&& build_id_verify (debug_bfd.get (),
|
|
|
|
|
build_id->size, build_id->data))
|
|
|
|
|
return { debug_bfd, std::string (symfile_path.get ()) };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
gdb: merge debug symbol file lookup code from coffread & elfread paths
This commit merges the code that looks for and loads the separate
debug symbol files from coffread.c and elfread.c. The factored out
code is moved into a new objfile::find_and_add_separate_symbol_file()
method.
For the elfread.c path there should be no user visible changes after
this commit.
For the coffread.c path GDB will now attempt to perform a debuginfod
lookup for the missing debug information, assuming that GDB can find a
build-id in the COFF file.
I don't know if COFF files can include a build-id, but I the existing
coffread.c code already includes a call to
find_separate_debug_file_by_build-id, so I know that it is at least OK
for GDB to ask a COFF file for a build-id. If the COFF file doesn't
include a build-id then the debuginfod lookup code will not trigger
and the new code is harmless.
If the COFF file does include a build-id, then we're going to end up
asking debuginfod for the debug file. As build-ids should be unique,
this should be harmless, even if debuginfod doesn't contain any
suitable debug data, it just costs us one debuginfod lookup, so I'm
not too worried about this for now.
As with the previous commit, I've done some minimal testing using the
mingw toolchain on a Linux machine, GDB seems to still access the
split debug information just fine.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 16:50:33 +08:00
|
|
|
|
/* See objfiles.h. */
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
objfile::find_and_add_separate_symbol_file (symfile_add_flags symfile_flags)
|
|
|
|
|
{
|
gdb: add an extension language hook for missing debug info
This commit adds a new extension_language_ops hook which allows an
extension to handle the case where GDB can't find a separate debug
information file for a particular objfile.
This commit doesn't actually implement the hook for any of GDB's
extension languages, the next commit will do that. This commit just
adds support for the hook to extension-priv.h and extension.[ch], and
then reworks symfile-debug.c to call the hook.
Right now the hook will always return its default value, which means
GDB should do nothing different. As such, there should be no user
visible changes after this commit.
I'll give a brief description of what the hook does here so that we
can understand the changes in symfile-debug.c. The next commit adds a
Python implementation for this new hook, and gives a fuller
description of the new functionality.
Currently, when looking for separate debug information GDB tries three
things, in this order:
1. Use the build-id to find the required debug information,
2. Check for .gnu_debuglink section and use that to look up the
required debug information,
3. Check with debuginfod to see if it can supply the required
information.
The new extension_language_ops::handle_missing_debuginfo hook is
called if all three steps fail to find any debug information. The
hook has three possible return values:
a. Nothing, no debug information is found, GDB continues without the
debug information for this objfile. This matches the current
behaviour of GDB, and is the default if nothing is implementing this
new hook,
b. Install debug information into a location that step #1 or #2
above would normally check, and then request that GDB repeats steps
#1 and #2 in the hope that GDB will now find the debug information.
If the debug information is still not found then GDB carries on
without the debug information. If the debug information is found
the GDB loads it and carries on,
c. Return a filename for a file containing the required debug
information. GDB loads the contents of this file and carries on.
The changes in this commit mostly involve placing the core of
objfile::find_and_add_separate_symbol_file into a loop which allows
for steps #1 and #2 to be repeated.
We take care to ensure that debuginfod is only queried once, the first
time through. The assumption is that no extension is going to be able
to control the replies from debuginfod, so there's no point making a
second request -- and as these requests go over the network, they
could potentially be slow.
The warnings that find_and_add_separate_symbol_file collects are
displayed only once assuming that no debug information is found. If
debug information is found, even after the extension has operated,
then the warnings are not shown; remember, these are warnings from GDB
about failure to find any suitable debug information, so it makes
sense to hide these if debug information is found.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 23:48:36 +08:00
|
|
|
|
bool has_dwarf2 = false;
|
|
|
|
|
|
|
|
|
|
/* Usually we only make a single pass when looking for separate debug
|
|
|
|
|
information. However, it is possible for an extension language hook
|
|
|
|
|
to request that GDB make a second pass, in which case max_attempts
|
|
|
|
|
will be updated, and the loop restarted. */
|
|
|
|
|
for (unsigned attempt = 0, max_attempts = 1;
|
|
|
|
|
attempt < max_attempts && !has_dwarf2;
|
|
|
|
|
++attempt)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (max_attempts <= 2);
|
|
|
|
|
|
|
|
|
|
deferred_warnings warnings;
|
|
|
|
|
gdb_bfd_ref_ptr debug_bfd;
|
|
|
|
|
std::string filename;
|
|
|
|
|
|
|
|
|
|
std::tie (debug_bfd, filename)
|
|
|
|
|
= simple_find_and_open_separate_symbol_file
|
|
|
|
|
(this, find_separate_debug_file_by_buildid, &warnings);
|
|
|
|
|
|
|
|
|
|
if (debug_bfd == nullptr)
|
|
|
|
|
std::tie (debug_bfd, filename)
|
|
|
|
|
= simple_find_and_open_separate_symbol_file
|
|
|
|
|
(this, find_separate_debug_file_by_debuglink, &warnings);
|
|
|
|
|
|
|
|
|
|
/* Only try debuginfod on the first attempt. Sure, we could imagine
|
|
|
|
|
an extension that somehow adds the required debug info to the
|
|
|
|
|
debuginfod server but, at least for now, we don't support this
|
|
|
|
|
scenario. Better for the extension to return new debug info
|
|
|
|
|
directly to GDB. Plus, going to the debuginfod server might be
|
|
|
|
|
slow, so that's a good argument for only doing this once. */
|
|
|
|
|
if (debug_bfd == nullptr && attempt == 0)
|
|
|
|
|
std::tie (debug_bfd, filename)
|
|
|
|
|
= debuginfod_find_and_open_separate_symbol_file (this);
|
|
|
|
|
|
|
|
|
|
if (debug_bfd != nullptr)
|
|
|
|
|
{
|
|
|
|
|
/* We found a separate debug info symbol file. If this is our
|
|
|
|
|
first attempt then setting HAS_DWARF2 will cause us to break
|
|
|
|
|
from the attempt loop. */
|
|
|
|
|
symbol_file_add_separate (debug_bfd, filename.c_str (),
|
|
|
|
|
symfile_flags, this);
|
|
|
|
|
has_dwarf2 = true;
|
|
|
|
|
}
|
|
|
|
|
else if (attempt == 0)
|
|
|
|
|
{
|
|
|
|
|
/* Failed to find a separate debug info symbol file. Call out to
|
|
|
|
|
the extension languages. The user might have registered an
|
|
|
|
|
extension that can find the debug info for us, or maybe give
|
|
|
|
|
the user a system specific message that guides them to finding
|
|
|
|
|
the missing debug info. */
|
|
|
|
|
|
2024-07-31 22:58:20 +08:00
|
|
|
|
ext_lang_missing_file_result ext_result
|
gdb: add an extension language hook for missing debug info
This commit adds a new extension_language_ops hook which allows an
extension to handle the case where GDB can't find a separate debug
information file for a particular objfile.
This commit doesn't actually implement the hook for any of GDB's
extension languages, the next commit will do that. This commit just
adds support for the hook to extension-priv.h and extension.[ch], and
then reworks symfile-debug.c to call the hook.
Right now the hook will always return its default value, which means
GDB should do nothing different. As such, there should be no user
visible changes after this commit.
I'll give a brief description of what the hook does here so that we
can understand the changes in symfile-debug.c. The next commit adds a
Python implementation for this new hook, and gives a fuller
description of the new functionality.
Currently, when looking for separate debug information GDB tries three
things, in this order:
1. Use the build-id to find the required debug information,
2. Check for .gnu_debuglink section and use that to look up the
required debug information,
3. Check with debuginfod to see if it can supply the required
information.
The new extension_language_ops::handle_missing_debuginfo hook is
called if all three steps fail to find any debug information. The
hook has three possible return values:
a. Nothing, no debug information is found, GDB continues without the
debug information for this objfile. This matches the current
behaviour of GDB, and is the default if nothing is implementing this
new hook,
b. Install debug information into a location that step #1 or #2
above would normally check, and then request that GDB repeats steps
#1 and #2 in the hope that GDB will now find the debug information.
If the debug information is still not found then GDB carries on
without the debug information. If the debug information is found
the GDB loads it and carries on,
c. Return a filename for a file containing the required debug
information. GDB loads the contents of this file and carries on.
The changes in this commit mostly involve placing the core of
objfile::find_and_add_separate_symbol_file into a loop which allows
for steps #1 and #2 to be repeated.
We take care to ensure that debuginfod is only queried once, the first
time through. The assumption is that no extension is going to be able
to control the replies from debuginfod, so there's no point making a
second request -- and as these requests go over the network, they
could potentially be slow.
The warnings that find_and_add_separate_symbol_file collects are
displayed only once assuming that no debug information is found. If
debug information is found, even after the extension has operated,
then the warnings are not shown; remember, these are warnings from GDB
about failure to find any suitable debug information, so it makes
sense to hide these if debug information is found.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 23:48:36 +08:00
|
|
|
|
= ext_lang_handle_missing_debuginfo (this);
|
|
|
|
|
if (!ext_result.filename ().empty ())
|
|
|
|
|
{
|
|
|
|
|
/* Extension found a suitable debug file for us. */
|
|
|
|
|
debug_bfd
|
|
|
|
|
= symfile_bfd_open_no_error (ext_result.filename ().c_str ());
|
gdb: merge debug symbol file lookup code from coffread & elfread paths
This commit merges the code that looks for and loads the separate
debug symbol files from coffread.c and elfread.c. The factored out
code is moved into a new objfile::find_and_add_separate_symbol_file()
method.
For the elfread.c path there should be no user visible changes after
this commit.
For the coffread.c path GDB will now attempt to perform a debuginfod
lookup for the missing debug information, assuming that GDB can find a
build-id in the COFF file.
I don't know if COFF files can include a build-id, but I the existing
coffread.c code already includes a call to
find_separate_debug_file_by_build-id, so I know that it is at least OK
for GDB to ask a COFF file for a build-id. If the COFF file doesn't
include a build-id then the debuginfod lookup code will not trigger
and the new code is harmless.
If the COFF file does include a build-id, then we're going to end up
asking debuginfod for the debug file. As build-ids should be unique,
this should be harmless, even if debuginfod doesn't contain any
suitable debug data, it just costs us one debuginfod lookup, so I'm
not too worried about this for now.
As with the previous commit, I've done some minimal testing using the
mingw toolchain on a Linux machine, GDB seems to still access the
split debug information just fine.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 16:50:33 +08:00
|
|
|
|
|
gdb: add an extension language hook for missing debug info
This commit adds a new extension_language_ops hook which allows an
extension to handle the case where GDB can't find a separate debug
information file for a particular objfile.
This commit doesn't actually implement the hook for any of GDB's
extension languages, the next commit will do that. This commit just
adds support for the hook to extension-priv.h and extension.[ch], and
then reworks symfile-debug.c to call the hook.
Right now the hook will always return its default value, which means
GDB should do nothing different. As such, there should be no user
visible changes after this commit.
I'll give a brief description of what the hook does here so that we
can understand the changes in symfile-debug.c. The next commit adds a
Python implementation for this new hook, and gives a fuller
description of the new functionality.
Currently, when looking for separate debug information GDB tries three
things, in this order:
1. Use the build-id to find the required debug information,
2. Check for .gnu_debuglink section and use that to look up the
required debug information,
3. Check with debuginfod to see if it can supply the required
information.
The new extension_language_ops::handle_missing_debuginfo hook is
called if all three steps fail to find any debug information. The
hook has three possible return values:
a. Nothing, no debug information is found, GDB continues without the
debug information for this objfile. This matches the current
behaviour of GDB, and is the default if nothing is implementing this
new hook,
b. Install debug information into a location that step #1 or #2
above would normally check, and then request that GDB repeats steps
#1 and #2 in the hope that GDB will now find the debug information.
If the debug information is still not found then GDB carries on
without the debug information. If the debug information is found
the GDB loads it and carries on,
c. Return a filename for a file containing the required debug
information. GDB loads the contents of this file and carries on.
The changes in this commit mostly involve placing the core of
objfile::find_and_add_separate_symbol_file into a loop which allows
for steps #1 and #2 to be repeated.
We take care to ensure that debuginfod is only queried once, the first
time through. The assumption is that no extension is going to be able
to control the replies from debuginfod, so there's no point making a
second request -- and as these requests go over the network, they
could potentially be slow.
The warnings that find_and_add_separate_symbol_file collects are
displayed only once assuming that no debug information is found. If
debug information is found, even after the extension has operated,
then the warnings are not shown; remember, these are warnings from GDB
about failure to find any suitable debug information, so it makes
sense to hide these if debug information is found.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 23:48:36 +08:00
|
|
|
|
if (debug_bfd != nullptr)
|
|
|
|
|
{
|
|
|
|
|
symbol_file_add_separate (debug_bfd,
|
|
|
|
|
ext_result.filename ().c_str (),
|
|
|
|
|
symfile_flags, this);
|
|
|
|
|
has_dwarf2 = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (ext_result.try_again ())
|
|
|
|
|
{
|
|
|
|
|
max_attempts = 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
gdb: merge debug symbol file lookup code from coffread & elfread paths
This commit merges the code that looks for and loads the separate
debug symbol files from coffread.c and elfread.c. The factored out
code is moved into a new objfile::find_and_add_separate_symbol_file()
method.
For the elfread.c path there should be no user visible changes after
this commit.
For the coffread.c path GDB will now attempt to perform a debuginfod
lookup for the missing debug information, assuming that GDB can find a
build-id in the COFF file.
I don't know if COFF files can include a build-id, but I the existing
coffread.c code already includes a call to
find_separate_debug_file_by_build-id, so I know that it is at least OK
for GDB to ask a COFF file for a build-id. If the COFF file doesn't
include a build-id then the debuginfod lookup code will not trigger
and the new code is harmless.
If the COFF file does include a build-id, then we're going to end up
asking debuginfod for the debug file. As build-ids should be unique,
this should be harmless, even if debuginfod doesn't contain any
suitable debug data, it just costs us one debuginfod lookup, so I'm
not too worried about this for now.
As with the previous commit, I've done some minimal testing using the
mingw toolchain on a Linux machine, GDB seems to still access the
split debug information just fine.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 16:50:33 +08:00
|
|
|
|
|
gdb: add an extension language hook for missing debug info
This commit adds a new extension_language_ops hook which allows an
extension to handle the case where GDB can't find a separate debug
information file for a particular objfile.
This commit doesn't actually implement the hook for any of GDB's
extension languages, the next commit will do that. This commit just
adds support for the hook to extension-priv.h and extension.[ch], and
then reworks symfile-debug.c to call the hook.
Right now the hook will always return its default value, which means
GDB should do nothing different. As such, there should be no user
visible changes after this commit.
I'll give a brief description of what the hook does here so that we
can understand the changes in symfile-debug.c. The next commit adds a
Python implementation for this new hook, and gives a fuller
description of the new functionality.
Currently, when looking for separate debug information GDB tries three
things, in this order:
1. Use the build-id to find the required debug information,
2. Check for .gnu_debuglink section and use that to look up the
required debug information,
3. Check with debuginfod to see if it can supply the required
information.
The new extension_language_ops::handle_missing_debuginfo hook is
called if all three steps fail to find any debug information. The
hook has three possible return values:
a. Nothing, no debug information is found, GDB continues without the
debug information for this objfile. This matches the current
behaviour of GDB, and is the default if nothing is implementing this
new hook,
b. Install debug information into a location that step #1 or #2
above would normally check, and then request that GDB repeats steps
#1 and #2 in the hope that GDB will now find the debug information.
If the debug information is still not found then GDB carries on
without the debug information. If the debug information is found
the GDB loads it and carries on,
c. Return a filename for a file containing the required debug
information. GDB loads the contents of this file and carries on.
The changes in this commit mostly involve placing the core of
objfile::find_and_add_separate_symbol_file into a loop which allows
for steps #1 and #2 to be repeated.
We take care to ensure that debuginfod is only queried once, the first
time through. The assumption is that no extension is going to be able
to control the replies from debuginfod, so there's no point making a
second request -- and as these requests go over the network, they
could potentially be slow.
The warnings that find_and_add_separate_symbol_file collects are
displayed only once assuming that no debug information is found. If
debug information is found, even after the extension has operated,
then the warnings are not shown; remember, these are warnings from GDB
about failure to find any suitable debug information, so it makes
sense to hide these if debug information is found.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 23:48:36 +08:00
|
|
|
|
/* If we still have not got a separate debug symbol file, then
|
|
|
|
|
emit any warnings we've collected so far. */
|
|
|
|
|
if (!has_dwarf2)
|
|
|
|
|
warnings.emit ();
|
gdb: merge debug symbol file lookup code from coffread & elfread paths
This commit merges the code that looks for and loads the separate
debug symbol files from coffread.c and elfread.c. The factored out
code is moved into a new objfile::find_and_add_separate_symbol_file()
method.
For the elfread.c path there should be no user visible changes after
this commit.
For the coffread.c path GDB will now attempt to perform a debuginfod
lookup for the missing debug information, assuming that GDB can find a
build-id in the COFF file.
I don't know if COFF files can include a build-id, but I the existing
coffread.c code already includes a call to
find_separate_debug_file_by_build-id, so I know that it is at least OK
for GDB to ask a COFF file for a build-id. If the COFF file doesn't
include a build-id then the debuginfod lookup code will not trigger
and the new code is harmless.
If the COFF file does include a build-id, then we're going to end up
asking debuginfod for the debug file. As build-ids should be unique,
this should be harmless, even if debuginfod doesn't contain any
suitable debug data, it just costs us one debuginfod lookup, so I'm
not too worried about this for now.
As with the previous commit, I've done some minimal testing using the
mingw toolchain on a Linux machine, GDB seems to still access the
split debug information just fine.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 16:50:33 +08:00
|
|
|
|
}
|
2023-10-13 23:17:20 +08:00
|
|
|
|
|
gdb: add an extension language hook for missing debug info
This commit adds a new extension_language_ops hook which allows an
extension to handle the case where GDB can't find a separate debug
information file for a particular objfile.
This commit doesn't actually implement the hook for any of GDB's
extension languages, the next commit will do that. This commit just
adds support for the hook to extension-priv.h and extension.[ch], and
then reworks symfile-debug.c to call the hook.
Right now the hook will always return its default value, which means
GDB should do nothing different. As such, there should be no user
visible changes after this commit.
I'll give a brief description of what the hook does here so that we
can understand the changes in symfile-debug.c. The next commit adds a
Python implementation for this new hook, and gives a fuller
description of the new functionality.
Currently, when looking for separate debug information GDB tries three
things, in this order:
1. Use the build-id to find the required debug information,
2. Check for .gnu_debuglink section and use that to look up the
required debug information,
3. Check with debuginfod to see if it can supply the required
information.
The new extension_language_ops::handle_missing_debuginfo hook is
called if all three steps fail to find any debug information. The
hook has three possible return values:
a. Nothing, no debug information is found, GDB continues without the
debug information for this objfile. This matches the current
behaviour of GDB, and is the default if nothing is implementing this
new hook,
b. Install debug information into a location that step #1 or #2
above would normally check, and then request that GDB repeats steps
#1 and #2 in the hope that GDB will now find the debug information.
If the debug information is still not found then GDB carries on
without the debug information. If the debug information is found
the GDB loads it and carries on,
c. Return a filename for a file containing the required debug
information. GDB loads the contents of this file and carries on.
The changes in this commit mostly involve placing the core of
objfile::find_and_add_separate_symbol_file into a loop which allows
for steps #1 and #2 to be repeated.
We take care to ensure that debuginfod is only queried once, the first
time through. The assumption is that no extension is going to be able
to control the replies from debuginfod, so there's no point making a
second request -- and as these requests go over the network, they
could potentially be slow.
The warnings that find_and_add_separate_symbol_file collects are
displayed only once assuming that no debug information is found. If
debug information is found, even after the extension has operated,
then the warnings are not shown; remember, these are warnings from GDB
about failure to find any suitable debug information, so it makes
sense to hide these if debug information is found.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 23:48:36 +08:00
|
|
|
|
return has_dwarf2;
|
gdb: merge debug symbol file lookup code from coffread & elfread paths
This commit merges the code that looks for and loads the separate
debug symbol files from coffread.c and elfread.c. The factored out
code is moved into a new objfile::find_and_add_separate_symbol_file()
method.
For the elfread.c path there should be no user visible changes after
this commit.
For the coffread.c path GDB will now attempt to perform a debuginfod
lookup for the missing debug information, assuming that GDB can find a
build-id in the COFF file.
I don't know if COFF files can include a build-id, but I the existing
coffread.c code already includes a call to
find_separate_debug_file_by_build-id, so I know that it is at least OK
for GDB to ask a COFF file for a build-id. If the COFF file doesn't
include a build-id then the debuginfod lookup code will not trigger
and the new code is harmless.
If the COFF file does include a build-id, then we're going to end up
asking debuginfod for the debug file. As build-ids should be unique,
this should be harmless, even if debuginfod doesn't contain any
suitable debug data, it just costs us one debuginfod lookup, so I'm
not too worried about this for now.
As with the previous commit, I've done some minimal testing using the
mingw toolchain on a Linux machine, GDB seems to still access the
split debug information just fine.
Approved-By: Tom Tromey <tom@tromey.com>
2023-10-13 16:50:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
/* Debugging version of struct sym_probe_fns. */
|
|
|
|
|
|
2019-05-01 13:47:54 +08:00
|
|
|
|
static const std::vector<std::unique_ptr<probe>> &
|
2013-09-26 07:17:12 +08:00
|
|
|
|
debug_sym_get_probes (struct objfile *objfile)
|
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2019-05-01 13:47:54 +08:00
|
|
|
|
const std::vector<std::unique_ptr<probe>> &retval
|
2017-09-12 19:37:00 +08:00
|
|
|
|
= debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"probes->sym_get_probes (%s) = %s\n",
|
|
|
|
|
objfile_debug_name (objfile),
|
|
|
|
|
host_address_to_string (retval.data ()));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct sym_probe_fns debug_sym_probe_fns =
|
|
|
|
|
{
|
|
|
|
|
debug_sym_get_probes,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Debugging version of struct sym_fns. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
debug_sym_new_init (struct objfile *objfile)
|
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "sf->sym_new_init (%s)\n",
|
|
|
|
|
objfile_debug_name (objfile));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
debug_data->real_sf->sym_new_init (objfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
debug_sym_init (struct objfile *objfile)
|
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "sf->sym_init (%s)\n",
|
|
|
|
|
objfile_debug_name (objfile));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
debug_data->real_sf->sym_init (objfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
Make symfile_add_flags and objfile->flags strongly typed
This makes these flag types be "enum flag" types. The benefit is
making use of C++'s stronger typing -- mixing the flags types by
mistake errors at compile time.
This caught one old bug in symbol_file_add_main_1 already, fixed by
this patch as well:
@@ -1318,7 +1326,7 @@ symbol_file_add_main_1 (const char *args, int from_tty, int flags)
what is frameless. */
reinit_frame_cache ();
- if ((flags & SYMFILE_NO_READ) == 0)
+ if ((add_flags & SYMFILE_NO_READ) == 0)
set_initial_language ();
}
Above, "flags" are objfile flags, not symfile_add_flags. So that was
actually checking for "flag & OBJF_PSYMTABS_READ", which has the same
value as SYMFILE_NO_READ...
I moved the flags definitions to separate files to break circular
dependencies.
Built with --enable-targets=all and tested on x86-64 Fedora 23.
gdb/ChangeLog:
2016-10-26 Pedro Alves <palves@redhat.com>
* coffread.c (coff_symfile_read): Use symfile_add_flags.
* dbxread.c (dbx_symfile_read): Ditto.
* elfread.c (elf_symfile_read): Ditto.
* inferior.h: Include symfile-add-flags.h.
(struct inferior) <symfile_flags>: Now symfile_add_flags.
* machoread.c (macho_add_oso_symfile, macho_symfile_read_all_oso)
(macho_symfile_read, mipscoff_symfile_read): Use
symfile_add_flags.
* objfile-flags.h: New file.
* objfiles.c (allocate_objfile): Use objfile_flags.
* objfiles.h: Include objfile-flags.h.
(struct objfile) <flags>: Now an objfile_flags.
(OBJF_REORDERED, OBJF_SHARED, OBJF_READNOW, OBJF_USERLOADED)
(OBJF_PSYMTABS_READ, OBJF_MAINLINE, OBJF_NOT_FILENAME): Delete.
Converted to an enum-flags in objfile-flags.h.
(allocate_objfile): Use objfile_flags.
* python/py-objfile.c (objfpy_add_separate_debug_file): Remove
unnecessary local.
* solib.c (solib_read_symbols, solib_add)
(reload_shared_libraries_1): Use symfile_add_flags.
* solib.h: Include "symfile-add-flags.h".
(solib_read_symbols): Use symfile_add_flags.
* symfile-add-flags.h: New file.
* symfile-debug.c (debug_sym_read): Use symfile_add_flags.
* symfile-mem.c (symbol_file_add_from_memory): Use
symfile_add_flags.
* symfile.c (read_symbols, syms_from_objfile_1)
(syms_from_objfile, finish_new_objfile): Use symfile_add_flags.
(symbol_file_add_with_addrs): Use symfile_add_flags and
objfile_flags.
(symbol_file_add_separate): Use symfile_add_flags.
(symbol_file_add_from_bfd, symbol_file_add): Use symfile_add_flags
and objfile_flags.
(symbol_file_add_main_1): : Use objfile_flags. Fix add_flags vs
flags confusion.
(symbol_file_command): Use objfile_flags.
(add_symbol_file_command): Use symfile_add_flags and
objfile_flags.
(clear_symtab_users): Use symfile_add_flags.
* symfile.h: Include "symfile-add-flags.h" and "objfile-flags.h".
(struct sym_fns) <sym_read>: Use symfile_add_flags.
(clear_symtab_users): Use symfile_add_flags.
(enum symfile_add_flags): Delete, moved to symfile-add-flags.h and
converted to enum-flags.
(symbol_file_add, symbol_file_add_from_bfd)
(symbol_file_add_separate): Use symfile_add_flags.
* xcoffread.c (xcoff_initial_scan): Use symfile_add_flags.
2016-10-26 23:47:10 +08:00
|
|
|
|
debug_sym_read (struct objfile *objfile, symfile_add_flags symfile_flags)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "sf->sym_read (%s, 0x%x)\n",
|
|
|
|
|
objfile_debug_name (objfile), (unsigned) symfile_flags);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
debug_data->real_sf->sym_read (objfile, symfile_flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
debug_sym_finish (struct objfile *objfile)
|
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "sf->sym_finish (%s)\n",
|
|
|
|
|
objfile_debug_name (objfile));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
debug_data->real_sf->sym_finish (objfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
debug_sym_offsets (struct objfile *objfile,
|
2018-03-13 11:50:33 +08:00
|
|
|
|
const section_addr_info &info)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "sf->sym_offsets (%s, %s)\n",
|
|
|
|
|
objfile_debug_name (objfile),
|
|
|
|
|
host_address_to_string (&info));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
debug_data->real_sf->sym_offsets (objfile, info);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 00:18:04 +08:00
|
|
|
|
static symfile_segment_data_up
|
2013-09-26 07:17:12 +08:00
|
|
|
|
debug_sym_segments (bfd *abfd)
|
|
|
|
|
{
|
|
|
|
|
/* This API function is annoying, it doesn't take a "this" pointer.
|
|
|
|
|
Fortunately it is only used in one place where we (re-)lookup the
|
|
|
|
|
sym_fns table to use. Thus we will never be called. */
|
|
|
|
|
gdb_assert_not_reached ("debug_sym_segments called");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
debug_sym_read_linetable (struct objfile *objfile)
|
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog, "sf->sym_read_linetable (%s)\n",
|
|
|
|
|
objfile_debug_name (objfile));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
debug_data->real_sf->sym_read_linetable (objfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bfd_byte *
|
|
|
|
|
debug_sym_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf)
|
|
|
|
|
{
|
2015-09-26 02:08:07 +08:00
|
|
|
|
const struct debug_sym_fns_data *debug_data
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
= symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
bfd_byte *retval;
|
|
|
|
|
|
|
|
|
|
retval = debug_data->real_sf->sym_relocate (objfile, sectp, buf);
|
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (gdb_stdlog,
|
|
|
|
|
"sf->sym_relocate (%s, %s, %s) = %s\n",
|
|
|
|
|
objfile_debug_name (objfile),
|
|
|
|
|
host_address_to_string (sectp),
|
|
|
|
|
host_address_to_string (buf),
|
|
|
|
|
host_address_to_string (retval));
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Template of debugging version of struct sym_fns.
|
|
|
|
|
A copy is made, with sym_flavour updated, and a pointer to the real table
|
|
|
|
|
installed in real_sf, and then a pointer to the copy is installed in the
|
|
|
|
|
objfile. */
|
|
|
|
|
|
|
|
|
|
static const struct sym_fns debug_sym_fns =
|
|
|
|
|
{
|
|
|
|
|
debug_sym_new_init,
|
|
|
|
|
debug_sym_init,
|
|
|
|
|
debug_sym_read,
|
|
|
|
|
debug_sym_finish,
|
|
|
|
|
debug_sym_offsets,
|
|
|
|
|
debug_sym_segments,
|
|
|
|
|
debug_sym_read_linetable,
|
|
|
|
|
debug_sym_relocate,
|
|
|
|
|
&debug_sym_probe_fns,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Install the debugging versions of the symfile functions for OBJFILE.
|
|
|
|
|
Do not call this if the debug versions are already installed. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
install_symfile_debug_logging (struct objfile *objfile)
|
|
|
|
|
{
|
|
|
|
|
const struct sym_fns *real_sf;
|
|
|
|
|
struct debug_sym_fns_data *debug_data;
|
|
|
|
|
|
|
|
|
|
/* The debug versions should not already be installed. */
|
|
|
|
|
gdb_assert (!symfile_debug_installed (objfile));
|
|
|
|
|
|
|
|
|
|
real_sf = objfile->sf;
|
|
|
|
|
|
|
|
|
|
/* Alas we have to preserve NULL entries in REAL_SF. */
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
debug_data = new struct debug_sym_fns_data;
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
#define COPY_SF_PTR(from, to, name, func) \
|
|
|
|
|
do { \
|
|
|
|
|
if ((from)->name) \
|
|
|
|
|
(to)->debug_sf.name = func; \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_new_init, debug_sym_new_init);
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_init, debug_sym_init);
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_read, debug_sym_read);
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_finish, debug_sym_finish);
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_offsets, debug_sym_offsets);
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_segments, debug_sym_segments);
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_read_linetable,
|
|
|
|
|
debug_sym_read_linetable);
|
|
|
|
|
COPY_SF_PTR (real_sf, debug_data, sym_relocate, debug_sym_relocate);
|
|
|
|
|
if (real_sf->sym_probe_fns)
|
|
|
|
|
debug_data->debug_sf.sym_probe_fns = &debug_sym_probe_fns;
|
|
|
|
|
|
|
|
|
|
#undef COPY_SF_PTR
|
|
|
|
|
|
|
|
|
|
debug_data->real_sf = real_sf;
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
symfile_debug_objfile_data_key.set (objfile, debug_data);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
objfile->sf = &debug_data->debug_sf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Uninstall the debugging versions of the symfile functions for OBJFILE.
|
|
|
|
|
Do not call this if the debug versions are not installed. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
uninstall_symfile_debug_logging (struct objfile *objfile)
|
|
|
|
|
{
|
|
|
|
|
struct debug_sym_fns_data *debug_data;
|
|
|
|
|
|
|
|
|
|
/* The debug versions should be currently installed. */
|
|
|
|
|
gdb_assert (symfile_debug_installed (objfile));
|
|
|
|
|
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
debug_data = symfile_debug_objfile_data_key.get (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
|
|
|
|
|
objfile->sf = debug_data->real_sf;
|
Convert symfile-debug.c to type-safe registry API
This changes symfile-debug.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
(symfile_debug_objfile_data_key): Change type.
(symfile_debug_installed, debug_qf_has_symbols)
(debug_qf_find_last_source_symtab)
(debug_qf_forget_cached_source_info)
(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
(debug_qf_print_stats, debug_qf_dump)
(debug_qf_expand_symtabs_for_function)
(debug_qf_expand_all_symtabs)
(debug_qf_expand_symtabs_with_fullname)
(debug_qf_map_matching_symbols)
(debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_compunit_symtab)
(debug_qf_map_symbol_filenames)
(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
(debug_sym_new_init, debug_sym_init, debug_sym_read)
(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
(debug_sym_read_linetable, debug_sym_relocate): Update.
(symfile_debug_free_objfile): Remove.
(install_symfile_debug_logging, _initialize_symfile_debug):
Update.
2019-04-22 02:37:59 +08:00
|
|
|
|
symfile_debug_objfile_data_key.clear (objfile);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Call this function to set OBJFILE->SF.
|
|
|
|
|
Do not set OBJFILE->SF directly. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
objfile_set_sym_fns (struct objfile *objfile, const struct sym_fns *sf)
|
|
|
|
|
{
|
|
|
|
|
if (symfile_debug_installed (objfile))
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (debug_symfile);
|
|
|
|
|
/* Remove the current one, and reinstall a new one later. */
|
|
|
|
|
uninstall_symfile_debug_logging (objfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Assume debug logging is disabled. */
|
|
|
|
|
objfile->sf = sf;
|
|
|
|
|
|
|
|
|
|
/* Turn debug logging on if enabled. */
|
|
|
|
|
if (debug_symfile)
|
|
|
|
|
install_symfile_debug_logging (objfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
Constify add_setshow_*
This constifies the add_setshow_* family of functions, and then fixes
up the fallout. The bulk of this patch was written by script.
gdb/ChangeLog
2017-11-07 Tom Tromey <tom@tromey.com>
* ada-lang.c (catch_ada_exception_command): Constify.
(catch_assert_command): Constify.
* break-catch-throw.c (catch_catch_command, catch_throw_command)
(catch_rethrow_command): Constify.
(catch_exception_command_1): Constify.
* breakpoint.h (add_catch_command): Constify.
* break-catch-syscall.c (catch_syscall_command_1): Constify.
(catch_syscall_split_args): Constify.
* break-catch-sig.c (catch_signal_command): Constify.
(catch_signal_split_args): Constify.
* cli/cli-decode.h (struct cmd_list_element) <function>: Use
cmd_const_sfunc_ftype.
* cli/cli-decode.c (add_setshow_cmd_full): Constify.
(add_setshow_enum_cmd, add_setshow_auto_boolean_cmd)
(add_setshow_boolean_cmd, add_setshow_filename_cmd)
(add_setshow_string_cmd, struct cmd_list_element)
(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
(add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd):
Constify.
(set_cmd_sfunc): Constify.
(empty_sfunc): Constify.
* command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd)
(add_setshow_boolean_cmd, add_setshow_filename_cmd)
(add_setshow_string_cmd, add_setshow_string_noescape_cmd)
(add_setshow_optional_filename_cmd, add_setshow_integer_cmd)
(add_setshow_uinteger_cmd, add_setshow_zinteger_cmd)
(add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd):
Constify.
(set_cmd_sfunc): Constify.
(cmd_sfunc_ftype): Remove.
* compile/compile.c (set_compile_args): Constify.
* infrun.c (set_disable_randomization): Constify.
* infcmd.c (set_args_command, set_cwd_command): Constify.
* breakpoint.c (set_condition_evaluation_mode): Constify.
(add_catch_command): Constify.
(catch_fork_command_1, catch_exec_command_1)
(catch_load_command_1, catch_unload_command_1): Constify.
(catch_load_or_unload): Constify.
* guile/scm-param.c (pascm_set_func): Constify.
(add_setshow_generic): Constify.
* python/py-param.c (get_set_value): Constify.
* top.h (set_verbose): Constify.
* tui/tui-win.c (tui_set_var_cmd): Constify.
* mi/mi-main.c (set_mi_async_command): Constify.
* cli/cli-logging.c (set_logging_overwrite)
(set_logging_redirect): Constify.
* value.c (set_max_value_size): Constify.
* valprint.c (set_input_radix, set_output_radix): Constify.
* utils.c (set_width_command, set_height_command): Constify.
* typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify.
* tracepoint.c (set_disconnected_tracing)
(set_circular_trace_buffer, set_trace_buffer_size)
(set_trace_user, set_trace_notes, set_trace_stop_notes): Constify.
* top.c (set_history_size_command, set_verbose, set_editing)
(set_gdb_datadir, set_history_filename): Constify.
* target.c (set_targetdebug, maint_set_target_async_command)
(maint_set_target_non_stop_command, set_target_permissions)
(set_write_memory_permission): Constify.
(open_target): Constify.
* target-descriptions.c (set_tdesc_filename_cmd): Constify.
* target-dcache.c (set_stack_cache, set_code_cache): Constify.
* symtab.c (set_symbol_cache_size_handler): Constify.
* symfile.c (set_ext_lang_command): Constify.
* symfile-debug.c (set_debug_symfile): Constify.
* source.c (set_directories_command): Constify.
* solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify.
* serial.c (set_parity): Constify.
* rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify.
* remote.c (set_remote_exec_file, set_remotebreak)
(set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify.
* record.c (set_record_insn_history_size)
(set_record_call_history_size): Constify.
* record-full.c (set_record_full_insn_max_num): Constify.
* proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify.
* osabi.c (set_osabi): Constify.
* mips-tdep.c (set_mips64_transfers_32bit_regs)
(reinit_frame_cache_sfunc, mips_abi_update): Constify.
* maint.c (maintenance_set_profile_cmd): Constify.
* linux-thread-db.c (set_libthread_db_search_path): Constify.
* language.c (set_language_command, set_range_command)
(set_case_command): Constify.
* infrun.c (set_non_stop, set_observer_mode)
(set_stop_on_solib_events, set_schedlock_func)
(set_exec_direction_func): Constify.
* infcmd.c (set_inferior_tty_command): Constify.
* disasm.c (set_disassembler_options_sfunc): Constify.
* demangle.c (set_demangling_command): Constify.
* dcache.c (set_dcache_size, set_dcache_line_size): Constify.
* cris-tdep.c (set_cris_version, set_cris_mode)
(set_cris_dwarf2_cfi): Constify.
* corefile.c (set_gnutarget_command): Constify.
* charset.c (set_host_charset_sfunc, set_target_charset_sfunc)
(set_target_wide_charset_sfunc): Constify.
* breakpoint.c (update_dprintf_commands): Constify.
* auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify.
* arm-tdep.c (set_fp_model_sfunc, arm_set_abi)
(set_disassembly_style_sfunc): Constify.
* arch-utils.c (set_endian, set_architecture): Constify.
* alpha-tdep.c (reinit_frame_cache_sfunc): Constify.
* agent.c (set_can_use_agent): Constify.
2017-10-14 23:07:00 +08:00
|
|
|
|
set_debug_symfile (const char *args, int from_tty, struct cmd_list_element *c)
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
2020-05-09 04:21:22 +08:00
|
|
|
|
for (struct program_space *pspace : program_spaces)
|
Change all_objfiles adapter to be a method on program_space
This changes the all_objfiles range adapter to be a method on the
program space, and fixes up all the users.
gdb/ChangeLog
2019-01-17 Tom Tromey <tom@tromey.com>
* progspace.h (program_space) <objfiles_range>: New typedef.
<objfiles>: New method.
<objfiles_head>: Rename from objfiles.
(object_files): Update.
* guile/scm-progspace.c (gdbscm_progspace_objfiles): Update.
* guile/scm-pretty-print.c
(ppscm_find_pretty_printer_from_objfiles): Update.
* guile/scm-objfile.c (gdbscm_objfiles): Update.
* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
Update.
* python/py-progspace.c (pspy_get_objfiles): Update.
* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
Update.
* python/py-objfile.c (objfpy_lookup_objfile_by_name)
(objfpy_lookup_objfile_by_build_id): Update.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
Update.
* symtab.c (iterate_over_symtabs, matching_obj_sections)
(expand_symtab_containing_pc, lookup_objfile_from_block)
(lookup_static_symbol, basic_lookup_transparent_type)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, info_sources_command)
(default_collect_symbol_completion_matches_break_on)
(make_source_files_completion_list, find_main_name): Update.
* symmisc.c (print_symbol_bcache_statistics)
(print_objfile_statistics, maintenance_print_symbols)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs)
(maintenance_expand_symtabs, maintenance_info_line_tables):
Update.
* symfile.c (remove_symbol_file_command, overlay_invalidate_all)
(find_pc_overlay, find_pc_mapped_section, list_overlays_command)
(map_overlay_command, unmap_overlay_command)
(simple_overlay_update, expand_symtabs_matching)
(map_symbol_filenames): Update.
* symfile-debug.c (set_debug_symfile): Update.
* spu-tdep.c (spu_overlay_update, spu_objfile_from_frame):
Update.
* source.c (select_source_symtab, forget_cached_source_info):
Update.
* solib.c (solib_read_symbols): Update.
* solib-spu.c (append_ocl_sos): Update.
* psymtab.c (maintenance_print_psymbols)
(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
* probe.c (parse_probes_in_pspace, find_probe_by_pc): Update.
* printcmd.c (info_symbol_command): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created):
Update.
* objfiles.h (class all_objfiles): Remove.
* objfiles.c (have_partial_symbols, have_full_symbols)
(have_minimal_symbols, qsort_cmp, update_section_map)
(shared_objfile_contains_address_p)
(default_iterate_over_objfiles_in_search_order): Update.
* objc-lang.c (info_selectors_command, info_classes_command)
(find_methods): Update.
* minsyms.c (find_solib_trampoline_target): Update.
* maint.c (maintenance_info_sections)
(maintenance_translate_address, count_symtabs_and_blocks):
Update.
* main.c (captured_main_1): Update.
* linux-thread-db.c (try_thread_db_load_from_pdir)
(has_libpthread): Update.
* linespec.c (iterate_over_all_matching_symtabs)
(search_minsyms_for_name): Update.
* jit.c (jit_find_objf_with_entry_addr): Update.
* hppa-tdep.c (find_unwind_entry)
(hppa_lookup_stub_minimal_symbol): Update.
* gcore.c (gcore_create_callback, objfile_find_memory_regions):
Update.
* elfread.c (elf_gnu_ifunc_resolve_by_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* dwarf2-frame.c (dwarf2_frame_find_fde): Update.
* dwarf-index-write.c (save_gdb_index_command): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* blockframe.c (find_pc_partial_function): Update.
* ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols)
(ada_collect_symbol_completion_matches)
(ada_add_global_exceptions): Update.
2019-01-16 07:55:05 +08:00
|
|
|
|
for (objfile *objfile : pspace->objfiles ())
|
2018-11-24 02:58:27 +08:00
|
|
|
|
{
|
|
|
|
|
if (debug_symfile)
|
|
|
|
|
{
|
|
|
|
|
if (!symfile_debug_installed (objfile))
|
|
|
|
|
install_symfile_debug_logging (objfile);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (symfile_debug_installed (objfile))
|
|
|
|
|
uninstall_symfile_debug_logging (objfile);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
show_debug_symfile (struct ui_file *file, int from_tty,
|
|
|
|
|
struct cmd_list_element *c, const char *value)
|
|
|
|
|
{
|
2022-01-03 02:46:15 +08:00
|
|
|
|
gdb_printf (file, _("Symfile debugging is %s.\n"), value);
|
2013-09-26 07:17:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-14 03:01:38 +08:00
|
|
|
|
void _initialize_symfile_debug ();
|
2013-09-26 07:17:12 +08:00
|
|
|
|
void
|
2020-01-14 03:01:38 +08:00
|
|
|
|
_initialize_symfile_debug ()
|
2013-09-26 07:17:12 +08:00
|
|
|
|
{
|
|
|
|
|
add_setshow_boolean_cmd ("symfile", no_class, &debug_symfile, _("\
|
|
|
|
|
Set debugging of the symfile functions."), _("\
|
|
|
|
|
Show debugging of the symfile functions."), _("\
|
|
|
|
|
When enabled, all calls to the symfile functions are logged."),
|
|
|
|
|
set_debug_symfile, show_debug_symfile,
|
|
|
|
|
&setdebuglist, &showdebuglist);
|
|
|
|
|
|
|
|
|
|
/* Note: We don't need a new-objfile observer because debug logging
|
|
|
|
|
will be installed when objfile init'n calls objfile_set_sym_fns. */
|
|
|
|
|
}
|