diff options
Diffstat (limited to 'winsup/mingw/samples/seh/exutil.c')
-rw-r--r-- | winsup/mingw/samples/seh/exutil.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/winsup/mingw/samples/seh/exutil.c b/winsup/mingw/samples/seh/exutil.c new file mode 100644 index 000000000..9d98d8350 --- /dev/null +++ b/winsup/mingw/samples/seh/exutil.c @@ -0,0 +1,68 @@ +
+#include <stdlib.h>
+#include <stdio.h>
+#include <excpt.h>
+#include <windows.h>
+
+#include "exutil.h"
+
+void
+WalkExceptionHandlers ()
+{
+ PEXCEPTION_REGISTRATION_RECORD p;
+ int i;
+
+ __asm__("movl %%fs:0,%%eax;movl %%eax,%0" : "=g" (p) : : "%eax");
+
+ i = 0;
+ while (p != (PEXCEPTION_REGISTRATION_RECORD) -1 && p)
+ {
+ printf ("Registration %d at %08x : ", i, p);
+ printf ("Handler = %08x ", p->handler);
+ printf ("Next Registration = %08x\n", p->prev);
+ p = p->prev;
+ i++;
+ }
+ printf ("End of exception handler list.\n");
+ fflush (stdout);
+}
+
+void
+DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec)
+{
+ printf ("Exception: Code = %08x Flags %08x", pExRec->ExceptionCode,
+ pExRec->ExceptionFlags);
+
+ if (pExRec->ExceptionFlags)
+ {
+ printf (" ( ");
+ if (pExRec->ExceptionFlags & EH_NONCONTINUABLE)
+ {
+ printf ("EH_NONCONTINUABLE ");
+ }
+ if (pExRec->ExceptionFlags & EH_UNWINDING)
+ {
+ printf ("EH_UNWINDING ");
+ }
+ if (pExRec->ExceptionFlags & EH_EXIT_UNWIND)
+ {
+ printf ("EH_EXIT_UNWIND ");
+ }
+ if (pExRec->ExceptionFlags & EH_STACK_INVALID)
+ {
+ printf ("EH_STACK_INVALID ");
+ }
+ if (pExRec->ExceptionFlags & EH_NESTED_CALL)
+ {
+ printf ("EH_NESTED_CALL ");
+ }
+ printf (")\n");
+ }
+ else
+ {
+ printf ("\n");
+ }
+
+ fflush(stdout);
+}
+
|