summaryrefslogtreecommitdiffstats
path: root/generic/tclPanic.c
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-12-16 08:52:37 (GMT)
committernijtmans <nijtmans>2010-12-16 08:52:37 (GMT)
commitea1de9848ccde7951194b1ed58065ee6b43f7c66 (patch)
treef6a3b71a40be33da4256477fb25da8e2573b127e /generic/tclPanic.c
parent8802a351978129fb686ef18982430a0c366fb06a (diff)
downloadtcl-ea1de9848ccde7951194b1ed58065ee6b43f7c66.zip
tcl-ea1de9848ccde7951194b1ed58065ee6b43f7c66.tar.gz
tcl-ea1de9848ccde7951194b1ed58065ee6b43f7c66.tar.bz2
[Patch 3124554]: Move WishPanic from Tk to Tcl
Better communication with debugger, if present.
Diffstat (limited to 'generic/tclPanic.c')
-rw-r--r--generic/tclPanic.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/generic/tclPanic.c b/generic/tclPanic.c
index d5d6142..6ef39e1 100644
--- a/generic/tclPanic.c
+++ b/generic/tclPanic.c
@@ -12,10 +12,16 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPanic.c,v 1.17 2010/12/15 14:03:52 nijtmans Exp $
+ * RCS: @(#) $Id: tclPanic.c,v 1.18 2010/12/16 08:52:37 nijtmans Exp $
*/
#include "tclInt.h"
+#ifdef _WIN32
+# ifdef _MSC_VER
+# include <intrin.h>
+# endif
+ MODULE_SCOPE void tclWinDebugPanic(const char *format, ...);
+#endif
/*
* The panicProc variable contains a pointer to an application specific panic
@@ -44,6 +50,10 @@ void
Tcl_SetPanicProc(
Tcl_PanicProc *proc)
{
+#ifdef _WIN32
+ /* tclWinDebugPanic only installs if there is no panicProc yet. */
+ if ((proc != tclWinDebugPanic) || (panicProc == NULL))
+#endif
panicProc = proc;
}
@@ -84,6 +94,10 @@ Tcl_PanicVA(
if (panicProc != NULL) {
panicProc(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+#ifdef _WIN32
+ } else if (IsDebuggerPresent()) {
+ tclWinDebugPanic(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+#endif
} else {
fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
arg8);
@@ -91,7 +105,16 @@ Tcl_PanicVA(
fflush(stderr);
}
/* In case the users panic proc does not abort, we do it here */
+#ifdef _WIN32
+# ifdef __GNUC__
+ __builtin_trap();
+# elif _MSC_VER
+ __debugbreak();
+# endif
+ ExitProcess(1);
+#else
abort();
+#endif
}
/*