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.133.124]) by sourceware.org (Postfix) with ESMTPS id ED984385701E for ; Tue, 25 Oct 2022 14:13:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED984385701E 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=1666707231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zTlIhJBChoQ5sNmbCWhvaACJYku1zrXEuJzzkA7migg=; b=DDUnKnhlN5wT58xhcKRjJORSxVaVcCkNVbfNQLvAMF0fZFwFfR7W42OpDndistEphGkIPV LpLucwR/VaaavIr35DUmd/+Ry/WKhrrLi1ttX28nZDKjBExp6uPYieQiC0lawZfIUbjN/g LUSa/kXxDWAzhLJ1ybmz9FFyexJHNAo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-532-dqqwSYn1M9ypFhuHCOBGcw-1; Tue, 25 Oct 2022 10:13:50 -0400 X-MC-Unique: dqqwSYn1M9ypFhuHCOBGcw-1 Received: by mail-wr1-f72.google.com with SMTP id w23-20020adf8bd7000000b002358f733307so4826782wra.17 for ; Tue, 25 Oct 2022 07:13:50 -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: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=zTlIhJBChoQ5sNmbCWhvaACJYku1zrXEuJzzkA7migg=; b=XmAaK4qhSy7ERbvCrgRid4PRFTQ5F/lavD7ms8LntZutBFAapBOVvc4LKIokFVOAVJ GvogRmh4KocQrrJ8XhckunpD+nUiliFA81FqovPdP1RdPOlcTB6GGFHsA2BdqXssELmB c+tSwizhzQSenG8SB45kB2qqg5gO1amrwsqoowybVxBz9Eq+ChGhNdO0JYb2z41EmCTl OKDBGq73tT8Uj84rxEWfiB4Eh+zRHKSM3IN5+57O0IyHwHBA2yXvwNyIre8eMHS9sEMJ SUkRMDh3HhXkK/fIIbogiUNg3P8unU52F4Rmbp03vXE18p+Io4dXgnFcketh7SxSGjkE 4TRQ== X-Gm-Message-State: ACrzQf0x4GQhTeeG/U/yDFgy6AGZJ5Yz8QNK2OC2ImvV0d0Ai9K1N+Qf xik8sOnkcR0ak8fQOpStBEdOrjSDRwymKaPanP8YGM3fZ2J6xvn2+UaSMdW6QlWApg+NvbsKn2N 8zIV60WTvjOugRTKQerRmbQ== X-Received: by 2002:a05:600c:34c1:b0:3cf:3921:ef22 with SMTP id d1-20020a05600c34c100b003cf3921ef22mr5610787wmq.204.1666707228746; Tue, 25 Oct 2022 07:13:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73VB7Bb8jIQMU3NarZsG96b1BAh5quP7q3rMutymjdVjmDStr6w/ObnSFQJw+PbzcGAGbJIw== X-Received: by 2002:a05:600c:34c1:b0:3cf:3921:ef22 with SMTP id d1-20020a05600c34c100b003cf3921ef22mr5610771wmq.204.1666707228547; Tue, 25 Oct 2022 07:13:48 -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 h20-20020a1ccc14000000b003b492753826sm2699779wmb.43.2022.10.25.07.13.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Oct 2022 07:13:48 -0700 (PDT) Message-ID: Date: Tue, 25 Oct 2022 16:13:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v4 1/2] Change calculation of frame_id by amd64 epilogue unwinder To: Simon Marchi , gdb-patches@sourceware.org References: <20221005103832.3163424-1-blarsen@redhat.com> <20221005103832.3163424-2-blarsen@redhat.com> <6975b747-e4fd-ca3c-1b89-d65b51d44d1f@simark.ca> From: Bruno Larsen In-Reply-To: <6975b747-e4fd-ca3c-1b89-d65b51d44d1f@simark.ca> 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: 7bit X-Spam-Status: No, score=-10.5 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 25/10/2022 15:59, Simon Marchi wrote: > On 10/25/22 09:44, Simon Marchi wrote: >> On 10/5/22 06:38, Bruno Larsen via Gdb-patches wrote: >>> When GDB is stopped at a ret instruction and no debug information is >>> available for unwinding, GDB defaults to the amd64 epilogue unwinder, to >>> be able to generate a decent backtrace. However, when calculating the >>> frame id, the epilogue unwinder generates information as if the return >>> instruction was the whole frame. >>> >>> This was an issue especially when attempting to reverse debug, as GDB >>> would place a step_resume_breakpoint from the epilogue of a function if >>> we were to attempt to skip that function, and this breakpoint should >>> ideally have the current function's frame_id to avoid other problems >>> such as PR record/16678. >>> >>> This commit changes the frame_id calculation for the amd64 epilogue, >>> so that it is always the same as the dwarf2 unwinder's frame_id. >>> >>> It also adds a test to confirm that the frame_id will be the same, >>> regardless of using the epilogue unwinder or not, thanks to Andrew >>> Burgess. >>> >>> Co-Authored-By: Andrew Burgess >>> --- >>> gdb/amd64-tdep.c | 10 +- >>> .../gdb.base/unwind-on-each-insn-foo.c | 22 +++ >>> gdb/testsuite/gdb.base/unwind-on-each-insn.c | 25 +++ >>> .../gdb.base/unwind-on-each-insn.exp | 154 ++++++++++++++++++/usr/lib/x86_64-linux-gnu/libasan.so.6 >>> 4 files changed, 206 insertions(+), 5 deletions(-) >>> create mode 100644 gdb/testsuite/gdb.base/unwind-on-each-insn-foo.c >>> create mode 100644 gdb/testsuite/gdb.base/unwind-on-each-insn.c >>> create mode 100644 gdb/testsuite/gdb.base/unwind-on-each-insn.exp >> Hi Bruno, >> >> On Ubuntu 22.04, I can get this new test to fail quite reliably with: >> >> $ taskset -c 1 make check TESTS="gdb.base/unwind-on-each-insn.exp" RUNTESTFLAGS="--target_board=native-gdbserver" >> >> Can you give it a try? >> >> Simon > Actually, I took the time to look into it, it turns out the problem is > simple. Here's a patch below. Ah great! I didn't even have time to finish making an Ubuntu VM lol. I just noticed one typo: > > > From 7090bf701b2f1cca89985ea1b45b0a2e3859e19e Mon Sep 17 00:00:00 2001 > From: Simon Marchi > Date: Tue, 25 Oct 2022 09:50:56 -0400 > Subject: [PATCH] gdb/testsuite: make sure to consume the prompt in > gdb.base/unwind-on-each-insn.exp > > This test fails quite reliably for me when ran as: > > $ taskset -c 1 make check TESTS="gdb.base/unwind-on-each-insn.exp" RUNTESTFLAGS="--target_board=native-gdbserver" > > or more simply: > > $ make check-read1 TESTS="gdb.base/unwind-on-each-insn.exp" > > The problem is that the that grabs the frame id from "maint print Missing word here. "The problem is that the __proc__" ? With this fixed, LGTM. Reviewed-By: Bruno Larsen Cheers, Bruno > frame-id" does not consume the prompt. Well, it does sometimes due to > the trailing .*, but not always. If the prompt is not consumed, the > following tests get confused: > > FAIL: gdb.base/unwind-on-each-insn.exp: gdb_breakpoint: set breakpoint at *foo > FAIL: gdb.base/unwind-on-each-insn.exp: disassemble foo > FAIL: gdb.base/unwind-on-each-insn.exp: get $sp and frame base in foo: get hexadecimal valueof "$sp" > > Use -wrap to make gdb_test_multiple consume the prompt. > > While at it, remove the bit that consumes the command name and do > exp_continue, it's not really necessary. And for consistency, do the > same changes to the gdb_test_multiple that consumes the stack address, > although that one was fine, it did consume the prompt explicitly. > > Change-Id: I2b7328c8844c7e98921ea494c4c05107162619fc > --- > gdb/testsuite/gdb.base/unwind-on-each-insn.exp | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp > index faa6a1a3f064..3b48805cff83 100644 > --- a/gdb/testsuite/gdb.base/unwind-on-each-insn.exp > +++ b/gdb/testsuite/gdb.base/unwind-on-each-insn.exp > @@ -44,11 +44,7 @@ proc get_sp_and_fba { testname } { > > set fba "" > gdb_test_multiple "info frame" "" { > - -re "^info frame\r\n" { > - exp_continue > - } > - > - -re "^Stack level ${::decimal}, frame at ($::hex):\r\n.*$::gdb_prompt $" { > + -re -wrap ".*Stack level ${::decimal}, frame at ($::hex):.*" { > set fba $expect_out(1,string) > } > } > @@ -62,11 +58,7 @@ proc get_sp_and_fba { testname } { > proc get_fid { } { > set fid "" > gdb_test_multiple "maint print frame-id" "" { > - -re "^maint print frame-id\r\n" { > - exp_continue > - } > - > - -re "^frame-id for frame #${::decimal}: (\[^\r\n\]+).*" { > + -re -wrap ".*frame-id for frame #${::decimal}: (.*)" { > set fid $expect_out(1,string) > } > }