diff options
Diffstat (limited to 'generic/tclPanic.c')
-rw-r--r-- | generic/tclPanic.c | 25 |
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 } /* |