annotate src/backtrace.h @ 261:405dd6d1825b r20-5b29

Import from CVS: tag r20-5b29
author cvs
date Mon, 13 Aug 2007 10:23:51 +0200
parents 376386a54a3c
children c5d627a313b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* The lisp stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. Contained redundantly in various C files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 in FSFmacs. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* Authorship:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 FSF: Original version; a long time ago.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 XEmacs: split out of some C files. (For some obscure reason, a header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 file couldn't be used in FSF Emacs, but XEmacs doesn't have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 that problem.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 Mly (probably) or JWZ: Some changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #ifndef _XEMACS_BACKTRACE_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #define _XEMACS_BACKTRACE_H_
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include <setjmp.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 /* These definitions are used in eval.c and alloc.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 struct backtrace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 struct backtrace *next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Lisp_Object *function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 Lisp_Object *args; /* Points to vector of args. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 int nargs; /* Length of vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 If nargs is UNEVALLED, args points to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 slot holding list of unevalled args */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 int pdlcount; /* specpdl_depth () when invoked */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #ifdef EMACS_BTL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 /* The value of a Lisp integer that specifies the symbol being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "invoked" by this node in the backtrace, or 0 if the backtrace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 doesn't correspond to a such an invocation */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 int id_number;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 char evalargs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 /* Nonzero means call value of debugger when done with this operation. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 char debug_on_exit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 /* This structure helps implement the `catch' and `throw' control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 structure. A struct catchtag contains all the information needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 to restore the state of the interpreter after a non-local jump.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Handlers for error conditions (represented by `struct handler'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 structures) just point to a catch tag to do the cleanup required
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 for their jumps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 catchtag structures are chained together in the C calling stack;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 the `next' member points to the next outer catchtag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 A call like (throw TAG VAL) searches for a catchtag whose `tag'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 member is TAG, and then unbinds to it. The `val' member is used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 hold VAL while the stack is unwound; `val' is returned as the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 of the catch form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 All the other members are concerned with restoring the interpreter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 state. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 struct catchtag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 Lisp_Object tag;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 struct catchtag *next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 struct gcpro *gcpro;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 JMP_BUF jmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 struct backtrace *backlist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 /* #### */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 struct handler *handlerlist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 int lisp_eval_depth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 int pdlcount;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 /* This is the equivalent of async_timer_suppress_count.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 We probably don't have to bother with this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 int poll_suppress_count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 /* Dynamic-binding-o-rama */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 /* Structure for recording Lisp call stack for backtrace purposes. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 /* The special binding stack holds the outer values of variables while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 they are bound by a function application or a let form, stores the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 code to be executed for Lisp unwind-protect forms, and stores the C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 functions to be called for record_unwind_protect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 If func is non-zero, undoing this binding applies func to old_value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 This implements record_unwind_protect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 If func is zero and symbol is nil, undoing this binding evaluates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 the list of forms in old_value; this implements Lisp's unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Otherwise, undoing this binding stores old_value as symbol's value; this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 undoes the bindings made by a let form or function call. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 struct specbinding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 Lisp_Object symbol, old_value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 Lisp_Object (*func) (Lisp_Object); /* for unwind-protect */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 #if 0 /* FSFmacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 /* #### */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 /* Everything needed to describe an active condition case. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 struct handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 /* The handler clauses and variable from the condition-case form. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 Lisp_Object handler;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 Lisp_Object var;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 /* Fsignal stores here the condition-case clause that applies,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 and Fcondition_case thus knows which clause to run. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 Lisp_Object chosen_clause;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 /* Used to effect the longjump out to the handler. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 struct catchtag *tag;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 /* The next enclosing handler. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 struct handler *next;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 extern struct handler *handlerlist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 /* These are extern because GC needs to mark them */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 extern struct specbinding *specpdl;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 extern struct specbinding *specpdl_ptr;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 extern struct catchtag *catchlist;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 extern struct backtrace *backtrace_list;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 #endif /* _XEMACS_BACKTRACE_H_ */