diff options
author | Pedro Alves <palves@redhat.com> | 2017-09-20 16:12:54 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-09-20 16:21:26 +0100 |
commit | 06871ae84096ed1672eb76f44cea4d5dbe79ae24 (patch) | |
tree | e08ebe280efb9b5ebf2bd9055a3d8b1423762d6a /gdb/symtab.c | |
parent | e5f25bc5d6dba5a5c4dd36e08afd57e918c63dea (diff) | |
download | gdb-06871ae84096ed1672eb76f44cea4d5dbe79ae24.zip gdb-06871ae84096ed1672eb76f44cea4d5dbe79ae24.tar.gz gdb-06871ae84096ed1672eb76f44cea4d5dbe79ae24.tar.bz2 |
Make "list ambiguous" show symbol names too
Currently, with an ambiguous "list first,last", we get:
(gdb) list bar,main
Specified first line 'bar' is ambiguous:
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
This commit makes gdb's output above a bit clearer by printing the
symbol name as well:
(gdb) list bar,main
Specified first line 'bar' is ambiguous:
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
And while at it, makes gdb print the symbol name when actually listing
multiple locations too. I.e., before (with "set listsize 2"):
(gdb) list bar
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97
96
97 int bar (A) { return 11; }
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98
97 int bar (A) { return 11; }
98 int bar (B) { return 22; }
After:
(gdb) list bar
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 97, symbol: "bar(A)"
96
97 int bar (A) { return 11; }
file: "src/gdb/testsuite/gdb.cp/overload.cc", line number: 98, symbol: "bar(B)"
97 int bar (A) { return 11; }
98 int bar (B) { return 22; }
Currently, the result of decoding a linespec loses information about
the original symbol that was found. All we end up with is an address.
This makes it difficult to find the original symbol again to get at
its print name. Fix that by storing a pointer to the symbol in the
sal. We already store the symtab and obj_section, so it feels like a
natural progression to me. This avoids having to do any extra symbol
lookup too.
gdb/ChangeLog:
2017-09-20 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (list_command): Use print_sal_location.
(print_sal_location): New function.
(ambiguous_line_spec): Use print_sal_location.
* linespec.c (symbol_to_sal): Record the symbol in the sal.
* symtab.c (find_function_start_sal): Likewise.
* symtab.h (symtab_and_line::symbol): New field.
gdb/testsuite/ChangeLog:
2017-09-20 Pedro Alves <palves@redhat.com>
* gdb.base/list-ambiguous.exp (test_list_ambiguous_symbol): Expect
symbol names in gdb's output.
* gdb.cp/overload.exp ("list all overloads"): Likewise.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index b504cd6..bf7ee64 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3461,6 +3461,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline) obj_section *section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym); symtab_and_line sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), section, 0); + sal.symbol = sym; if (funfirstline && sal.symtab != NULL && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab)) @@ -3484,6 +3485,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline) sal.pspace = current_program_space; sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); sal.section = section; + sal.symbol = sym; } if (funfirstline) |