From patchwork Thu Jul 27 07:41:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 73254 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 9387F3856DC6 for ; Thu, 27 Jul 2023 07:42:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9387F3856DC6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690443727; bh=Be7TTNAscMSjkG66BkP00LpJuFZkTJ2Dq9I8xSVOJSc=; 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=ed4r3b+2typyiCmEwXPDCUmvb9N4v+3zX9T1BTxg4m81rHikPUO1TujOIOF/Zw4LN 4CnioaDYg8JxVvLnHP120PFiQfwT3hKjL48DqUAW5FOMITxVO5dW0zrBPEUIzlk4Bc d9j2hgPHCskfJxA7jpHS2NXqCtZ/ACiZr4CHfYEM= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 52F3A385AF89 for ; Thu, 27 Jul 2023 07:41:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52F3A385AF89 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-645-8u5ICVdbNTCJeHpuRzV_vQ-1; Thu, 27 Jul 2023 03:41:41 -0400 X-MC-Unique: 8u5ICVdbNTCJeHpuRzV_vQ-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 781E185A58A for ; Thu, 27 Jul 2023 07:41:41 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F29084094DC1; Thu, 27 Jul 2023 07:41:40 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH v2 1/4] gdb/testsuite: Fix many errors in gdb.reverse with clang Date: Thu, 27 Jul 2023 09:41:15 +0200 Message-ID: <20230727074118.1583199-2-blarsen@redhat.com> In-Reply-To: <20230727074118.1583199-1-blarsen@redhat.com> References: <20230725095833.236804-1-blarsen@redhat.com> <20230727074118.1583199-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.5 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_H4, RCVD_IN_MSPIKE_WL, 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-Patchwork-Original-From: Bruno Larsen via Gdb-patches From: Guinevere Larsen Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Clang does not add line information for lines that only contain a closing } in functions. Many tests in the gdb.reverse folder set a breakpoint in that line, but don't seem to use information available after the return statement is executed, so this commit moves the breakpoint to the previous line, where the return statement is. --- gdb/testsuite/gdb.reverse/break-reverse.c | 4 ++-- gdb/testsuite/gdb.reverse/finish-reverse.c | 4 ++-- gdb/testsuite/gdb.reverse/watch-reverse.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/break-reverse.c b/gdb/testsuite/gdb.reverse/break-reverse.c index 5f54a8f2bd7..4ae459f1bba 100644 --- a/gdb/testsuite/gdb.reverse/break-reverse.c +++ b/gdb/testsuite/gdb.reverse/break-reverse.c @@ -33,5 +33,5 @@ int main () { xyz = 0; /* break in main */ foo (); - return (xyz == 2 ? 0 : 1); -} /* end of main */ + return (xyz == 2 ? 0 : 1); /* end of main */ +} diff --git a/gdb/testsuite/gdb.reverse/finish-reverse.c b/gdb/testsuite/gdb.reverse/finish-reverse.c index 609a14568a5..cc056ecfa8a 100644 --- a/gdb/testsuite/gdb.reverse/finish-reverse.c +++ b/gdb/testsuite/gdb.reverse/finish-reverse.c @@ -123,6 +123,6 @@ int main (int argc, char **argv) testval.double_testval = 3.14159265358979323846; /* float_checkpoint */ double_resultval = double_func (); main_test = 1; /* double_checkpoint */ - return 0; -} /* end of main */ + return 0; /* end of main */ +} diff --git a/gdb/testsuite/gdb.reverse/watch-reverse.c b/gdb/testsuite/gdb.reverse/watch-reverse.c index 8b7d1be0db5..e1b024af10b 100644 --- a/gdb/testsuite/gdb.reverse/watch-reverse.c +++ b/gdb/testsuite/gdb.reverse/watch-reverse.c @@ -206,6 +206,6 @@ int main () func4 (); - return 0; -} /* end of main */ + return 0; /* end of main */ +} From patchwork Thu Jul 27 07:41:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 73257 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 E4BF93857027 for ; Thu, 27 Jul 2023 07:42:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4BF93857027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690443744; bh=zYqkhN4uCC9aC6qcSDDwCTSxegdqc+lO3LRlt5Q5spo=; 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=RlMhRmIRoP7QXNP5xeldMJ6G1cEke6teQOpz+QIrBQJP42HbWrhNOZedqPk9APCI3 vRQi2SW7xZgm7i28dLN506kxrtn/jDosYX7oX/EvLLAAmLhjJS7O3nNuxPy8LF/iNw 2l332PX4emdXZ6o9/So9uFCStNS4iebkjqH0u+Y4= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 50A5F385702B for ; Thu, 27 Jul 2023 07:41:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50A5F385702B Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-433-3k3FVWf2O3KYWivL20tFKQ-1; Thu, 27 Jul 2023 03:41:57 -0400 X-MC-Unique: 3k3FVWf2O3KYWivL20tFKQ-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 393963814957 for ; Thu, 27 Jul 2023 07:41:42 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2A714094DC1; Thu, 27 Jul 2023 07:41:41 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH v2 2/4] gdb/testsuite: fix gdb.reverse/solib-*.exp tests when using clang Date: Thu, 27 Jul 2023 09:41:16 +0200 Message-ID: <20230727074118.1583199-3-blarsen@redhat.com> In-Reply-To: <20230727074118.1583199-1-blarsen@redhat.com> References: <20230725095833.236804-1-blarsen@redhat.com> <20230727074118.1583199-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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_H4, RCVD_IN_MSPIKE_WL, 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-Patchwork-Original-From: Bruno Larsen via Gdb-patches From: Guinevere Larsen Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The tests gdb.reverse/solib-precsave.exp and solib-reverse.exp have the assumption that line tables will have an entry for the closing } in a function. Not all compiles do this, one example being clang. To fix this, this commit changes the function in shr2.c to have multiple lines, and the test to accept either line as a correct step location. To properly re-sync the inferiors, the function repeat_cmd_until had to be slightly changed to work with empty "current locations", so that we are able to step through multiple lines. This also changes the annotations used to determine the breakpoint locations in solib-reverse.c, adding a simple variable assignment right before the return statement. This way GDB will not set a breakpoint in the closing } line. --- gdb/testsuite/gdb.reverse/shr2.c | 3 ++- gdb/testsuite/gdb.reverse/solib-precsave.exp | 24 ++++++++++++++++---- gdb/testsuite/gdb.reverse/solib-reverse.c | 5 ++-- gdb/testsuite/gdb.reverse/solib-reverse.exp | 24 ++++++++++++++++---- gdb/testsuite/lib/gdb.exp | 6 ++--- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/shr2.c b/gdb/testsuite/gdb.reverse/shr2.c index 84a03de1b8c..16c3bf3bc6c 100644 --- a/gdb/testsuite/gdb.reverse/shr2.c +++ b/gdb/testsuite/gdb.reverse/shr2.c @@ -19,7 +19,8 @@ int shr2(int x) { - return 2*x; + int y = 2*x; + return y; } int shr2_local(int x) diff --git a/gdb/testsuite/gdb.reverse/solib-precsave.exp b/gdb/testsuite/gdb.reverse/solib-precsave.exp index 3ca73828063..f89969222c6 100644 --- a/gdb/testsuite/gdb.reverse/solib-precsave.exp +++ b/gdb/testsuite/gdb.reverse/solib-precsave.exp @@ -140,8 +140,17 @@ gdb_test_multiple "reverse-step" "reverse-step into solib function one" { pass $gdb_test_name } } -gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one" -gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one" +# Depending on wether the closing } has a line associated, we might have +# different acceptable results here +gdb_test_multiple "reverse-step" "reverse-step within solib function one" { + -re -wrap "return y;.*" { + pass $gdb_test_name + } + -re -wrap "int y =.*" { + pass $gdb_test_name + } +} +repeat_cmd_until "reverse-step" "" "main .. at" "reverse-step back to main one" gdb_test_multiple "reverse-step" "reverse-step into solib function two" { -re -wrap "begin part two.*" { @@ -152,8 +161,15 @@ gdb_test_multiple "reverse-step" "reverse-step into solib function two" { pass $gdb_test_name } } -gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two" -gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two" +gdb_test_multiple "reverse-step" "reverse-step within solib function two" { + -re -wrap "return y;.*" { + pass $gdb_test_name + } + -re -wrap "int y =.*" { + pass $gdb_test_name + } +} +repeat_cmd_until "reverse-step" "" "main .. at" "reverse-step back to main two" # # Test reverse-next over debuggable solib function diff --git a/gdb/testsuite/gdb.reverse/solib-reverse.c b/gdb/testsuite/gdb.reverse/solib-reverse.c index 7aa60089df3..20288e0bee8 100644 --- a/gdb/testsuite/gdb.reverse/solib-reverse.c +++ b/gdb/testsuite/gdb.reverse/solib-reverse.c @@ -43,6 +43,7 @@ int main () shr1 ("message 2\n"); /* shr1 two */ shr1 ("message 3\n"); /* shr1 three */ - return 0; /* end part one */ -} /* end of main */ + b[0] = 0; /* end part one */ + return 0; /* end of main */ +} diff --git a/gdb/testsuite/gdb.reverse/solib-reverse.exp b/gdb/testsuite/gdb.reverse/solib-reverse.exp index c061086a8d7..afc4659184a 100644 --- a/gdb/testsuite/gdb.reverse/solib-reverse.exp +++ b/gdb/testsuite/gdb.reverse/solib-reverse.exp @@ -116,8 +116,17 @@ gdb_test_multiple "reverse-step" "reverse-step into solib function one" { pass $gdb_test_name } } -gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function one" -gdb_test "reverse-step" " middle part two.*" "reverse-step back to main one" +# Depending on wether the closing } has a line associated, we might have +# different acceptable results here +gdb_test_multiple "reverse-step" "reverse-step within solib function one" { + -re -wrap "return y;.*" { + pass $gdb_test_name + } + -re -wrap "int y =.*" { + pass $gdb_test_name + } +} +repeat_cmd_until "reverse-step" "" "main .. at" "reverse-step back to main one" gdb_test_multiple "reverse-step" "reverse-step into solib function two" { -re -wrap "begin part two.*" { @@ -128,8 +137,15 @@ gdb_test_multiple "reverse-step" "reverse-step into solib function two" { pass $gdb_test_name } } -gdb_test "reverse-step" "return 2.x.*" "reverse-step within solib function two" -gdb_test "reverse-step" " begin part two.*" "reverse-step back to main two" +gdb_test_multiple "reverse-step" "reverse-step within solib function two" { + -re -wrap "return y;.*" { + pass $gdb_test_name + } + -re -wrap "int y =.*" { + pass $gdb_test_name + } +} +repeat_cmd_until "reverse-step" "" "main .. at" "reverse-step back to main two" # # Test reverse-next over debuggable solib function diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 66c04a2efe2..63b6291fc36 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9679,6 +9679,9 @@ proc repeat_cmd_until { command current target \ set count 0 gdb_test_multiple "$command" "$test_name" { + -re "$target.*$gdb_prompt $" { + pass "$test_name" + } -re "$current.*$gdb_prompt $" { incr count if { $count < $max_steps } { @@ -9688,9 +9691,6 @@ proc repeat_cmd_until { command current target \ fail "$test_name" } } - -re "$target.*$gdb_prompt $" { - pass "$test_name" - } } } From patchwork Thu Jul 27 07:41:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 73255 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 49809385AFB1 for ; Thu, 27 Jul 2023 07:42:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49809385AFB1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690443733; bh=BkowRi3WnnSbhYv3USM2+g79CIjEbW8OrvBMTHDD0II=; 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=CHmGEV1jkR7GNsVjLaSwfGokYmrqgL0Z9TzsichbCbEUOs+W7rGHtyTcz4boYPn7j O5tX2BnJylcKlc4ypbOnyn6E4ryVFi9UxgNe9zFfCPnSyo/p0GkO1qkEOmnHrlvCWz pvhxtcvKl9r6ekpF1VilIfv+oNnfXDCqKxNzvvjk= 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 4D0B23856DCD for ; Thu, 27 Jul 2023 07:41:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D0B23856DCD Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-298-Jul8au60Obaa9-e5LWElcA-1; Thu, 27 Jul 2023 03:41:43 -0400 X-MC-Unique: Jul8au60Obaa9-e5LWElcA-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 ED28B1C4766D for ; Thu, 27 Jul 2023 07:41:42 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7429E4094DC1; Thu, 27 Jul 2023 07:41:42 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH v2 3/4] gdb/testsuite: fix testing gdb.reverse/step-reverse.exp with clang Date: Thu, 27 Jul 2023 09:41:17 +0200 Message-ID: <20230727074118.1583199-4-blarsen@redhat.com> In-Reply-To: <20230727074118.1583199-1-blarsen@redhat.com> References: <20230725095833.236804-1-blarsen@redhat.com> <20230727074118.1583199-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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_H4, RCVD_IN_MSPIKE_WL, 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-Patchwork-Original-From: Bruno Larsen via Gdb-patches From: Guinevere Larsen Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" When testing using reverse-stepi to fully step through a function, the code checks for an infinite loop by seeing if we land on the line that contains the return statement multiple times. This assumption only works if there is only one instruction associated with that line, which is how GCC handles line information, but other compilers may handle it differently. Clang-15, for instance, associates 6. Because of this, the inferior used to get seriously out of sync with the test expectations, and result in 13 spurious failures. The same issue occurs with gdb.reverse/step-precsave.exp. This commit changes the test so that we check for PC instead of line number. The test still only happens when the same line is detected, to simplify the resulting log. With this change, no new failures are emitted when using clang. It also adds a new parameter to get_hexadecimal_valueof, so that we can use it without generating new passes, otherwise we'd get multiple duplicate test names. This change shouldn't affect any other test using this proc. --- gdb/testsuite/gdb.reverse/step-precsave.exp | 18 +++++++++++++++++- gdb/testsuite/gdb.reverse/step-reverse.exp | 20 +++++++++++++++++++- gdb/testsuite/lib/gdb.exp | 6 ++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp index 19cd5d9930e..da3a47e07e2 100644 --- a/gdb/testsuite/gdb.reverse/step-precsave.exp +++ b/gdb/testsuite/gdb.reverse/step-precsave.exp @@ -30,6 +30,16 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } +proc get_current_pc {} { + set pc 0 + gdb_test_multiple "print \$pc" "" { + -re -wrap ".*0x(\[0-9a-f\]+).*" { + set pc $expect_out(1,string) + } + } + return $pc +} + runto_main # Activate process record/replay @@ -209,11 +219,17 @@ gdb_test_multiple "stepi" "$test_message" { # stepi backward out of a function call +set start_pc [get_current_pc] set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"] set test_message "reverse stepi from a function call" gdb_test_multiple "stepi" "$test_message" { -re "ARRIVED IN CALLEE.*$gdb_prompt $" { - fail "$test_message (start statement)" + if { [get_current_pc] == $start_pc } { + fail "$test_message (start statement)" + } else { + send_gdb "stepi\n" + exp_continue + } } -re "ENTER CALLEE.*$gdb_prompt $" { send_gdb "stepi\n" diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp index 4b78a8f8fb7..9ff97bfde42 100644 --- a/gdb/testsuite/gdb.reverse/step-reverse.exp +++ b/gdb/testsuite/gdb.reverse/step-reverse.exp @@ -28,6 +28,16 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 } +proc get_current_pc {} { + set pc 0 + gdb_test_multiple "print \$pc" "" { + -re -wrap ".*0x(\[0-9a-f\]+).*" { + set pc $expect_out(1,string) + } + } + return $pc +} + runto_main if [supports_process_record] { @@ -174,11 +184,19 @@ gdb_test_multiple "stepi" "$test_message" { # stepi backward out of a function call +# When testing stepi, we dont want to infinitely step if we're not moving +# so we store the starting PC, in case we land on the same line as above +set start_pc [get_hexadecimal_valueof "\$pc" 0 "" "false"] set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"] set test_message "reverse stepi from a function call" gdb_test_multiple "stepi" "$test_message" { -re "ARRIVED IN CALLEE.*$gdb_prompt $" { - fail "$test_message (start statement)" + if { [get_hexadecimal_valueof "\$pc" 0 "" "false"] == $start_pc } { + fail "$test_message (start statement)" + } else { + send_gdb "stepi\n" + exp_continue + } } -re "ENTER CALLEE.*$gdb_prompt $" { send_gdb "stepi\n" diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 63b6291fc36..37342583e0a 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -7919,7 +7919,7 @@ proc get_integer_valueof { exp default {test ""} } { # TEST is the test message to use. It can be omitted, in which case # a test message is built from EXP. -proc get_hexadecimal_valueof { exp default {test ""} } { +proc get_hexadecimal_valueof { exp default {test ""} {pass true} } { global gdb_prompt if {$test == ""} { @@ -7930,7 +7930,9 @@ proc get_hexadecimal_valueof { exp default {test ""} } { gdb_test_multiple "print /x ${exp}" $test { -re "\\$\[0-9\]* = (0x\[0-9a-zA-Z\]+).*$gdb_prompt $" { set val $expect_out(1,string) - pass "$test" + if { "$pass" == "true" } { + pass "$test" + } } } return ${val} From patchwork Thu Jul 27 07:41:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 73256 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 EAB4E3853D34 for ; Thu, 27 Jul 2023 07:42:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAB4E3853D34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690443734; bh=E2VlXJ0Sh+gis11UBOsVBKAjSYcMAMX9wuu1/7cPXMY=; 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=AG9ql8lxKAu54gM2Frvyb8ChO4XpX8V6sVhgN49nK/wQYRhyJKOCktQ4wQs336w9I 3RMaQPH4y1FUKlq6r/92yQzF77djyrL2km1JYHlaMKYrFkcHchIuaKM+vowv+CzeT/ yPDz2iy6tT3/h757ltxlDfKMJLi3fWpwOxnSslYY= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id C451D385AF84 for ; Thu, 27 Jul 2023 07:41:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C451D385AF84 Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-605-lCqp5ZLMP9CrYeKBAtZSMw-1; Thu, 27 Jul 2023 03:41:44 -0400 X-MC-Unique: lCqp5ZLMP9CrYeKBAtZSMw-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 D0E241C47667 for ; Thu, 27 Jul 2023 07:41:43 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33F5E4094DC1; Thu, 27 Jul 2023 07:41:43 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH v2 4/4] gdb/testsuite: Multiple improvements for gdb.reverse/insn-reverse.exp Date: Thu, 27 Jul 2023 09:41:18 +0200 Message-ID: <20230727074118.1583199-5-blarsen@redhat.com> In-Reply-To: <20230727074118.1583199-1-blarsen@redhat.com> References: <20230725095833.236804-1-blarsen@redhat.com> <20230727074118.1583199-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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_H4, RCVD_IN_MSPIKE_WL, 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-Patchwork-Original-From: Bruno Larsen via Gdb-patches From: Guinevere Larsen Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This commits tackles 2 problems in the test gdb.reverse/insn-reverse.exp. They are, broadly: flawed logic when an unexpected error occurs, and badly formed asm expressions. For the first, what happens is that if the inferior stops progressing for some reason, the test will emit an UNSUPPORTED and continue testing by reversing from the current location and checking all registers for every instruction. However, due to how the outputs are indexed in the test, this early exit will cause most of the subsequent tests to be de-synced and will emit many unrelated failures. This commit changes the UNSUPPORTED for a FAIL, since the test has in fact failed to record the execution of the whole function, and decrements the recorded instruction count by one so that the indexes are in sync once more. At the time of committing, this reduces the amount of failures when testing with clang-15 from around 150 to 2, and correctly identifies where the issue lies. The second problem is in how the asm statements in the *-x86.c file are written. As an example, let's examine the following line: __asm__ volatile ("rdrand %%ebp;" : "=r" (number)); This statement says that number is being used as the output variable, but is not indicating which registers were clobbered so that the compiler is able to properly output. GCC decides to just not save anything, whereas clang assumes that the output is in %rax, and writes it to the variable. This hid the problem that any compiler is not good at dealing with asm statements that change the rbp register. It can be seen more explicitly by informing gcc that rbp has been clobbered like so: __asm__ volatile ("rdrand %%ebp;" : "=r" (number) : : "%ebp"); This statement gets compiled into the following assembly: rdrandl %ebp movl %eax, -4(%rbp) Which is clearly using the incorrect rbp to find the memory location of the variable. Since the test only exercises GDB's ability to record the register changes, this commit removes the output to memory. Finally, correctly informing the compiler of clobbered registers makes gcc throw an error that the rsp is no longer usable at the end of the function. To avoid that, this commit compresses the 3 asm statements that would save, change and reset registers into a single asm statement. --- gdb/testsuite/gdb.reverse/insn-reverse-x86.c | 324 +++++++++---------- gdb/testsuite/gdb.reverse/insn-reverse.exp | 4 +- 2 files changed, 165 insertions(+), 163 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/insn-reverse-x86.c b/gdb/testsuite/gdb.reverse/insn-reverse-x86.c index da9999e9942..2b4fb4c10e0 100644 --- a/gdb/testsuite/gdb.reverse/insn-reverse-x86.c +++ b/gdb/testsuite/gdb.reverse/insn-reverse-x86.c @@ -64,100 +64,100 @@ rdrand (void) return; /* 16-bit random numbers. */ - __asm__ volatile ("rdrand %%ax;" : "=r" (number)); - __asm__ volatile ("rdrand %%bx;" : "=r" (number)); - __asm__ volatile ("rdrand %%cx;" : "=r" (number)); - __asm__ volatile ("rdrand %%dx;" : "=r" (number)); + __asm__ volatile ("rdrand %%ax;": : : "%ax"); + __asm__ volatile ("rdrand %%bx;": : : "%bx"); + __asm__ volatile ("rdrand %%cx;": : : "%cx"); + __asm__ volatile ("rdrand %%dx;": : : "%dx"); - __asm__ volatile ("mov %%di, %%ax;" : "=r" (number)); - __asm__ volatile ("rdrand %%di;" : "=r" (number)); - __asm__ volatile ("mov %%ax, %%di;" : "=r" (number)); + __asm__ volatile ("mov %%di, %%ax;\n\ + rdrand %%di;\n\ + mov %%ax, %%di;" : : : "%ax"); - __asm__ volatile ("mov %%si, %%ax;" : "=r" (number)); - __asm__ volatile ("rdrand %%si;" : "=r" (number)); - __asm__ volatile ("mov %%ax, %%si;" : "=r" (number)); + __asm__ volatile ("mov %%si, %%ax;\n\ + rdrand %%si;\n\ + mov %%ax, %%si;" : : : "%ax"); - __asm__ volatile ("mov %%bp, %%ax;" : "=r" (number)); - __asm__ volatile ("rdrand %%bp;" : "=r" (number)); - __asm__ volatile ("mov %%ax, %%bp;" : "=r" (number)); + __asm__ volatile ("mov %%bp, %%ax;\n\ + rdrand %%bp;\n\ + mov %%ax, %%bp;" : : : "%ax"); - __asm__ volatile ("mov %%sp, %%ax;" : "=r" (number)); - __asm__ volatile ("rdrand %%sp;" : "=r" (number)); - __asm__ volatile ("mov %%ax, %%sp;" : "=r" (number)); + __asm__ volatile ("mov %%sp, %%ax;\n\ + rdrand %%sp;\n\ + mov %%ax, %%sp;" : : : "%ax"); #ifdef __x86_64__ - __asm__ volatile ("rdrand %%r8w;" : "=r" (number)); - __asm__ volatile ("rdrand %%r9w;" : "=r" (number)); - __asm__ volatile ("rdrand %%r10w;" : "=r" (number)); - __asm__ volatile ("rdrand %%r11w;" : "=r" (number)); - __asm__ volatile ("rdrand %%r12w;" : "=r" (number)); - __asm__ volatile ("rdrand %%r13w;" : "=r" (number)); - __asm__ volatile ("rdrand %%r14w;" : "=r" (number)); - __asm__ volatile ("rdrand %%r15w;" : "=r" (number)); + __asm__ volatile ("rdrand %%r8w;": : : "%r8"); + __asm__ volatile ("rdrand %%r9w;": : : "%r9"); + __asm__ volatile ("rdrand %%r10w;": : : "%r10"); + __asm__ volatile ("rdrand %%r11w;": : : "%r11"); + __asm__ volatile ("rdrand %%r12w;": : : "%r12"); + __asm__ volatile ("rdrand %%r13w;": : : "%r13"); + __asm__ volatile ("rdrand %%r14w;": : : "%r14"); + __asm__ volatile ("rdrand %%r15w;": : : "%r15"); #endif /* 32-bit random numbers. */ - __asm__ volatile ("rdrand %%eax;" : "=r" (number)); - __asm__ volatile ("rdrand %%ebx;" : "=r" (number)); - __asm__ volatile ("rdrand %%ecx;" : "=r" (number)); - __asm__ volatile ("rdrand %%edx;" : "=r" (number)); + __asm__ volatile ("rdrand %%eax;": : : "%eax"); + __asm__ volatile ("rdrand %%ebx;": : : "%ebx"); + __asm__ volatile ("rdrand %%ecx;": : : "%ecx"); + __asm__ volatile ("rdrand %%edx;": : : "%edx"); #ifdef __x86_64__ - __asm__ volatile ("mov %%rdi, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%edi;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rdi;" : "=r" (number)); - - __asm__ volatile ("mov %%rsi, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%esi;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rsi;" : "=r" (number)); - - __asm__ volatile ("mov %%rbp, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%ebp;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rbp;" : "=r" (number)); - - __asm__ volatile ("mov %%rsp, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%esp;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rsp;" : "=r" (number)); - - __asm__ volatile ("rdrand %%r8d;" : "=r" (number)); - __asm__ volatile ("rdrand %%r9d;" : "=r" (number)); - __asm__ volatile ("rdrand %%r10d;" : "=r" (number)); - __asm__ volatile ("rdrand %%r11d;" : "=r" (number)); - __asm__ volatile ("rdrand %%r12d;" : "=r" (number)); - __asm__ volatile ("rdrand %%r13d;" : "=r" (number)); - __asm__ volatile ("rdrand %%r14d;" : "=r" (number)); - __asm__ volatile ("rdrand %%r15d;" : "=r" (number)); + __asm__ volatile ("mov %%rdi, %%rax;\n\ + rdrand %%edi;\n\ + mov %%rax, %%rdi;" : : : "%rax"); + + __asm__ volatile ("mov %%rsi, %%rax;\n\ + rdrand %%esi;\n\ + mov %%rax, %%rsi;" : : : "%rax"); + + __asm__ volatile ("mov %%rbp, %%rax;\n\ + rdrand %%ebp;\n\ + mov %%rax, %%rbp;" : : : "%rax"); + + __asm__ volatile ("mov %%rsp, %%rax;\n\ + rdrand %%esp;\n\ + mov %%rax, %%rsp;" : : : "%rax"); + + __asm__ volatile ("rdrand %%r8d;": : : "%r8"); + __asm__ volatile ("rdrand %%r9d;": : : "%r9"); + __asm__ volatile ("rdrand %%r10d;": : : "%r10"); + __asm__ volatile ("rdrand %%r11d;": : : "%r11"); + __asm__ volatile ("rdrand %%r12d;": : : "%r12"); + __asm__ volatile ("rdrand %%r13d;": : : "%r13"); + __asm__ volatile ("rdrand %%r14d;": : : "%r14"); + __asm__ volatile ("rdrand %%r15d;": : : "%r15"); /* 64-bit random numbers. */ - __asm__ volatile ("rdrand %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%rbx;" : "=r" (number)); - __asm__ volatile ("rdrand %%rcx;" : "=r" (number)); - __asm__ volatile ("rdrand %%rdx;" : "=r" (number)); - - __asm__ volatile ("mov %%rdi, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%rdi;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rdi;" : "=r" (number)); - - __asm__ volatile ("mov %%rsi, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%rsi;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rsi;" : "=r" (number)); - - __asm__ volatile ("mov %%rbp, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%rbp;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rbp;" : "=r" (number)); - - __asm__ volatile ("mov %%rsp, %%rax;" : "=r" (number)); - __asm__ volatile ("rdrand %%rsp;" : "=r" (number)); - __asm__ volatile ("mov %%rax, %%rsp;" : "=r" (number)); - - __asm__ volatile ("rdrand %%r8;" : "=r" (number)); - __asm__ volatile ("rdrand %%r9;" : "=r" (number)); - __asm__ volatile ("rdrand %%r10;" : "=r" (number)); - __asm__ volatile ("rdrand %%r11;" : "=r" (number)); - __asm__ volatile ("rdrand %%r12;" : "=r" (number)); - __asm__ volatile ("rdrand %%r13;" : "=r" (number)); - __asm__ volatile ("rdrand %%r14;" : "=r" (number)); - __asm__ volatile ("rdrand %%r15;" : "=r" (number)); + __asm__ volatile ("rdrand %%rax;": : : "%rax"); + __asm__ volatile ("rdrand %%rbx;": : : "%rbx"); + __asm__ volatile ("rdrand %%rcx;": : : "%rcx"); + __asm__ volatile ("rdrand %%rdx;": : : "%rdx"); + + __asm__ volatile ("mov %%rdi, %%rax;\n\ + rdrand %%rdi;\n\ + mov %%rax, %%rdi;" : : : "%rax"); + + __asm__ volatile ("mov %%rsi, %%rax;\n\ + rdrand %%rsi;\n\ + mov %%rax, %%rsi;" : : : "%rax"); + + __asm__ volatile ("mov %%rbp, %%rax;\n\ + rdrand %%rbp;\n\ + mov %%rax, %%rbp;" : : : "%rax"); + + __asm__ volatile ("mov %%rsp, %%rax;\n\ + rdrand %%rsp;\n\ + mov %%rax, %%rsp;" : : : "%rax"); + + __asm__ volatile ("rdrand %%r8;": : : "%r8"); + __asm__ volatile ("rdrand %%r9;": : : "%r9"); + __asm__ volatile ("rdrand %%r10;": : : "%r10"); + __asm__ volatile ("rdrand %%r11;": : : "%r11"); + __asm__ volatile ("rdrand %%r12;": : : "%r12"); + __asm__ volatile ("rdrand %%r13;": : : "%r13"); + __asm__ volatile ("rdrand %%r14;": : : "%r14"); + __asm__ volatile ("rdrand %%r15;": : : "%r15"); #endif } @@ -173,100 +173,100 @@ rdseed (void) return; /* 16-bit random seeds. */ - __asm__ volatile ("rdseed %%ax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%bx;" : "=r" (seed)); - __asm__ volatile ("rdseed %%cx;" : "=r" (seed)); - __asm__ volatile ("rdseed %%dx;" : "=r" (seed)); + __asm__ volatile ("rdseed %%ax;": : : "%ax"); + __asm__ volatile ("rdseed %%bx;": : : "%bx"); + __asm__ volatile ("rdseed %%cx;": : : "%cx"); + __asm__ volatile ("rdseed %%dx;": : : "%dx"); - __asm__ volatile ("mov %%di, %%ax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%di;" : "=r" (seed)); - __asm__ volatile ("mov %%ax, %%di;" : "=r" (seed)); + __asm__ volatile ("mov %%di, %%ax;\n\ + rdseed %%di;\n\ + mov %%ax, %%di;" : : : "%ax"); - __asm__ volatile ("mov %%si, %%ax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%si;" : "=r" (seed)); - __asm__ volatile ("mov %%ax, %%si;" : "=r" (seed)); + __asm__ volatile ("mov %%si, %%ax;\n\ + rdseed %%si;\n\ + mov %%ax, %%si;" : : : "%ax"); - __asm__ volatile ("mov %%bp, %%ax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%bp;" : "=r" (seed)); - __asm__ volatile ("mov %%ax, %%bp;" : "=r" (seed)); + __asm__ volatile ("mov %%bp, %%ax;\n\ + rdseed %%bp;\n\ + mov %%ax, %%bp;" : : : "%ax"); - __asm__ volatile ("mov %%sp, %%ax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%sp;" : "=r" (seed)); - __asm__ volatile ("mov %%ax, %%sp;" : "=r" (seed)); + __asm__ volatile ("mov %%sp, %%ax;\n\ + rdseed %%sp;\n\ + mov %%ax, %%sp;" : : : "%ax"); #ifdef __x86_64__ - __asm__ volatile ("rdseed %%r8w;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r9w;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r10w;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r11w;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r12w;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r13w;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r14w;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r15w;" : "=r" (seed)); + __asm__ volatile ("rdseed %%r8w;": : : "%r8"); + __asm__ volatile ("rdseed %%r9w;": : : "%r9"); + __asm__ volatile ("rdseed %%r10w;": : : "%r10"); + __asm__ volatile ("rdseed %%r11w;": : : "%r11"); + __asm__ volatile ("rdseed %%r12w;": : : "%r12"); + __asm__ volatile ("rdseed %%r13w;": : : "%r13"); + __asm__ volatile ("rdseed %%r14w;": : : "%r14"); + __asm__ volatile ("rdseed %%r15w;": : : "%r15"); #endif /* 32-bit random seeds. */ - __asm__ volatile ("rdseed %%eax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%ebx;" : "=r" (seed)); - __asm__ volatile ("rdseed %%ecx;" : "=r" (seed)); - __asm__ volatile ("rdseed %%edx;" : "=r" (seed)); + __asm__ volatile ("rdseed %%eax;": : : "%eax"); + __asm__ volatile ("rdseed %%ebx;": : : "%ebx"); + __asm__ volatile ("rdseed %%ecx;": : : "%ecx"); + __asm__ volatile ("rdseed %%edx;": : : "%edx"); #ifdef __x86_64__ - __asm__ volatile ("mov %%rdi, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%edi;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rdi;" : "=r" (seed)); - - __asm__ volatile ("mov %%rsi, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%esi;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rsi;" : "=r" (seed)); - - __asm__ volatile ("mov %%rbp, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%ebp;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rbp;" : "=r" (seed)); - - __asm__ volatile ("mov %%rsp, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%esp;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rsp;" : "=r" (seed)); - - __asm__ volatile ("rdseed %%r8d;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r9d;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r10d;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r11d;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r12d;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r13d;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r14d;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r15d;" : "=r" (seed)); + __asm__ volatile ("mov %%rdi, %%rax;\n\ + rdseed %%edi;\n\ + mov %%rax, %%rdi;" : : : "%rax"); + + __asm__ volatile ("mov %%rsi, %%rax;\n\ + rdseed %%esi;\n\ + mov %%rax, %%rsi;" : : : "%rax"); + + __asm__ volatile ("mov %%rbp, %%rax;\n\ + rdseed %%ebp;\n\ + mov %%rax, %%rbp;" : : : "%rax"); + + __asm__ volatile ("mov %%rsp, %%rax;\n\ + rdseed %%esp;\n\ + mov %%rax, %%rsp;" : : : "%rax"); + + __asm__ volatile ("rdseed %%r8d;": : : "%r8"); + __asm__ volatile ("rdseed %%r9d;": : : "%r9"); + __asm__ volatile ("rdseed %%r10d;": : : "%r10"); + __asm__ volatile ("rdseed %%r11d;": : : "%r11"); + __asm__ volatile ("rdseed %%r12d;": : : "%r12"); + __asm__ volatile ("rdseed %%r13d;": : : "%r13"); + __asm__ volatile ("rdseed %%r14d;": : : "%r14"); + __asm__ volatile ("rdseed %%r15d;": : : "%r15"); /* 64-bit random seeds. */ - __asm__ volatile ("rdseed %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%rbx;" : "=r" (seed)); - __asm__ volatile ("rdseed %%rcx;" : "=r" (seed)); - __asm__ volatile ("rdseed %%rdx;" : "=r" (seed)); - - __asm__ volatile ("mov %%rdi, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%rdi;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rdi;" : "=r" (seed)); - - __asm__ volatile ("mov %%rsi, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%rsi;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rsi;" : "=r" (seed)); - - __asm__ volatile ("mov %%rbp, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%rbp;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rbp;" : "=r" (seed)); - - __asm__ volatile ("mov %%rsp, %%rax;" : "=r" (seed)); - __asm__ volatile ("rdseed %%rsp;" : "=r" (seed)); - __asm__ volatile ("mov %%rax, %%rsp;" : "=r" (seed)); - - __asm__ volatile ("rdseed %%r8;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r9;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r10;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r11;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r12;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r13;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r14;" : "=r" (seed)); - __asm__ volatile ("rdseed %%r15;" : "=r" (seed)); + __asm__ volatile ("rdseed %%rax;": : : "%rax"); + __asm__ volatile ("rdseed %%rbx;": : : "%rbx"); + __asm__ volatile ("rdseed %%rcx;": : : "%rcx"); + __asm__ volatile ("rdseed %%rdx;": : : "%rdx"); + + __asm__ volatile ("mov %%rdi, %%rax;\n\ + rdseed %%rdi;\n\ + mov %%rax, %%rdi;" : : : "%rax"); + + __asm__ volatile ("mov %%rsi, %%rax;\n\ + rdseed %%rsi;\n\ + mov %%rax, %%rsi;" : : : "%rax"); + + __asm__ volatile ("mov %%rbp, %%rax;\n\ + rdseed %%rbp;\n\ + mov %%rax, %%rbp;" : : : "%rax"); + + __asm__ volatile ("mov %%rsp, %%rax;\n\ + rdseed %%rsp;\n\ + mov %%rax, %%rsp;" : : : "%rax"); + + __asm__ volatile ("rdseed %%r8;": : : "%r8"); + __asm__ volatile ("rdseed %%r9;": : : "%r9"); + __asm__ volatile ("rdseed %%r10;": : : "%r10"); + __asm__ volatile ("rdseed %%r11;": : : "%r11"); + __asm__ volatile ("rdseed %%r12;": : : "%r12"); + __asm__ volatile ("rdseed %%r13;": : : "%r13"); + __asm__ volatile ("rdseed %%r14;": : : "%r14"); + __asm__ volatile ("rdseed %%r15;": : : "%r15"); #endif } diff --git a/gdb/testsuite/gdb.reverse/insn-reverse.exp b/gdb/testsuite/gdb.reverse/insn-reverse.exp index 1a575b2d43e..206e765dd50 100644 --- a/gdb/testsuite/gdb.reverse/insn-reverse.exp +++ b/gdb/testsuite/gdb.reverse/insn-reverse.exp @@ -95,7 +95,9 @@ proc test { func testcase_nr } { if { $prev_insn_addr == $insn_addr } { # Failed to make progress, might have run into SIGILL. - unsupported "no progress at: $expect_out(2,string)" + fail "no progress at: $expect_out(2,string)" + # Ignore the last instruction recorded + incr count -1 break }