From patchwork Wed Feb 8 13:41:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 19175 Received: (qmail 61757 invoked by alias); 8 Feb 2017 13:41:42 -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 61716 invoked by uid 89); 8 Feb 2017 13:41:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=eval, main_arena, wasting, 3197 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Feb 2017 13:41:31 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1cbSV0-00037t-1t from Luis_Gustavo@mentor.com ; Wed, 08 Feb 2017 05:41:30 -0800 Received: from Opsys.world.mentorg.com (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.224.2; Wed, 8 Feb 2017 05:41:28 -0800 From: Luis Machado To: , , Subject: [PATCH, v3] Fix gdb.linespec/explicit.exp Date: Wed, 8 Feb 2017 07:41:24 -0600 Message-ID: <1486561284-7016-1-git-send-email-lgustavo@codesourcery.com> In-Reply-To: <1485552639-18470-1-git-send-email-lgustavo@codesourcery.com> References: <1485552639-18470-1-git-send-email-lgustavo@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes Changes in v3: - New function with unique name. - Change test to match said new function. Changes in v2: - Adjusted hex character pattern based on Keith Seitz's feedback and removed trailing whitespace. This patch addresses timeout failures i noticed while testing aarch64-elf. FAIL: gdb.linespec/explicit.exp: complete unique function name (timeout) FAIL: gdb.linespec/explicit.exp: complete non-unique function name (timeout) FAIL: gdb.linespec/explicit.exp: complete non-existant function name (timeout) FAIL: gdb.linespec/explicit.exp: complete unique file name (timeout) FAIL: gdb.linespec/explicit.exp: complete non-unique file name (timeout) The timeouts were caused by an attempt to match a bell character (x07) that doesn't show up on my particular test setup. The bell character is output whenever one tries to complete a pattern and there are multiple possible matches. When there is only one possible match, GDB will complete the input pattern without outputting the bell character. The reason for the discrepancy in this test's behavior is due to the use of "main" for a unique name test. On glibc-based systems, GDB may notice the "main_arena" symbol, which is a data global part of glibc's malloc implementation. Therefore a bell character will be output because we have a couple possible completion matches. GDB should not be outputting such a data symbol as a possible match, but this problem may/will be addressed in a future change and is besides the point of this particular change. On systems that are not based on glibc, GDB will not see any other possible matches for completing "main", so there will be no bell characters. The use of main is a bit fragile though, so the patch adds a new local function with a name that has a greater chance of being unique and adjusts the test to iuse it. I've also added the regular expression switch (-re) to all the gdb_test_multiple calls that were missing it. Hopefully this will reduce the chances of someone wasting time trying to match a regular expression (a much more common use case) when, in reality, the pattern is supposed to be matched literally. gdb/testsuite/ChangeLog YYYY-MM-DD Luis Machado * gdb.linespec/explicit.c (my_unique_function_name): New function. (main): Call my_unique_function_name. * gdb.linespec/explicit.exp: Use my_unique_function_name to test completion of patterns with a single match. Add missing -re switches to gdb_test_multiple calls. --- gdb/testsuite/gdb.linespec/explicit.c | 15 +++++++++++++++ gdb/testsuite/gdb.linespec/explicit.exp | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/gdb/testsuite/gdb.linespec/explicit.c b/gdb/testsuite/gdb.linespec/explicit.c index 765f62a..f523b0e 100644 --- a/gdb/testsuite/gdb.linespec/explicit.c +++ b/gdb/testsuite/gdb.linespec/explicit.c @@ -42,6 +42,19 @@ myfunction (int arg) return r; } +static int +my_unique_function_name (int arg) +{ + int j = 0; + + /* Just do something random. We only care about the unique function + name. */ + if (arg == 50) + j = 10; + + return j; +} + int main (void) { @@ -52,5 +65,7 @@ main (void) for (i = 0, j = 0; i < 1000; ++i) j += myfunction (0); + my_unique_function_name (j); + return myfunction2 (j); } diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp index 637f476..65d78ca 100644 --- a/gdb/testsuite/gdb.linespec/explicit.exp +++ b/gdb/testsuite/gdb.linespec/explicit.exp @@ -154,7 +154,7 @@ namespace eval $testfile { set tst "complete 'break -$abbrev'" send_gdb "break -${abbrev}\t" gdb_test_multiple "" $tst { - "break -$full " { + -re "break -$full " { send_gdb "\n" gdb_test_multiple "" $tst { -re "missing argument for \"-$full\".*$gdb_prompt " { @@ -185,9 +185,9 @@ namespace eval $testfile { } set tst "complete unique function name" - send_gdb "break -function mai\t" + send_gdb "break -function my_unique_func\t" gdb_test_multiple "" $tst { - "break -function mai\\\x07n" { + -re "break -function my_unique_function_name" { send_gdb "\n" gdb_test "" ".*Breakpoint \[0-9\]+.*" $tst gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint" @@ -197,7 +197,7 @@ namespace eval $testfile { set tst "complete non-unique function name" send_gdb "break -function myfunc\t" gdb_test_multiple "" $tst { - "break -function myfunc\\\x07tion" { + -re "break -function myfunc\\\x07tion" { send_gdb "\t\t" gdb_test_multiple "" $tst { -re "\\\x07\r\nmyfunction\[ \t\]+myfunction2\[ \t\]+myfunction3\[ \t\]+myfunction4\[ \t\]+\r\n$gdb_prompt " { @@ -211,7 +211,7 @@ namespace eval $testfile { set tst "complete non-existant function name" send_gdb "break -function foo\t" gdb_test_multiple "" $tst { - "break -function foo\\\x07" { + -re "break -function foo\\\x07" { send_gdb "\t\t" gdb_test_multiple "" $tst { -re "\\\x07\\\x07" { @@ -225,7 +225,7 @@ namespace eval $testfile { set tst "complete unique file name" send_gdb "break -source 3ex\t" gdb_test_multiple "" $tst { - "break -source 3explicit.c " { + -re "break -source 3explicit.c " { send_gdb "\n" gdb_test "" \ {Source filename requires function, label, or line offset.} $tst @@ -235,7 +235,7 @@ namespace eval $testfile { set tst "complete non-unique file name" send_gdb "break -source exp\t" gdb_test_multiple "" $tst { - "break -source exp\\\x07licit" { + -re "break -source exp\\\x07licit" { send_gdb "\t\t" gdb_test_multiple "" $tst { -re "\\\x07\r\nexplicit.c\[ \t\]+explicit2.c\[ \t\]+\r\n$gdb_prompt" { @@ -247,7 +247,7 @@ namespace eval $testfile { } } - "break -source exp\\\x07l" { + -re "break -source exp\\\x07l" { # This pattern may occur when glibc debuginfo is installed. send_gdb "\t\t" gdb_test_multiple "" $tst { @@ -264,10 +264,10 @@ namespace eval $testfile { set tst "complete non-existant file name" send_gdb "break -source foo\t" gdb_test_multiple "" $tst { - "break -source foo" { + -re "break -source foo" { send_gdb "\t\t" gdb_test_multiple "" $tst { - "\\\x07\\\x07" { + -re "\\\x07\\\x07" { send_gdb "\n" gdb_test "" \ {Source filename requires function, label, or line offset.} \ @@ -280,7 +280,7 @@ namespace eval $testfile { set tst "complete filename and unique function name" send_gdb "break -source explicit.c -function ma\t" gdb_test_multiple "" $tst { - "break -source explicit.c -function main " { + -re "break -source explicit.c -function main " { send_gdb "\n" gdb_test "" ".*Breakpoint .*" $tst gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint" @@ -290,7 +290,7 @@ namespace eval $testfile { set tst "complete filename and non-unique function name" send_gdb "break -so 3explicit.c -func myfunc\t" gdb_test_multiple "" $tst { - "break -so 3explicit.c -func myfunc\\\x07tion" { + -re "break -so 3explicit.c -func myfunc\\\x07tion" { send_gdb "\t\t" gdb_test_multiple "" $tst { -re "\\\x07\r\nmyfunction3\[ \t\]+myfunction4\[ \t\]+\r\n$gdb_prompt " { @@ -304,10 +304,10 @@ namespace eval $testfile { set tst "complete filename and non-existant function name" send_gdb "break -sou 3explicit.c -fun foo\t" gdb_test_multiple "" $tst { - "break -sou 3explicit.c -fun foo\\\x07" { + -re "break -sou 3explicit.c -fun foo\\\x07" { send_gdb "\t\t" gdb_test_multiple "" $tst { - "\\\x07\\\x07" { + -re "\\\x07\\\x07" { send_gdb "\n" gdb_test "" \ {Function "foo" not defined in "3explicit.c".} $tst @@ -319,7 +319,7 @@ namespace eval $testfile { set tst "complete filename and function reversed" send_gdb "break -func myfunction4 -source 3ex\t" gdb_test_multiple "" $tst { - "break -func myfunction4 -source 3explicit.c " { + -re "break -func myfunction4 -source 3explicit.c " { send_gdb "\n" gdb_test "" "Breakpoint \[0-9\]+.*" $tst gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint"