From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 183EC3858D32; Mon, 23 Jan 2023 09:32:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 183EC3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674466370; bh=P0tHvxrJfCE0BPyQUX4U8cbVLoWca6LFSb8TWxNev5Q=; h=From:To:Subject:Date:From; b=Ev5UWu0OaNaaeXxiqwQQ1D94PkJi0yrb2txijHXWuBgnYfarg8iAhbVaxWs0uLejb qayyTiaYxGzJtWTskxSaFNGoAvFtBZaM5V0PTteIuJAxz7TdiimDh1XwODIkVvsYRP 0txkgd5XnQKASq/BD2BS4q7zRYeyfGjUtAfw3OGE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Simplify gdb.base/unwind-on-each-insn.exp X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: bc0c6793fb45b491c6324614298a2880a34d3966 X-Git-Newrev: 36025e8f484a9d1a6ecc5f436344b1d7a09f470b Message-Id: <20230123093250.183EC3858D32@sourceware.org> Date: Mon, 23 Jan 2023 09:32:50 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D36025e8f484a= 9d1a6ecc5f436344b1d7a09f470b commit 36025e8f484a9d1a6ecc5f436344b1d7a09f470b Author: Tom de Vries Date: Mon Jan 23 10:32:45 2023 +0100 [gdb/testsuite] Simplify gdb.base/unwind-on-each-insn.exp =20 In test-case gdb.base/unwind-on-each-insn.exp, we try to determine the = last disassembled insn in function foo. =20 This in it self is fragile, as demonstrated by commit 91836f41e20 ("Pow= erpc fix for gdb.base/unwind-on-each-insn.exp"). =20 The use of the last disassembled insn in the test-case is to stop stepp= ing in foo once reaching it. =20 However, the intent is to stop stepping just before returning to main. =20 There is no guarantee that the last disassembled insn: - is actually executed - is executed just before returning to main - is executed only once. =20 Fix this by simplying the test-case to continue stepping till stepping = out of foo. =20 Tested on x86_64-linux. Diff: --- gdb/testsuite/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" =20 -# 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: -# =3D> 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" ".*" =20 - set pc [get_hexadecimal_valueof "\$pc" "*UNKNOWN*"] - if { $pc =3D=3D $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 } =20 - 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 + } } }