Clarify "list" output when specified lines are ambiguous
authorPedro Alves <palves@redhat.com>
Mon, 4 Sep 2017 15:49:29 +0000 (16:49 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 4 Sep 2017 15:49:29 +0000 (16:49 +0100)
commite439fa140afdaedb28a97acaa2b0432b884d8a91
tree93a1682af136319ce89647a5186295ccc0feb1f9
parent7525b645dfaa302091591d0f87d9682ce988ed13
Clarify "list" output when specified lines are ambiguous

Currently, with "list LINESPEC1,LINESPEC2", if one of the linespecs is
ambiguous, i.e., if it expands to multiple locations, you get this
seemingly odd output:

 (gdb) list foo,bar
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

Since "foo" above expands to multiple locations, the specified range
is indeterminate, and GDB is trying to be helpful by showing you what
was ambiguous.  It looks confusing to me, though.  I think it'd be
much more user friendly if GDB actually told you that, like this:

 (gdb) list foo,bar
 Specified first line 'foo' is ambiguous:
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

 (gdb) list bar,foo
 Specified last line 'foo' is ambiguous:
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

Note, I'm using "first" and "last" in the output because that's what
the manual uses:

 ~~~
 list first,last

     Print lines from first to last. [...]
 ~~~

Tested on x86-64 GNU/Linux.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

* cli/cli-cmds.c (edit_command): Pass message to
ambiguous_line_spec.
(list_command): Pass message to ambiguous_line_spec.  Say
"first"/"last" instead of "start" and "end" to be consistent with
the manual.
(ambiguous_line_spec): Add 'format' and vararg parameters.  Use
them to print formatted message.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

* gdb.base/list-ambiguous.exp: New file.
* gdb.base/list-ambiguous0.c: New file.
* gdb.base/list-ambiguous1.c: New file.
* gdb.base/list.exp (test_list_range): Adjust expected output.
gdb/ChangeLog
gdb/cli/cli-cmds.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/list-ambiguous.exp [new file with mode: 0644]
gdb/testsuite/gdb.base/list-ambiguous0.c [new file with mode: 0644]
gdb/testsuite/gdb.base/list-ambiguous1.c [new file with mode: 0644]
gdb/testsuite/gdb.base/list.exp