0
|
1 /* Debugging aids -- togglable assertions.
|
|
2 Copyright (C) 1994 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: Not in FSF. */
|
|
22
|
|
23 /* This file has been Mule-ized. */
|
|
24
|
|
25 /* Written by Chuck Thompson */
|
|
26
|
|
27 #include <config.h>
|
|
28 #include "lisp.h"
|
|
29 #include "debug.h"
|
|
30 #include "bytecode.h"
|
|
31
|
|
32 /*
|
|
33 * To add a new debug class:
|
|
34 * 1. Add a symbol definition for it here, if one doesn't exist
|
|
35 * elsewhere. If you add it here, make sure to add a defsymbol
|
|
36 * line for it in syms_of_debug.
|
|
37 * 2. Add an extern definition for the symbol to debug.h.
|
|
38 * 3. Add entries for the class to struct debug_classes in debug.h.
|
|
39 * 4. Add a FROB line for it in xemacs_debug_loop.
|
|
40 */
|
|
41
|
424
|
42 static Lisp_Object Qredisplay, Qbuffers, Qfaces, Qwindows, Qframes, Qdevices;
|
0
|
43
|
|
44 struct debug_classes active_debug_classes;
|
|
45
|
|
46 enum debug_loop
|
|
47 {
|
412
|
48 ADD,
|
|
49 DELETE,
|
|
50 LIST,
|
|
51 ACTIVE,
|
|
52 INIT,
|
|
53 VALIDATE,
|
|
54 TYPE,
|
|
55 SETTYPE
|
0
|
56 };
|
|
57
|
|
58 static Lisp_Object
|
|
59 xemacs_debug_loop (enum debug_loop op, Lisp_Object class, Lisp_Object type)
|
|
60 {
|
412
|
61 int flag = (op == ADD) ? 1 : 0;
|
0
|
62 Lisp_Object retval = Qnil;
|
|
63
|
380
|
64 #define FROB(item) \
|
412
|
65 if (op == LIST || op == ACTIVE || op == INIT || EQ (class, Q##item)) \
|
0
|
66 { \
|
412
|
67 if (op == ADD || op == DELETE || op == INIT) \
|
0
|
68 active_debug_classes.item = flag; \
|
412
|
69 else if (op == LIST \
|
|
70 || (op == ACTIVE && active_debug_classes.item)) \
|
0
|
71 retval = Fcons (Q##item, retval); \
|
412
|
72 else if (op == VALIDATE) \
|
0
|
73 return Qt; \
|
412
|
74 else if (op == SETTYPE) \
|
0
|
75 active_debug_classes.types_of_##item = XINT (type); \
|
412
|
76 else if (op == TYPE) \
|
380
|
77 retval = make_int (active_debug_classes.types_of_##item); \
|
412
|
78 if (op == INIT) active_debug_classes.types_of_##item = VALBITS; \
|
0
|
79 }
|
|
80
|
|
81 FROB (redisplay);
|
|
82 FROB (buffers);
|
|
83 FROB (extents);
|
|
84 FROB (faces);
|
|
85 FROB (windows);
|
|
86 FROB (frames);
|
|
87 FROB (devices);
|
|
88 FROB (byte_code);
|
185
|
89
|
0
|
90 return retval;
|
|
91 #undef FROB
|
|
92 }
|
|
93
|
20
|
94 DEFUN ("add-debug-class-to-check", Fadd_debug_class_to_check, 1, 1, 0, /*
|
0
|
95 Add a debug class to the list of active classes.
|
20
|
96 */
|
|
97 (class))
|
0
|
98 {
|
412
|
99 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
0
|
100 error ("No such debug class exists");
|
|
101 else
|
412
|
102 xemacs_debug_loop (ADD, class, Qnil);
|
0
|
103
|
412
|
104 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
0
|
105 }
|
|
106
|
20
|
107 DEFUN ("delete-debug-class-to-check", Fdelete_debug_class_to_check, 1, 1, 0, /*
|
0
|
108 Delete a debug class from the list of active classes.
|
20
|
109 */
|
|
110 (class))
|
0
|
111 {
|
412
|
112 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
0
|
113 error ("No such debug class exists");
|
|
114 else
|
412
|
115 xemacs_debug_loop (DELETE, class, Qnil);
|
0
|
116
|
412
|
117 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
0
|
118 }
|
|
119
|
20
|
120 DEFUN ("debug-classes-being-checked", Fdebug_classes_being_checked, 0, 0, 0, /*
|
0
|
121 Return a list of active debug classes.
|
20
|
122 */
|
|
123 ())
|
0
|
124 {
|
412
|
125 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
0
|
126 }
|
|
127
|
20
|
128 DEFUN ("debug-classes-list", Fdebug_classes_list, 0, 0, 0, /*
|
0
|
129 Return a list of all defined debug classes.
|
20
|
130 */
|
|
131 ())
|
0
|
132 {
|
412
|
133 return (xemacs_debug_loop (LIST, Qnil, Qnil));
|
0
|
134 }
|
|
135
|
20
|
136 DEFUN ("set-debug-classes-to-check", Fset_debug_classes_to_check, 1, 1, 0, /*
|
0
|
137 Set which classes of debug statements should be active.
|
|
138 CLASSES should be a list of debug classes.
|
20
|
139 */
|
|
140 (classes))
|
0
|
141 {
|
|
142 Lisp_Object rest;
|
|
143
|
|
144 CHECK_LIST (classes);
|
|
145
|
|
146 /* Make sure all objects in the list are valid. If anyone is not
|
|
147 valid, reject the entire list without doing anything. */
|
|
148 LIST_LOOP (rest, classes )
|
|
149 {
|
412
|
150 if (NILP (xemacs_debug_loop (VALIDATE, XCAR (rest), Qnil)))
|
0
|
151 error ("Invalid object in class list");
|
|
152 }
|
|
153
|
|
154 LIST_LOOP (rest, classes)
|
|
155 Fadd_debug_class_to_check (XCAR (rest));
|
|
156
|
412
|
157 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
0
|
158 }
|
|
159
|
20
|
160 DEFUN ("set-debug-class-types-to-check", Fset_debug_class_types_to_check, 2, 2, 0, /*
|
0
|
161 For the given debug CLASS, set which TYPES are actually interesting.
|
|
162 TYPES should be an integer representing the or'd value of all desired types.
|
|
163 Lists of defined types and their values are located in the source code.
|
20
|
164 */
|
|
165 (class, type))
|
0
|
166 {
|
|
167 CHECK_INT (type);
|
412
|
168 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
0
|
169 error ("Invalid debug class");
|
|
170
|
412
|
171 xemacs_debug_loop (SETTYPE, class, type);
|
0
|
172
|
412
|
173 return (xemacs_debug_loop (TYPE, class, Qnil));
|
0
|
174 }
|
|
175
|
20
|
176 DEFUN ("debug-types-being-checked", Fdebug_types_being_checked, 1, 1, 0, /*
|
0
|
177 For the given CLASS, return the associated type value.
|
20
|
178 */
|
|
179 (class))
|
0
|
180 {
|
412
|
181 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
0
|
182 error ("Invalid debug class");
|
|
183
|
412
|
184 return (xemacs_debug_loop (TYPE, class, Qnil));
|
0
|
185 }
|
|
186
|
|
187 void
|
|
188 syms_of_debug (void)
|
|
189 {
|
|
190 defsymbol (&Qredisplay, "redisplay");
|
|
191 defsymbol (&Qbuffers, "buffers");
|
|
192 defsymbol (&Qfaces, "faces");
|
|
193 defsymbol (&Qwindows, "windows");
|
|
194 defsymbol (&Qframes, "frames");
|
|
195 defsymbol (&Qdevices, "devices");
|
|
196
|
20
|
197 DEFSUBR (Fadd_debug_class_to_check);
|
|
198 DEFSUBR (Fdelete_debug_class_to_check);
|
|
199 DEFSUBR (Fdebug_classes_being_checked);
|
|
200 DEFSUBR (Fdebug_classes_list);
|
|
201 DEFSUBR (Fset_debug_classes_to_check);
|
|
202 DEFSUBR (Fset_debug_class_types_to_check);
|
|
203 DEFSUBR (Fdebug_types_being_checked);
|
0
|
204 }
|
|
205
|
|
206 void
|
424
|
207 reinit_vars_of_debug (void)
|
0
|
208 {
|
|
209 /* If you need to have any classes active early on in startup, then
|
|
210 the flags should be set here.
|
|
211 All functions called by this function are "allowed" according
|
|
212 to emacs.c. */
|
412
|
213 xemacs_debug_loop (INIT, Qnil, Qnil);
|
0
|
214 }
|
424
|
215
|
|
216 void
|
|
217 vars_of_debug (void)
|
|
218 {
|
|
219 reinit_vars_of_debug ();
|
|
220 }
|