[newlib-cygwin] Teach stackinfo::walk() how to virtually unwind the tls sigstack
Jon TURNEY
jturney@sourceware.org
Fri Mar 13 13:08:00 GMT 2015
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e9e47b8ce6158d7d0486abf6c1ff4e2dd790a084
commit e9e47b8ce6158d7d0486abf6c1ff4e2dd790a084
Author: Jon TURNEY <jon.turney@dronecode.org.uk>
Date: Mon Mar 9 21:55:29 2015 +0000
Teach stackinfo::walk() how to virtually unwind the tls sigstack
This improves how stackinfo::dumpstack() dumps _sigbe and sigdelayed frames
* exceptions.cc (stack_info): Add sigstackptr member.
(walk): Unwind sigstackptr inside _sigbe and sigdelayed.
* gendef (_sigdelayed_end): Add symbol to mark end of sigdelayed.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Diff:
---
winsup/cygwin/ChangeLog | 6 ++++++
winsup/cygwin/exceptions.cc | 13 +++++++++++++
winsup/cygwin/gendef | 2 ++
3 files changed, 21 insertions(+)
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f6261bd..18dcc25 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-12 Jon TURNEY <jon.turney@dronecode.org.uk>
+
+ * exceptions.cc (stack_info): Add sigstackptr member.
+ (walk): Unwind sigstackptr inside _sigbe and sigdelayed.
+ * gendef (_sigdelayed_end): Add symbol to mark end of sigdelayed.
+
2015-03-13 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/sys_time.h: Remove. Definitions moved to newlib's
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index c16b073..3af9a54 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -45,6 +45,8 @@ details. */
#define CALL_HANDLER_RETRY_INNER 10
char debugger_command[2 * NT_MAX_PATH + 20];
+extern u_char _sigbe;
+extern u_char _sigdelayed_end;
static BOOL WINAPI ctrl_c_handler (DWORD);
@@ -224,6 +226,7 @@ class stack_info
#ifdef __x86_64__
CONTEXT c;
UNWIND_HISTORY_TABLE hist;
+ __stack_t *sigstackptr;
#endif
public:
STACKFRAME sf; /* For storing the stack information */
@@ -252,6 +255,7 @@ stack_info::init (PUINT_PTR framep, bool wantargs, PCONTEXT ctx)
memset (&c, 0, sizeof c);
c.ContextFlags = CONTEXT_ALL;
}
+ sigstackptr = _my_tls.stackptr;
#endif
memset (&sf, 0, sizeof (sf));
if (ctx)
@@ -287,6 +291,15 @@ stack_info::walk ()
sf.AddrStack.Offset = c.Rsp;
sf.AddrFrame.Offset = c.Rbp;
+ if ((c.Rip >= (DWORD64)&_sigbe) && (c.Rip < (DWORD64)&_sigdelayed_end))
+ {
+ /* _sigbe and sigdelayed don't have SEH unwinding data, so virtually
+ unwind the tls sigstack */
+ c.Rip = sigstackptr[-1];
+ sigstackptr--;
+ return 1;
+ }
+
f = RtlLookupFunctionEntry (c.Rip, &imagebase, &hist);
if (f)
RtlVirtualUnwind (0, imagebase, c.Rip, f, &c, &hdl, &establisher, NULL);
diff --git a/winsup/cygwin/gendef b/winsup/cygwin/gendef
index 4ea7f54..58b95eb 100755
--- a/winsup/cygwin/gendef
+++ b/winsup/cygwin/gendef
@@ -311,6 +311,8 @@ sigdelayed:
xchgq %r10,(%rsp)
ret
.seh_endproc
+_sigdelayed_end:
+ .global _sigdelayed_end
# _cygtls::pop
.global _ZN7_cygtls3popEv
More information about the Cygwin-cvs
mailing list