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.129.124]) by sourceware.org (Postfix) with ESMTPS id 2D32D3858D37 for ; Wed, 2 Nov 2022 10:08:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D32D3858D37 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=1667383738; 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=5GZ9cnMGTHGCNYBlodcHtqLMXf7kOkq/3ZYBQmx4ovw=; b=L5uTdQGLumamU92xIgSdY2MT04Y9zc+vcw/lWWuHr0j/TxSM7S+sHCC12UoD/OdeCF3776 XdTm1OLz8eOfHdXRRdj/lK1L+NqEsq1VSENIVNbXxvbonEYIdWXXDcwdfe1yfsjqBAkDBp FEWWzTHIzkLkr0wKABEwFyZuFQOZh3A= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-147-8rkrybGjPAOuVK69kdVGxg-1; Wed, 02 Nov 2022 06:08:57 -0400 X-MC-Unique: 8rkrybGjPAOuVK69kdVGxg-1 Received: by mail-qt1-f198.google.com with SMTP id y8-20020ac87088000000b003a528a5b844so5357044qto.18 for ; Wed, 02 Nov 2022 03:08:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5GZ9cnMGTHGCNYBlodcHtqLMXf7kOkq/3ZYBQmx4ovw=; b=HbCe7PDT1h7e/pYxb0Aiq4PThmV/SvqERTORgZzYSKH5SwA4oUHDutARKjVx2tWZaY yH77bJFTIydszIPGVZ/wvHmK8ONwL06OkrMXCTyMYU2TaYAAQ2wTRLHcbAK1Yul8a4WF w8ebT/6JW10NvLTnQBjED/6T3b9oiYIPvAYJ3g9rKCdM5f+l9pBgfg/Q/kTweh14bn3Y UFdQvdDI36XwwoLJun6ymEo3k82CdkxqkBvr0q9v09//izwweNz5DbLS9WKdMn5/e8ko cv9e1iBcbLupMVv4Rfys/ad56oTrPN2DuaClMz+PvsgEhFAdnWjkDuy4Ln+CO/EmUq5q VRNA== X-Gm-Message-State: ACrzQf14L+f55nwiCrt1QAquMKn4wQk3+BA72SwLGrsQWDwc/cXQwCbR a2Foyvz1QdftV6k+PFaDXDWP3LltmuPznO82ogIxuREQEiB5HepLU6sndUyviCqS0njzjwBRj2m SqMUCqu22YmXnmQmq7CoD6Q== X-Received: by 2002:a05:620a:22d9:b0:6e0:3e5:1271 with SMTP id o25-20020a05620a22d900b006e003e51271mr16390700qki.556.1667383737166; Wed, 02 Nov 2022 03:08:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6O+NMqu4T5Y07GJYjgr9VC58M8hF+jotiy2KgM/TKyygqcvYnVSC5ZrIR1p/u/aSgN33kuxQ== X-Received: by 2002:a05:620a:22d9:b0:6e0:3e5:1271 with SMTP id o25-20020a05620a22d900b006e003e51271mr16390691qki.556.1667383736923; Wed, 02 Nov 2022 03:08:56 -0700 (PDT) Received: from [192.168.0.45] (ip-62-245-66-121.bb.vodafone.cz. [62.245.66.121]) by smtp.gmail.com with ESMTPSA id r10-20020ac85e8a000000b0039cb5c9dbacsm6340113qtx.22.2022.11.02.03.08.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Nov 2022 03:08:56 -0700 (PDT) Message-ID: Date: Wed, 2 Nov 2022 11:08:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: Question: [PATCH] Change calculation of frame_id by amd64 epilogue unwinder To: Carl Love Cc: "gdb-patches@sourceware.org" , Ulrich Weigand , Will Schmidt References: <711495ea-57f4-276d-db50-067b29c14de6@redhat.com> <9cbed9664acd4483eb8ec5a5d1b30a4f44f56ecf.camel@us.ibm.com> From: Bruno Larsen In-Reply-To: <9cbed9664acd4483eb8ec5a5d1b30a4f44f56ecf.camel@us.ibm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,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 List-Id: On 01/11/2022 20:51, Carl Love wrote: > Bruno: > > I found the issue after chasing down a few dead ends... > > Basically, the test disassembles function foo and then scans thru the > disassembly looking for the address of the last instruction which is > assumed to be right before the line "End of assembler dump". The > PowerPC disassembly has three addresses containing a .long after the > last instruction in the function. So, the test gets the wrong final > address for function foo. Basicaly, the test works fine until you walk > past the end of the function. I added a condition to the test > gdb_test_multiple "disassemble foo" to ignore the lines with the .long > entries so the correct address for the last instruction is recorded. > This fixes all of the errors and warnings. > > The break foo* does not seem to be a problem on this test as I was > concerned that it would be. > > I have tested the patch on PowerPC and Intel. Please take a look and > see what you think. If it looks OK to you, I will formally post it to > the mailing list for review and approval. Thanks. > > Carl > ----------------------------------- > From 764f4476f16fa222e95ab2a7087355dfae818502 Mon Sep 17 00:00:00 2001 > From: Carl Love > Date: Tue, 1 Nov 2022 15:33:17 -0400 > Subject: [PATCH] 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 follwing 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. Hi Carl, The idea of the patch looks fine, I just have a few style nits inlined. > --- > .../gdb.base/unwind-on-each-insn.exp | 25 +++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp > index 3b48805cff8..c908a4b838e 100644 > --- a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp > +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp > @@ -41,7 +41,6 @@ if ![runto_main] then { > proc get_sp_and_fba { testname } { > with_test_prefix "get \$sp and frame base $testname" { > set sp [get_hexadecimal_valueof "\$sp" "*UNKNOWN*"] > - > set fba "" > gdb_test_multiple "info frame" "" { > -re -wrap ".*Stack level ${::decimal}, frame at ($::hex):.*" { > @@ -75,6 +74,23 @@ 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. Ignore the .long > +# entries following the blr instruction. > gdb_test_multiple "disassemble foo" "" { > -re "^disassemble foo\r\n" { > exp_continue > @@ -84,7 +100,11 @@ gdb_test_multiple "disassemble foo" "" { > exp_continue > } > > - -re "^...($hex) \[^\r\n\]+\r\n" { > + -re "^...($hex) \[<>+0-9:\s\t\]*\.long\[\s\t\]*\[^\r\n\]*\r\n" { I wonder if this pattern is unnecessarily strict. Correct me if I'm wrong, but I think that no architecture has an instruction that starts with a .  so this pattern could probably be simplified to ^...($hex) \[<>+0-9:\s\t\]*\.[^\r\n\]*\r\n And no other architectures would have a similar problem in the future. I'm not very knowledgeable on assembly so you may know better in this area. > + exp_continue > + } > + > + -re "^...($hex)\[^\r\n\]+\r\n" { You removed a space here, which makes no difference in the pattern and makes the diff more confusing > set last_addr_in_foo $expect_out(1,string) > exp_continue > } > @@ -137,6 +157,7 @@ for { set i_count 1 } { true } { incr i_count } { > gdb_test "frame 0" ".*" > > set pc [get_hexadecimal_valueof "\$pc" "*UNKNOWN*"] > + Unnecessary new line here. Cheers, Bruno > if { $pc == $last_addr_in_foo } { > break > }