binutils-gdb/gdb/cli
Pedro Alves 06871ae840 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.
2017-09-20 16:21:26 +01:00
..
cli-cmds.c Make "list ambiguous" show symbol names too 2017-09-20 16:21:26 +01:00
cli-cmds.h Change return type of find_and_open_script 2017-08-03 07:58:53 -06:00
cli-decode.c Introduce class completion_tracker & rewrite completion<->readline interaction 2017-07-17 14:45:59 +01:00
cli-decode.h Clean up "completer_handle_brkchars" callback handling 2017-07-17 12:05:03 +01:00
cli-dump.c Rename _const functions to use overloading instead 2017-09-11 15:46:12 -06:00
cli-interp.c Remove unnecessary function prototypes. 2017-09-09 11:02:37 -07:00
cli-interp.h C++-fy struct interp/cli_interp/tui_interp/mi_interp 2017-02-03 16:30:04 +00:00
cli-logging.c Remove unnecessary function prototypes. 2017-09-09 11:02:37 -07:00
cli-script.c Replace clear_hook_in_cleanup with scoped_restore_hook_in 2017-09-11 16:15:09 -06:00
cli-script.h Move command lines types/declarations to cli-script.h 2017-09-04 19:09:12 +02:00
cli-setshow.c Rename _const functions to use overloading instead 2017-09-11 15:46:12 -06:00
cli-setshow.h update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
cli-utils.c Make extract_arg return a std::string 2017-09-11 15:46:14 -06:00
cli-utils.h Make extract_arg return a std::string 2017-09-11 15:46:14 -06:00