From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +P2AC+Bb2GLkTRcAWB0awg (envelope-from ) for ; Wed, 20 Jul 2022 15:47:44 -0400 Received: by simark.ca (Postfix, from userid 112) id 2BA431E5EA; Wed, 20 Jul 2022 15:47:44 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=TYoW8eTg; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8B4F71E21F for ; Wed, 20 Jul 2022 15:47:43 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3BCF5385AE42 for ; Wed, 20 Jul 2022 19:47:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BCF5385AE42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1658346463; bh=zakJLtuLfUfLoNGocd8P/F0iEHf88b7qrERH+C4kX4U=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TYoW8eTgdwjS1KM962kDMUg5v6WYmsxmrprW7CvUUC1BXU1u0svhM4yCK1jLymz15 tQu6FSrQCpXatvDgyYRAYAB2buT5Eim3zwg2/ktCWQis81iBUsYjLKbVLr/h0Jwsb7 rthg8fe6wODIYIW20PTg4+QfnIUOrmPSOKc2o1tw= 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 12D4D385829A for ; Wed, 20 Jul 2022 19:45:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 12D4D385829A Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-mKpYbUPgPUiOknjNNfp9Kw-1; Wed, 20 Jul 2022 15:45:10 -0400 X-MC-Unique: mKpYbUPgPUiOknjNNfp9Kw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8D60C85A585 for ; Wed, 20 Jul 2022 19:45:10 +0000 (UTC) Received: from blarsen.com (ovpn-116-8.gru2.redhat.com [10.97.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E53E840D2962; Wed, 20 Jul 2022 19:45:09 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH v4 14/15] gdb.base/skip.exp: Use finish to exit functions Date: Wed, 20 Jul 2022 16:44:40 -0300 Message-Id: <20220720194441.168906-16-blarsen@redhat.com> In-Reply-To: <20220720194441.168906-1-blarsen@redhat.com> References: <20220720194441.168906-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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: , From: Bruno Larsen via Gdb-patches Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" gdb.base/skip.exp was making use of a fixed amount of step commands to exit some functions. This caused some problems when using clang to test GDB, as GDB would need fewer steps to reach the desired spots. For instance, when testing in the section "step after disabling 3", the log looks like this: Breakpoint 4, main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:32 32 x = baz ((bar (), foo ())); (gdb) step bar () at binutils-gdb/gdb/testsuite/gdb.base/skip1.c:21 21 return 1; (gdb) PASS: gdb.base/skip.exp: step after disabling 3: step 1 step foo () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:42 42 return 0; (gdb) PASS: gdb.base/skip.exp: step after disabling 3: step 2 step main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:34 34 test_skip_file_and_function (); (gdb) step test_skip_file_and_function () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:59 59 test_skip (); (gdb) FAIL: gdb.base/skip.exp: step after disabling 3: step 3 step test_skip () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:48 48 } (gdb) PASS: gdb.base/skip.exp: step after disabling 3: step 4 step test_skip_file_and_function () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:60 60 skip1_test_skip_file_and_function (); (gdb) FAIL: gdb.base/skip.exp: step after disabling 3: step 5 This shows that the feature is working, but it is not easy to use steps to test this feature without analyzing all possible outputs, such as using gdb_step_until_regexp. Instead, skip.exp now uses finish to leave functions, synchronizing through compilers and compiler versions. Some test names were also changed to be a bit more descriptive. The new log looks like this, independently of compiler used: Breakpoint 4, main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:32 32 x = baz ((bar (), foo ())); (gdb) step bar () at binutils-gdb/gdb/testsuite/gdb.base/skip1.c:21 21 return 1; (gdb) PASS: gdb.base/skip.exp: step after disabling 3: step into bar finish Run till exit from #0 bar () at binutils-gdb/gdb/testsuite/gdb.base/skip1.c:21 main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:32 32 x = baz ((bar (), foo ())); Value returned is $2 = 1 (gdb) PASS: gdb.base/skip.exp: step after disabling 3: return from bar step foo () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:42 42 return 0; (gdb) PASS: gdb.base/skip.exp: step after disabling 3: step into foo finish Run till exit from #0 foo () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:42 main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:32 32 x = baz ((bar (), foo ())); Value returned is $3 = 0 (gdb) PASS: gdb.base/skip.exp: step after disabling 3: Return from foo step 34 test_skip_file_and_function (); (gdb) PASS: gdb.base/skip.exp: step after disabling 3: step and skip baz --- gdb/testsuite/gdb.base/skip.exp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp index e6b660004d9..5b08cde93b7 100644 --- a/gdb/testsuite/gdb.base/skip.exp +++ b/gdb/testsuite/gdb.base/skip.exp @@ -100,6 +100,12 @@ if ![runto_main] { gdb_test "step" ".*" "step in the main" gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored" +proc step_foo_skip_bar_baz {} { + gdb_test "step" "foo \\(\\) at.*" "step and skip bar" + gdb_test "finish" ".*" "return from bar" + gdb_test "step" ".*test_skip_file_and_function.*" "step and skip baz" +} + # Now remove skip.c from the skiplist. Our first step should take us # into foo(), and our second step should take us to the next line in main(). @@ -117,21 +123,19 @@ with_test_prefix "step after deleting 1" { return } - gdb_test "step" "foo \\(\\) at.*" "step 1" - gdb_test "step" ".*" "step 2" ; # Return from foo() - gdb_test "step" "main \\(\\) at.*" "step 3" + step_foo_skip_bar_baz } # Test that we step into foo(), then into bar(), but not into baz(). proc step_bar_foo_skip_baz {} { - gdb_test "step" "bar \\(\\) at.*" "step 1" - gdb_test "step" ".*" "step 2"; # Return from bar() + gdb_test "step" "bar \\(\\) at.*" "step into bar" + gdb_test "finish" ".*" "return from bar" # With at least gcc 6.5.0 and 9.2.0, we jump once back to main # before entering foo here. If that happens try to step a second # time. set stepped_again 0 - gdb_test_multiple "step" "step 3" { + gdb_test_multiple "step" "step into foo" { -re -wrap "foo \\(\\) at.*" { pass $gdb_test_name } @@ -144,8 +148,8 @@ proc step_bar_foo_skip_baz {} { } } - gdb_test "step" ".*" "step 4"; # Return from foo() - gdb_test "step" "main \\(\\) at.*" "step 5" + gdb_test "finish" ".*" "Return from foo" + gdb_test "step" ".*test_skip_file_and_function.*" "step and skip baz" } # Now disable the skiplist entry for skip1.c. We should now @@ -178,9 +182,7 @@ with_test_prefix "step after enable 3" { return } - gdb_test "step" "foo \\(\\) at.*" "step 1" - gdb_test "step" ".*" "step 2"; # Return from foo() - gdb_test "step" "main \\(\\) at.*" "step 3" + step_foo_skip_bar_baz } # Admin tests (disable,enable,delete). @@ -249,9 +251,7 @@ with_test_prefix "step using -fi" { gdb_test_no_output "skip disable" gdb_test_no_output "skip enable 5" - gdb_test "step" "foo \\(\\) at.*" "step 1" - gdb_test "step" ".*" "step 2"; # Return from foo() - gdb_test "step" "main \\(\\) at.*" "step 3" + step_foo_skip_bar_baz } with_test_prefix "step using -gfi" { @@ -261,9 +261,7 @@ with_test_prefix "step using -gfi" { gdb_test_no_output "skip disable" gdb_test_no_output "skip enable 6" - gdb_test "step" "foo \\(\\) at.*" "step 1" - gdb_test "step" ".*" "step 2"; # Return from foo() - gdb_test "step" "main \\(\\) at.*" "step 3" + step_foo_skip_bar_baz } with_test_prefix "step using -fu for baz" { -- 2.31.1