From patchwork Tue Sep 1 13:01:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 1354985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=martin.st Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=martin-st.20150623.gappssmtp.com header.i=@martin-st.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=BjgqI4+3; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BgnJk3xyQz9sVT for ; Tue, 1 Sep 2020 23:01:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0ABD23870889; Tue, 1 Sep 2020 13:01:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by sourceware.org (Postfix) with ESMTPS id 65BAE384241D for ; Tue, 1 Sep 2020 13:01:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 65BAE384241D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=martin.st Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=martin@martin.st Received: by mail-lf1-x142.google.com with SMTP id y2so709911lfy.10 for ; Tue, 01 Sep 2020 06:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=F0NfTRs0YslKiYnQkjEyqn6iQN2fXx49hF+6hxuyB7M=; b=BjgqI4+3aM0ZP2Yo6WF4wV1PNUXQP5NnEsQw+X64/WbE1GL4eeaYAQewYLREnSn+gn 2jOYaKtl+UqtQ8/kI9RI8YskqHFaVGdlsf5oVpsVOVta/YxHN6u9hdLxvb9S9FrW7Huo c3aXuTygYFKnf9IeU39gemokw1vYuNe5Q4xgqEB0sLCnLrTzXaj/WQKkkfDnyvXp6w5A Xvf7xW28rZ7hjZP+Wik07bDVWl3kV7izaJ02QCrfUii41h+l3Z68Pgxs7pamcublWo/j THE5ZSAvES2HjjNOErdOPdjAIXRIYgMvIFwr9QeYeapnmq5UxQvqmIeo8OELAQ6TNXQb Zzvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=F0NfTRs0YslKiYnQkjEyqn6iQN2fXx49hF+6hxuyB7M=; b=ePNgWHDZw/WXgH5/q/RVVzY499xp+YbXGnkrnZQNU3yRDzRbSRlf1CCi/n1CWq70qT nvjpUFEHOffIUT5mVnN6txmjx4zublYSCGgES0KMnnAHQrUNkcNm/2LkVsJcn0nkme59 +KcgeREy6oscRxfJy27jrpKH8qEaf4aX9+uHNbp+/IBBjQtSoEC+ryB4BQLaf0iI9NAq HHZMj+AIf/3vJgEtPue2ZwBkG7Td3k22t5ZuQhg9UPqDdht9Bsbe+4CEr4qrwxsdxjDl cJYR8SKqMPxkTtvihiZruL8fCeRZjgTPTGTbo+T3Mz07fvbSmp0R8cdrj1b8jtUOCie7 4TGw== X-Gm-Message-State: AOAM533ue6xO1kZBPZKns8hv/OFa+gE6FIxtiEUrBL8NV/EITLEu9l7w mjOfL5twYUZLGW9WANmiur6kQN3qw1/AYhKb X-Google-Smtp-Source: ABdhPJzND4q3f1d3W+fN+tgZlQiDZcTptvthS7jKrpw7/YBTq788qVxvb3r6+DiL4eDKd1b3r1aM1g== X-Received: by 2002:ac2:5e2b:: with SMTP id o11mr583428lfg.24.1598965288374; Tue, 01 Sep 2020 06:01:28 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id b11sm271329lfo.66.2020.09.01.06.01.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 06:01:27 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: gcc-patches@gcc.gnu.org Subject: [PATCH] libgcc: Expose the current instruction pointer in SEH _Unwind_Backtrace Date: Tue, 1 Sep 2020 16:01:26 +0300 Message-Id: <20200901130126.6266-1-martin@martin.st> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Previously, the SEH version of _Unwind_Backtrace did unwind the stack and call the provided callback function as intended, but there was little the caller could do within the callback to actually get any info about that particular level in the unwind. Set the ra pointer, which is used by _Unwind_GetIP, to allow using this function to inspect the state within the callback, before calling the callback function. 2020-09-01 Martin Storsjö libgcc/Changelog: * unwind-seh.c (_Unwind_Backtrace): Set the ra pointer before calling the callback. --- libgcc/unwind-seh.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libgcc/unwind-seh.c b/libgcc/unwind-seh.c index 1a70180cfaa..72473135862 100644 --- a/libgcc/unwind-seh.c +++ b/libgcc/unwind-seh.c @@ -466,6 +466,8 @@ _Unwind_Backtrace(_Unwind_Trace_Fn trace, &gcc_context.disp->HandlerData, &gcc_context.disp->EstablisherFrame, NULL); + gcc_context.ra = ms_context.Rip; + /* Call trace function. */ if (trace (&gcc_context, trace_argument) != _URC_NO_REASON) return _URC_FATAL_PHASE1_ERROR;