src/lib/errabort.c 1.15
1.15 2009/06/07 07:13:37 markd
make stack dump on warn/abort stack under/overlow permanet
Index: src/lib/errabort.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/errabort.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -b -B -U 4 -r1.14 -r1.15
--- src/lib/errabort.c 4 Jun 2009 17:53:20 -0000 1.14
+++ src/lib/errabort.c 7 Jun 2009 07:13:37 -0000 1.15
@@ -16,9 +16,9 @@
#include "errabort.h"
static char const rcsid[] = "$Id$";
-int errAbortDebugPopUnderflow = FALSE; // FIXME tmp hack to try to find source of popWarnHandler underflows in browse
+static boolean debugPushPopErr = FALSE; // generate stack dump on push/pop error
static void defaultVaWarn(char *format, va_list args)
/* Default error message handler. */
{
@@ -63,18 +63,22 @@
void pushWarnHandler(WarnHandler handler)
/* Set abort handler */
{
if (warnIx >= maxWarnHandlers-1)
+ {
+ if (debugPushPopErr)
+ dumpStack("pushWarnHandler overflow");
errAbort("Too many pushWarnHandlers, can only handle %d\n", maxWarnHandlers-1);
+ }
warnArray[++warnIx] = handler;
}
void popWarnHandler()
/* Revert to old warn handler. */
{
if (warnIx <= 0)
{
- if (errAbortDebugPopUnderflow)
+ if (debugPushPopErr)
dumpStack("popWarnHandler underflow");
errAbort("Too many popWarnHandlers\n");
}
--warnIx;
@@ -131,19 +135,23 @@
void pushAbortHandler(AbortHandler handler)
/* Set abort handler */
{
if (abortIx >= maxAbortHandlers-1)
+ {
+ if (debugPushPopErr)
+ dumpStack("pushAbortHandler overflow");
errAbort("Too many pushAbortHandlers, can only handle %d\n", maxAbortHandlers-1);
+ }
abortArray[++abortIx] = handler;
}
void popAbortHandler()
/* Revert to old abort handler. */
{
if (abortIx <= 0)
{
- if (errAbortDebugPopUnderflow)
- dumpStack("popWarnHandler underflow");
+ if (debugPushPopErr)
+ dumpStack("popAbortHandler underflow");
errAbort("Too many popAbortHandlers\n");
}
--abortIx;
}
@@ -173,4 +181,10 @@
/* Push handler that will abort on warnings. */
{
pushWarnHandler(warnAbortHandler);
}
+
+void errAbortDebugnPushPopErr()
+/* generate stack dump if there is a error in the push/pop functions */
+{
+debugPushPopErr = TRUE;
+}