From: sof Date: Sun, 5 Oct 1997 20:28:54 +0000 (+0000) Subject: [project @ 1997-10-05 20:28:54 by sof] X-Git-Tag: Approx_2487_patches~1436 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=b6c47c885295e2755da8970057884ce55dd894de;p=ghc-hetmet.git [project @ 1997-10-05 20:28:54 by sof] Use GetThreadContext() to fish out faulting address for segv handlers under cygwin32 --- diff --git a/ghc/runtime/main/Signals.lc b/ghc/runtime/main/Signals.lc index 97fb56b..f473cae 100644 --- a/ghc/runtime/main/Signals.lc +++ b/ghc/runtime/main/Signals.lc @@ -206,24 +206,28 @@ install_segv_handler(STG_NO_ARGS) # elif defined(cygwin32_TARGET_OS) /* - The signal handlers in cygwin32 (beta14) are only passed the signal + The signal handlers in cygwin32 are only passed the signal number, no sigcontext/siginfo is passed as event data..sigh. For SIGSEGV, to get at the violating address, we need to use the Win32's - WaitForDebugEvent() to get out any status information. + GetThreadContext() to get at the faulting address. */ static void segv_handler(sig) int sig; { - /* From gdb/win32-nat.c */ - DEBUG_EVENT event; - BOOL t = WaitForDebugEvent (&event, INFINITE); + CONTEXT context; + HANDLE hThread; + BOOL t; + + context.ContextFlags = CONTEXT_CONTROL; + hThread = GetCurrentThread(); /* cannot fail */ + t = GetThreadContext(hThread,&context); fflush(stdout); if (t == FALSE) { fprintf(stderr, "Segmentation fault caught, address unknown\n"); } else { - void *si_addr = event.u.Exception.ExceptionRecord.ExceptionAddress; + void *si_addr = context.Eip; /* magic */ if (si_addr >= (void *) stks_space && si_addr < (void *) (stks_space + RTSflags.GcFlags.stksSize)) StackOverflow(); @@ -239,7 +243,6 @@ install_segv_handler() return (int) signal(SIGSEGV, segv_handler) == -1; } - # else /* ! (cygwin32|irix6|sunos4|linux*|*bsd|aix) */ # if defined(irix_TARGET_OS)