public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch for 96948
@ 2020-09-07  6:12 Kirill Müller
  2020-09-08 12:08 ` Martin Storsjö
  0 siblings, 1 reply; 8+ messages in thread
From: Kirill Müller @ 2020-09-07  6:12 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 184 bytes --]

Hi


As requested, attaching a patch for 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96948. This solves a 
problem with _Unwind_Backtrace() on mingw64 + SEH.


Best regards

Kirill


[-- Attachment #2: 48.patch --]
[-- Type: text/x-patch, Size: 1503 bytes --]

From bbc163476cab9bcaaa044d8aa9ecee824f7284f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kirill=20M=C3=BCller?= <krlmlr@mailbox.org>
Date: Sun, 6 Sep 2020 10:01:46 +0200
Subject: [PATCH] Fix _Unwind_Backtrace() for SEH

---
 libgcc/unwind-seh.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libgcc/unwind-seh.c b/libgcc/unwind-seh.c
index 8c6aade9a3b3..a2d51b6df02b 100644
--- a/libgcc/unwind-seh.c
+++ b/libgcc/unwind-seh.c
@@ -450,8 +450,11 @@ _Unwind_Backtrace(_Unwind_Trace_Fn trace,
   gcc_context.disp->ContextRecord = &ms_context;
   gcc_context.disp->HistoryTable = &ms_history;
 
+  int first = 1;
   while (1)
     {
+      gcc_context.cfa = ms_context.Rsp;
+      gcc_context.ra = ms_context.Rip;
       gcc_context.disp->ControlPc = ms_context.Rip;
       gcc_context.disp->FunctionEntry
 	= RtlLookupFunctionEntry (ms_context.Rip, &gcc_context.disp->ImageBase,
@@ -466,9 +469,14 @@ _Unwind_Backtrace(_Unwind_Trace_Fn trace,
 			    &gcc_context.disp->HandlerData,
 			    &gcc_context.disp->EstablisherFrame, NULL);
 
-      /* Call trace function.  */
-      if (trace (&gcc_context, trace_argument) != _URC_NO_REASON)
-	return _URC_FATAL_PHASE1_ERROR;
+      /* Call trace function, skip first call.  */
+      if (first) {
+	first = 0;
+      }
+      else {
+	if (trace (&gcc_context, trace_argument) != _URC_NO_REASON)
+	  return _URC_FATAL_PHASE1_ERROR;
+      }
 
       /* ??? Check for invalid stack pointer.  */
       if (ms_context.Rip == 0)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-06 20:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07  6:12 Patch for 96948 Kirill Müller
2020-09-08 12:08 ` Martin Storsjö
2020-09-08 13:29   ` Kirill Müller
2020-09-08 15:34     ` Martin Storsjö
2020-09-08 15:50       ` Kirill Müller
2020-09-08 19:34         ` Martin Storsjö
2020-11-06 16:42       ` Jeff Law
2020-11-06 20:53         ` Martin Storsjö

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).