From: fjh AT cs DOT mu DOT OZ DOT AU (Fergus Henderson) Subject: SML-NJ for CygWin32 Bugs/Problems 17 Jun 1997 14:43:32 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199706170922.TAA26910.cygnus.gnu-win32@mundook.cs.mu.OZ.AU> Original-To: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com Sergey Okhapkin wrote: > Gary Fuehrer wrote: > > 2. The signal handling in CygWin32 doesn't let me do the following: > > a. Get and Set the "eip" register (or any register) of the > > excepting thread. > > b. Ascertain the kind of floating point exception that occurred. > > The need is for "siginfo_t" and "sigcontext" parameters that can be > > optionally received and modified by signal handlers. > > What unix analogs do you speak about? Here's a program that works on some Unix systems. #include #include #define FAULT_ADDRESS ((int *)112) extern void handler(int signum, siginfo_t *info, void *context); int main() { struct sigaction act; act.sa_flags = SA_SIGINFO | SA_RESTART; act.sa_sigaction = handler; if (sigemptyset(&act.sa_mask) != 0) exit(1); if (sigaction(SIGSEGV, &act, NULL) != 0) exit(1); /* provoke a SIGSEGV */ (*FAULT_ADDRESS)++; exit(1); } void handler(int signum, siginfo_t *info, void *context) { if (signum == SIGSEGV && info->si_signo == SIGSEGV && info->si_code > 0 && (int *)info->si_addr == FAULT_ADDRESS) { exit(0); } else { exit(1); } } Here's another one that works on Linux (you may need to #define HAVE_ASM_SIGCONTEXT, depending on the exact Linux version). #define sigcontext_struct sigcontext #define __KERNEL__ #include #undef __KERNEL__ #ifdef HAVE_ASM_SIGCONTEXT #include #endif #include extern void handler(int signum, struct sigcontext_struct info); #define FAULT_ADDRESS ((int *)112) int main() { signal(SIGSEGV, (void (*)(int))handler); /* provoke a SIGSEGV */ (*FAULT_ADDRESS)++; exit(1); } void handler(int signum, struct sigcontext_struct context) { if (signum == SIGSEGV && (int *) context.cr2 == FAULT_ADDRESS) { exit(0); } else { exit(1); } } -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3 | -- the last words of T. S. Garp. - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".