From patchwork Wed Nov 2 17:03:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 59798 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 B76643857031 for ; Wed, 2 Nov 2022 17:03:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B76643857031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667408626; bh=vpAPat/SMfCyMzF7l0lXHH379WNX0kMcTooLcF7kwYQ=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=DJdaIW/O2ZVg8r9neczGJFMaKQ9t3hmBnyMAxKRoAJnik4mAw1k7FM9mifg891aEn JrENRfJkXTC5u8rZx50F4tq+Jso8xCMVkYWJTxMqadxX3sJ2aGwkbEdw5rM2m93ar0 5n7DzfckkalUV6ReDJUkgtirQ64DFtM3FlMR4kVw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 8B39438582A6 for ; Wed, 2 Nov 2022 17:03:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B39438582A6 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A2G3co2023305 for ; Wed, 2 Nov 2022 17:03:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kkmqg17s6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 02 Nov 2022 17:03:19 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2A2GGAx3025434 for ; Wed, 2 Nov 2022 17:03:18 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kkmqg17r7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Nov 2022 17:03:18 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2A2GooUW007148; Wed, 2 Nov 2022 17:03:17 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02dal.us.ibm.com with ESMTP id 3kgutajyc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Nov 2022 17:03:17 +0000 Received: from smtpav04.dal12v.mail.ibm.com ([9.208.128.131]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2A2H3KAR49742100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Nov 2022 17:03:20 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 225015804E; Wed, 2 Nov 2022 17:03:16 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4A9158063; Wed, 2 Nov 2022 17:03:15 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.10.231]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 2 Nov 2022 17:03:15 +0000 (GMT) Message-ID: Subject: [PATCH] Powerpc fix for gdb.base/unwind-on-each-insn.exp To: "gdb-patches@sourceware.org" , Ulrich Weigand Date: Wed, 02 Nov 2022 10:03:15 -0700 X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Br6Gsy-ajF_B64krkEoudUHZSAazEqQl X-Proofpoint-ORIG-GUID: z-6mEm2qMdFnnuXeTBkvqyCny0Xh0i8T X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-02_13,2022-11-02_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 clxscore=1015 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 mlxlogscore=991 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211020112 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, 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 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: Carl Love via Gdb-patches From: Carl Love Reply-To: Carl Love Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" GDB maintainers: The test gdb.base/unwind-on-each-insn.exp was recently added. The patch generates about 575 failures on PowerPC. The issue is the code to determine the number of lines in function foo does not work correctly on PowerPC. As a result, the test doesn't stop the frame checks when it reaches the end of the function. The test keeps going past the end of the function which results in the errors and warnings. This patch adds code to skip lines with the .long specifier in the disassembly output that follow the last instruction in the function. With this fix, the test correctly determines the number of lines in function foo. Please let me know if the patch is acceptable for mainline. Thanks. Carl Love -------------------------------------------- Powerpc fix for gdb.base/unwind-on-each-insn.exp 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. The PowerPC disassembly of the function foo 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 blr instruction is the last instruction in function foo. The lines with .long following the blr instruction need to be ignored. This patch adds a new condition to the gdb_test_multiple "disassemble foo" test to ignore the lines with the .long. The patch has been tested on PowerPC and Intel X86-64. Reviewed-By: Bruno Larsen --- .../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" # 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 @@ -84,6 +102,10 @@ gdb_test_multiple "disassemble foo" "" { 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