Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index
Date: Fri, 24 Feb 2017 17:15:00 -0000	[thread overview]
Message-ID: <9d115e42-31d8-5eec-93a0-5ef5a17c6f82@redhat.com> (raw)
In-Reply-To: <86poi77gd0.fsf@gmail.com>

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



  reply	other threads:[~2017-02-24 17:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 14:50 [PATCH 0/3] Introduce gdb::function_view & fix completion bug Pedro Alves
2017-02-22 14:50 ` [PATCH 3/3] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-02-23 16:02   ` Yao Qi
2017-02-23 17:12     ` Pedro Alves
2017-02-23 17:24     ` [PATCH v2 0/2] " Pedro Alves
2017-02-23 17:24       ` [PATCH v2 1/2] symtab.c: Small refactor Pedro Alves
2017-02-23 21:45         ` Yao Qi
2017-02-24 17:45           ` Pedro Alves
2017-02-23 17:24       ` [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-02-24 15:34         ` Yao Qi
2017-02-24 17:15           ` Pedro Alves [this message]
2017-02-22 14:50 ` [PATCH 1/3] Introduce gdb::function_view Pedro Alves
2017-02-22 15:15   ` Simon Marchi
2017-02-22 17:40     ` Pedro Alves
2017-02-22 17:49       ` [PATCH v1.1 " Pedro Alves
2017-02-22 22:12         ` Yao Qi
2017-02-23 14:49           ` Pedro Alves
2017-02-23 15:11             ` Yao Qi
2017-02-23 15:20               ` Pedro Alves
2017-02-23 15:34                 ` Yao Qi
2017-02-22 22:23         ` Yao Qi
2017-02-23 14:50           ` [PATCH v1.2 " Pedro Alves
2017-02-23 14:58             ` Yao Qi
2017-02-23 14:59               ` Pedro Alves
2017-02-22 18:02       ` [PATCH " Simon Marchi
2017-02-22 14:50 ` [PATCH 2/3] Use gdb::function_view in iterate_over_symtabs & co Pedro Alves
2017-02-22 22:40   ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d115e42-31d8-5eec-93a0-5ef5a17c6f82@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox