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 998783857723 for ; Tue, 25 Jul 2023 09:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 998783857723 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690279124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u3f4oTzCRuFjBiDgr3MA8CaWK5TjzWX5on1avMp51ac=; b=EABynEb92cEVul7wY/meLR3dtvEA5kAkhg3oGI852VdIzLTDvQ+4Dt5nnpRPsb/uvaYmW5 yxngov3A4X/IfiTwvyhFsEMJeRukEK6t/4PtbEZ5Pdwd+c7jM7dpv5Ml1nUVr7HrQsxjq8 CwAH+lWVaJIffpiZj5xvelJI/JxBQ7U= 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-248-Gr2vbPHmMUiSG7R-cdHMqQ-1; Tue, 25 Jul 2023 05:58:42 -0400 X-MC-Unique: Gr2vbPHmMUiSG7R-cdHMqQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA75C101A54E for ; Tue, 25 Jul 2023 09:58:42 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3070B492C13; Tue, 25 Jul 2023 09:58:42 +0000 (UTC) From: Bruno Larsen To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH 3/4] gdb/testsuite: fix testing gdb.reverse/step-reverse.exp with clang Date: Tue, 25 Jul 2023 11:58:32 +0200 Message-ID: <20230725095833.236804-4-blarsen@redhat.com> In-Reply-To: <20230725095833.236804-1-blarsen@redhat.com> References: <20230725095833.236804-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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-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 List-Id: 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. --- gdb/testsuite/gdb.reverse/step-precsave.exp | 18 +++++++++++++++++- gdb/testsuite/gdb.reverse/step-reverse.exp | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 2 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..1c45c6f645a 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_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" -- 2.41.0