gdb/gdb-rhbz1228556-bpt-inlined...

137 lines
5.3 KiB
Diff

commit 06871ae84096ed1672eb76f44cea4d5dbe79ae24
Author: Pedro Alves <palves@redhat.com>
Date: Wed Sep 20 16:12:54 2017 +0100
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.
### a/gdb/ChangeLog
### b/gdb/ChangeLog
## -1,5 +1,14 @@
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.
+
+2017-09-20 Pedro Alves <palves@redhat.com>
+
* linespec.c (minsym_found): Handle non-text minsyms.
(symbol_to_sal): Record a sal.pc for non-block, non-label symbols.
Index: gdb-8.0.1/gdb/linespec.c
===================================================================
--- gdb-8.0.1.orig/gdb/linespec.c 2017-10-20 21:28:18.444609776 +0200
+++ gdb-8.0.1/gdb/linespec.c 2017-10-20 21:29:12.382094104 +0200
@@ -3864,6 +3864,7 @@
{
init_sal (result);
result->symtab = symbol_symtab (sym);
+ result->symbol = sym;
result->line = SYMBOL_LINE (sym);
result->pc = SYMBOL_VALUE_ADDRESS (sym);
result->pspace = SYMTAB_PSPACE (result->symtab);
@@ -3879,6 +3880,7 @@
/* We know its line number. */
init_sal (result);
result->symtab = symbol_symtab (sym);
+ result->symbol = sym;
result->line = SYMBOL_LINE (sym);
result->pspace = SYMTAB_PSPACE (result->symtab);
return 1;
Index: gdb-8.0.1/gdb/symtab.c
===================================================================
--- gdb-8.0.1.orig/gdb/symtab.c 2017-10-20 21:28:18.446609794 +0200
+++ gdb-8.0.1/gdb/symtab.c 2017-10-20 21:29:51.390444377 +0200
@@ -3478,6 +3478,7 @@
fixup_symbol_section (sym, NULL);
section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym);
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))
@@ -3501,6 +3502,7 @@
sal.pspace = current_program_space;
sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
sal.section = section;
+ sal.symbol = sym;
}
if (funfirstline)
Index: gdb-8.0.1/gdb/symtab.h
===================================================================
--- gdb-8.0.1.orig/gdb/symtab.h 2017-10-20 21:28:21.205634569 +0200
+++ gdb-8.0.1/gdb/symtab.h 2017-10-20 21:28:40.933811716 +0200
@@ -1420,6 +1420,7 @@
struct program_space *pspace;
struct symtab *symtab;
+ struct symbol *symbol;
struct obj_section *section;
/* Line number. Line numbers start at 1 and proceed through symtab->nlines.
0 is never a valid line number; it is used to indicate that line number