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: Martin Storsjo X-Patchwork-Id: 248861 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4214476ilg; Tue, 1 Sep 2020 06:01:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfWhe2xMnf+zdGYBZ7SWgZx2r2QuZAGjo/riRdeuioHCSz3lo8lbXXNQquKhyZn62DCPCY X-Received: by 2002:a17:907:264c:: with SMTP id ar12mr1436843ejc.80.1598965299236; Tue, 01 Sep 2020 06:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598965299; cv=none; d=google.com; s=arc-20160816; b=FiAAM6KCFVlAd8+WxuRi1tlMjRi3Vd2P6kPnsq9nPh+pgD74cCsEbbBqk3u3kwcfat D8Y8S3o9mQtw6vtMEMV0KcaL08F4F2iG3HSiuFprABl27a6S3cdP/Dqf1T2b+PKw2wHi gsF0jfXYnmzQMxaOw3yRCTSMIiSGv48+EClkecGCUjzkYgGejQ8hVfn/icGszZ1N5SnH VIrU+TKwGC4OK8Q4GvESbHhDMXWXF9KAq453xBv5Ealwp0difx20bX5CWrJ+NYyqsVPC zsVv/CGus+X3fMTTz5ZGOMsUJ7YmrUPlOJE+wTkDgcIcxWRChlqzAfG0SARDZm/fMDLK AcEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :dmarc-filter:delivered-to; bh=F0NfTRs0YslKiYnQkjEyqn6iQN2fXx49hF+6hxuyB7M=; b=MENQx1oJDZhl81lwhAOBeKRtc8Uqa6HWjWdkgEQLk0kSNGnlTyOFUwpPYgcvZ0YJfp yL9pWcB9jgcyG6sWCvB0xN5f8YGVUwkXbJhoj/tikxa+dO1frctxt1l3RF4BYmM6M3Ob q+FhRmqQ/LwiG3sWccCGPxYFUbRVlM7iyeoulSrXgyjY8l6lNOwDbRtR/GfVn2T1Nmi1 v4oHxIFq5jUKQycqzttuuJqXSorXikFs/gmBl9l9rHyAEvgPiD3Ob0dIx8qdU3GY4X4t hyHBVMkDts5pYA+ubY1JpXKtCZaCNnMwBWaB4PnOfzEJK90J+8yvp5lL6QuMz8EFsdzn Cl2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@martin-st.20150623.gappssmtp.com header.s=20150623 header.b=BjgqI4+3; spf=pass (google.com: domain of gcc-patches-bounces@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom=gcc-patches-bounces@gcc.gnu.org Return-Path: Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h6si580481ejo.247.2020.09.01.06.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 06:01:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@martin-st.20150623.gappssmtp.com header.s=20150623 header.b=BjgqI4+3; spf=pass (google.com: domain of gcc-patches-bounces@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom=gcc-patches-bounces@gcc.gnu.org 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-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(+) -- 2.17.1 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;