From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1983) id 0F424385840D; Fri, 4 Nov 2022 16:07:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F424385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667578073; bh=NRH/bEwLpWxlaUUsshx+1hC0QuzYh1O+k0SiLfqHsmQ=; h=From:To:Subject:Date:From; b=Yp6ElrCXdelPiFVSzd/dLVO7vHu1eGZByuHRRDwRLIiQ8HaVnhB+bg6+F7yDikU+4 IEQVhXJJLwmwmTUaBbezxP1Pp26WsqlOk15kaczszzMuWqzBEBFRiRmUsslrCMn1n+ lF9tcBat+SdLIADg2Gbw27+5rChEAOKPNM5sGKYs= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Carl Love To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Powerpc fix for gdb.base/unwind-on-each-insn.exp X-Act-Checkin: binutils-gdb X-Git-Author: Carl Love X-Git-Refname: refs/heads/master X-Git-Oldrev: ac87b20a96adec653af45253fc3b2daf1a0710eb X-Git-Newrev: 91836f41e209a60a8a836faef2e7889e144df297 Message-Id: <20221104160753.0F424385840D@sourceware.org> Date: Fri, 4 Nov 2022 16:07:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D91836f41e209= a60a8a836faef2e7889e144df297 commit 91836f41e209a60a8a836faef2e7889e144df297 Author: Carl Love Date: Fri Nov 4 12:06:37 2022 -0400 Powerpc fix for gdb.base/unwind-on-each-insn.exp =20 The test disassembles function foo and searches for the line "End of assembler dump" to determing the last address in the function. = The assumption is the last instruction will be given right before the line "End of assembler dump". This assumption fails on PowerPC. =20 The PowerPC disassembly of the function foo 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. =20 The blr instruction is the last instruction in function foo. The lines with .long following the blr instruction need to be ignored. =20 This patch adds a new condition to the gdb_test_multiple "disassemble f= oo" test to ignore the lines with the .long. =20 The patch has been tested on PowerPC and Intel X86-64. Diff: --- gdb/testsuite/gdb.base/unwind-on-each-insn.exp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp b/gdb/testsuite= /gdb.base/unwind-on-each-insn.exp index 3b48805cff8..d8863ad2895 100644 --- a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp @@ -75,6 +75,24 @@ 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 @@ -84,6 +102,10 @@ gdb_test_multiple "disassemble foo" "" { exp_continue } =20 + -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