From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 F2BBC3858C51 for ; Tue, 17 May 2022 16:38:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F2BBC3858C51 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-154-Gz76YIziPHaGj1Z3mRAJ3g-1; Tue, 17 May 2022 12:38:05 -0400 X-MC-Unique: Gz76YIziPHaGj1Z3mRAJ3g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC8A21C0F680 for ; Tue, 17 May 2022 16:38:04 +0000 (UTC) Received: from [10.97.116.34] (ovpn-116-34.gru2.redhat.com [10.97.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 769FD2166B2F for ; Tue, 17 May 2022 16:38:04 +0000 (UTC) Message-ID: <259a0597-147c-050b-5631-d4e91d1bc3b9@redhat.com> Date: Tue, 17 May 2022 13:38:02 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step To: "gdb-patches@sourceware.org" References: <20220411201333.81453-1-blarsen@redhat.com> <20220411201333.81453-4-blarsen@redhat.com> From: Bruno Larsen In-Reply-To: <20220411201333.81453-4-blarsen@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Tue, 17 May 2022 16:38:08 -0000 This patch no longer applies, and has non-trivial merge conflicts. However, the rest of the series does not depend on this patch, so please continue reviewing the rest and ignore this specific patch. Cheers! Bruno Larsen On 4/11/22 17:13, Bruno Larsen wrote: > skip.exp was making use of a fixed amount of step commands to exit > some functions. This caused some problems when testing GDB with clang, > as it doesn't add epilogue information for functions, along with some > unreliable results depending on the version of GCC, as sometimes gdb > could stop in either of the 2 lines after 2 steps: > > x = bax ((bar (), foo ())) > test_skip_file_and_function (); > > whereas using clang will always stop on the second line after 1 step. > To deal with GCC unreliability, this test case used to use the question > mechanism from gdb_test, but Pedro mentioned that this is a mis-use of > that feature, and it doesn't deal with the clang case. This commit > changes it to use gdb_test_multiple and deal with all possible cases, > only considering it a pass when test_skip_file_and_function () is > reached. > --- > gdb/testsuite/gdb.base/skip.exp | 164 +++++++++++++++++++++++++------- > 1 file changed, 131 insertions(+), 33 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp > index 7c71bb07a84..5021b696668 100644 > --- a/gdb/testsuite/gdb.base/skip.exp > +++ b/gdb/testsuite/gdb.base/skip.exp > @@ -117,9 +117,23 @@ 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" > + gdb_test "step" "foo \\(\\) at.*" "step" > + # step until we are after foo and bar calls, while making sure that > + # we never step into baz. > + gdb_test_multiple "step" "step until main" { > + # gcc stop in this line before continuing > + -re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*\}\r\n$gdb_prompt $" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*test_skip_file_and_function \\(\\).*" { > + pass "step until main" > + } > + } > } > > # Now disable the skiplist entry for skip1.c. We should now > @@ -137,13 +151,27 @@ with_test_prefix "step after disabling 3" { > } > > gdb_test "step" "bar \\(\\) at.*" "step 1" > - gdb_test "step" ".*" "step 2"; # Return from bar() > - # With gcc 9.2.0 we jump once back to main before entering foo here. > - # If that happens try to step a second time. > - gdb_test "step" "foo \\(\\) at.*" "step 3" \ > - "main \\(\\) at .*\r\n$gdb_prompt " "step" > - gdb_test "step" ".*" "step 4"; # Return from foo() > - gdb_test "step" "main \\(\\) at.*" "step 5" > + # guarantee that we jump once back to main before entering foo here. > + # This makes behavior more consistent over different compilers and > + # different compiler versions > + gdb_test "finish" ".*" "finish 1"; # Return to main() > + gdb_test "step" "foo \\(\\) at.*" "step 2" > + # step until we are after foo and bar calls, while making sure that > + # we never step into baz. > + gdb_test_multiple "step" "step until main" { > + # gcc stop in this line before continuing > + -re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*\}\r\n$gdb_prompt $" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*test_skip_file_and_function \\(\\).*" { > + pass "step until main" > + } > + } > } > > # Enable skiplist entry 3 and make sure we step over it like before. > @@ -159,9 +187,23 @@ 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" > + gdb_test "step" "foo \\(\\) at.*" "step" > + # step until we are after foo and bar calls, while making sure that > + # we never step into baz. > + gdb_test_multiple "step" "step until main" { > + # gcc stop in this line before continuing > + -re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*\}\r\n$gdb_prompt $" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*test_skip_file_and_function \\(\\).*" { > + pass "step until main" > + } > + } > } > > # Admin tests (disable,enable,delete). > @@ -230,9 +272,23 @@ 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" > + gdb_test "step" "foo \\(\\) at.*" "step" > + # step until we are after foo and bar calls, while making sure that > + # we never step into baz. > + gdb_test_multiple "step" "step until main" { > + # gcc stop in this line before continuing > + -re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*\}\r\n$gdb_prompt $" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*test_skip_file_and_function \\(\\).*" { > + pass "step until main" > + } > + } > } > > with_test_prefix "step using -gfi" { > @@ -242,9 +298,23 @@ 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" > + gdb_test "step" "foo \\(\\) at.*" "step" > + # step until we are after foo and bar calls, while making sure that > + # we never step into baz. > + gdb_test_multiple "step" "step until main" { > + # gcc stop in this line before continuing > + -re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*\}\r\n$gdb_prompt $" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*test_skip_file_and_function \\(\\).*" { > + pass "step until main" > + } > + } > } > > with_test_prefix "step using -fu for baz" { > @@ -255,13 +325,27 @@ with_test_prefix "step using -fu for baz" { > gdb_test_no_output "skip disable" > gdb_test_no_output "skip enable 7" > gdb_test "step" "bar \\(\\) at.*" "step 1" > - gdb_test "step" ".*" "step 2"; # Return from bar() > - # With gcc 9.2.0 we jump once back to main before entering foo here. > - # If that happens try to step a second time. > - gdb_test "step" "foo \\(\\) at.*" "step 3" \ > - "main \\(\\) at .*\r\n$gdb_prompt " "step" > - gdb_test "step" ".*" "step 4"; # Return from foo() > - gdb_test "step" "main \\(\\) at.*" "step 5" > + # guarantee that we jump once back to main before entering foo here. > + # This makes behavior more consistent over different compilers and > + # different compiler versions > + gdb_test "finish" ".*" "finish 1"; # Return to main() > + gdb_test "step" "foo \\(\\) at.*" "step 2" > + # step until we are after foo and bar calls, while making sure that > + # we never step into baz. > + gdb_test_multiple "step" "step until main" { > + # gcc stop in this line before continuing > + -re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*\}\r\n$gdb_prompt $" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*test_skip_file_and_function \\(\\).*" { > + pass "step until main" > + } > + } > } > > with_test_prefix "step using -rfu for baz" { > @@ -272,13 +356,27 @@ with_test_prefix "step using -rfu for baz" { > gdb_test_no_output "skip disable" > gdb_test_no_output "skip enable 8" > gdb_test "step" "bar \\(\\) at.*" "step 1" > - gdb_test "step" ".*" "step 2"; # Return from bar() > - # With gcc 9.2.0 we jump once back to main before entering foo here. > - # If that happens try to step a second time. > - gdb_test "step" "foo \\(\\) at.*" "step 3" \ > - "main \\(\\) at .*\r\n$gdb_prompt " "step" > - gdb_test "step" ".*" "step 4"; # Return from foo() > - gdb_test "step" "main \\(\\) at.*" "step 5" > + # guarantee that we jump once back to main before entering foo here. > + # This makes behavior more consistent over different compilers and > + # different compiler versions > + gdb_test "finish" ".*" "finish 1"; # Return to main() > + gdb_test "step" "foo \\(\\) at.*" "step 2" > + # step until we are after foo and bar calls, while making sure that > + # we never step into baz. > + gdb_test_multiple "step" "step until main" { > + # gcc stop in this line before continuing > + -re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*\}\r\n$gdb_prompt $" { > + send_gdb "step\n" > + exp_continue > + } > + -re ".*test_skip_file_and_function \\(\\).*" { > + pass "step until main" > + } > + } > } > > # Test -fi + -fu.