From patchwork Fri Mar 31 20:20:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 67164 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C79A385782B for ; Fri, 31 Mar 2023 20:22:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C79A385782B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680294133; bh=Dd7ucqFbggyb0juxKB19zp1VnZfvFAwPU2+eqxIuDlU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xCeNrcf3aglarvWyG/CO06OzDE3MSk4qzKagbbQ0epAIQuL4AhMU8mI3iXOPQBrZC 11E27IcoJUxzYM1XPfmBXEXHoCR0PfNXHRSlZWvuX1QcqUuOMQETxD6IGJc2GDna6s XNCXldQlprgKICaIazhmHsrnHb8h7g64TkWo13Zk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E164D38582BC for ; Fri, 31 Mar 2023 20:21:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E164D38582BC Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-338-CL3u7QDsOvGid5ePCzUgQQ-1; Fri, 31 Mar 2023 16:21:10 -0400 X-MC-Unique: CL3u7QDsOvGid5ePCzUgQQ-1 Received: by mail-wm1-f69.google.com with SMTP id o28-20020a05600c511c00b003ef69894934so8626874wms.6 for ; Fri, 31 Mar 2023 13:21:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680294069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dd7ucqFbggyb0juxKB19zp1VnZfvFAwPU2+eqxIuDlU=; b=cYABygoVdvMQdfadOAgXNdinqwimvyHRaztV6R+/kG7YMRlIcjdcLsVylYV/D99Mqt xF5dGEsIFAKi8air4Y2YTOaAVuYn8JZlzz2qImNNDwy09YNqGO11+JOcuzMhrGtdSAwU VcvptfNqqSbGyqcYRzg4216stu3QN+nhd7a3HO++G6ZBtuQYkVYzUV9+PCESwKlKt8NW YkEmomIkHJ46kPgfFWKugV01r7SBTLEA4uJ/K6RlM9GgpCsiVSJaJMn2dap3EmBVu3+Y 00uSk3tt3lOvwOM5R8JXw2iTcffMGug6xg7ft5O5xp5vsxQ5UTWOlLSvzZkz8ERBafPZ 22fA== X-Gm-Message-State: AAQBX9dpKBowIRlLHwlplVwK46G6CsdHMnQud9eKpzTy4GU1TAWS9wKL JbGRupA3HFvsQ3v403UvOMcLmvYxMrzZFouSoBWnaX4mB2Rxig0zOQPDiueLsOhBMXHLWP2dM+y kSSts6gH91k0hoY1E7KVSbdXC3vX2UHJ4llCwFqiVMjTXO7dMA+Ew3DxccgI7twG4tHWPCjmF+D g5E7UfWQ== X-Received: by 2002:adf:e94c:0:b0:2cf:e688:51bd with SMTP id m12-20020adfe94c000000b002cfe68851bdmr20353676wrn.31.1680294068750; Fri, 31 Mar 2023 13:21:08 -0700 (PDT) X-Google-Smtp-Source: AKy350a9VFd0fY+Yo7RD69OiVKjsGOMFmKS9OexLleRcECLzRwCT6kEfT5T7u46KfkJwhmTHFNjSlA== X-Received: by 2002:adf:e94c:0:b0:2cf:e688:51bd with SMTP id m12-20020adfe94c000000b002cfe68851bdmr20353661wrn.31.1680294068212; Fri, 31 Mar 2023 13:21:08 -0700 (PDT) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id c17-20020a5d63d1000000b002d1daafea30sm3035726wrw.34.2023.03.31.13.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 13:21:07 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 5/5] gdb/testsuite: special case '^' in gdb_test pattern Date: Fri, 31 Mar 2023 21:20:58 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" In this commit I propose that we add special handling for the '^' when used at the start of a gdb_test pattern. Consider this usage: gdb_test "some_command" "^command output pattern" I think the intention here is pretty clear - run 'some_command', and the output from the command should be exactly 'command output pattern'. After the previous commit which tightened up how gdb_test matches the final newline and prompt we know that the only thing after the output pattern will be a single newline and prompt, and the leading '^' ensures that there's no output before 'command output pattern', so this will do what I want, right? ... except it doesn't. The command itself will also be available and needs to be matched, so I should really write: gdb_test "some_command" "^some_command\r\ncommand output pattern" which will do what I want, right? Well, that's fine until I change the command and include some regexp character, then I have to write: gdb_test "some_command" \ "^[string_to_regexp some_command]\r\ncommand output pattern" which, honestly, is horrid. So in most cases I simply don't bother anchoring the output with a '^', and a quick scan of the testsuite would indicate that most other folk don't both either. What I propose is this: the *only* thing that can appear immediately after the '^' is the command converted into a regexp, so lets do that automatically, moving the work into gdb_test. Thus, when I write: gdb_test "some_command" "^command output pattern" Inside gdb_test we will spot the leading '^' in the pattern, and inject the regexp version of the command after the '^', followed by a '\r\n'. My hope is that given this new ability, folk will be more inclined to anchor their output patterns when this makes sense to do so. This should increase our ability to catch any excess warnings or unexpected junk that might get printed by GDB. There is one problem case we need to consider, sometime people do this: # ... something that sends a command to GDB ... gdb_test "" "^expected output pattern" In this case my proposed new feature injects the command regexp, which is the empty string (as the command itself is empty), but still injects the '\r\n' after the command regexp, thus we end up with this pattern: ^\r\nexpected output pattern This extra '\r\n' is not what we expected here. This gets a special case inside gdb_test -- if the command is empty then don't add anything after the '^' character. There are a bunch of tests that do already use '^' followed by the command, and these can all be simplified in this commit. --- gdb/testsuite/gdb.arch/amd64-entry-value.exp | 59 ++++++++++++++----- .../gdb.arch/amd64-invalid-stack-middle.exp | 4 +- .../gdb.arch/amd64-invalid-stack-top.exp | 4 +- gdb/testsuite/gdb.base/compare-sections.exp | 2 +- gdb/testsuite/gdb.base/fullpath-expand.exp | 4 +- .../gdb.base/multi-line-starts-subshell.exp | 2 +- gdb/testsuite/gdb.base/new-ui-echo.exp | 4 +- gdb/testsuite/gdb.base/new-ui.exp | 6 +- gdb/testsuite/gdb.base/settings.exp | 9 ++- gdb/testsuite/gdb.base/signals.exp | 2 +- gdb/testsuite/gdb.base/with.exp | 15 +++-- gdb/testsuite/gdb.linespec/break-ask.exp | 4 +- .../gdb.mi/user-selected-context-sync.exp | 2 +- gdb/testsuite/gdb.python/py-framefilter.exp | 2 +- gdb/testsuite/gdb.python/python.exp | 2 +- gdb/testsuite/lib/gdb.exp | 22 +++++-- 16 files changed, 97 insertions(+), 46 deletions(-) diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.exp b/gdb/testsuite/gdb.arch/amd64-entry-value.exp index a700e9a691b..3c666acc117 100644 --- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp +++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp @@ -48,8 +48,11 @@ gdb_breakpoint "breakhere_reference" gdb_continue_to_breakpoint "entry: breakhere" -gdb_test "bt" "^bt\r\n#0 +d *\\(i=31, i@entry=30, j=31\\.5, j@entry=30\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ - "entry: bt" +gdb_test "bt" \ + [multi_line \ + "^#0 +d *\\(i=31, i@entry=30, j=31\\.5, j@entry=30\\.5\\) \[^\r\n\]*" \ + "#1 +0x\[0-9a-f\]+ in main .*"] \ + "entry: bt" gdb_test "p i" " = 31" "entry: p i" gdb_test "p i@entry" " = 30" "entry: p i@entry" gdb_test "p j" { = 31\.5} "entry: p j" @@ -61,21 +64,30 @@ gdb_test "p j@entry" { = 30\.5} "entry: p j@entry" gdb_continue_to_breakpoint "entry_locexpr: breakhere_locexpr" gdb_test "p i" " = 30" "entry_locexpr: p i" gdb_test_no_output "set variable i = 0" "entry_locexpr: set variable i = 0" -gdb_test "bt" "^bt\r\n#0 +locexpr *\\(i=0, i@entry=30\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ - "entry_locexpr: bt" +gdb_test "bt" \ + [multi_line \ + "^#0 +locexpr *\\(i=0, i@entry=30\\) \[^\r\n\]*" \ + "#1 +0x\[0-9a-f\]+ in main .*"] \ + "entry_locexpr: bt" # Test @entry values for stack passed parameters. gdb_continue_to_breakpoint "entry_stack: stacktest" -gdb_test "bt" "^bt\r\n#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=s1@entry=11, s2=s2@entry=12, \[^\r\n\]+, d9=d9@entry=11\\.5, da=da@entry=12\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ - "entry_stack: bt at entry" +gdb_test "bt" \ + [multi_line \ + "^#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=s1@entry=11, s2=s2@entry=12, \[^\r\n\]+, d9=d9@entry=11\\.5, da=da@entry=12\\.5\\) \[^\r\n\]*" \ + "#1 +0x\[0-9a-f\]+ in main .*"] \ + "entry_stack: bt at entry" gdb_continue_to_breakpoint "entry_stack: breakhere_stacktest" -gdb_test "bt" "^bt\r\n#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=3, s1@entry=11, s2=4, s2@entry=12, \[^\r\n\]+, d9=3\\.5, d9@entry=11\\.5, da=4\\.5, da@entry=12\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ - "entry_stack: bt" +gdb_test "bt" \ + [multi_line \ + "^#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=3, s1@entry=11, s2=4, s2@entry=12, \[^\r\n\]+, d9=3\\.5, d9@entry=11\\.5, da=4\\.5, da@entry=12\\.5\\) \[^\r\n\]*" \ + "#1 +0x\[0-9a-f\]+ in main .*"] \ + "entry_stack: bt" gdb_test "p s1" " = 3" "entry_stack: p s1" gdb_test "p s1@entry" " = 11" "entry_stack: p s1@entry" @@ -202,8 +214,13 @@ gdb_test "p nodataparam@entry" "Cannot resolve DW_AT_call_data_value" "entry_ref gdb_continue_to_breakpoint "tailcall: breakhere" -gdb_test "bt" "^bt\r\n#0 +d *\\(i=71, i@entry=70, j=73\\.5, j@entry=72\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in c \\(i=i@entry=7, j=j@entry=7\\.25\\) \[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in b \\(i=i@entry=5, j=j@entry=5\\.25\\) \[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in main \[^\r\n\]*" \ - "tailcall: bt" +gdb_test "bt" \ + [multi_line \ + "^#0 +d *\\(i=71, i@entry=70, j=73\\.5, j@entry=72\\.5\\) \[^\r\n\]*" \ + "#1 +0x\[0-9a-f\]+ in c \\(i=i@entry=7, j=j@entry=7\\.25\\) \[^\r\n\]*" \ + "#2 +0x\[0-9a-f\]+ in b \\(i=i@entry=5, j=j@entry=5\\.25\\) \[^\r\n\]*" \ + "#3 +0x\[0-9a-f\]+ in main \[^\r\n\]*"] \ + "tailcall: bt" gdb_test "p i" " = 71" "tailcall: p i" gdb_test "p i@entry" " = 70" "tailcall: p i@entry" gdb_test "p j" " = 73\\.5" "tailcall: p j" @@ -243,8 +260,16 @@ gdb_test_multiple $test $test { gdb_continue_to_breakpoint "ambiguous: breakhere" -gdb_test "bt" "^bt\r\n#0 +d \\(i=, j=\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in amb_z \\(i=\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in amb_y \\(i=\\)\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in amb_x \\(i=\\)\[^\r\n\]*\r\n#4 +0x\[0-9a-f\]+ in amb_b \\(i=i@entry=101\\)\[^\r\n\]*\r\n#5 +0x\[0-9a-f\]+ in amb_a \\(i=i@entry=100\\)\[^\r\n\]*\r\n#6 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \ - "ambiguous: bt" +gdb_test "bt" \ + [multi_line \ + "^#0 +d \\(i=, j=\\)\[^\r\n\]*" \ + "#1 +0x\[0-9a-f\]+ in amb_z \\(i=\\)\[^\r\n\]*" \ + "#2 +0x\[0-9a-f\]+ in amb_y \\(i=\\)\[^\r\n\]*" \ + "#3 +0x\[0-9a-f\]+ in amb_x \\(i=\\)\[^\r\n\]*" \ + "#4 +0x\[0-9a-f\]+ in amb_b \\(i=i@entry=101\\)\[^\r\n\]*" \ + "#5 +0x\[0-9a-f\]+ in amb_a \\(i=i@entry=100\\)\[^\r\n\]*" \ + "#6 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*"] \ + "ambiguous: bt" # Test self tail calls verification. @@ -252,8 +277,14 @@ gdb_test "bt" "^bt\r\n#0 +d \\(i=, j=\\)\[^\r\n\]* gdb_continue_to_breakpoint "self: breakhere" -gdb_test "bt" "^bt\r\n#0 +d \\(i=, j=\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in self \\(i=\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in self2 \\(i=\\)\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in self \\(i=\\)\[^\r\n\]*\r\n#4 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \ - "self: bt" +gdb_test "bt" \ + [multi_line \ + "^#0 +d \\(i=, j=\\)\[^\r\n\]*" \ + "#1 +0x\[0-9a-f\]+ in self \\(i=\\)\[^\r\n\]*" \ + "#2 +0x\[0-9a-f\]+ in self2 \\(i=\\)\[^\r\n\]*" \ + "#3 +0x\[0-9a-f\]+ in self \\(i=\\)\[^\r\n\]*" \ + "#4 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*"] \ + "self: bt" gdb_test_no_output "set debug entry-values 1" gdb_test "bt" "DW_OP_entry_value resolving has found function \"self\\(int\\)\" at 0x\[0-9a-f\]+ can call itself via tail calls\r\n.*" \ diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp index 156300be1d9..c90b92cbf3f 100644 --- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp +++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp @@ -39,10 +39,10 @@ if ![runto breakpt] { return -1 } -gdb_test "bt" "^bt\r\n#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ +gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ "first backtrace, with error message" -gdb_test "bt" "^bt\r\n#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ +gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ "second backtrace, with error message" clean_restart ${binfile} diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp index b6a25f8525f..03edcef7fcc 100644 --- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp +++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp @@ -43,10 +43,10 @@ if ![runto breakpt] { # Use 'bt no-filters' here as the python filters will raise their own # error during initialisation, the no-filters case is simpler. -gdb_test "bt no-filters" "^bt no-filters\r\n#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ +gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ "first backtrace, with error message" -gdb_test "bt no-filters" "^bt no-filters\r\n#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ +gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \ "second backtrace, with error message" clean_restart ${binfile} diff --git a/gdb/testsuite/gdb.base/compare-sections.exp b/gdb/testsuite/gdb.base/compare-sections.exp index f24ff16f868..7fa89391b4d 100644 --- a/gdb/testsuite/gdb.base/compare-sections.exp +++ b/gdb/testsuite/gdb.base/compare-sections.exp @@ -38,7 +38,7 @@ proc compare_sections { {options ""} } { -re "MIS-MATCHED.*$gdb_prompt $" { fail $test } - -re "warning.*One or more sections.*does not match.*loaded file.*$gdb_prompt $" { + -re "warning: One or more sections.*does not match.*loaded file.*$gdb_prompt $" { fail $test } -re "Section.*matched.*$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.base/fullpath-expand.exp b/gdb/testsuite/gdb.base/fullpath-expand.exp index 285d0be08ec..82d3b24fe2a 100644 --- a/gdb/testsuite/gdb.base/fullpath-expand.exp +++ b/gdb/testsuite/gdb.base/fullpath-expand.exp @@ -41,8 +41,8 @@ if { $result != 0 || $realsrcfile2 == "" } { clean_restart ${testfile} -gdb_test "rbreak $realsrcfile2:func" "^rbreak \[^\r\n\]*:func\r\nBreakpoint 1 at 0x\[0-9a-f\]+: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\.\r\nvoid func\\(void\\);" "rbreak XXX/fullpath-expand-func.c:func" +gdb_test "rbreak $realsrcfile2:func" "^Breakpoint 1 at 0x\[0-9a-f\]+: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\.\r\nvoid func\\(void\\);" "rbreak XXX/fullpath-expand-func.c:func" # Verify the compilation pathnames are as expected: gdb_test "list func" "\tfunc \\(void\\)\r\n.*" -gdb_test "info source" "^info source\r\nCurrent source file is [string_to_regexp ${subdir}/${srcfile2}]\r\nCompilation directory is /.*" +gdb_test "info source" "^Current source file is [string_to_regexp ${subdir}/${srcfile2}]\r\nCompilation directory is /.*" diff --git a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp index 640c3be064c..ee58691fd3f 100644 --- a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp +++ b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp @@ -52,4 +52,4 @@ gdb_test_multiple "if 1\nshell ${shell_cmd}\nend\nPS1=\"$shell_prompt\"" $test { } # Check that we restore input in GDB correctly. -gdb_test "print 1" "^print 1\r\n.. = 1" "gdb input still works" +gdb_test "print 1" "^\\\$$decimal = 1" "gdb input still works" diff --git a/gdb/testsuite/gdb.base/new-ui-echo.exp b/gdb/testsuite/gdb.base/new-ui-echo.exp index efcc711e666..96181483752 100644 --- a/gdb/testsuite/gdb.base/new-ui-echo.exp +++ b/gdb/testsuite/gdb.base/new-ui-echo.exp @@ -103,10 +103,10 @@ proc echo_test {driver} { # Ensure echo remains enabled in both consoles. with_spawn_id $con1_spawn_id { - gdb_test "print 1" "^print 1\r\n\\\$1 = 1" "print on $con1_name echoes" + gdb_test "print 1" "\\\$1 = 1" "print on $con1_name echoes" } with_spawn_id $con2_spawn_id { - gdb_test "print 2" "^print 2\r\n\\\$2 = 2" "print on $con2_name echoes" + gdb_test "print 2" "\\\$2 = 2" "print on $con2_name echoes" } } diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp index 2056d80f6cc..a6a38fa94d4 100644 --- a/gdb/testsuite/gdb.base/new-ui.exp +++ b/gdb/testsuite/gdb.base/new-ui.exp @@ -28,7 +28,7 @@ proc ensure_no_output {message} { # Run a command and use an anchor to make sure no output appears # before the command's expected output. - gdb_test "print 999" "^print 999\r\n\\\$$decimal = 999" $message + gdb_test "print 999" "^\\\$$decimal = 999" $message } # Run a few execution-related commands on CON1, and ensure the proper @@ -121,10 +121,10 @@ proc_with_prefix do_test {} { # Ensure non-execution commands in one console don't cause output # in the other consoles. with_spawn_id $gdb_main_spawn_id { - gdb_test "print 1" "^print 1\r\n\\\$1 = 1" "print on main console" + gdb_test "print 1" "^\\\$1 = 1" "print on main console" } with_spawn_id $extra_spawn_id { - gdb_test "print 2" "^print 2\r\n\\\$2 = 2" "print on extra console" + gdb_test "print 2" "^\\\$2 = 2" "print on extra console" } # Verify that we get proper queries on the main UI, but that they are diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp index e54203924ec..eb127d246d2 100644 --- a/gdb/testsuite/gdb.base/settings.exp +++ b/gdb/testsuite/gdb.base/settings.exp @@ -540,7 +540,9 @@ proc test-string {variant} { # Checks that gdb doesn't crash if we haven't set the string yet. if {$variant != "filename"} { - gdb_test "$show_cmd" "^$show_cmd\r\n" "$show_cmd: show default" + # This odd expected output here is because we expect GDB to + # emit a single blank line as a result of this command. + gdb_test "$show_cmd" "^" "$show_cmd: show default" } else { gdb_test "$show_cmd" "/foo/bar" "$show_cmd: show default" } @@ -570,8 +572,9 @@ proc test-string {variant} { show_setting "$show_cmd" "\"hello world\"" } else { gdb_test_no_output "$set_cmd" - gdb_test "$show_cmd" \ - "^$show_cmd\r\n" "$show_cmd: empty second time" + # This odd expected output here is because we expect GDB to + # emit a single blank line as a result of this command. + gdb_test "$show_cmd" "^" "$show_cmd: empty second time" } } diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp index 338cf4b298c..de613a25f49 100644 --- a/gdb/testsuite/gdb.base/signals.exp +++ b/gdb/testsuite/gdb.base/signals.exp @@ -88,7 +88,7 @@ if {[runto_main]} { # ...call the function - gdb_test "p func1 ()" "^p func1 \\(\\)\r\n.\[0-9\]* = void" \ + gdb_test "p func1 ()" "^\\\$$decimal = void" \ "p func1 () #1" # ...veryfiy that the cout was updated diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp index 233dc30d509..ebe84c05992 100644 --- a/gdb/testsuite/gdb.base/with.exp +++ b/gdb/testsuite/gdb.base/with.exp @@ -54,14 +54,17 @@ proc test_with_error {setting tmp_val expected_re} { global gdb_prompt with_test_prefix "$setting, $tmp_val" { - set test "save org value" set org_val "" - gdb_test_multiple "maint show test-settings $setting" $test { - -re "(.*)\r\n$gdb_prompt $" { - set org_val $expect_out(1,string) - pass $test + gdb_test_multiple "maint show test-settings $setting" \ + "save org value" { + -re "^maint show test-settings $setting\r\n" { + exp_continue + } + -re "^(.*)\r\n$gdb_prompt $" { + set org_val $expect_out(1,string) + pass $gdb_test_name + } } - } gdb_test \ "maint with test-settings $setting $tmp_val -- p 1" \ diff --git a/gdb/testsuite/gdb.linespec/break-ask.exp b/gdb/testsuite/gdb.linespec/break-ask.exp index 8de8a958022..251f7dd76ba 100644 --- a/gdb/testsuite/gdb.linespec/break-ask.exp +++ b/gdb/testsuite/gdb.linespec/break-ask.exp @@ -68,7 +68,7 @@ gdb_test_multiple $cmd $test { pass $test } } -gdb_test "2" "^2\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." +gdb_test "2" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." gdb_breakpoint "body_elsewhere" @@ -88,7 +88,7 @@ gdb_test_multiple $cmd $test { pass $test } } -gdb_test "3" "^3\r\nBreakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." +gdb_test "3" "^Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file thefile\\.cc, line \[0-9a-f\]+\\." gdb_breakpoint "body_elsewhere" diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp index 9bcc90f06b4..4889c31aff3 100644 --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp @@ -500,7 +500,7 @@ proc ensure_no_output { test } { if { $gdb_spawn_id == $gdb_main_spawn_id } { # CLI gdb_test "print 666" \ - "^print 666\r\n\\\$$decimal = 666" \ + "^\\\$$decimal = 666" \ "$test, ensure no output CLI" } elseif { $gdb_spawn_id == $mi_spawn_id } { # MI diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp index 6897518a20e..f02fc861225 100644 --- a/gdb/testsuite/gdb.python/py-framefilter.exp +++ b/gdb/testsuite/gdb.python/py-framefilter.exp @@ -97,7 +97,7 @@ foreach bttype [list "bt" "bt full"] { pass $test } } - gdb_test "q" "^q\r\nQuit" "pagination quit - $bttype - q" + gdb_test "q" "^Quit" "pagination quit - $bttype - q" } gdb_test_no_output "set height unlimited" "pagination quit - set height unlimited" diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 8fe119fead1..7e9ddaa6fcd 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -69,7 +69,7 @@ with_test_prefix "python interactive help" { # The "quit" must be seen on the output. A buggy GDB # would not display it. - gdb_test "quit" "^quit.*leaving help.*" "quit help" + gdb_test "quit" "^\r\nYou are now leaving help.*" "quit help" } } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index d3245ec3b43..b4746651c15 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1400,10 +1400,12 @@ proc gdb_test_multiline { name args } { # # COMMAND is the command to execute, send to GDB with send_gdb. If # this is the null string no command is sent. -# PATTERN is the pattern to match for a PASS, and must NOT include -# the \r\n sequence immediately before the gdb prompt. This argument -# may be omitted to just match the prompt, ignoring whatever output -# precedes it. +# PATTERN is the pattern to match for a PASS, and must NOT include the +# \r\n sequence immediately before the gdb prompt (see -nonl below). +# This argument may be omitted to just match the prompt, ignoring +# whatever output precedes it. If PATTERN starts with '^' then +# PATTERN will be anchored such that it should match all output from +# COMMAND. # MESSAGE is an optional message to be printed. If this is # omitted, then the pass/fail messages use the command string as the # message. (If this is the empty string, then sometimes we don't @@ -1457,6 +1459,18 @@ proc gdb_test { args } { set saw_question 0 + # If the pattern starts with a '^' then we want to match all the + # output from COMMAND. To support this, here we inject an + # additional pattern that matches the command immediately after + # the '^'. + if {[string range $pattern 0 0] eq "^"} { + set command_regex [string_to_regexp $command] + set pattern [string range $pattern 1 end] + if {$command_regex ne ""} { + set pattern "^${command_regex}\r\n$pattern" + } + } + set user_code {} lappend user_code { -re "(?:$pattern)$nl$prompt" {