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 C02263858C20 for ; Mon, 14 Aug 2023 10:52:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C02263858C20 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=1692010326; 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=RKBsXkPJjQ1r6OPxJRochYzB582itXyNrAMu8zjz0eo=; b=HWcycVjhMIZ8XgU4OgnIz9fNvtS3kci0crX23oAUxLnhQSHp5jyFSSkfY4M3ElbVRUZf2v OgVWvBrmsbWq3yQzHvzAqX2O289joy1RBRxOHMLLThZ2Wr9OQRRnrPJu4q5mB21cbUlL4/ SKYv9hkbeG/VVwVOwLlq2IeTQyDVGiA= 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-520-PtQ-Ie3OM7eRbe1Z_lfl4A-1; Mon, 14 Aug 2023 06:52:04 -0400 X-MC-Unique: PtQ-Ie3OM7eRbe1Z_lfl4A-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADC23381AE41 for ; Mon, 14 Aug 2023 10:52:04 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.118]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34335492C13; Mon, 14 Aug 2023 10:52:04 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH v3 3/4] gdb/testsuite: fix testing gdb.reverse/step-reverse.exp with clang Date: Mon, 14 Aug 2023 12:48:19 +0200 Message-ID: <20230814104819.207097-5-blarsen@redhat.com> In-Reply-To: <20230814104819.207097-2-blarsen@redhat.com> References: <20230814104819.207097-2-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.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 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. 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 | 10 +++++++++- gdb/testsuite/gdb.reverse/step-reverse.exp | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp index 19cd5d9930e..e2971621c57 100644 --- a/gdb/testsuite/gdb.reverse/step-precsave.exp +++ b/gdb/testsuite/gdb.reverse/step-precsave.exp @@ -209,11 +209,19 @@ gdb_test_multiple "stepi" "$test_message" { # stepi backward out of a function call +set start_pc [get_hexadecimal_valueof "\$pc" 0 "getting PC at start of stepi backwards"] +set step_count 0 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)" + incr step_count + if { [get_hexadecimal_valueof "\$pc" 0 "getting PC after $step_count steps"] == $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..b7d00fb4bd3 100644 --- a/gdb/testsuite/gdb.reverse/step-reverse.exp +++ b/gdb/testsuite/gdb.reverse/step-reverse.exp @@ -174,11 +174,21 @@ 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 "get PC at start"] +set get_pc_count 0 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)" + incr get_pc_count + if { [get_hexadecimal_valueof "\$pc" 0 "get PC again $get_pc_count"] == $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