This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index
On 02/24/2017 03:34 PM, Yao Qi wrote:
> then, as you described in commit log, we have to iterate all symtabs
> rather than stop on the first matched symtab. We need to replace
> "return true;" with "return false;" above. Presumably, this replacement
> will fix the fails in completion.exp.
Yeah, that's a good way to put it.
>
> Then, it turns out that the whole block "if (s == NULL) {...}" is
> removed by this patch. I'll dig deep to see this block is still needed
> or not.
>
Here are some tests that fail with current master, due to that
second block, but pass with the patch. (I haven't tried
to split in two patches.)
>From 40a60624d4a6efd8560f374fd3e60dde9ac2b610 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Fri, 24 Feb 2017 17:03:01 +0000
Subject: [PATCH] test
---
gdb/testsuite/gdb.linespec/base/one/thefile.cc | 5 ++
gdb/testsuite/gdb.linespec/base/two/thefile.cc | 5 ++
gdb/testsuite/gdb.linespec/linespec.exp | 93 +++++++++++++++++++++++++-
3 files changed, 100 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.linespec/base/one/thefile.cc b/gdb/testsuite/gdb.linespec/base/one/thefile.cc
index 0417b7a..34bc547 100644
--- a/gdb/testsuite/gdb.linespec/base/one/thefile.cc
+++ b/gdb/testsuite/gdb.linespec/base/one/thefile.cc
@@ -23,3 +23,8 @@ int NameSpace::overload(int x)
{
return x + 23;
}
+
+int z1 ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.linespec/base/two/thefile.cc b/gdb/testsuite/gdb.linespec/base/two/thefile.cc
index 88188a5..264ae97 100644
--- a/gdb/testsuite/gdb.linespec/base/two/thefile.cc
+++ b/gdb/testsuite/gdb.linespec/base/two/thefile.cc
@@ -24,3 +24,8 @@ int NameSpace::overload(double x)
{
return (int) x - 23;
}
+
+int z2 ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp
index ccb73c8..3a7bae5 100644
--- a/gdb/testsuite/gdb.linespec/linespec.exp
+++ b/gdb/testsuite/gdb.linespec/linespec.exp
@@ -43,6 +43,9 @@ if {$l1 != $l2} {
error "somebody incompatibly modified the source files needed by linespec.exp"
}
+gdb_test_no_output "set breakpoint pending off" \
+ "disable pending breakpoints for linespec tests"
+
# Copying files to a remote host loses the directory prefix during
# compilation.
if { [is_remote host] } {
@@ -55,6 +58,93 @@ if { [is_remote host] } {
gdb_test "clear one/thefile.cc:$l1" \
"Deleted breakpoint $decimal *" \
"clear breakpoint using dir/file:line"
+
+ if { [readline_is_used] } {
+ # There are functions name twodup in both source files. Both
+ # should be found if we restrict the linespec to the ambiguous
+ # "thefile.cc" source filename. Check both completion and
+ # setting the breakpoint.
+ set tst "complete unique function name in two source files"
+ send_gdb "break thefile.cc:t\t"
+ gdb_test_multiple "" $tst {
+ -re "break thefile.cc:twodup\\(\\) " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Breakpoint $decimal at $hex: thefile.cc:twodup\\(\\). \[(\]2 locations\[)\]" \
+ "set break at unique function name in two source files"
+ }
+ }
+
+ # Check both completing and setting a breakpoint on a linespec
+ # with a source component, where there's more than one source
+ # file with the same basename. We should find the functions
+ # in all matching sources -- one/thefile.cc and
+ # two/thefile.cc. The "one" file has "z1()", while the "two"
+ # file has "z2()".
+ set tst "complete non-unique function name in two source files"
+ send_gdb "break thefile.cc:z\t"
+ gdb_test_multiple "" $tst {
+ -re "break thefile.cc:z\\\x07" {
+ send_gdb "\t"
+ gdb_test_multiple "" $tst {
+ -re "\r\nz1\\(\\)\[ \t\]+z2\\(\\)\[ \t\]+\r\n$gdb_prompt " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Function \"z\" not defined in \"thefile.cc\"." \
+ "set break at non-unique function name in two source files"
+ }
+ }
+ }
+ }
+
+ # Now check that disambiguating the source path makes GDB only
+ # match the symbols in that file. "z" should now have a
+ # unique completion to "z1()", and setting the breakpoint
+ # should find only one location.
+ set tst "complete unique function name in disambiguated source file"
+ send_gdb "break one/thefile.cc:z\t"
+ gdb_test_multiple "" $tst {
+ -re "break one/thefile.cc:z1\\(\\) " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Breakpoint $decimal at $hex: file .*thefile.cc, line \[^\r\n\]*" \
+ "set break at unique function name in disambiguated source file"
+ }
+ }
+
+ # Check that using a non-existing source path does not confuse
+ # gdb. It should not match any symbol.
+ set dir_file "one/thefile.cc"
+ set non_existing "/some/non-existing/absolute/path/prefix/$dir_file"
+ set non_existing_re [string_to_regexp $non_existing]
+
+ set tst "complete functions in non-existing absolute path"
+ send_gdb "break $non_existing:\t"
+ gdb_test_multiple "" $tst {
+ -re "break $non_existing_re:\\\x07" {
+ send_gdb "\t\t"
+ gdb_test_multiple "" $tst {
+ -re "^\\\x07\\\x07" {
+ pass $tst
+
+ # There's a function called twodup in each of
+ # the thefile.cc files. Make sure none is
+ # picked.
+ send_gdb "twodup\n"
+ gdb_test "" \
+ "No source file named $non_existing_re." \
+ "set break in function in non-existing absolute path"
+ }
+ }
+ }
+ }
+ }
}
gdb_test "break thefile.cc:$l1" \
@@ -73,9 +163,6 @@ gdb_test "break dupname:label" \
# not the locations.
gdb_test "complete condition " "condition $decimal\r\ncondition $decimal\r\ncondition $decimal"
-gdb_test_no_output "set breakpoint pending off" \
- "disable pending breakpoints for linespec tests"
-
# This is PR breakpoints/12856.
gdb_test "break lspec.cc:nosuchfunction" \
"Function \"nosuchfunction\" not defined in \"lspec.cc\"." \
--
2.5.5