From patchwork Thu Jan 19 10:46:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 63392 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 CC8D8385B508 for ; Thu, 19 Jan 2023 10:46:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC8D8385B508 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674125201; bh=NgMEZTu3kRgFDD4+yVRDwGGA0e9Onyvy5fucS89vzNM=; 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=lgHpruGKvutMmSjS6njUkwHov/6BNiTiINXbkepJPWPC9+//UCXhnqflScUUEF6iX c1ok3co+a2Hxz2vN5opTTfm0yaPPPSIIred5nxmRVC6cJYcjZIxhR7rgqGQ9TNmGhm TDr9+m4PVuL6jwiUZRe+xv1G2bl5SJO+6EPAn8BU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 05E383858C53 for ; Thu, 19 Jan 2023 10:46:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05E383858C53 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 389165CC61; Thu, 19 Jan 2023 10:46:19 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 170E6139ED; Thu, 19 Jan 2023 10:46:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UC1+BHsfyWOMJwAAMHmgww (envelope-from ); Thu, 19 Jan 2023 10:46:19 +0000 To: gdb-patches@sourceware.org Cc: Bruno Larsen , Andrew Burgess , Luis Machado Subject: [PATCH 1/4] [gdb/testsuite] Simplify gdb.base/unwind-on-each-insn.exp Date: Thu, 19 Jan 2023 11:46:15 +0100 Message-Id: <20230119104618.15503-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230119104618.15503-1-tdevries@suse.de> References: <20230119104618.15503-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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 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: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" In test-case gdb.base/unwind-on-each-insn.exp, we try to determine the last insn in function foo. This in it self is fragile, as demonstrated by commit 91836f41e20 ("Powerpc fix for gdb.base/unwind-on-each-insn.exp"). But the purpose of finding the last insn is to stop stepping in foo when arriving at that last insn. There is however no guarantee that: - the last insn is actually executed, nor - that the last insn is executed last, nor - that the last insn is executed once. Fix this by simplying the test-case to continue stepping till stepping out of foo. Tested on x86_64-linux. --- .../gdb.base/unwind-on-each-insn.exp | 62 ++++--------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp index c8748d5ae14..5e822effaf1 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp @@ -73,51 +73,6 @@ set main_fid [get_fid] gdb_breakpoint "*foo" gdb_continue_to_breakpoint "enter foo" -# Figure out the range of addresses covered by this function. -set last_addr_in_foo "" - -# The disassembly of foo on PowerPC looks like: -# Dump of assembler code for function foo: -# => 0x00000000100006dc <+0>: std r31,-8(r1) -# 0x00000000100006e0 <+4>: stdu r1,-48(r1) -# 0x00000000100006e4 <+8>: mr r31,r1 -# 0x00000000100006e8 <+12>: nop -# 0x00000000100006ec <+16>: addi r1,r31,48 -# 0x00000000100006f0 <+20>: ld r31,-8(r1) -# 0x00000000100006f4 <+24>: blr -# 0x00000000100006f8 <+28>: .long 0x0 -# 0x00000000100006fc <+32>: .long 0x0 -# 0x0000000010000700 <+36>: .long 0x1000180 -# End of assembler dump. -# -# The last instruction in function foo is blr. Need to ignore the .long -# entries following the blr instruction. - -gdb_test_multiple "disassemble foo" "" { - -re "^disassemble foo\r\n" { - exp_continue - } - - -re "^Dump of assembler code for function foo:\r\n" { - exp_continue - } - - -re "^...($hex) \[<>+0-9:\s\t\]*\.long\[\s\t\]*\[^\r\n\]*\r\n" { - exp_continue - } - - -re "^...($hex) \[^\r\n\]+\r\n" { - set last_addr_in_foo $expect_out(1,string) - exp_continue - } - - -wrap -re "^End of assembler dump\\." { - gdb_assert { ![string equal $last_addr_in_foo ""] } \ - "found some addresses in foo" - pass $gdb_test_name - } -} - # Record the current stack-pointer, and the frame base address. lassign [get_sp_and_fba "in foo"] foo_sp foo_fba set foo_fid [get_fid] @@ -158,11 +113,6 @@ for { set i_count 1 } { true } { incr i_count } { # Move back to the inner most frame. gdb_test "frame 0" ".*" - set pc [get_hexadecimal_valueof "\$pc" "*UNKNOWN*"] - if { $pc == $last_addr_in_foo } { - break - } - if { $i_count > 100 } { # We expect a handful of instructions, if we reach 100, # something is going wrong. Avoid an infinite loop. @@ -170,6 +120,16 @@ for { set i_count 1 } { true } { incr i_count } { break } - gdb_test "stepi" ".*" + set in_foo 0 + gdb_test_multiple "stepi" "" { + -re -wrap "$hex in foo \\(\\)" { + set in_foo 1 + } + -re -wrap "" {} + } + + if { ! $in_foo } { + break + } } }