added insure debug support
authorAndrew Tridgell <tridge@samba.org>
Sat, 24 Jun 2000 13:19:53 +0000 (13:19 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sat, 24 Jun 2000 13:19:53 +0000 (13:19 +0000)
util.c

diff --git a/util.c b/util.c
index d8d4e9d68a75256b6ffd98057fd5667a0308a3a9..4fef0b3ec7e2d9e696c3c8b23284382fa1c18845 100644 (file)
--- a/util.c
+++ b/util.c
@@ -941,3 +941,35 @@ void wait_process(pid_t pid, int *status)
        waitpid(pid, status, 0);
        *status = WEXITSTATUS(*status);
 }
+
+
+#ifdef __INSURE__
+#include <dlfcn.h>
+
+/*******************************************************************
+This routine is a trick to immediately catch errors when debugging
+with insure. A xterm with a gdb is popped up when insure catches
+a error. It is Linux specific.
+********************************************************************/
+int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6)
+{
+       static int (*fn)();
+       int ret;
+       char cmd[1024];
+
+       sprintf(cmd, "/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; gdb /proc/%d/exe %d'", 
+               getpid(), getpid(), getpid());
+
+       if (!fn) {
+               static void *h;
+               h = dlopen("/usr/local/parasoft/insure++lite/lib.linux2/libinsure.so", RTLD_LAZY);
+               fn = dlsym(h, "_Insure_trap_error");
+       }
+
+       ret = fn(a1, a2, a3, a4, a5, a6);
+
+       system(cmd);
+
+       return ret;
+}
+#endif