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
|
|
42 Lisp_Object Qredisplay, Qbuffers, Qfaces;
|
|
43 Lisp_Object Qwindows, Qframes, Qdevices;
|
|
44
|
|
45 /* Lisp_Object Qbyte_code; in bytecode.c */
|
|
46
|
|
47 struct debug_classes active_debug_classes;
|
|
48
|
|
49 enum debug_loop
|
|
50 {
|
|
51 ADD,
|
|
52 DELETE,
|
|
53 LIST,
|
|
54 ACTIVE,
|
|
55 INIT,
|
|
56 VALIDATE,
|
|
57 TYPE,
|
|
58 SETTYPE
|
|
59 };
|
|
60
|
|
61 static Lisp_Object
|
|
62 xemacs_debug_loop (enum debug_loop op, Lisp_Object class, Lisp_Object type)
|
|
63 {
|
|
64 int flag = ((op == ADD) ? 1 : 0);
|
|
65 Lisp_Object retval = Qnil;
|
|
66
|
|
67 #define FROB(item)\
|
|
68 if (op == LIST || op == ACTIVE || op == INIT || EQ (class, Q##item)) \
|
|
69 { \
|
|
70 if (op == ADD || op == DELETE || op == INIT) \
|
|
71 active_debug_classes.item = flag; \
|
|
72 else if (op == LIST \
|
|
73 || (op == ACTIVE && active_debug_classes.item)) \
|
|
74 retval = Fcons (Q##item, retval); \
|
|
75 else if (op == VALIDATE) \
|
|
76 return Qt; \
|
|
77 else if (op == SETTYPE) \
|
|
78 active_debug_classes.types_of_##item = XINT (type); \
|
|
79 else if (op == TYPE) \
|
|
80 retval = make_int (active_debug_classes.types_of_##item), Qnil; \
|
|
81 if (op == INIT) active_debug_classes.types_of_##item = VALBITS; \
|
|
82 }
|
|
83
|
|
84 FROB (redisplay);
|
|
85 FROB (buffers);
|
|
86 FROB (extents);
|
|
87 FROB (faces);
|
|
88 FROB (windows);
|
|
89 FROB (frames);
|
|
90 FROB (devices);
|
|
91 FROB (byte_code);
|
|
92
|
|
93 return retval;
|
|
94 #undef FROB
|
|
95 }
|
|
96
|
20
|
97 DEFUN ("add-debug-class-to-check", Fadd_debug_class_to_check, 1, 1, 0, /*
|
0
|
98 Add a debug class to the list of active classes.
|
20
|
99 */
|
|
100 (class))
|
0
|
101 {
|
|
102 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
|
103 error ("No such debug class exists");
|
|
104 else
|
|
105 xemacs_debug_loop (ADD, class, Qnil);
|
|
106
|
|
107 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
|
108 }
|
|
109
|
20
|
110 DEFUN ("delete-debug-class-to-check", Fdelete_debug_class_to_check, 1, 1, 0, /*
|
0
|
111 Delete a debug class from the list of active classes.
|
20
|
112 */
|
|
113 (class))
|
0
|
114 {
|
|
115 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
|
116 error ("No such debug class exists");
|
|
117 else
|
|
118 xemacs_debug_loop (DELETE, class, Qnil);
|
|
119
|
|
120 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
|
121 }
|
|
122
|
20
|
123 DEFUN ("debug-classes-being-checked", Fdebug_classes_being_checked, 0, 0, 0, /*
|
0
|
124 Return a list of active debug classes.
|
20
|
125 */
|
|
126 ())
|
0
|
127 {
|
|
128 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
|
129 }
|
|
130
|
20
|
131 DEFUN ("debug-classes-list", Fdebug_classes_list, 0, 0, 0, /*
|
0
|
132 Return a list of all defined debug classes.
|
20
|
133 */
|
|
134 ())
|
0
|
135 {
|
|
136 return (xemacs_debug_loop (LIST, Qnil, Qnil));
|
|
137 }
|
|
138
|
20
|
139 DEFUN ("set-debug-classes-to-check", Fset_debug_classes_to_check, 1, 1, 0, /*
|
0
|
140 Set which classes of debug statements should be active.
|
|
141 CLASSES should be a list of debug classes.
|
20
|
142 */
|
|
143 (classes))
|
0
|
144 {
|
|
145 Lisp_Object rest;
|
|
146
|
|
147 CHECK_LIST (classes);
|
|
148
|
|
149 /* Make sure all objects in the list are valid. If anyone is not
|
|
150 valid, reject the entire list without doing anything. */
|
|
151 LIST_LOOP (rest, classes )
|
|
152 {
|
|
153 if (NILP (xemacs_debug_loop (VALIDATE, XCAR (rest), Qnil)))
|
|
154 error ("Invalid object in class list");
|
|
155 }
|
|
156
|
|
157 LIST_LOOP (rest, classes)
|
|
158 Fadd_debug_class_to_check (XCAR (rest));
|
|
159
|
|
160 return (xemacs_debug_loop (ACTIVE, Qnil, Qnil));
|
|
161 }
|
|
162
|
20
|
163 DEFUN ("set-debug-class-types-to-check", Fset_debug_class_types_to_check, 2, 2, 0, /*
|
0
|
164 For the given debug CLASS, set which TYPES are actually interesting.
|
|
165 TYPES should be an integer representing the or'd value of all desired types.
|
|
166 Lists of defined types and their values are located in the source code.
|
20
|
167 */
|
|
168 (class, type))
|
0
|
169 {
|
|
170 CHECK_INT (type);
|
|
171 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
|
172 error ("Invalid debug class");
|
|
173
|
|
174 xemacs_debug_loop (SETTYPE, class, type);
|
|
175
|
|
176 return (xemacs_debug_loop (TYPE, class, Qnil));
|
|
177 }
|
|
178
|
20
|
179 DEFUN ("debug-types-being-checked", Fdebug_types_being_checked, 1, 1, 0, /*
|
0
|
180 For the given CLASS, return the associated type value.
|
20
|
181 */
|
|
182 (class))
|
0
|
183 {
|
|
184 if (NILP (xemacs_debug_loop (VALIDATE, class, Qnil)))
|
|
185 error ("Invalid debug class");
|
|
186
|
|
187 return (xemacs_debug_loop (TYPE, class, Qnil));
|
|
188 }
|
|
189
|
|
190 void
|
|
191 syms_of_debug (void)
|
|
192 {
|
|
193 defsymbol (&Qredisplay, "redisplay");
|
|
194 defsymbol (&Qbuffers, "buffers");
|
|
195 defsymbol (&Qfaces, "faces");
|
|
196 defsymbol (&Qwindows, "windows");
|
|
197 defsymbol (&Qframes, "frames");
|
|
198 defsymbol (&Qdevices, "devices");
|
|
199 /* defsymbol (&Qbyte_code, "byte-code"); in bytecode.c */
|
|
200
|
20
|
201 DEFSUBR (Fadd_debug_class_to_check);
|
|
202 DEFSUBR (Fdelete_debug_class_to_check);
|
|
203 DEFSUBR (Fdebug_classes_being_checked);
|
|
204 DEFSUBR (Fdebug_classes_list);
|
|
205 DEFSUBR (Fset_debug_classes_to_check);
|
|
206 DEFSUBR (Fset_debug_class_types_to_check);
|
|
207 DEFSUBR (Fdebug_types_being_checked);
|
0
|
208 }
|
|
209
|
|
210 void
|
|
211 vars_of_debug (void)
|
|
212 {
|
|
213 Fprovide (intern ("debug"));
|
|
214
|
|
215 /* If you need to have any classes active early on in startup, then
|
|
216 the flags should be set here.
|
|
217 All functions called by this function are "allowed" according
|
|
218 to emacs.c. */
|
|
219 xemacs_debug_loop (INIT, Qnil, Qnil);
|
|
220 }
|
|
221
|