From c9d95fa3d034ae614e33b631e0bc019015c444e9 Mon Sep 17 00:00:00 2001 From: Christian Biesinger Date: Fri, 22 Nov 2019 12:05:14 -0600 Subject: [PATCH] Replace the MSYMBOL_*_NAME macros with member functions Improves readability. In the future, it will also allow making the name private, once the name setter functions become member functions. gdb/ChangeLog: 2019-11-22 Christian Biesinger * ada-lang.c (ada_lookup_simple_minsym): Update. (ada_collect_symbol_completion_matches): Update. * ada-tasks.c (read_atcb): Update. * amd64-windows-tdep.c (amd64_skip_main_prologue): Update. (amd64_windows_skip_trampoline_code): Update. * arm-tdep.c (skip_prologue_function): Update. (arm_skip_stack_protector): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. (arm_wince_skip_main_prologue): Update. * ax-gdb.c (gen_expr): Update. * block.c (call_site_for_pc): Update. * blockframe.c (find_pc_partial_function): Update. * breakpoint.c (set_breakpoint_location_function): Update. * btrace.c (ftrace_print_function_name): Update. (ftrace_function_switched): Update. * c-valprint.c (print_unpacked_pointer): Update. * coffread.c (coff_symfile_read): Update. * compile/compile-c-symbols.c (convert_symbol_bmsym): Update. * compile/compile-cplus-symbols.c (convert_symbol_bmsym): Update. * dwarf-index-write.c (write_psymbols): Update. * dwarf2loc.c (call_site_to_target_addr): Update. (func_verify_no_selftailcall): Update. (tailcall_dump): Update. (call_site_find_chain_1): Update. (dwarf_expr_reg_to_entry_parameter): Update. * elfread.c (elf_gnu_ifunc_record_cache): Update. * eval.c (evaluate_funcall): Update. (evaluate_subexp_standard): Update. (evaluate_subexp_for_sizeof): Update. * expprint.c (print_subexp_standard): Update. (dump_subexp_body_standard): Update. * frame.c (get_prev_frame_always_1): Update. * frv-tdep.c (frv_skip_main_prologue): Update. * gnu-v2-abi.c (gnuv2_value_rtti_type): Update. * gnu-v3-abi.c (gnuv3_rtti_type): Update. (gnuv3_get_typename_from_type_info): Update. (gnuv3_skip_trampoline): Update. * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update. * i386-tdep.c (i386_skip_main_prologue): Update. (i386_pe_skip_trampoline_code): Update. * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update. * infcall.c (get_function_name): Update. * linespec.c (minsym_found): Update. * linux-fork.c (info_checkpoints_command): Update. * m32c-tdep.c (m32c_m16c_address_to_pointer): Update. (m32c_m16c_pointer_to_address): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (add_minsym_to_hash_table): Update. (add_minsym_to_demangled_hash_table): Update. (lookup_minimal_symbol_mangled): Update. (lookup_minimal_symbol_demangled): Update. (lookup_minimal_symbol_linkage): Update. (lookup_minimal_symbol_text): Update. (lookup_minimal_symbol_by_pc_name): Update. (minimal_symbol_is_less_than): Update. (compact_minimal_symbols): Update. (build_minimal_symbol_hash_tables): Update. (find_solib_trampoline_target): Update. * mips-tdep.c (mips_stub_frame_sniffer): Update. (mips_skip_pic_trampoline_code): Update. * msp430-tdep.c (msp430_skip_trampoline_code): Update. * objc-lang.c (info_selectors_command): Update. (info_classes_command): Update. (find_methods): Update. (find_imps): Update. * p-valprint.c (pascal_val_print): Update. * ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic): Update. (info_symbol_command): Update. * psymtab.c (psymbol_name_matches): Update. (match_partial_symbol): Update. (lookup_partial_symbol): Update. (print_partial_symbols): Update. (sort_pst_symbols): Update. (maintenance_check_psymtabs): Update. * python/py-framefilter.c (py_print_frame): Update. * python/python.c (gdbpy_rbreak): Update. * record-btrace.c (btrace_get_bfun_name): Update. (btrace_call_history): Update. * rs6000-tdep.c (rs6000_skip_main_prologue): Update. (rs6000_skip_trampoline_code): Update. * sol-thread.c (info_cb): Update. * stabsread.c (scan_file_globals): Update. * stack.c (find_frame_funname): Update. (info_frame_command_core): Update. * symmisc.c (dump_msymbols): Update. * symtab.c (symbol_natural_name): Rename to.., (general_symbol_info::natural_name): ...this. (symbol_demangled_name): Rename to... (general_symbol_info::demangled_name): ...this. (symbol_search_name): Rename to... (general_symbol_info::search_name): ...this. (symbol_matches_search_name): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (search_symbols): Update. (print_msymbol_info): Update. (rbreak_command): Update. (completion_list_add_msymbol): Update. (completion_list_objc_symbol): Update. (get_msymbol_address): Update. * symtab.h (struct general_symbol_info): Add member functions natural_name (), linkage_name (), print_name (), demangled_name (), and search_name (). (SYMBOL_NATURAL_NAME): Update. (symbol_natural_name): Move to a member function on general_symbol_info. (SYMBOL_DEMANGLED_NAME): Update. (symbol_demangled_name): Move to a member function on general_symbol_info. (SYMBOL_SEARCH_NAME): Update. (symbol_search_name): Move to a member function on general_symbol_info. (MSYMBOL_NATURAL_NAME): Remove. (MSYMBOL_LINKAGE_NAME): Remove. (MSYMBOL_PRINT_NAME): Remove. (MSYMBOL_DEMANGLED_NAME): Remove. (MSYMBOL_SEARCH_NAME): Remove. * x86-tdep.c (x86_in_indirect_branch_thunk): Update. Change-Id: I65aa529843a9903e174ce799037e41f954a9fcee --- gdb/ChangeLog | 121 ++++++++++++++++++++++++++++ gdb/ada-lang.c | 4 +- gdb/ada-tasks.c | 2 +- gdb/amd64-windows-tdep.c | 6 +- gdb/arm-tdep.c | 6 +- gdb/arm-wince-tdep.c | 6 +- gdb/ax-gdb.c | 2 +- gdb/block.c | 2 +- gdb/blockframe.c | 2 +- gdb/breakpoint.c | 2 +- gdb/btrace.c | 4 +- gdb/c-valprint.c | 5 +- gdb/coffread.c | 2 +- gdb/compile/compile-c-symbols.c | 2 +- gdb/compile/compile-cplus-symbols.c | 2 +- gdb/dwarf-index-write.c | 4 +- gdb/dwarf2loc.c | 24 +++--- gdb/elfread.c | 2 +- gdb/eval.c | 6 +- gdb/expprint.c | 4 +- gdb/frame.c | 2 +- gdb/frv-tdep.c | 4 +- gdb/gnu-v2-abi.c | 2 +- gdb/gnu-v3-abi.c | 8 +- gdb/hppa-tdep.c | 2 +- gdb/i386-tdep.c | 6 +- gdb/ia64-tdep.c | 2 +- gdb/infcall.c | 2 +- gdb/linespec.c | 4 +- gdb/linux-fork.c | 2 +- gdb/m32c-tdep.c | 4 +- gdb/maint.c | 2 +- gdb/minsyms.c | 32 ++++---- gdb/mips-tdep.c | 8 +- gdb/msp430-tdep.c | 2 +- gdb/objc-lang.c | 14 ++-- gdb/p-valprint.c | 5 +- gdb/ppc-linux-tdep.c | 5 +- gdb/ppc-sysv-tdep.c | 4 +- gdb/printcmd.c | 6 +- gdb/psymtab.c | 20 ++--- gdb/python/py-framefilter.c | 2 +- gdb/python/python.c | 2 +- gdb/record-btrace.c | 4 +- gdb/rs6000-tdep.c | 8 +- gdb/sol-thread.c | 4 +- gdb/stabsread.c | 4 +- gdb/stack.c | 4 +- gdb/symmisc.c | 6 +- gdb/symtab.c | 68 +++++++--------- gdb/symtab.h | 73 +++++++++-------- gdb/x86-tdep.c | 2 +- 52 files changed, 320 insertions(+), 201 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 838262eba3e..f4878447ac3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,124 @@ +2019-11-22 Christian Biesinger + + * ada-lang.c (ada_lookup_simple_minsym): Update. + (ada_collect_symbol_completion_matches): Update. + * ada-tasks.c (read_atcb): Update. + * amd64-windows-tdep.c (amd64_skip_main_prologue): Update. + (amd64_windows_skip_trampoline_code): Update. + * arm-tdep.c (skip_prologue_function): Update. + (arm_skip_stack_protector): Update. + * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. + (arm_wince_skip_main_prologue): Update. + * ax-gdb.c (gen_expr): Update. + * block.c (call_site_for_pc): Update. + * blockframe.c (find_pc_partial_function): Update. + * breakpoint.c (set_breakpoint_location_function): Update. + * btrace.c (ftrace_print_function_name): Update. + (ftrace_function_switched): Update. + * c-valprint.c (print_unpacked_pointer): Update. + * coffread.c (coff_symfile_read): Update. + * compile/compile-c-symbols.c (convert_symbol_bmsym): Update. + * compile/compile-cplus-symbols.c (convert_symbol_bmsym): Update. + * dwarf-index-write.c (write_psymbols): Update. + * dwarf2loc.c (call_site_to_target_addr): Update. + (func_verify_no_selftailcall): Update. + (tailcall_dump): Update. + (call_site_find_chain_1): Update. + (dwarf_expr_reg_to_entry_parameter): Update. + * elfread.c (elf_gnu_ifunc_record_cache): Update. + * eval.c (evaluate_funcall): Update. + (evaluate_subexp_standard): Update. + (evaluate_subexp_for_sizeof): Update. + * expprint.c (print_subexp_standard): Update. + (dump_subexp_body_standard): Update. + * frame.c (get_prev_frame_always_1): Update. + * frv-tdep.c (frv_skip_main_prologue): Update. + * gnu-v2-abi.c (gnuv2_value_rtti_type): Update. + * gnu-v3-abi.c (gnuv3_rtti_type): Update. + (gnuv3_get_typename_from_type_info): Update. + (gnuv3_skip_trampoline): Update. + * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update. + * i386-tdep.c (i386_skip_main_prologue): Update. + (i386_pe_skip_trampoline_code): Update. + * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update. + * infcall.c (get_function_name): Update. + * linespec.c (minsym_found): Update. + * linux-fork.c (info_checkpoints_command): Update. + * m32c-tdep.c (m32c_m16c_address_to_pointer): Update. + (m32c_m16c_pointer_to_address): Update. + * maint.c (maintenance_translate_address): Update. + * minsyms.c (add_minsym_to_hash_table): Update. + (add_minsym_to_demangled_hash_table): Update. + (lookup_minimal_symbol_mangled): Update. + (lookup_minimal_symbol_demangled): Update. + (lookup_minimal_symbol_linkage): Update. + (lookup_minimal_symbol_text): Update. + (lookup_minimal_symbol_by_pc_name): Update. + (minimal_symbol_is_less_than): Update. + (compact_minimal_symbols): Update. + (build_minimal_symbol_hash_tables): Update. + (find_solib_trampoline_target): Update. + * mips-tdep.c (mips_stub_frame_sniffer): Update. + (mips_skip_pic_trampoline_code): Update. + * msp430-tdep.c (msp430_skip_trampoline_code): Update. + * objc-lang.c (info_selectors_command): Update. + (info_classes_command): Update. + (find_methods): Update. + (find_imps): Update. + * p-valprint.c (pascal_val_print): Update. + * ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code): Update. + * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. + * printcmd.c (build_address_symbolic): Update. + (info_symbol_command): Update. + * psymtab.c (psymbol_name_matches): Update. + (match_partial_symbol): Update. + (lookup_partial_symbol): Update. + (print_partial_symbols): Update. + (sort_pst_symbols): Update. + (maintenance_check_psymtabs): Update. + * python/py-framefilter.c (py_print_frame): Update. + * python/python.c (gdbpy_rbreak): Update. + * record-btrace.c (btrace_get_bfun_name): Update. + (btrace_call_history): Update. + * rs6000-tdep.c (rs6000_skip_main_prologue): Update. + (rs6000_skip_trampoline_code): Update. + * sol-thread.c (info_cb): Update. + * stabsread.c (scan_file_globals): Update. + * stack.c (find_frame_funname): Update. + (info_frame_command_core): Update. + * symmisc.c (dump_msymbols): Update. + * symtab.c (symbol_natural_name): Rename to.., + (general_symbol_info::natural_name): ...this. + (symbol_demangled_name): Rename to... + (general_symbol_info::demangled_name): ...this. + (symbol_search_name): Rename to... + (general_symbol_info::search_name): ...this. + (symbol_matches_search_name): Update. + (find_pc_sect_line): Update. + (skip_prologue_sal): Update. + (search_symbols): Update. + (print_msymbol_info): Update. + (rbreak_command): Update. + (completion_list_add_msymbol): Update. + (completion_list_objc_symbol): Update. + (get_msymbol_address): Update. + * symtab.h (struct general_symbol_info): Add member functions + natural_name (), linkage_name (), print_name (), demangled_name (), + and search_name (). + (SYMBOL_NATURAL_NAME): Update. + (symbol_natural_name): Move to a member function on general_symbol_info. + (SYMBOL_DEMANGLED_NAME): Update. + (symbol_demangled_name): Move to a member function on + general_symbol_info. + (SYMBOL_SEARCH_NAME): Update. + (symbol_search_name): Move to a member function on general_symbol_info. + (MSYMBOL_NATURAL_NAME): Remove. + (MSYMBOL_LINKAGE_NAME): Remove. + (MSYMBOL_PRINT_NAME): Remove. + (MSYMBOL_DEMANGLED_NAME): Remove. + (MSYMBOL_SEARCH_NAME): Remove. + * x86-tdep.c (x86_in_indirect_branch_thunk): Update. + 2019-11-22 Christian Biesinger * symtab.c (create_demangled_names_hash): Use per_bfd-> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 36001ef3235..723ac36659c 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4946,7 +4946,7 @@ ada_lookup_simple_minsym (const char *name) { for (minimal_symbol *msymbol : objfile->msymbols ()) { - if (match_name (MSYMBOL_LINKAGE_NAME (msymbol), lookup_name, NULL) + if (match_name (msymbol->linkage_name (), lookup_name, NULL) && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) { result.minsym = msymbol; @@ -6449,7 +6449,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker, completion_list_add_name (tracker, symbol_language, - MSYMBOL_LINKAGE_NAME (msymbol), + msymbol->linkage_name (), lookup_name, text, word); } } diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index e5504e9bd3d..110a710a5ff 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -669,7 +669,7 @@ read_atcb (CORE_ADDR task_id, struct ada_task_info *task_info) msym = lookup_minimal_symbol_by_pc (task_id); if (msym.minsym) { - const char *full_name = MSYMBOL_LINKAGE_NAME (msym.minsym); + const char *full_name = msym.minsym->linkage_name (); const char *task_name = full_name; const char *p; diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 61ac2a5c3ef..71a5e570187 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -358,8 +358,8 @@ amd64_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) call_dest = pc + 5 + extract_signed_integer (buf, 4, byte_order); s = lookup_minimal_symbol_by_pc (call_dest); if (s.minsym != NULL - && MSYMBOL_LINKAGE_NAME (s.minsym) != NULL - && strcmp (MSYMBOL_LINKAGE_NAME (s.minsym), "__main") == 0) + && s.minsym->linkage_name () != NULL + && strcmp (s.minsym->linkage_name (), "__main") == 0) pc += 5; } } @@ -1187,7 +1187,7 @@ amd64_windows_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) = (indirect_addr ? lookup_minimal_symbol_by_pc (indirect_addr).minsym : NULL); - const char *symname = indsym ? MSYMBOL_LINKAGE_NAME (indsym) : NULL; + const char *symname = indsym ? indsym->linkage_name () : NULL; if (symname) { diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 3cf3abb9fa6..69c87c5a432 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -550,9 +550,9 @@ skip_prologue_function (struct gdbarch *gdbarch, CORE_ADDR pc, int is_thumb) msym = lookup_minimal_symbol_by_pc (pc); if (msym.minsym != NULL && BMSYMBOL_VALUE_ADDRESS (msym) == pc - && MSYMBOL_LINKAGE_NAME (msym.minsym) != NULL) + && msym.minsym->linkage_name () != NULL) { - const char *name = MSYMBOL_LINKAGE_NAME (msym.minsym); + const char *name = msym.minsym->linkage_name (); /* The GNU linker's Thumb call stub to foo is named __foo_from_thumb. */ @@ -1254,7 +1254,7 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) /* ADDR must correspond to a symbol whose name is __stack_chk_guard. Otherwise, this sequence cannot be for stack protector. */ if (stack_chk_guard.minsym == NULL - || !startswith (MSYMBOL_LINKAGE_NAME (stack_chk_guard.minsym), "__stack_chk_guard")) + || !startswith (stack_chk_guard.minsym->linkage_name (), "__stack_chk_guard")) return pc; if (is_thumb) diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c index 584eef9fedc..916c56dab20 100644 --- a/gdb/arm-wince-tdep.c +++ b/gdb/arm-wince-tdep.c @@ -66,7 +66,7 @@ arm_pe_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) if (indsym.minsym == NULL) return 0; - symname = MSYMBOL_LINKAGE_NAME (indsym.minsym); + symname = indsym.minsym->linkage_name (); if (symname == NULL || !startswith (symname, "__imp_")) return 0; @@ -104,8 +104,8 @@ arm_wince_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) struct bound_minimal_symbol s = lookup_minimal_symbol_by_pc (call_dest); if (s.minsym != NULL - && MSYMBOL_LINKAGE_NAME (s.minsym) != NULL - && strcmp (MSYMBOL_LINKAGE_NAME (s.minsym), "__gccmain") == 0) + && s.minsym->linkage_name () != NULL + && strcmp (s.minsym->linkage_name (), "__gccmain") == 0) pc += 4; } diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index ecbb2fe17a1..23a4120e165 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -2020,7 +2020,7 @@ gen_expr (struct expression *exp, union exp_element **pc, gen_msym_var_ref (ax, value, (*pc)[2].msymbol, (*pc)[1].objfile); if (TYPE_CODE (value->type) == TYPE_CODE_ERROR) - error_unknown_type (MSYMBOL_PRINT_NAME ((*pc)[2].msymbol)); + error_unknown_type ((*pc)[2].msymbol->linkage_name ()); (*pc) += 4; break; diff --git a/gdb/block.c b/gdb/block.c index 40cd3f4b48e..a4592e36e65 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -242,7 +242,7 @@ call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc) "DW_TAG_call_site %s in %s"), paddress (gdbarch, pc), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym))); + : msym.minsym->print_name ())); } return (struct call_site *) *slot; diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 4306b5409ad..fd835174df2 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -337,7 +337,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, } cache_pc_function_low = BMSYMBOL_VALUE_ADDRESS (msymbol); - cache_pc_function_name = MSYMBOL_LINKAGE_NAME (msymbol.minsym); + cache_pc_function_name = msymbol.minsym->linkage_name (); cache_pc_function_section = section; cache_pc_function_high = minimal_symbol_upper_bound (msymbol); cache_pc_function_block = nullptr; diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c9587ffe95a..e90a1c0fbe8 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7085,7 +7085,7 @@ set_breakpoint_location_function (struct bp_location *loc) { struct breakpoint *b = loc->owner; - function_name = MSYMBOL_LINKAGE_NAME (loc->msymbol); + function_name = loc->msymbol->linkage_name (); if (b->type == bp_breakpoint && b->loc == loc && loc->next == NULL && b->related_breakpoint == b) diff --git a/gdb/btrace.c b/gdb/btrace.c index cf0a4e747fd..9422c2b7158 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -85,7 +85,7 @@ ftrace_print_function_name (const struct btrace_function *bfun) return SYMBOL_PRINT_NAME (sym); if (msym != NULL) - return MSYMBOL_PRINT_NAME (msym); + return msym->print_name (); return ""; } @@ -197,7 +197,7 @@ ftrace_function_switched (const struct btrace_function *bfun, /* If the minimal symbol changed, we certainly switched functions. */ if (mfun != NULL && msym != NULL - && strcmp (MSYMBOL_LINKAGE_NAME (mfun), MSYMBOL_LINKAGE_NAME (msym)) != 0) + && strcmp (mfun->linkage_name (), msym->linkage_name ()) != 0) return 1; /* If the symbol changed, we certainly switched functions. */ diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 58675f6d9df..607fb80c58f 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -187,7 +187,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype, if (want_space) fputs_filtered (" ", stream); fputs_filtered (" <", stream); - fputs_filtered (MSYMBOL_PRINT_NAME (msymbol.minsym), stream); + fputs_filtered (msymbol.minsym->print_name (), stream); fputs_filtered (">", stream); want_space = 1; } @@ -203,8 +203,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype, if (msymbol.minsym != NULL) { - const char *search_name - = MSYMBOL_SEARCH_NAME (msymbol.minsym); + const char *search_name = msymbol.minsym->search_name (); wsym = lookup_symbol_search_name (search_name, NULL, VAR_DOMAIN).symbol; } diff --git a/gdb/coffread.c b/gdb/coffread.c index 2ec48d60d56..8564be1faa2 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -640,7 +640,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) { for (minimal_symbol *msym : objfile->msymbols ()) { - const char *name = MSYMBOL_LINKAGE_NAME (msym); + const char *name = msym->linkage_name (); /* If the minimal symbols whose name are prefixed by "__imp_" or "_imp_", get rid of the prefix, and search the minimal diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index 9545caac1e3..abd0aeabab7 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -308,7 +308,7 @@ convert_symbol_bmsym (compile_c_instance *context, } sym_type = context->convert_type (type); - decl = context->plugin ().build_decl (MSYMBOL_NATURAL_NAME (msym), + decl = context->plugin ().build_decl (msym->natural_name (), kind, sym_type, NULL, addr, NULL, 0); context->plugin ().bind (decl, 1 /* is_global */); diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c index 10ee8566b15..1acd07d316a 100644 --- a/gdb/compile/compile-cplus-symbols.c +++ b/gdb/compile/compile-cplus-symbols.c @@ -323,7 +323,7 @@ convert_symbol_bmsym (compile_cplus_instance *instance, sym_type = instance->convert_type (type); instance->plugin ().push_namespace (""); instance->plugin ().build_decl - ("minsym", MSYMBOL_NATURAL_NAME (msym), kind, sym_type, nullptr, addr, + ("minsym", msym->natural_name (), kind, sym_type, nullptr, addr, nullptr, 0); instance->plugin ().pop_binding_level (""); } diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c index 48f385efb00..7e89de43309 100644 --- a/gdb/dwarf-index-write.c +++ b/gdb/dwarf-index-write.c @@ -550,7 +550,7 @@ write_psymbols (struct mapped_symtab *symtab, { gdb_index_symbol_kind kind = symbol_kind (psym); - add_index_entry (symtab, symbol_search_name (&psym->ginfo), + add_index_entry (symtab, psym->ginfo.search_name (), is_static, kind, cu_index); } } @@ -686,7 +686,7 @@ public: const int dwarf_tag = psymbol_tag (psym); if (dwarf_tag == 0) return; - const char *name = symbol_search_name (&psym->ginfo); + const char *name = psym->ginfo.search_name (); if (psym->ginfo.language == language_ada) { diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index e25ee6680b4..1ac56b273ad 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -800,7 +800,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, _("DW_AT_call_target is not specified at %s in %s"), paddress (call_site_gdbarch, call_site->pc), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym))); + : msym.minsym->print_name ())); } if (caller_frame == NULL) @@ -814,7 +814,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, "available at %s in %s"), paddress (call_site_gdbarch, call_site->pc), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym))); + : msym.minsym->print_name ())); } caller_arch = get_frame_arch (caller_frame); @@ -846,7 +846,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, "at %s in %s"), physname, paddress (call_site_gdbarch, call_site->pc), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym))); + : msym.minsym->print_name ())); } return BMSYMBOL_VALUE_ADDRESS (msym); @@ -934,7 +934,7 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr) "function \"%s\" at %s can call itself via tail " "calls"), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym)), + : msym.minsym->print_name ()), paddress (gdbarch, verify_addr)); } @@ -955,7 +955,7 @@ tailcall_dump (struct gdbarch *gdbarch, const struct call_site *call_site) fprintf_unfiltered (gdb_stdlog, " %s(%s)", paddress (gdbarch, addr), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym))); + : msym.minsym->print_name ())); } @@ -1173,10 +1173,10 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, "callers or callees between caller function \"%s\" at %s " "and callee function \"%s\" at %s"), (msym_caller.minsym == NULL - ? "???" : MSYMBOL_PRINT_NAME (msym_caller.minsym)), + ? "???" : msym_caller.minsym->print_name ()), paddress (gdbarch, caller_pc), (msym_callee.minsym == NULL - ? "???" : MSYMBOL_PRINT_NAME (msym_callee.minsym)), + ? "???" : msym_callee.minsym->print_name ()), paddress (gdbarch, callee_pc)); } @@ -1276,7 +1276,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, gdbarch_bfd_arch_info (gdbarch)->printable_name, paddress (gdbarch, func_addr), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym)), + : msym.minsym->print_name ()), gdbarch_bfd_arch_info (caller_gdbarch)->printable_name); } @@ -1289,7 +1289,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, "requires caller of %s (%s)"), paddress (gdbarch, func_addr), (msym.minsym == NULL ? "???" - : MSYMBOL_PRINT_NAME (msym.minsym))); + : msym.minsym->print_name ())); } caller_pc = get_frame_pc (caller_frame); call_site = call_site_for_pc (gdbarch, caller_pc); @@ -1305,9 +1305,9 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, _("DW_OP_entry_value resolving expects callee %s at %s " "but the called frame is for %s at %s"), (target_msym == NULL ? "???" - : MSYMBOL_PRINT_NAME (target_msym)), + : target_msym->print_name ()), paddress (gdbarch, target_addr), - func_msym == NULL ? "???" : MSYMBOL_PRINT_NAME (func_msym), + func_msym == NULL ? "???" : func_msym->print_name (), paddress (gdbarch, func_addr)); } @@ -1331,7 +1331,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, throw_error (NO_ENTRY_VALUE_ERROR, _("Cannot find matching parameter " "at DW_TAG_call_site %s at %s"), paddress (gdbarch, caller_pc), - msym == NULL ? "???" : MSYMBOL_PRINT_NAME (msym)); + msym == NULL ? "???" : msym->print_name ()); } *per_cu_return = call_site->per_cu; diff --git a/gdb/elfread.c b/gdb/elfread.c index 226e3f09d38..44b793d8f14 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -714,7 +714,7 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr) /* If .plt jumps back to .plt the symbol is still deferred for later resolution and it has no use for GDB. */ - const char *target_name = MSYMBOL_LINKAGE_NAME (msym.minsym); + const char *target_name = msym.minsym->linkage_name (); size_t len = strlen (target_name); /* Note we check the symbol's name instead of checking whether the diff --git a/gdb/eval.c b/gdb/eval.c index 71e79d623a3..6dca8be93cc 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1044,7 +1044,7 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, if (op == OP_VAR_MSYM_VALUE) { minimal_symbol *msym = exp->elts[*pos + 2].msymbol; - var_func_name = MSYMBOL_PRINT_NAME (msym); + var_func_name = msym->print_name (); } else if (op == OP_VAR_VALUE) { @@ -1323,7 +1323,7 @@ evaluate_subexp_standard (struct type *expect_type, type = value_type (val); if (TYPE_CODE (type) == TYPE_CODE_ERROR && (noside != EVAL_AVOID_SIDE_EFFECTS || pc != 0)) - error_unknown_type (MSYMBOL_PRINT_NAME (msymbol)); + error_unknown_type (msymbol->print_name ()); return val; } @@ -3218,7 +3218,7 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos, type = value_type (mval); if (TYPE_CODE (type) == TYPE_CODE_ERROR) - error_unknown_type (MSYMBOL_PRINT_NAME (msymbol)); + error_unknown_type (msymbol->print_name ()); return value_from_longest (size_type, TYPE_LENGTH (type)); } diff --git a/gdb/expprint.c b/gdb/expprint.c index c98638ab7fe..70b9eb5bf66 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -138,7 +138,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_VAR_MSYM_VALUE: { (*pos) += 3; - fputs_filtered (MSYMBOL_PRINT_NAME (exp->elts[pc + 2].msymbol), stream); + fputs_filtered (exp->elts[pc + 2].msymbol->print_name (), stream); } return; @@ -908,7 +908,7 @@ dump_subexp_body_standard (struct expression *exp, fprintf_filtered (stream, ", msymbol @"); gdb_print_host_address (exp->elts[elt + 1].msymbol, stream); fprintf_filtered (stream, " (%s)", - MSYMBOL_PRINT_NAME (exp->elts[elt + 1].msymbol)); + exp->elts[elt + 1].msymbol->print_name ()); elt += 3; break; case OP_VAR_ENTRY_VALUE: diff --git a/gdb/frame.c b/gdb/frame.c index 3ebdc99e9ff..660f8cfa00e 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -2043,7 +2043,7 @@ get_prev_frame_always_1 (struct frame_info *this_frame) this_pc_in_block = get_frame_address_in_block (this_frame); morestack_msym = lookup_minimal_symbol_by_pc (this_pc_in_block).minsym; if (morestack_msym) - morestack_name = MSYMBOL_LINKAGE_NAME (morestack_msym); + morestack_name = morestack_msym->linkage_name (); if (!morestack_name || strcmp (morestack_name, "__morestack") != 0) { if (frame_debug) diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 76354042fd0..a80c0437cb6 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1074,8 +1074,8 @@ frv_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) s = lookup_minimal_symbol_by_pc (call_dest); if (s.minsym != NULL - && MSYMBOL_LINKAGE_NAME (s.minsym) != NULL - && strcmp (MSYMBOL_LINKAGE_NAME (s.minsym), "__main") == 0) + && s.minsym->linkage_name () != NULL + && strcmp (s.minsym->linkage_name (), "__main") == 0) { pc += 4; return pc; diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 30405684dd8..000f82579bd 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -243,7 +243,7 @@ gnuv2_value_rtti_type (struct value *v, int *full, LONGEST *top, int *using_enc) /* Try to find a symbol that is the vtable. */ minsym=lookup_minimal_symbol_by_pc(vtbl); if (minsym.minsym==NULL - || (linkage_name=MSYMBOL_LINKAGE_NAME (minsym.minsym))==NULL + || (linkage_name=minsym.minsym->linkage_name ())==NULL || !is_vtable_name (linkage_name)) return NULL; diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 2a5486c8a10..d630ec07b11 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -328,7 +328,7 @@ gnuv3_rtti_type (struct value *value, If we didn't like this approach, we could instead look in the type_info object itself to get the class name. But this way should work just as well, and doesn't read target memory. */ - vtable_symbol_name = MSYMBOL_DEMANGLED_NAME (vtable_symbol); + vtable_symbol_name = vtable_symbol->demangled_name (); if (vtable_symbol_name == NULL || !startswith (vtable_symbol_name, "vtable for ")) { @@ -1148,11 +1148,11 @@ gnuv3_get_typename_from_type_info (struct value *type_info_ptr) #define TYPEINFO_PREFIX "typeinfo for " #define TYPEINFO_PREFIX_LEN (sizeof (TYPEINFO_PREFIX) - 1) - symname = MSYMBOL_DEMANGLED_NAME (typeinfo_sym.minsym); + symname = typeinfo_sym.minsym->demangled_name (); if (symname == NULL || strncmp (symname, TYPEINFO_PREFIX, TYPEINFO_PREFIX_LEN)) error (_("typeinfo symbol '%s' has unexpected name"), - MSYMBOL_LINKAGE_NAME (typeinfo_sym.minsym)); + typeinfo_sym.minsym->linkage_name ()); class_name = symname + TYPEINFO_PREFIX_LEN; /* Strip off @plt and version suffixes. */ @@ -1202,7 +1202,7 @@ gnuv3_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc) /* The symbol's demangled name should be something like "virtual thunk to FUNCTION", where FUNCTION is the name of the function being thunked to. */ - thunk_name = MSYMBOL_DEMANGLED_NAME (thunk_sym.minsym); + thunk_name = thunk_sym.minsym->demangled_name (); if (thunk_name == NULL || strstr (thunk_name, " thunk to ") == NULL) return 0; diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index ae1554af0a9..8e4168dbdd9 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -2537,7 +2537,7 @@ hppa_lookup_stub_minimal_symbol (const char *name, { for (minimal_symbol *msym : objfile->msymbols ()) { - if (strcmp (MSYMBOL_LINKAGE_NAME (msym), name) == 0) + if (strcmp (msym->linkage_name (), name) == 0) { struct unwind_table_entry *u; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 52d286a8d73..5445dd11b96 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1948,8 +1948,8 @@ i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) call_dest = call_dest & 0xffffffffU; s = lookup_minimal_symbol_by_pc (call_dest); if (s.minsym != NULL - && MSYMBOL_LINKAGE_NAME (s.minsym) != NULL - && strcmp (MSYMBOL_LINKAGE_NAME (s.minsym), "__main") == 0) + && s.minsym->linkage_name () != NULL + && strcmp (s.minsym->linkage_name (), "__main") == 0) pc += 5; } } @@ -3933,7 +3933,7 @@ i386_pe_skip_trampoline_code (struct frame_info *frame, read_memory_unsigned_integer (pc + 2, 4, byte_order); struct minimal_symbol *indsym = indirect ? lookup_minimal_symbol_by_pc (indirect).minsym : 0; - const char *symname = indsym ? MSYMBOL_LINKAGE_NAME (indsym) : 0; + const char *symname = indsym ? indsym->linkage_name () : 0; if (symname) { diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index ceaf69eae56..f8b75bf6c8e 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -3615,7 +3615,7 @@ ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, minsym = lookup_minimal_symbol_by_pc (addr); if (minsym.minsym - && is_vtable_name (MSYMBOL_LINKAGE_NAME (minsym.minsym))) + && is_vtable_name (minsym.minsym->linkage_name ())) return read_memory_unsigned_integer (addr, 8, byte_order); } diff --git a/gdb/infcall.c b/gdb/infcall.c index 9fc30acd2d8..7ea2e2ee542 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -395,7 +395,7 @@ get_function_name (CORE_ADDR funaddr, char *buf, int buf_size) struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (funaddr); if (msymbol.minsym) - return MSYMBOL_PRINT_NAME (msymbol.minsym); + return msymbol.minsym->print_name (); } { diff --git a/gdb/linespec.c b/gdb/linespec.c index 9b7a8c9715b..817d1a42ef8 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -4221,7 +4221,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, if (is_function) { - const char *msym_name = MSYMBOL_LINKAGE_NAME (msymbol); + const char *msym_name = msymbol->linkage_name (); if (MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc || MSYMBOL_TYPE (msymbol) == mst_data_gnu_ifunc) @@ -4250,7 +4250,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile, sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol); if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc)) - add_sal_to_sals (self, result, &sal, MSYMBOL_NATURAL_NAME (msymbol), 0); + add_sal_to_sals (self, result, &sal, msymbol->natural_name (), 0); } /* A helper function to classify a minimal_symbol_type according to diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 87cfacc8e8a..8373093b13b 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -597,7 +597,7 @@ info_checkpoints_command (const char *arg, int from_tty) msym = lookup_minimal_symbol_by_pc (pc); if (msym.minsym) - printf_filtered (", <%s>", MSYMBOL_LINKAGE_NAME (msym.minsym)); + printf_filtered (", <%s>", msym.minsym->linkage_name ()); } putchar_filtered ('\n'); diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index 657c6b7930f..4e4e7c35be3 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -2418,7 +2418,7 @@ m32c_m16c_address_to_pointer (struct gdbarch *gdbarch, "couldn't find a symbol at that address, to find trampoline."), paddress (gdbarch, addr)); - func_name = MSYMBOL_LINKAGE_NAME (func_msym.minsym); + func_name = func_msym.minsym->linkage_name (); tramp_name = (char *) xmalloc (strlen (func_name) + 5); strcpy (tramp_name, func_name); strcat (tramp_name, ".plt"); @@ -2492,7 +2492,7 @@ m32c_m16c_pointer_to_address (struct gdbarch *gdbarch, if (ptr_msym.minsym) { - const char *ptr_msym_name = MSYMBOL_LINKAGE_NAME (ptr_msym.minsym); + const char *ptr_msym_name = ptr_msym.minsym->linkage_name (); int len = strlen (ptr_msym_name); if (len > 4 diff --git a/gdb/maint.c b/gdb/maint.c index a253584a150..ce59ef6cca4 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -569,7 +569,7 @@ maintenance_translate_address (const char *arg, int from_tty) if (sym.minsym) { - const char *symbol_name = MSYMBOL_PRINT_NAME (sym.minsym); + const char *symbol_name = sym.minsym->print_name (); const char *symbol_offset = pulongest (address - BMSYMBOL_VALUE_ADDRESS (sym)); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 78cb15b5677..a9ba66bef0a 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -141,7 +141,7 @@ add_minsym_to_hash_table (struct minimal_symbol *sym, if (sym->hash_next == NULL) { unsigned int hash - = msymbol_hash (MSYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE; + = msymbol_hash (sym->linkage_name ()) % MINIMAL_SYMBOL_HASH_SIZE; sym->hash_next = table[hash]; table[hash] = sym; @@ -157,7 +157,7 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, if (sym->demangled_hash_next == NULL) { unsigned int hash = search_name_hash (MSYMBOL_LANGUAGE (sym), - MSYMBOL_SEARCH_NAME (sym)); + sym->search_name ()); objfile->per_bfd->demangled_hash_languages.set (MSYMBOL_LANGUAGE (sym)); @@ -252,7 +252,7 @@ lookup_minimal_symbol_mangled (const char *lookup_name, msymbol != NULL; msymbol = msymbol->hash_next) { - const char *symbol_name = MSYMBOL_LINKAGE_NAME (msymbol); + const char *symbol_name = msymbol->linkage_name (); if (namecmp (symbol_name, lookup_name) == 0 && found.maybe_collect (sfile, objfile, msymbol)) @@ -276,7 +276,7 @@ lookup_minimal_symbol_demangled (const lookup_name_info &lookup_name, msymbol != NULL; msymbol = msymbol->demangled_hash_next) { - const char *symbol_name = MSYMBOL_SEARCH_NAME (msymbol); + const char *symbol_name = msymbol->search_name (); if (matcher (symbol_name, lookup_name, NULL) && found.maybe_collect (sfile, objfile, msymbol)) @@ -487,7 +487,7 @@ iterate_over_minimal_symbols iter != NULL; iter = iter->hash_next) { - if (mangled_cmp (MSYMBOL_LINKAGE_NAME (iter), name) == 0) + if (mangled_cmp (iter->linkage_name (), name) == 0) if (callback (iter)) return; } @@ -511,7 +511,7 @@ iterate_over_minimal_symbols for (minimal_symbol *iter = objf->per_bfd->msymbol_demangled_hash[hash]; iter != NULL; iter = iter->demangled_hash_next) - if (name_match (MSYMBOL_SEARCH_NAME (iter), lookup_name, NULL)) + if (name_match (iter->search_name (), lookup_name, NULL)) if (callback (iter)) return; } @@ -530,7 +530,7 @@ lookup_minimal_symbol_linkage (const char *name, struct objfile *objf) msymbol != NULL; msymbol = msymbol->hash_next) { - if (strcmp (MSYMBOL_LINKAGE_NAME (msymbol), name) == 0 + if (strcmp (msymbol->linkage_name (), name) == 0 && (MSYMBOL_TYPE (msymbol) == mst_data || MSYMBOL_TYPE (msymbol) == mst_bss)) return {msymbol, objfile}; @@ -563,7 +563,7 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf) msymbol != NULL && found_symbol.minsym == NULL; msymbol = msymbol->hash_next) { - if (strcmp (MSYMBOL_LINKAGE_NAME (msymbol), name) == 0 && + if (strcmp (msymbol->linkage_name (), name) == 0 && (MSYMBOL_TYPE (msymbol) == mst_text || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc || MSYMBOL_TYPE (msymbol) == mst_file_text)) @@ -611,7 +611,7 @@ lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name, msymbol = msymbol->hash_next) { if (MSYMBOL_VALUE_ADDRESS (objfile, msymbol) == pc - && strcmp (MSYMBOL_LINKAGE_NAME (msymbol), name) == 0) + && strcmp (msymbol->linkage_name (), name) == 0) return msymbol; } } @@ -1164,8 +1164,8 @@ minimal_symbol_is_less_than (const minimal_symbol &fn1, else /* addrs are equal: sort by name */ { - const char *name1 = MSYMBOL_LINKAGE_NAME (&fn1); - const char *name2 = MSYMBOL_LINKAGE_NAME (&fn2); + const char *name1 = fn1.linkage_name (); + const char *name2 = fn2.linkage_name (); if (name1 && name2) /* both have names */ return strcmp (name1, name2) < 0; @@ -1220,8 +1220,8 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount, if (MSYMBOL_VALUE_RAW_ADDRESS (copyfrom) == MSYMBOL_VALUE_RAW_ADDRESS ((copyfrom + 1)) && MSYMBOL_SECTION (copyfrom) == MSYMBOL_SECTION (copyfrom + 1) - && strcmp (MSYMBOL_LINKAGE_NAME (copyfrom), - MSYMBOL_LINKAGE_NAME ((copyfrom + 1))) == 0) + && strcmp (copyfrom->linkage_name (), + (copyfrom + 1)->linkage_name ()) == 0) { if (MSYMBOL_TYPE ((copyfrom + 1)) == mst_unknown) { @@ -1268,7 +1268,7 @@ build_minimal_symbol_hash_tables (struct objfile *objfile) add_minsym_to_hash_table (msym, objfile->per_bfd->msymbol_hash); msym->demangled_hash_next = 0; - if (MSYMBOL_SEARCH_NAME (msym) != MSYMBOL_LINKAGE_NAME (msym)) + if (msym->search_name () != msym->linkage_name ()) add_minsym_to_demangled_hash_table (msym, objfile); } } @@ -1402,8 +1402,8 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc) || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc || MSYMBOL_TYPE (msymbol) == mst_data || MSYMBOL_TYPE (msymbol) == mst_data_gnu_ifunc) - && strcmp (MSYMBOL_LINKAGE_NAME (msymbol), - MSYMBOL_LINKAGE_NAME (tsymbol)) == 0) + && strcmp (msymbol->linkage_name (), + tsymbol->linkage_name ()) == 0) { CORE_ADDR func; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 6870db82024..0852851595f 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -3821,8 +3821,8 @@ mips_stub_frame_sniffer (const struct frame_unwind *self, stub. The stub for foo is named ".pic.foo". */ msym = lookup_minimal_symbol_by_pc (pc); if (msym.minsym != NULL - && MSYMBOL_LINKAGE_NAME (msym.minsym) != NULL - && startswith (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.")) + && msym.minsym->linkage_name () != NULL + && startswith (msym.minsym->linkage_name (), ".pic.")) return 1; return 0; @@ -7818,8 +7818,8 @@ mips_skip_pic_trampoline_code (struct frame_info *frame, CORE_ADDR pc) msym = lookup_minimal_symbol_by_pc (pc); if (msym.minsym == NULL || BMSYMBOL_VALUE_ADDRESS (msym) != pc - || MSYMBOL_LINKAGE_NAME (msym.minsym) == NULL - || !startswith (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.")) + || msym.minsym->linkage_name () == NULL + || !startswith (msym.minsym->linkage_name (), ".pic.")) return 0; /* A two-instruction header. */ diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index 0e55eab22fe..947a669f28f 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -808,7 +808,7 @@ msp430_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) if (!bms.minsym) return pc; - stub_name = MSYMBOL_LINKAGE_NAME (bms.minsym); + stub_name = bms.minsym->linkage_name (); if (gdbarch_tdep (gdbarch)->code_model == MSP_SMALL_CODE_MODEL && msp430_in_return_stub (gdbarch, pc, stub_name)) diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 946a0a1faed..bd0626411d0 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -610,7 +610,7 @@ info_selectors_command (const char *regexp, int from_tty) for (minimal_symbol *msymbol : objfile->msymbols ()) { QUIT; - name = MSYMBOL_NATURAL_NAME (msymbol); + name = msymbol->natural_name (); if (name && (name[0] == '-' || name[0] == '+') && name[1] == '[') /* Got a method name. */ @@ -623,7 +623,7 @@ info_selectors_command (const char *regexp, int from_tty) if (name == NULL) { complaint (_("Bad method name '%s'"), - MSYMBOL_NATURAL_NAME (msymbol)); + msymbol->natural_name ()); continue; } if (regexp == NULL || re_exec(++name) != 0) @@ -650,7 +650,7 @@ info_selectors_command (const char *regexp, int from_tty) for (minimal_symbol *msymbol : objfile->msymbols ()) { QUIT; - name = MSYMBOL_NATURAL_NAME (msymbol); + name = msymbol->natural_name (); if (name && (name[0] == '-' || name[0] == '+') && name[1] == '[') /* Got a method name. */ @@ -764,7 +764,7 @@ info_classes_command (const char *regexp, int from_tty) for (minimal_symbol *msymbol : objfile->msymbols ()) { QUIT; - name = MSYMBOL_NATURAL_NAME (msymbol); + name = msymbol->natural_name (); if (name && (name[0] == '-' || name[0] == '+') && name[1] == '[') /* Got a method name. */ @@ -791,7 +791,7 @@ info_classes_command (const char *regexp, int from_tty) for (minimal_symbol *msymbol : objfile->msymbols ()) { QUIT; - name = MSYMBOL_NATURAL_NAME (msymbol); + name = msymbol->natural_name (); if (name && (name[0] == '-' || name[0] == '+') && name[1] == '[') /* Got a method name. */ @@ -1014,7 +1014,7 @@ find_methods (char type, const char *theclass, const char *category, /* Check the symbol name first as this can be done entirely without sending any query to the target. */ - symname = MSYMBOL_NATURAL_NAME (msymbol); + symname = msymbol->natural_name (); if (symname == NULL) continue; @@ -1152,7 +1152,7 @@ find_imps (const char *method, std::vector *symbol_names) = lookup_minimal_symbol (selector, 0, 0); if (msym.minsym != NULL) - symbol_names->push_back (MSYMBOL_NATURAL_NAME (msym.minsym)); + symbol_names->push_back (msym.minsym->natural_name ()); } } diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index c465d1455b4..e1e1a00cae1 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -240,7 +240,7 @@ pascal_val_print (struct type *type, if (want_space) fputs_filtered (" ", stream); fputs_filtered ("<", stream); - fputs_filtered (MSYMBOL_PRINT_NAME (msymbol.minsym), stream); + fputs_filtered (msymbol.minsym->print_name (), stream); fputs_filtered (">", stream); want_space = 1; } @@ -255,8 +255,7 @@ pascal_val_print (struct type *type, if (msymbol.minsym != NULL) { - const char *search_name - = MSYMBOL_SEARCH_NAME (msymbol.minsym); + const char *search_name = msymbol.minsym->search_name (); wsym = lookup_symbol_search_name (search_name, NULL, VAR_DOMAIN).symbol; } diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index fd88a8918c6..ecfaee391f6 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -312,9 +312,8 @@ powerpc_linux_in_dynsym_resolve_code (CORE_ADDR pc) /* Check if we are in the resolver. */ sym = lookup_minimal_symbol_by_pc (pc); if (sym.minsym != NULL - && (strcmp (MSYMBOL_LINKAGE_NAME (sym.minsym), "__glink") == 0 - || strcmp (MSYMBOL_LINKAGE_NAME (sym.minsym), - "__glink_PLTresolve") == 0)) + && (strcmp (sym.minsym->linkage_name (), "__glink") == 0 + || strcmp (sym.minsym->linkage_name (), "__glink_PLTresolve") == 0)) return 1; return 0; diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 2a732d09259..fb8c9e2fe01 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -1043,7 +1043,7 @@ convert_code_addr_to_desc_addr (CORE_ADDR code_addr, CORE_ADDR *desc_addr) /* Find the minimal symbol that corresponds to CODE_ADDR (should have a name of the form ".FN"). */ dot_fn = lookup_minimal_symbol_by_pc (code_addr); - if (dot_fn.minsym == NULL || MSYMBOL_LINKAGE_NAME (dot_fn.minsym)[0] != '.') + if (dot_fn.minsym == NULL || dot_fn.minsym->linkage_name ()[0] != '.') return 0; /* Get the section that contains CODE_ADDR. Need this for the "objfile" that it contains. */ @@ -1054,7 +1054,7 @@ convert_code_addr_to_desc_addr (CORE_ADDR code_addr, CORE_ADDR *desc_addr) address. Only look for the minimal symbol in ".FN"'s object file - avoids problems when two object files (i.e., shared libraries) contain a minimal symbol with the same name. */ - fn = lookup_minimal_symbol (MSYMBOL_LINKAGE_NAME (dot_fn.minsym) + 1, NULL, + fn = lookup_minimal_symbol (dot_fn.minsym->linkage_name () + 1, NULL, dot_fn_section->objfile); if (fn.minsym == NULL) return 0; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 0251d465bd9..bf61d590381 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -671,9 +671,9 @@ build_address_symbolic (struct gdbarch *gdbarch, symbol = 0; name_location = BMSYMBOL_VALUE_ADDRESS (msymbol); if (do_demangle || asm_demangle) - name_temp = MSYMBOL_PRINT_NAME (msymbol.minsym); + name_temp = msymbol.minsym->print_name (); else - name_temp = MSYMBOL_LINKAGE_NAME (msymbol.minsym); + name_temp = msymbol.minsym->linkage_name (); } } if (symbol == NULL && msymbol.minsym == NULL) @@ -1349,7 +1349,7 @@ info_symbol_command (const char *arg, int from_tty) offset = sect_addr - MSYMBOL_VALUE_ADDRESS (objfile, msymbol); mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped"); sec_name = osect->the_bfd_section->name; - msym_name = MSYMBOL_PRINT_NAME (msymbol); + msym_name = msymbol->print_name (); /* Don't print the offset if it is zero. We assume there's no need to handle i18n of "sym + offset". */ diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 67e3e36aa9e..c3155007bbd 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -534,7 +534,7 @@ psymbol_name_matches (partial_symbol *psym, const language_defn *lang = language_def (psym->ginfo.language); symbol_name_matcher_ftype *name_match = get_symbol_name_matcher (lang, lookup_name); - return name_match (symbol_search_name (&psym->ginfo), lookup_name, NULL); + return name_match (psym->ginfo.search_name (), lookup_name, NULL); } /* Look in PST for a symbol in DOMAIN whose name matches NAME. Search @@ -585,7 +585,7 @@ match_partial_symbol (struct objfile *objfile, const char *lang_ln = name.language_lookup_name (lang).c_str (); - if (ordered_compare (symbol_search_name (&(*center)->ginfo), + if (ordered_compare ((*center)->ginfo.search_name (), lang_ln) >= 0) top = center; else @@ -693,7 +693,7 @@ lookup_partial_symbol (struct objfile *objfile, if (!(center < top)) internal_error (__FILE__, __LINE__, _("failed internal consistency check")); - if (strcmp_iw_ordered (symbol_search_name (&(*center)->ginfo), + if (strcmp_iw_ordered ((*center)->ginfo.search_name (), search_name.get ()) >= 0) { top = center; @@ -836,10 +836,10 @@ print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile, { QUIT; fprintf_filtered (outfile, " `%s'", (*p)->ginfo.name); - if (symbol_demangled_name (&(*p)->ginfo) != NULL) + if ((*p)->ginfo.demangled_name () != NULL) { fprintf_filtered (outfile, " `%s'", - symbol_demangled_name (&(*p)->ginfo)); + (*p)->ginfo.demangled_name ()); } fputs_filtered (", ", outfile); switch ((*p)->domain) @@ -1283,7 +1283,7 @@ recursively_search_psymtabs && (*psym)->aclass == LOC_TYPEDEF)) && psymbol_name_matches (*psym, lookup_name) && (sym_matcher == NULL - || sym_matcher (symbol_search_name (&(*psym)->ginfo)))) + || sym_matcher ((*psym)->ginfo.search_name ()))) { /* Found a match, so notify our caller. */ result = PST_SEARCHED_AND_FOUND; @@ -1478,8 +1478,8 @@ sort_pst_symbols (struct objfile *objfile, struct partial_symtab *pst) std::sort (begin, end, [] (partial_symbol *s1, partial_symbol *s2) { - return strcmp_iw_ordered (symbol_search_name (&s1->ginfo), - symbol_search_name (&s2->ginfo)) < 0; + return strcmp_iw_ordered (s1->ginfo.search_name (), + s2->ginfo.search_name ()) < 0; }); } @@ -2106,7 +2106,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) length = ps->n_static_syms; while (length--) { - sym = block_lookup_symbol (b, symbol_search_name (&(*psym)->ginfo), + sym = block_lookup_symbol (b, (*psym)->ginfo.search_name (), symbol_name_match_type::SEARCH_NAME, (*psym)->domain); if (!sym) @@ -2124,7 +2124,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty) length = ps->n_global_syms; while (length--) { - sym = block_lookup_symbol (b, symbol_search_name (&(*psym)->ginfo), + sym = block_lookup_symbol (b, (*psym)->ginfo.search_name (), symbol_name_match_type::SEARCH_NAME, (*psym)->domain); if (!sym) diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index 4dd6243ae99..3ef5b6a488d 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -934,7 +934,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, msymbol = lookup_minimal_symbol_by_pc (addr); if (msymbol.minsym != NULL) - function = MSYMBOL_PRINT_NAME (msymbol.minsym); + function = msymbol.minsym->print_name (); } else if (py_func != Py_None) { diff --git a/gdb/python/python.c b/gdb/python/python.c index f94214e1b24..609e1fbf0a7 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -794,7 +794,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw) symbol_name += SYMBOL_LINKAGE_NAME (p.symbol); } else - symbol_name = MSYMBOL_LINKAGE_NAME (p.msymbol.minsym); + symbol_name = p.msymbol.minsym->linkage_name (); gdbpy_ref<> argList (Py_BuildValue("(s)", symbol_name.c_str ())); gdbpy_ref<> obj (PyObject_CallObject ((PyObject *) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 3fd4007fd65..04bd09ae9ce 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1117,7 +1117,7 @@ btrace_get_bfun_name (const struct btrace_function *bfun) if (sym != NULL) return SYMBOL_PRINT_NAME (sym); else if (msym != NULL) - return MSYMBOL_PRINT_NAME (msym); + return msym->print_name (); else return "??"; } @@ -1178,7 +1178,7 @@ btrace_call_history (struct ui_out *uiout, uiout->field_string ("function", SYMBOL_PRINT_NAME (sym), function_name_style.style ()); else if (msym != NULL) - uiout->field_string ("function", MSYMBOL_PRINT_NAME (msym), + uiout->field_string ("function", msym->print_name (), function_name_style.style ()); else if (!uiout->is_mi_like_p ()) uiout->field_string ("function", "??", diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 9c4df4a61d6..07a186011cb 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2119,9 +2119,9 @@ rs6000_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) to __eabi in case the GCC option "-fleading-underscore" was used to compile the program. */ if (s.minsym != NULL - && MSYMBOL_LINKAGE_NAME (s.minsym) != NULL - && (strcmp (MSYMBOL_LINKAGE_NAME (s.minsym), "__eabi") == 0 - || strcmp (MSYMBOL_LINKAGE_NAME (s.minsym), "___eabi") == 0)) + && s.minsym->linkage_name () != NULL + && (strcmp (s.minsym->linkage_name (), "__eabi") == 0 + || strcmp (s.minsym->linkage_name (), "___eabi") == 0)) pc += 4; } return pc; @@ -2205,7 +2205,7 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) msymbol = lookup_minimal_symbol_by_pc (pc); if (msymbol.minsym && rs6000_in_solib_return_trampoline (gdbarch, pc, - MSYMBOL_LINKAGE_NAME (msymbol.minsym))) + msymbol.minsym->linkage_name ())) { /* Double-check that the third instruction from PC is relative "b". */ op = read_memory_integer (pc + 8, 4, byte_order); diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 6b4cf205228..e9ca1c577ae 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -1109,7 +1109,7 @@ info_cb (const td_thrhandle_t *th, void *s) printf_filtered (" startfunc=%s", msym.minsym - ? MSYMBOL_PRINT_NAME (msym.minsym) + ? msym.minsym->print_name () : paddress (target_gdbarch (), ti.ti_startfunc)); } @@ -1121,7 +1121,7 @@ info_cb (const td_thrhandle_t *th, void *s) printf_filtered (" sleepfunc=%s", msym.minsym - ? MSYMBOL_PRINT_NAME (msym.minsym) + ? msym.minsym->print_name () : paddress (target_gdbarch (), ti.ti_pc)); } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index ef4aa47345c..0fde12080fe 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -4610,11 +4610,11 @@ scan_file_globals (struct objfile *objfile) /* Get the hash index and check all the symbols under that hash index. */ - hash = hashname (MSYMBOL_LINKAGE_NAME (msymbol)); + hash = hashname (msymbol->linkage_name ()); for (sym = global_sym_chain[hash]; sym;) { - if (strcmp (MSYMBOL_LINKAGE_NAME (msymbol), + if (strcmp (msymbol->linkage_name (), SYMBOL_LINKAGE_NAME (sym)) == 0) { /* Splice this symbol out of the hash chain and diff --git a/gdb/stack.c b/gdb/stack.c index b02f1779337..0568e704f48 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1290,7 +1290,7 @@ find_frame_funname (struct frame_info *frame, enum language *funlang, msymbol = lookup_minimal_symbol_by_pc (pc); if (msymbol.minsym != NULL) { - funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym))); + funname.reset (xstrdup (msymbol.minsym->print_name ())); *funlang = MSYMBOL_LANGUAGE (msymbol.minsym); } } @@ -1516,7 +1516,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p) msymbol = lookup_minimal_symbol_by_pc (frame_pc); if (msymbol.minsym != NULL) { - funname = MSYMBOL_PRINT_NAME (msymbol.minsym); + funname = msymbol.minsym->print_name (); funlang = MSYMBOL_LANGUAGE (msymbol.minsym); } } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 24ee255f6b6..bf48435bff2 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -243,7 +243,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) + ANOFFSET (objfile->section_offsets, msymbol->section)); fputs_filtered (paddress (gdbarch, addr), outfile); - fprintf_filtered (outfile, " %s", MSYMBOL_LINKAGE_NAME (msymbol)); + fprintf_filtered (outfile, " %s", msymbol->linkage_name ()); if (section) { if (section->the_bfd_section != NULL) @@ -253,9 +253,9 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) fprintf_filtered (outfile, " spurious section %ld", (long) (section - objfile->sections)); } - if (MSYMBOL_DEMANGLED_NAME (msymbol) != NULL) + if (msymbol->demangled_name () != NULL) { - fprintf_filtered (outfile, " %s", MSYMBOL_DEMANGLED_NAME (msymbol)); + fprintf_filtered (outfile, " %s", msymbol->demangled_name ()); } if (msymbol->filename) fprintf_filtered (outfile, " %s", msymbol->filename); diff --git a/gdb/symtab.c b/gdb/symtab.c index 6affdef58c5..92e8dcdf50c 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -944,49 +944,47 @@ symbol_set_names (struct general_symbol_info *gsymbol, symbol_set_demangled_name (gsymbol, NULL, &per_bfd->storage_obstack); } -/* Return the source code name of a symbol. In languages where - demangling is necessary, this is the demangled name. */ +/* See symtab.h. */ const char * -symbol_natural_name (const struct general_symbol_info *gsymbol) +general_symbol_info::natural_name () const { - switch (gsymbol->language) + switch (language) { case language_cplus: case language_d: case language_go: case language_objc: case language_fortran: - if (symbol_get_demangled_name (gsymbol) != NULL) - return symbol_get_demangled_name (gsymbol); + if (symbol_get_demangled_name (this) != NULL) + return symbol_get_demangled_name (this); break; case language_ada: - return ada_decode_symbol (gsymbol); + return ada_decode_symbol (this); default: break; } - return gsymbol->name; + return name; } -/* Return the demangled name for a symbol based on the language for - that symbol. If no demangled name exists, return NULL. */ +/* See symtab.h. */ const char * -symbol_demangled_name (const struct general_symbol_info *gsymbol) +general_symbol_info::demangled_name () const { const char *dem_name = NULL; - switch (gsymbol->language) + switch (language) { case language_cplus: case language_d: case language_go: case language_objc: case language_fortran: - dem_name = symbol_get_demangled_name (gsymbol); + dem_name = symbol_get_demangled_name (this); break; case language_ada: - dem_name = ada_decode_symbol (gsymbol); + dem_name = ada_decode_symbol (this); break; default: break; @@ -994,18 +992,15 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol) return dem_name; } -/* Return the search name of a symbol---generally the demangled or - linkage name of the symbol, depending on how it will be searched for. - If there is no distinct demangled name, then returns the same value - (same pointer) as SYMBOL_LINKAGE_NAME. */ +/* See symtab.h. */ const char * -symbol_search_name (const struct general_symbol_info *gsymbol) +general_symbol_info::search_name () const { - if (gsymbol->language == language_ada) - return gsymbol->name; + if (language == language_ada) + return name; else - return symbol_natural_name (gsymbol); + return natural_name (); } /* See symtab.h. */ @@ -1016,7 +1011,7 @@ symbol_matches_search_name (const struct general_symbol_info *gsymbol, { symbol_name_matcher_ftype *name_match = get_symbol_name_matcher (language_def (gsymbol->language), name); - return name_match (symbol_search_name (gsymbol), name, NULL); + return name_match (gsymbol->search_name (), name, NULL); } @@ -3127,7 +3122,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) if (MSYMBOL_TYPE (msymbol.minsym) == mst_solib_trampoline) { struct bound_minimal_symbol mfunsym - = lookup_minimal_symbol_text (MSYMBOL_LINKAGE_NAME (msymbol.minsym), + = lookup_minimal_symbol_text (msymbol.minsym->linkage_name (), NULL); if (mfunsym.minsym == NULL) @@ -3733,7 +3728,7 @@ skip_prologue_sal (struct symtab_and_line *sal) objfile = msymbol.objfile; pc = BMSYMBOL_VALUE_ADDRESS (msymbol); section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym); - name = MSYMBOL_LINKAGE_NAME (msymbol.minsym); + name = msymbol.minsym->linkage_name (); } gdbarch = get_objfile_arch (objfile); @@ -4599,7 +4594,7 @@ search_symbols (const char *regexp, enum search_domain kind, || MSYMBOL_TYPE (msymbol) == ourtype4) { if (!preg.has_value () - || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0, + || preg->exec (msymbol->natural_name (), 0, NULL, 0) == 0) { /* Note: An important side-effect of these @@ -4611,8 +4606,7 @@ search_symbols (const char *regexp, enum search_domain kind, (MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) == NULL) : (lookup_symbol_in_objfile_from_linkage_name - (objfile, MSYMBOL_LINKAGE_NAME (msymbol), - VAR_DOMAIN) + (objfile, msymbol->linkage_name (), VAR_DOMAIN) .symbol == NULL)) found_misc = 1; } @@ -4707,7 +4701,7 @@ search_symbols (const char *regexp, enum search_domain kind, || MSYMBOL_TYPE (msymbol) == ourtype4) { if (!preg.has_value () - || preg->exec (MSYMBOL_NATURAL_NAME (msymbol), 0, + || preg->exec (msymbol->natural_name (), 0, NULL, 0) == 0) { /* For functions we can do a quick check of whether the @@ -4718,8 +4712,7 @@ search_symbols (const char *regexp, enum search_domain kind, == NULL)) { if (lookup_symbol_in_objfile_from_linkage_name - (objfile, MSYMBOL_LINKAGE_NAME (msymbol), - VAR_DOMAIN) + (objfile, msymbol->linkage_name (), VAR_DOMAIN) .symbol == NULL) { /* match */ @@ -4829,8 +4822,7 @@ print_msymbol_info (struct bound_minimal_symbol msymbol) printf_filtered (_("%ps %ps\n"), styled_string (address_style.style (), tmp), - styled_string (sym_style, - MSYMBOL_PRINT_NAME (msymbol.minsym))); + styled_string (sym_style, msymbol.minsym->print_name ())); } /* This is the guts of the commands "info functions", "info types", and @@ -5143,11 +5135,11 @@ rbreak_command (const char *regexp, int from_tty) else { string = string_printf ("'%s'", - MSYMBOL_LINKAGE_NAME (p.msymbol.minsym)); + p.msymbol.minsym->linkage_name ()); break_command (&string[0], from_tty); printf_filtered (" %s;\n", - MSYMBOL_PRINT_NAME (p.msymbol.minsym)); + p.msymbol.minsym->print_name ()); } } } @@ -5230,7 +5222,7 @@ completion_list_add_msymbol (completion_tracker &tracker, const char *text, const char *word) { completion_list_add_name (tracker, MSYMBOL_LANGUAGE (sym), - MSYMBOL_NATURAL_NAME (sym), + sym->natural_name (), lookup_name, text, word); } @@ -5250,7 +5242,7 @@ completion_list_objc_symbol (completion_tracker &tracker, const char *method, *category, *selector; char *tmp2 = NULL; - method = MSYMBOL_NATURAL_NAME (msymbol); + method = msymbol->natural_name (); /* Is it a method? */ if ((method[0] != '-') && (method[0] != '+')) @@ -6319,7 +6311,7 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym) gdb_assert (minsym->maybe_copied); gdb_assert ((objf->flags & OBJF_MAINLINE) == 0); - const char *linkage_name = MSYMBOL_LINKAGE_NAME (minsym); + const char *linkage_name = minsym->linkage_name (); for (objfile *objfile : current_program_space->objfiles ()) { diff --git a/gdb/symtab.h b/gdb/symtab.h index 8f95a3a4d27..3eb9c0e1d27 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -67,7 +67,7 @@ enum class symbol_name_match_type /* Search name matching. This is like FULL, but the search name did not come from the user; instead it is already a search name - retrieved from a SYMBOL_SEARCH_NAME/MSYMBOL_SEARCH_NAME call. + retrieved from a SYMBOL_SEARCH_NAME/search_name () call. For Ada, this avoids re-encoding an already-encoded search name (which would potentially incorrectly lowercase letters in the linkage/search name that should remain uppercase). For C++, it @@ -380,6 +380,42 @@ typedef bool (symbol_name_matcher_ftype) struct general_symbol_info { + /* Short version as to when to use which name accessor: + Use natural_name () to refer to the name of the symbol in the original + source code. Use linkage_name () if you want to know what the linker + thinks the symbol's name is. Use print_name () for output. Use + demangled_name () if you specifically need to know whether natural_name () + and linkage_name () are different. */ + + const char *linkage_name () const + { return name; } + + /* Return SYMBOL's "natural" name, i.e. the name that it was called in + the original source code. In languages like C++ where symbols may + be mangled for ease of manipulation by the linker, this is the + demangled name. */ + const char *natural_name () const; + + /* Returns a version of the name of a symbol that is + suitable for output. In C++ this is the "demangled" form of the + name if demangle is on and the "mangled" form of the name if + demangle is off. In other languages this is just the symbol name. + The result should never be NULL. Don't use this for internal + purposes (e.g. storing in a hashtable): it's only suitable for output. */ + const char *print_name () const + { return demangle ? natural_name () : linkage_name (); } + + /* Return the demangled name for a symbol based on the language for + that symbol. If no demangled name exists, return NULL. */ + const char *demangled_name () const; + + /* Returns the name to be used when sorting and searching symbols. + In C++, we search for the demangled form of a name, + and so sort symbols accordingly. In Ada, however, we search by mangled + name. If there is no distinct demangled name, then this + returns the same value (same pointer) as linkage_name (). */ + const char *search_name () const; + /* Name of the symbol. This is a required field. Storage for the name is allocated on the objfile_obstack for the associated objfile. For languages like C++ that make a distinction between @@ -518,15 +554,8 @@ extern void symbol_set_names (struct general_symbol_info *symbol, specifically need to know whether SYMBOL_NATURAL_NAME and SYMBOL_LINKAGE_NAME are different. */ -/* Return SYMBOL's "natural" name, i.e. the name that it was called in - the original source code. In languages like C++ where symbols may - be mangled for ease of manipulation by the linker, this is the - demangled name. */ - #define SYMBOL_NATURAL_NAME(symbol) \ - (symbol_natural_name ((symbol))) -extern const char *symbol_natural_name - (const struct general_symbol_info *symbol); + ((symbol)->natural_name ()) /* Return SYMBOL's name from the point of view of the linker. In languages like C++ where symbols may be mangled for ease of @@ -535,12 +564,8 @@ extern const char *symbol_natural_name #define SYMBOL_LINKAGE_NAME(symbol) (symbol)->name -/* Return the demangled name for a symbol based on the language for - that symbol. If no demangled name exists, return NULL. */ #define SYMBOL_DEMANGLED_NAME(symbol) \ - (symbol_demangled_name ((symbol))) -extern const char *symbol_demangled_name - (const struct general_symbol_info *symbol); + ((symbol)->demangled_name ()) /* Macro that returns a version of the name of a symbol that is suitable for output. In C++ this is the "demangled" form of the @@ -555,14 +580,8 @@ extern const char *symbol_demangled_name #define SYMBOL_PRINT_NAME(symbol) \ (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol)) -/* Macro that returns the name to be used when sorting and searching symbols. - In C++, we search for the demangled form of a name, - and so sort symbols accordingly. In Ada, however, we search by mangled - name. If there is no distinct demangled name, then SYMBOL_SEARCH_NAME - returns the same value (same pointer) as SYMBOL_LINKAGE_NAME. */ #define SYMBOL_SEARCH_NAME(symbol) \ - (symbol_search_name (symbol)) -extern const char *symbol_search_name (const struct general_symbol_info *ginfo); + ((symbol)->search_name ()) /* Return true if NAME matches the "search" name of SYMBOL, according to the symbol's language. */ @@ -750,16 +769,6 @@ extern CORE_ADDR get_msymbol_address (struct objfile *objf, ? (&(((objfile)->sections)[(symbol)->section])) \ : NULL) -#define MSYMBOL_NATURAL_NAME(symbol) \ - (symbol_natural_name (symbol)) -#define MSYMBOL_LINKAGE_NAME(symbol) (symbol)->name -#define MSYMBOL_PRINT_NAME(symbol) \ - (demangle ? MSYMBOL_NATURAL_NAME (symbol) : MSYMBOL_LINKAGE_NAME (symbol)) -#define MSYMBOL_DEMANGLED_NAME(symbol) \ - (symbol_demangled_name (symbol)) -#define MSYMBOL_SEARCH_NAME(symbol) \ - (symbol_search_name (symbol)) - #include "minsyms.h" @@ -1632,7 +1641,7 @@ extern struct block_symbol lookup_symbol (const char *, global/static blocks if BLOCK is NULL. The passed-in search name should not come from the user; instead it should already be a search name as retrieved from a - SYMBOL_SEARCH_NAME/MSYMBOL_SEARCH_NAME call. See definition of + SYMBOL_SEARCH_NAME/search_name () call. See definition of symbol_name_match_type::SEARCH_NAME. Returns the struct symbol pointer, or NULL if no symbol is found. The symbol's section is fixed up if necessary. */ diff --git a/gdb/x86-tdep.c b/gdb/x86-tdep.c index 41b209ef546..fdd9d199145 100644 --- a/gdb/x86-tdep.c +++ b/gdb/x86-tdep.c @@ -47,7 +47,7 @@ x86_in_indirect_branch_thunk (CORE_ADDR pc, const char **register_names, if (bmfun.minsym == nullptr) return false; - const char *name = MSYMBOL_LINKAGE_NAME (bmfun.minsym); + const char *name = bmfun.minsym->linkage_name (); if (name == nullptr) return false; -- 2.30.2