Re: [RFC] creating Wine's own 'assert' variant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> A better approach would be to leave assert() alone, and raise an
> exception on the SIGABRT signal.

Hmmm, yeah, seems like a better solution. Does the attached patch seems
correct (at least on my testings, I got the debugger instead of an 'abort
message' on the terminal :-) ).

Changelog:
 Raise an exception if any Wine or Winelib code does an assert.

                      Lionel

-- 
		 Lionel Ulmer - http://www.bbrox.org/
Index: dlls/ntdll/signal_i386.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/signal_i386.c,v
retrieving revision 1.46
diff -u -r1.46 signal_i386.c
--- dlls/ntdll/signal_i386.c	12 Sep 2002 22:07:03 -0000	1.46
+++ dlls/ntdll/signal_i386.c	27 Oct 2002 08:00:01 -0000
@@ -1040,6 +1040,26 @@
     }
 }
 
+/**********************************************************************
+ *		abrt_handler
+ *
+ * Handler for SIGABRT.
+ */
+static HANDLER_DEF(abrt_handler)
+{
+    EXCEPTION_RECORD rec;
+    CONTEXT context;
+
+    save_context( &context, HANDLER_CONTEXT );
+    rec.ExceptionCode    = STATUS_NONCONTINUABLE_EXCEPTION;
+    rec.ExceptionFlags   = EH_NONCONTINUABLE;
+    rec.ExceptionRecord  = NULL;
+    rec.ExceptionAddress = (LPVOID)context.Eip;
+    rec.NumberParameters = 0;
+    EXC_RtlRaiseException( &rec, &context ); /* Should never return.. */
+    restore_context( &context, HANDLER_CONTEXT );
+}
+
 
 /***********************************************************************
  *           set_handler
@@ -1124,6 +1144,7 @@
     if (set_handler( SIGFPE,  have_sigaltstack, (void (*)())fpe_handler ) == -1) goto error;
     if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
     if (set_handler( SIGILL,  have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
+    if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error;
 #ifdef SIGBUS
     if (set_handler( SIGBUS,  have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
 #endif
Index: dlls/ntdll/signal_powerpc.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/signal_powerpc.c,v
retrieving revision 1.4
diff -u -r1.4 signal_powerpc.c
--- dlls/ntdll/signal_powerpc.c	12 Sep 2002 22:07:03 -0000	1.4
+++ dlls/ntdll/signal_powerpc.c	27 Oct 2002 08:00:01 -0000
@@ -381,6 +381,26 @@
     }
 }
 
+/**********************************************************************
+ *		abrt_handler
+ *
+ * Handler for SIGABRT.
+ */
+static HANDLER_DEF(abrt_handler)
+{
+    EXCEPTION_RECORD rec;
+    CONTEXT context;
+
+    save_context( &context, HANDLER_CONTEXT );
+    rec.ExceptionCode    = STATUS_NONCONTINUABLE_EXCEPTION;
+    rec.ExceptionFlags   = EH_NONCONTINUABLE;
+    rec.ExceptionRecord  = NULL;
+    rec.ExceptionAddress = (LPVOID)context.Eip;
+    rec.NumberParameters = 0;
+    EXC_RtlRaiseException( &rec, &context ); /* Should never return.. */
+    restore_context( &context, HANDLER_CONTEXT );
+}
+
 
 /***********************************************************************
  *           set_handler
@@ -440,6 +460,7 @@
     if (set_handler( SIGFPE,  have_sigaltstack, (void (*)())fpe_handler ) == -1) goto error;
     if (set_handler( SIGSEGV, have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
     if (set_handler( SIGILL,  have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
+    if (set_handler( SIGABRT, have_sigaltstack, (void (*)())abrt_handler ) == -1) goto error;
 #ifdef SIGBUS
     if (set_handler( SIGBUS,  have_sigaltstack, (void (*)())segv_handler ) == -1) goto error;
 #endif
Index: dlls/ntdll/signal_sparc.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/signal_sparc.c,v
retrieving revision 1.19
diff -u -r1.19 signal_sparc.c
--- dlls/ntdll/signal_sparc.c	12 Sep 2002 22:07:03 -0000	1.19
+++ dlls/ntdll/signal_sparc.c	27 Oct 2002 08:00:01 -0000
@@ -343,6 +343,25 @@
     }
 }
 
+/**********************************************************************
+ *		abrt_handler
+ *
+ * Handler for SIGABRT.
+ */
+static HANDLER_DEF(abrt_handler)
+{
+    EXCEPTION_RECORD rec;
+    CONTEXT context;
+
+    save_context( &context, HANDLER_CONTEXT );
+    rec.ExceptionCode    = STATUS_NONCONTINUABLE_EXCEPTION;
+    rec.ExceptionFlags   = EH_NONCONTINUABLE;
+    rec.ExceptionRecord  = NULL;
+    rec.ExceptionAddress = (LPVOID)context.Eip;
+    rec.NumberParameters = 0;
+    EXC_RtlRaiseException( &rec, &context ); /* Should never return.. */
+    restore_context( &context, HANDLER_CONTEXT );
+}
 
 /***********************************************************************
  *           set_handler
@@ -398,7 +417,8 @@
     if (set_handler( SIGILL,  (void (*)())ill_handler  ) == -1) goto error;
     if (set_handler( SIGBUS,  (void (*)())bus_handler  ) == -1) goto error;
     if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error;
-    return TRUE;
+    if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error;
+   return TRUE;
 
  error:
     perror("sigaction");

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux