aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-11-22 12:05:14 -0600
committerChristian Biesinger <cbiesinger@google.com>2019-11-22 12:05:14 -0600
commitc9d95fa3d034ae614e33b631e0bc019015c444e9 (patch)
tree3837298ae4aa0eb537234305f019cbf14348307e /gdb/symtab.c
parentf8bab2d61d84b4e122ca667c4e458cd2ca29e3b6 (diff)
downloadgdb-c9d95fa3d034ae614e33b631e0bc019015c444e9.zip
gdb-c9d95fa3d034ae614e33b631e0bc019015c444e9.tar.gz
gdb-c9d95fa3d034ae614e33b631e0bc019015c444e9.tar.bz2
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 <cbiesinger@google.com> * 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
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6affdef..92e8dcd 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 ("<function, no debug info> %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 ())
{