From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7862) id CA1BA3858299; Thu, 22 Sep 2022 09:05:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA1BA3858299 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663837519; bh=evUhsBOaVjdZxCbtwXxA6h/B8WzrufY2MRWg+QYVXjY=; h=From:To:Subject:Date:From; b=FLIRD39JqM4+xgZuFnLdwvnUGwOcXEhbmRyiPaLMmjLGUGb5RpZnh+tg1UPuPEoM6 Uu/TXyyY8XeVLKz3GUXf1dmImAzQAmSQFuNB1W+egvZsqoW9c/aC+zreFhtUuisb2t 0yzYXgmbnKaOv9XIEfHiJ7i/ntmcVzIHZ2tngOBQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Bruno Larsen To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb.base/skip.exp: Use finish to exit functions X-Act-Checkin: binutils-gdb X-Git-Author: Bruno Larsen X-Git-Refname: refs/heads/master X-Git-Oldrev: 53d4a55bebf56c5ceb6bcf7ff43efd05043a0fc7 X-Git-Newrev: 7e1cd467b5c12b719c764fe219c7f6736ccf8c31 Message-Id: <20220922090519.CA1BA3858299@sourceware.org> Date: Thu, 22 Sep 2022 09:05:19 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7e1cd467b5c1= 2b719c764fe219c7f6736ccf8c31 commit 7e1cd467b5c12b719c764fe219c7f6736ccf8c31 Author: Bruno Larsen Date: Wed Jul 20 16:44:40 2022 -0300 gdb.base/skip.exp: Use finish to exit functions =20 gdb.base/skip.exp was making use of a fixed number 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: =20 Breakpoint 4, main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c= :32 32 x =3D 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.ba= se/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.ba= se/skip.c:60 60 skip1_test_skip_file_and_function (); (gdb) FAIL: gdb.base/skip.exp: step after disabling 3: step 5 =20 This shows that the feature is working but because the inferior lands in a different location, it registers as a failure. Seeing as along with this difference, there are also some differences that depend on gcc versions (where gdb might stop back at line 32 before entering foo), it would not be easy to test for this behavior using steps and analzing where the inferior stops at each point. On the other hand, using gdb_step_until is not feasible because we'd possibly gloss over stepping into baz and rendering the whole test useless. 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 us= ed: =20 Breakpoint 4, main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c= :32 32 x =3D 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.bas= e/skip1.c:21 main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:32 32 x =3D baz ((bar (), foo ())); Value returned is $2 =3D 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.bas= e/skip.c:42 main () at binutils-gdb/gdb/testsuite/gdb.base/skip.c:32 32 x =3D baz ((bar (), foo ())); Value returned is $3 =3D 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 ski= p baz Diff: --- gdb/testsuite/gdb.base/skip.exp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.= exp index e6b660004d9..0864e445f13 100644 --- a/gdb/testsuite/gdb.base/skip.exp +++ b/gdb/testsuite/gdb.base/skip.exp @@ -100,6 +100,14 @@ if ![runto_main] { gdb_test "step" ".*" "step in the main" gdb_test "bt" "\\s*\\#0\\s+main.*" "step after all ignored" =20 +# This proc tests that GDB can step into the function foo, exit it +# and skip the functions bar and baz. +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(= ). =20 @@ -117,21 +125,19 @@ with_test_prefix "step after deleting 1" { return } =20 - 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 } =20 # 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" =20 # 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 +150,8 @@ proc step_bar_foo_skip_baz {} { } } =20 - 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" } =20 # Now disable the skiplist entry for skip1.c. We should now @@ -178,9 +184,7 @@ with_test_prefix "step after enable 3" { return } =20 - 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 } =20 # Admin tests (disable,enable,delete). @@ -249,9 +253,7 @@ with_test_prefix "step using -fi" { =20 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 } =20 with_test_prefix "step using -gfi" { @@ -261,9 +263,7 @@ with_test_prefix "step using -gfi" { =20 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 } =20 with_test_prefix "step using -fu for baz" {