From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by sourceware.org (Postfix) with ESMTPS id 35DA7386F80F for ; Mon, 27 Apr 2020 12:07:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 35DA7386F80F Received: by mail-qv1-xf42.google.com with SMTP id 59so6227305qva.13 for ; Mon, 27 Apr 2020 05:07:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=P/c5yQCn1bsMQ3aAOmZbT3cKOjjiC8UmT2UdQJpI57c=; b=ue6bq+XAKQmjUNh70hpf/nfoYYf1KQIvgDivumwG+wXD/nNhaLGRirFiYbrLfkm7BB LeDSfpGkNez9SX56uA87kDyVkwiAClWiA4unBskfWa+BDDf2QrvgfPzwAEaeBJSncP9R TTIDNkO7gVnIrlVOosDHxt3H/zPmlAilpUMgWQbLUPqjliH54OOVyeNVXq2OUFikswEr aQStywwFiX3gEg8ikrs4xueCvg5LzQHgrbvSkHRtgYLuhwuMPQIZXVpYyfI8sDAoQHNO ord/KVgTPmx5fvU26X/4n1ykmSdytAx3LSdUJgf/38DwMgWhTbf08vNgFNPc34qVFgKV jQ6A== X-Gm-Message-State: AGi0PuahYd2yY6mu/CcFh7qYMXTeaz1r4j7LR2aWn+KuvQx7W3UxYeb5 JCLCSktQQPfDZvQzpbVz+SDFJdZcdMA= X-Google-Smtp-Source: APiQypKt9tBXLP/Sx5vC9JPDAy5xjZJB175zlaRzOV6+1Dqmm9nTyvLwtDunWCgFw6tEeOX6ZcHZHg== X-Received: by 2002:ad4:458a:: with SMTP id x10mr22010812qvu.199.1587989240644; Mon, 27 Apr 2020 05:07:20 -0700 (PDT) Received: from [192.168.0.185] ([191.249.229.169]) by smtp.gmail.com with ESMTPSA id f7sm1534970qto.61.2020.04.27.05.07.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Apr 2020 05:07:19 -0700 (PDT) Subject: Re: [PATCH] Fix remaining inline/tailcall unwinding breakage for x86_64 To: Tom de Vries , gdb-patches@sourceware.org Cc: tromey@adacore.com, andrew.burgess@embecosm.com References: <20200425040934.17011-1-luis.machado@linaro.org> From: Luis Machado Message-ID: Date: Mon, 27 Apr 2020 09:07:16 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Mon, 27 Apr 2020 12:07:22 -0000 On 4/25/20 12:53 PM, Tom de Vries wrote: > On 25-04-2020 06:09, Luis Machado wrote: >> Commit 5939967b355ba6a940887d19847b7893a4506067 fixed inline >> frame unwinding breakage for some targets (aarch64, riscv, s390...) >> but regressed a few amd64 testcases related to tailcalls. >> >> Given the following example situation... >> >> Frame #-1 - sentinel frame >> Frame # 0 - inline frame >> Frame # 1 - normal frame >> >> ... suppose we're at level #1 and call into dwarf2_tailcall_sniffer_first. >> >> We'll attempt to fetch PC, which used to be done via the gdbarch_unwind_pc call >> (before 5939967b355ba6a940887d19847b7893a4506067), but now it is being handled >> by the get_frame_register function. >> >> gdbarch_unwind_pc will attempt to use frame #1's cache to retrieve information >> about the PC. Here's where different architectures behave differently. >> >> x86_64 will find a dwarf rule to retrieve PC from memory, at a CFA + offset >> location. So the PC value is readily available and there is no need to >> create a lazy value. >> >> For aarch64 (and others), GCC doesn't emit an explicit location for PC, so we >> eventually will find that PC is DWARF2_FRAME_REG_UNSPECIFIED. This is known >> and is handled by GDB by assuming GCC really meant DWARF2_FRAME_REG_SAME_VALUE. >> >> This means we'll attempt to fetch the register value from frame #0, via a call >> to frame_unwind_got_register, which will trigger the creation of a lazy value >> that requires a valid frame id for frame #0. >> >> We don't have a valid id for frame #0 yet, so we assert. >> >> Given the above, the following patch attempts to handle the situation without >> being too hacky. We verify if the next frame is an inline frame and if its >> frame id has been computed already. If it hasn't been computed yet, then we >> use the safer get_frame_register function, otherwise we use the regular >> gdbarch_unwind_pc hook. >> >> I've verified this makes both aarch64-linux and x86_64 happy testsuite-wise. >> > > Hi Luis, > > thanks for working on this. > > I've tested this patch on x86_64-linux and can confirm that this fixes > all the regressions I saw. > > I've reviewed the patch and it looks ok to me. > > Please check this in, given that if fixes regressions. If there are any > comments from others to be addressed, that can still be done post-commit. > > Thanks, > - Tom > Thanks for the quick review. Pushed now.