diff options
author | Christian Biesinger <cbiesinger@google.com> | 2019-11-22 12:05:14 -0600 |
---|---|---|
committer | Christian Biesinger <cbiesinger@google.com> | 2019-11-22 12:05:14 -0600 |
commit | c9d95fa3d034ae614e33b631e0bc019015c444e9 (patch) | |
tree | 3837298ae4aa0eb537234305f019cbf14348307e /gdb/symtab.h | |
parent | f8bab2d61d84b4e122ca667c4e458cd2ca29e3b6 (diff) | |
download | fsf-binutils-gdb-c9d95fa3d034ae614e33b631e0bc019015c444e9.zip fsf-binutils-gdb-c9d95fa3d034ae614e33b631e0bc019015c444e9.tar.gz fsf-binutils-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.h')
-rw-r--r-- | gdb/symtab.h | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/gdb/symtab.h b/gdb/symtab.h index 8f95a3a..3eb9c0e 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. */ |