diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-07-28 11:48:15 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-07-28 11:48:15 -0600 |
commit | f75a069335831a4f375923b5ab815ce0b6b2ebdf (patch) | |
tree | f9788692981cbb95e60b1e1bd5cc3be34a301326 /gdb/blockframe.c | |
parent | 16f3242c055e2a740dfc42b65cc3509b6ccf71e8 (diff) | |
download | fsf-binutils-gdb-f75a069335831a4f375923b5ab815ce0b6b2ebdf.zip fsf-binutils-gdb-f75a069335831a4f375923b5ab815ce0b6b2ebdf.tar.gz fsf-binutils-gdb-f75a069335831a4f375923b5ab815ce0b6b2ebdf.tar.bz2 |
Demangle function names when disassembling
Andrew Burgess pointed out a regression, which he described in
PR symtab/26270:
================
After commit:
commit bcfe6157ca288efed127c5efe21ad7924e0d98cf (refs/bisect/bad)
Date: Fri Apr 24 15:35:01 2020 -0600
Use the linkage name if it exists
The disassembler no longer demangles function names in its output. So
we see things like this:
(gdb) disassemble tree_insert
Dump of assembler code for function _Z11tree_insertP4nodei:
....
Instead of this:
(gdb) disassemble tree_insert
Dump of assembler code for function tree_insert(node*, int):
....
This is because find_pc_partial_function now returns the linkage name
rather than the demangled name.
================
This patch fixes the problem by introducing a new "overload" of
find_pc_partial_function, which returns the general_symbol_info rather
than simply the name. This lets the disassemble command choose which
name to show.
Regression tested on x86-64 Fedora 32.
gdb/ChangeLog
2020-07-28 Tom Tromey <tromey@adacore.com>
PR symtab/26270:
* symtab.h (find_pc_partial_function_sym): Declare.
* cli/cli-cmds.c (disassemble_command): Use
find_pc_partial_function_sym. Check asm_demangle.
* blockframe.c (cache_pc_function_sym): New global.
(cache_pc_function_name): Remove.
(clear_pc_function_cache): Update.
(find_pc_partial_function_sym): New function, from
find_pc_partial_function.
(find_pc_partial_function): Rewrite using
find_pc_partial_function_sym.
gdb/testsuite/ChangeLog
2020-07-28 Andrew Burgess <andrew.burgess@embecosm.com>
PR symtab/26270:
* gdb.cp/disasm-func-name.cc: New file.
* gdb.cp/disasm-func-name.exp: New file.
Diffstat (limited to 'gdb/blockframe.c')
-rw-r--r-- | gdb/blockframe.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 05c26bc..80b7695 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -191,7 +191,7 @@ find_pc_sect_containing_function (CORE_ADDR pc, struct obj_section *section) static CORE_ADDR cache_pc_function_low = 0; static CORE_ADDR cache_pc_function_high = 0; -static const char *cache_pc_function_name = 0; +static const general_symbol_info *cache_pc_function_sym = nullptr; static struct obj_section *cache_pc_function_section = NULL; static const struct block *cache_pc_function_block = nullptr; @@ -202,7 +202,7 @@ clear_pc_function_cache (void) { cache_pc_function_low = 0; cache_pc_function_high = 0; - cache_pc_function_name = (char *) 0; + cache_pc_function_sym = nullptr; cache_pc_function_section = NULL; cache_pc_function_block = nullptr; } @@ -210,8 +210,10 @@ clear_pc_function_cache (void) /* See symtab.h. */ bool -find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, - CORE_ADDR *endaddr, const struct block **block) +find_pc_partial_function_sym (CORE_ADDR pc, + const struct general_symbol_info **sym, + CORE_ADDR *address, CORE_ADDR *endaddr, + const struct block **block) { struct obj_section *section; struct symbol *f; @@ -257,7 +259,7 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, { const struct block *b = SYMBOL_BLOCK_VALUE (f); - cache_pc_function_name = f->linkage_name (); + cache_pc_function_sym = f; cache_pc_function_section = section; cache_pc_function_block = b; @@ -313,8 +315,8 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, if (msymbol.minsym == NULL) { /* No available symbol. */ - if (name != NULL) - *name = 0; + if (sym != nullptr) + *sym = 0; if (address != NULL) *address = 0; if (endaddr != NULL) @@ -325,7 +327,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.minsym->linkage_name (); + cache_pc_function_sym = msymbol.minsym; cache_pc_function_section = section; cache_pc_function_high = minimal_symbol_upper_bound (msymbol); cache_pc_function_block = nullptr; @@ -340,8 +342,8 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, *address = cache_pc_function_low; } - if (name) - *name = cache_pc_function_name; + if (sym != nullptr) + *sym = cache_pc_function_sym; if (endaddr) { @@ -368,6 +370,20 @@ find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, /* See symtab.h. */ bool +find_pc_partial_function (CORE_ADDR pc, const char **name, CORE_ADDR *address, + CORE_ADDR *endaddr, const struct block **block) +{ + const general_symbol_info *gsi; + bool r = find_pc_partial_function_sym (pc, &gsi, address, endaddr, block); + if (name != nullptr) + *name = r ? gsi->linkage_name () : nullptr; + return r; +} + + +/* See symtab.h. */ + +bool find_function_entry_range_from_pc (CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr) { |