sl@0
|
1 |
/*
|
sl@0
|
2 |
* tclPanic.c --
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* Source code for the "Tcl_Panic" library procedure for Tcl;
|
sl@0
|
5 |
* individual applications will probably call Tcl_SetPanicProc()
|
sl@0
|
6 |
* to set an application-specific panic procedure.
|
sl@0
|
7 |
*
|
sl@0
|
8 |
* Copyright (c) 1988-1993 The Regents of the University of California.
|
sl@0
|
9 |
* Copyright (c) 1994 Sun Microsystems, Inc.
|
sl@0
|
10 |
* Copyright (c) 1998-1999 by Scriptics Corporation.
|
sl@0
|
11 |
* Portions Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiaries. All rights reserved.
|
sl@0
|
12 |
*
|
sl@0
|
13 |
* See the file "license.terms" for information on usage and redistribution
|
sl@0
|
14 |
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
sl@0
|
15 |
*
|
sl@0
|
16 |
* RCS: @(#) $Id: tclPanic.c,v 1.4.12.2 2006/03/09 23:11:23 dgp Exp $
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "tclInt.h"
|
sl@0
|
20 |
#include "tclPort.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
/*
|
sl@0
|
23 |
* The panicProc variable contains a pointer to an application
|
sl@0
|
24 |
* specific panic procedure.
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
|
sl@0
|
27 |
static Tcl_PanicProc *panicProc = NULL;
|
sl@0
|
28 |
|
sl@0
|
29 |
/*
|
sl@0
|
30 |
* The platformPanicProc variable contains a pointer to a platform
|
sl@0
|
31 |
* specific panic procedure, if any. ( TclpPanic may be NULL via
|
sl@0
|
32 |
* a macro. )
|
sl@0
|
33 |
*/
|
sl@0
|
34 |
|
sl@0
|
35 |
static Tcl_PanicProc * CONST platformPanicProc = TclpPanic;
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
/*
|
sl@0
|
39 |
*----------------------------------------------------------------------
|
sl@0
|
40 |
*
|
sl@0
|
41 |
* Tcl_SetPanicProc --
|
sl@0
|
42 |
*
|
sl@0
|
43 |
* Replace the default panic behavior with the specified functiion.
|
sl@0
|
44 |
*
|
sl@0
|
45 |
* Results:
|
sl@0
|
46 |
* None.
|
sl@0
|
47 |
*
|
sl@0
|
48 |
* Side effects:
|
sl@0
|
49 |
* Sets the panicProc variable.
|
sl@0
|
50 |
*
|
sl@0
|
51 |
*----------------------------------------------------------------------
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
|
sl@0
|
54 |
EXPORT_C void
|
sl@0
|
55 |
Tcl_SetPanicProc(proc)
|
sl@0
|
56 |
Tcl_PanicProc *proc;
|
sl@0
|
57 |
{
|
sl@0
|
58 |
panicProc = proc;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
/*
|
sl@0
|
62 |
*----------------------------------------------------------------------
|
sl@0
|
63 |
*
|
sl@0
|
64 |
* Tcl_PanicVA --
|
sl@0
|
65 |
*
|
sl@0
|
66 |
* Print an error message and kill the process.
|
sl@0
|
67 |
*
|
sl@0
|
68 |
* Results:
|
sl@0
|
69 |
* None.
|
sl@0
|
70 |
*
|
sl@0
|
71 |
* Side effects:
|
sl@0
|
72 |
* The process dies, entering the debugger if possible.
|
sl@0
|
73 |
*
|
sl@0
|
74 |
*----------------------------------------------------------------------
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
|
sl@0
|
77 |
EXPORT_C void
|
sl@0
|
78 |
Tcl_PanicVA (format, argList)
|
sl@0
|
79 |
CONST char *format; /* Format string, suitable for passing to
|
sl@0
|
80 |
* fprintf. */
|
sl@0
|
81 |
va_list argList; /* Variable argument list. */
|
sl@0
|
82 |
{
|
sl@0
|
83 |
char *arg1, *arg2, *arg3, *arg4; /* Additional arguments (variable in
|
sl@0
|
84 |
* number) to pass to fprintf. */
|
sl@0
|
85 |
char *arg5, *arg6, *arg7, *arg8;
|
sl@0
|
86 |
|
sl@0
|
87 |
arg1 = va_arg(argList, char *);
|
sl@0
|
88 |
arg2 = va_arg(argList, char *);
|
sl@0
|
89 |
arg3 = va_arg(argList, char *);
|
sl@0
|
90 |
arg4 = va_arg(argList, char *);
|
sl@0
|
91 |
arg5 = va_arg(argList, char *);
|
sl@0
|
92 |
arg6 = va_arg(argList, char *);
|
sl@0
|
93 |
arg7 = va_arg(argList, char *);
|
sl@0
|
94 |
arg8 = va_arg(argList, char *);
|
sl@0
|
95 |
|
sl@0
|
96 |
if (panicProc != NULL) {
|
sl@0
|
97 |
(void) (*panicProc)(format, arg1, arg2, arg3, arg4,
|
sl@0
|
98 |
arg5, arg6, arg7, arg8);
|
sl@0
|
99 |
} else if (platformPanicProc != NULL) {
|
sl@0
|
100 |
(void) (*platformPanicProc)(format, arg1, arg2, arg3, arg4,
|
sl@0
|
101 |
arg5, arg6, arg7, arg8);
|
sl@0
|
102 |
} else {
|
sl@0
|
103 |
(void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6,
|
sl@0
|
104 |
arg7, arg8);
|
sl@0
|
105 |
(void) fprintf(stderr, "\n");
|
sl@0
|
106 |
(void) fflush(stderr);
|
sl@0
|
107 |
abort();
|
sl@0
|
108 |
}
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
/*
|
sl@0
|
112 |
*----------------------------------------------------------------------
|
sl@0
|
113 |
*
|
sl@0
|
114 |
* Tcl_Panic --
|
sl@0
|
115 |
*
|
sl@0
|
116 |
* Print an error message and kill the process.
|
sl@0
|
117 |
*
|
sl@0
|
118 |
* Results:
|
sl@0
|
119 |
* None.
|
sl@0
|
120 |
*
|
sl@0
|
121 |
* Side effects:
|
sl@0
|
122 |
* The process dies, entering the debugger if possible.
|
sl@0
|
123 |
*
|
sl@0
|
124 |
*----------------------------------------------------------------------
|
sl@0
|
125 |
*/
|
sl@0
|
126 |
|
sl@0
|
127 |
/* VARARGS ARGSUSED */
|
sl@0
|
128 |
EXPORT_C void
|
sl@0
|
129 |
Tcl_Panic TCL_VARARGS_DEF(CONST char *,arg1)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
va_list argList;
|
sl@0
|
132 |
CONST char *format;
|
sl@0
|
133 |
|
sl@0
|
134 |
format = TCL_VARARGS_START(CONST char *,arg1,argList);
|
sl@0
|
135 |
Tcl_PanicVA(format, argList);
|
sl@0
|
136 |
va_end (argList);
|
sl@0
|
137 |
}
|