From patchwork Fri Feb 24 17:15:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 19375 Received: (qmail 74292 invoked by alias); 24 Feb 2017 17:15:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 74140 invoked by uid 89); 24 Feb 2017 17:15:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=l1 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Feb 2017 17:15:03 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B74E4E4CF; Fri, 24 Feb 2017 17:15:03 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1OHF2dN013637; Fri, 24 Feb 2017 12:15:02 -0500 Subject: Re: [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index To: Yao Qi References: <86a89cc2u6.fsf@gmail.com> <1487870642-29926-1-git-send-email-palves@redhat.com> <1487870642-29926-3-git-send-email-palves@redhat.com> <86poi77gd0.fsf@gmail.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <9d115e42-31d8-5eec-93a0-5ef5a17c6f82@redhat.com> Date: Fri, 24 Feb 2017 17:15:00 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 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 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\"." \