This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Make "list ambiguous" show symbol names too


*** TEST RESULTS FOR COMMIT 06871ae84096ed1672eb76f44cea4d5dbe79ae24 ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: 06871ae84096ed1672eb76f44cea4d5dbe79ae24

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]