aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2014-03-29 21:16:09 +0000
committerChristopher Faylor <me@cgf.cx>2014-03-29 21:16:09 +0000
commitc6eaf1f3f77b29d4dd8f8b241845cffa75a44f40 (patch)
treefbcfa204e5292a9550e3de728b931b2196621876
parent20738749f60c85f58329015b7285289f6eb2b7c9 (diff)
downloadnewlib-c6eaf1f3f77b29d4dd8f8b241845cffa75a44f40.zip
newlib-c6eaf1f3f77b29d4dd8f8b241845cffa75a44f40.tar.gz
newlib-c6eaf1f3f77b29d4dd8f8b241845cffa75a44f40.tar.bz2
* DevNotes: Add entry cgf-000025.
* exceptions.cc (_cygtls::signal_debugger): Reorganize to avoid contacting the debugger if we have already done so via the exception handler. Eliminate need for goto. Remove an ifdef in favor of just allocating a larger buffer.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/DevNotes8
-rw-r--r--winsup/cygwin/exceptions.cc41
3 files changed, 30 insertions, 27 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 1713b98..faf5c36 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+2014-03-29 Christopher Faylor <me.cygwin2014@cgf.cx>
+
+ * DevNotes: Add entry cgf-000025.
+ * exceptions.cc (_cygtls::signal_debugger): Reorganize to avoid
+ contacting the debugger if we have already done so via the exception
+ handler. Eliminate need for goto. Remove an ifdef in favor of just
+ allocating a larger buffer.
+
2014-03-28 Corinna Vinschen <corinna@vinschen.de>
* dcrt0.cc (dll_crt0_0): Install myfault exception handler on x86_64.
diff --git a/winsup/cygwin/DevNotes b/winsup/cygwin/DevNotes
index b8820a9..0f48095 100644
--- a/winsup/cygwin/DevNotes
+++ b/winsup/cygwin/DevNotes
@@ -1,3 +1,11 @@
+2014-03-29 cgf-000025
+
+Reorganized _cygtls::signal_debugger to avoid sending anything to the
+debugger if we've seen an exception. I think it used to work that way
+and I changed it without noting why. It sure seems like, if we don't do
+this, gdb will see two signals and, it really does, when there has been
+a Windows-recognized exception.
+
2014-02-15 cgf-000024
Wow. It's hard getting the screen handling stuff working correctly when
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index c288913..120d71b 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1461,42 +1461,29 @@ _cygtls::call_signal_handler ()
void
_cygtls::signal_debugger (siginfo_t& si)
{
- HANDLE th = NULL;
- if (isinitialized () && being_debugged ())
+ HANDLE th;
+ /* If si.si_cyg is set then the signal was already sent to the debugger. */
+ if (isinitialized () && !si.si_cyg && (th = (HANDLE) *this)
+ && being_debugged () && SuspendThread (th) >= 0)
{
CONTEXT c;
- CONTEXT *pc;
-
- if (si.si_cyg)
- pc = ((cygwin_exception *) si.si_cyg)->context ();
- else if (!(th = (HANDLE) *this))
- return;
- else
+ c.ContextFlags = CONTEXT_FULL;
+ if (GetThreadContext (th, &c))
{
- SuspendThread (th);
- c.ContextFlags = CONTEXT_FULL;
- if (!GetThreadContext (th, &c))
- goto out;
if (incyg)
#ifdef __x86_64__
c.Rip = retaddr ();
#else
c.Eip = retaddr ();
#endif
- pc = &c;
+ memcpy (&thread_context, &c, (&thread_context._internal -
+ (unsigned char *) &thread_context));
+ /* Enough space for 32/64 bit addresses */
+ char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffffffffffff")];
+ __small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %d %y %p", si.si_signo,
+ thread_id, &thread_context);
+ OutputDebugString (sigmsg);
}
- memcpy (&thread_context, pc, (&thread_context._internal -
- (unsigned char *) &thread_context));
-#ifdef __x86_64__
- char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffffffffffff")];
-#else
- char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffff")];
-#endif
- __small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %d %y %p", si.si_signo,
- thread_id, &thread_context);
- OutputDebugString (sigmsg);
+ ResumeThread (th);
}
-out:
- if (th)
- ResumeThread (th);
}