272
|
1 # -*- ksh -*-
|
|
2 # Copyright (C) 1998 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 # Author: Martin Buchholz
|
|
22
|
|
23 # Some useful commands for debugging emacs with gdb 4.16 or better.
|
|
24 # Install this as your .gdbinit file in your home directory,
|
|
25 # or source this file from your .gdbinit
|
|
26 # Configure xemacs with --debug, and compile with -g.
|
0
|
27 #
|
272
|
28 # See also the question of the XEmacs FAQ, titled
|
0
|
29 # "How to Debug an XEmacs problem with a debugger".
|
272
|
30 #
|
|
31 # This can be used to debug XEmacs no matter how the following are
|
|
32 # specified:
|
|
33
|
|
34 # USE_UNION_TYPE
|
|
35 # USE_MINIMAL_TAGBITS
|
|
36 # USE_INDEXED_LRECORD_IMPLEMENTATION
|
|
37 # LRECORD_(SYMBOL|STRING|VECTOR)
|
|
38
|
|
39 # (the above all have configure equivalents)
|
|
40
|
|
41 # Some functions defined here require a running process, but most
|
|
42 # don't. Considerable effort has been expended to this end.
|
|
43
|
|
44 # See the dbg_ C support code in src/alloc.c that allows the functions
|
|
45 # defined in this file to work correctly.
|
0
|
46
|
|
47 set print union off
|
|
48 set print pretty off
|
|
49
|
272
|
50 define decode_object
|
|
51 set $obj = (unsigned long) $arg0
|
|
52 if dbg_USE_MINIMAL_TAGBITS
|
|
53 if $obj & 1
|
|
54 # It's an int
|
|
55 set $val = $obj >> 1
|
337
|
56 set $type = Lisp_Type_Int
|
272
|
57 else
|
|
58 set $type = $obj & dbg_typemask
|
337
|
59 if $type == Lisp_Type_Char
|
272
|
60 set $val = ($obj & dbg_valmask) >> dbg_gctypebits
|
|
61 else
|
|
62 # It's a record pointer
|
|
63 set $val = $obj
|
|
64 end
|
|
65 end
|
|
66 else
|
|
67 # not dbg_USE_MINIMAL_TAGBITS
|
|
68 set $val = $obj & dbg_valmask
|
|
69 set $type = ($obj & dbg_typemask) >> (dbg_valbits + 1)
|
|
70 end
|
|
71
|
337
|
72 if $type == Lisp_Type_Record
|
272
|
73 set $lheader = (struct lrecord_header *) $val
|
|
74 if dbg_USE_INDEXED_LRECORD_IMPLEMENTATION
|
|
75 set $imp = lrecord_implementations_table[$lheader->type]
|
|
76 else
|
|
77 set $imp = $lheader->implementation
|
365
|
78 if $imp->finalizer == this_marks_a_marked_record
|
|
79 set $imp = $imp -1
|
|
80 printf "marked lrecord:\n"
|
|
81 end
|
272
|
82 end
|
|
83 else
|
|
84 set $imp = -1
|
|
85 end
|
|
86 end
|
|
87
|
|
88 document decode_object
|
|
89 Usage: decode_object lisp_object
|
|
90 Extract implementation information from a Lisp Object.
|
|
91 Defines variables $val, $type and $imp.
|
|
92 end
|
|
93
|
|
94 define xint
|
|
95 decode_object $arg0
|
|
96 print ((long) $val)
|
0
|
97 end
|
|
98
|
272
|
99 define xtype
|
|
100 decode_object $arg0
|
337
|
101 if $type == Lisp_Type_Int
|
272
|
102 echo int\n
|
|
103 else
|
337
|
104 if $type == Lisp_Type_Char
|
272
|
105 echo char\n
|
|
106 else
|
337
|
107 if $type == Lisp_Type_Symbol
|
272
|
108 echo symbol\n
|
|
109 else
|
337
|
110 if $type == Lisp_Type_String
|
272
|
111 echo string\n
|
|
112 else
|
337
|
113 if $type == Lisp_Type_Vector
|
272
|
114 echo vector\n
|
|
115 else
|
337
|
116 if $type == Lisp_Type_Cons
|
272
|
117 echo cons\n
|
|
118 else
|
|
119 printf "record type: %s\n", $imp->name
|
|
120 # barf
|
|
121 end
|
|
122 end
|
|
123 end
|
|
124 end
|
|
125 end
|
|
126 end
|
|
127 end
|
|
128
|
337
|
129 define lisp-shadows
|
|
130 run -batch -vanilla -f list-load-path-shadows
|
|
131 end
|
|
132
|
|
133 document lisp-shadows
|
|
134 Usage: lisp-shadows
|
|
135 Run xemacs to check for lisp shadows
|
|
136 end
|
|
137
|
|
138 define environment-to-run-temacs
|
284
|
139 unset env EMACSLOADPATH
|
337
|
140 set env EMACSBOOTSTRAPLOADPATH=../lisp/:..
|
|
141 set env EMACSBOOTSTRAPMODULEPATH=../modules/:..
|
|
142 end
|
|
143
|
|
144 define run-temacs
|
|
145 environment-to-run-temacs
|
284
|
146 run -batch -l ../lisp/loadup.el run-temacs -q
|
272
|
147 end
|
|
148
|
|
149 document run-temacs
|
|
150 Usage: run-temacs
|
|
151 Run temacs interactively, like xemacs.
|
|
152 Use this with debugging tools (like purify) that cannot deal with dumping,
|
|
153 or when temacs builds successfully, but xemacs does not.
|
|
154 end
|
|
155
|
|
156 define update-elc
|
337
|
157 environment-to-run-temacs
|
284
|
158 run -batch -l ../lisp/update-elc.el
|
272
|
159 end
|
|
160
|
|
161 document update-elc
|
|
162 Usage: update-elc
|
284
|
163 Run the core lisp byte compilation part of the build procedure.
|
272
|
164 Use when debugging temacs, not xemacs!
|
|
165 Use this when temacs builds successfully, but xemacs does not.
|
|
166 end
|
|
167
|
|
168 define dump-temacs
|
337
|
169 environment-to-run-temacs
|
284
|
170 run -batch -l ../lisp/loadup.el dump
|
272
|
171 end
|
|
172
|
|
173 document dump-temacs
|
|
174 Usage: dump-temacs
|
|
175 Run the dumping part of the build procedure.
|
|
176 Use when debugging temacs, not xemacs!
|
|
177 Use this when temacs builds successfully, but xemacs does not.
|
|
178 end
|
0
|
179
|
|
180 # if you use Purify, do this:
|
272
|
181 # export PURIFYOPTIONS='-pointer-mask=0x0fffffff'
|
0
|
182
|
272
|
183 define ldp
|
|
184 printf "%s", "Lisp => "
|
|
185 call debug_print($arg0)
|
|
186 end
|
|
187
|
|
188 document ldp
|
|
189 Usage: ldp lisp_object
|
|
190 Print a Lisp Object value using the Lisp printer.
|
|
191 Requires a running xemacs process.
|
0
|
192 end
|
|
193
|
|
194 define lbt
|
272
|
195 call debug_backtrace()
|
0
|
196 end
|
|
197
|
272
|
198 document lbt
|
|
199 Usage: lbt
|
|
200 Print the current Lisp stack trace.
|
|
201 Requires a running xemacs process.
|
0
|
202 end
|
|
203
|
337
|
204
|
|
205 define leval
|
|
206 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
|
|
207 end
|
|
208
|
|
209 document leval
|
|
210 Usage: leval "SEXP"
|
|
211 Eval a lisp expression.
|
|
212 Requires a running xemacs process.
|
|
213
|
|
214 Example:
|
|
215 (gdb) leval "(+ 1 2)"
|
|
216 Lisp ==> 3
|
|
217 end
|
|
218
|
|
219
|
272
|
220 define wtype
|
|
221 print $arg0->core.widget_class->core_class.class_name
|
0
|
222 end
|
|
223
|
272
|
224 define xtname
|
|
225 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
|
0
|
226 end
|
|
227
|
272
|
228 # GDB's command language makes you want to ...
|
0
|
229
|
272
|
230 define pstruct
|
|
231 set $xstruct = (struct $arg0 *) $val
|
|
232 print $xstruct
|
|
233 print *$xstruct
|
0
|
234 end
|
|
235
|
272
|
236 define pobj
|
|
237 decode_object $arg0
|
337
|
238 if $type == Lisp_Type_Int
|
272
|
239 printf "Integer: %d\n", $val
|
|
240 else
|
337
|
241 if $type == Lisp_Type_Char
|
|
242 if $val > 32 && $val < 128
|
272
|
243 printf "Char: %c\n", $val
|
|
244 else
|
|
245 printf "Char: %d\n", $val
|
|
246 end
|
|
247 else
|
337
|
248 if $type == Lisp_Type_String || $imp == lrecord_string
|
272
|
249 pstruct Lisp_String
|
|
250 else
|
337
|
251 if $type == Lisp_Type_Cons || $imp == lrecord_cons
|
272
|
252 pstruct Lisp_Cons
|
|
253 else
|
337
|
254 if $type == Lisp_Type_Symbol || $imp == lrecord_symbol
|
272
|
255 pstruct Lisp_Symbol
|
|
256 printf "Symbol name: %s\n", $xstruct->name->_data
|
|
257 else
|
337
|
258 if $type == Lisp_Type_Vector || $imp == lrecord_vector
|
272
|
259 pstruct Lisp_Vector
|
|
260 printf "Vector of length %d\n", $xstruct->size
|
|
261 #print *($xstruct->_data) @ $xstruct->size
|
|
262 else
|
|
263 if $imp == lrecord_bit_vector
|
|
264 pstruct Lisp_Bit_Vector
|
|
265 else
|
|
266 if $imp == lrecord_buffer
|
|
267 pstruct buffer
|
|
268 else
|
|
269 if $imp == lrecord_char_table
|
|
270 pstruct Lisp_Char_Table
|
|
271 else
|
|
272 if $imp == lrecord_char_table_entry
|
|
273 pstruct Lisp_Char_Table_Entry
|
|
274 else
|
|
275 if $imp == lrecord_charset
|
|
276 pstruct Lisp_Charset
|
|
277 else
|
|
278 if $imp == lrecord_coding_system
|
|
279 pstruct Lisp_Coding_System
|
|
280 else
|
|
281 if $imp == lrecord_color_instance
|
|
282 pstruct Lisp_Color_Instance
|
|
283 else
|
|
284 if $imp == lrecord_command_builder
|
|
285 pstruct command_builder
|
|
286 else
|
|
287 if $imp == lrecord_compiled_function
|
|
288 pstruct Lisp_Compiled_Function
|
|
289 else
|
|
290 if $imp == lrecord_console
|
|
291 pstruct console
|
|
292 else
|
|
293 if $imp == lrecord_database
|
337
|
294 pstruct Lisp_Database
|
272
|
295 else
|
|
296 if $imp == lrecord_device
|
|
297 pstruct device
|
|
298 else
|
|
299 if $imp == lrecord_event
|
|
300 pstruct Lisp_Event
|
|
301 else
|
|
302 if $imp == lrecord_extent
|
|
303 pstruct extent
|
|
304 else
|
|
305 if $imp == lrecord_extent_auxiliary
|
|
306 pstruct extent_auxiliary
|
|
307 else
|
|
308 if $imp == lrecord_extent_info
|
|
309 pstruct extent_info
|
|
310 else
|
|
311 if $imp == lrecord_face
|
|
312 pstruct Lisp_Face
|
|
313 else
|
|
314 if $imp == lrecord_float
|
|
315 pstruct Lisp_Float
|
|
316 else
|
|
317 if $imp == lrecord_font_instance
|
|
318 pstruct Lisp_Font_Instance
|
|
319 else
|
|
320 if $imp == lrecord_frame
|
|
321 pstruct frame
|
|
322 else
|
|
323 if $imp == lrecord_glyph
|
|
324 pstruct Lisp_Glyph
|
|
325 else
|
|
326 if $imp == lrecord_hashtable
|
365
|
327 pstruct hashtable
|
272
|
328 else
|
|
329 if $imp == lrecord_image_instance
|
|
330 pstruct Lisp_Image_Instance
|
|
331 else
|
|
332 if $imp == lrecord_keymap
|
337
|
333 pstruct Lisp_Keymap
|
0
|
334 else
|
272
|
335 if $imp == lrecord_lcrecord_list
|
|
336 pstruct lcrecord_list
|
|
337 else
|
|
338 if $imp == lrecord_lstream
|
|
339 pstruct lstream
|
0
|
340 else
|
272
|
341 if $imp == lrecord_marker
|
|
342 pstruct Lisp_Marker
|
|
343 else
|
|
344 if $imp == lrecord_opaque
|
|
345 pstruct Lisp_Opaque
|
0
|
346 else
|
272
|
347 if $imp == lrecord_opaque_list
|
|
348 pstruct Lisp_Opaque_List
|
|
349 else
|
|
350 if $imp == lrecord_popup_data
|
|
351 pstruct popup_data
|
0
|
352 else
|
272
|
353 if $imp == lrecord_process
|
|
354 pstruct Lisp_Process
|
|
355 else
|
|
356 if $imp == lrecord_range_table
|
|
357 pstruct Lisp_Range_Table
|
0
|
358 else
|
272
|
359 if $imp == lrecord_specifier
|
|
360 pstruct Lisp_Specifier
|
|
361 else
|
|
362 if $imp == lrecord_subr
|
|
363 pstruct Lisp_Subr
|
0
|
364 else
|
272
|
365 if $imp == lrecord_symbol_value_buffer_local
|
|
366 pstruct symbol_value_buffer_local
|
|
367 else
|
|
368 if $imp == lrecord_symbol_value_forward
|
|
369 pstruct symbol_value_forward
|
0
|
370 else
|
272
|
371 if $imp == lrecord_symbol_value_lisp_magic
|
|
372 pstruct symbol_value_lisp_magic
|
|
373 else
|
|
374 if $imp == lrecord_symbol_value_varalias
|
|
375 pstruct symbol_value_varalias
|
0
|
376 else
|
272
|
377 if $imp == lrecord_toolbar_button
|
|
378 pstruct toolbar_button
|
0
|
379 else
|
272
|
380 if $imp == lrecord_tooltalk_message
|
|
381 pstruct Lisp_Tooltalk_Message
|
0
|
382 else
|
272
|
383 if $imp == lrecord_tooltalk_pattern
|
|
384 pstruct Lisp_Tooltalk_Pattern
|
0
|
385 else
|
272
|
386 if $imp == lrecord_weak_list
|
|
387 pstruct weak_list
|
0
|
388 else
|
272
|
389 if $imp == lrecord_window
|
|
390 pstruct window
|
|
391 else
|
|
392 if $imp == lrecord_window_configuration
|
|
393 pstruct window_config
|
0
|
394 else
|
272
|
395 echo Unknown Lisp Object type\n
|
|
396 print $arg0
|
|
397 # Barf, gag, retch
|
|
398 end
|
|
399 end
|
|
400 end
|
|
401 end
|
|
402 end
|
|
403 end
|
|
404 end
|
|
405 end
|
|
406 end
|
|
407 end
|
|
408 end
|
|
409 end
|
|
410 end
|
|
411 end
|
|
412 end
|
337
|
413 # Repeat after me... gdb sux, gdb sux, gdb sux...
|
272
|
414 end
|
|
415 end
|
|
416 end
|
|
417 end
|
|
418 end
|
|
419 end
|
|
420 end
|
|
421 end
|
|
422 end
|
|
423 end
|
|
424 end
|
|
425 end
|
|
426 end
|
|
427 end
|
|
428 end
|
|
429 end
|
|
430 end
|
0
|
431 end
|
337
|
432 # Are we having fun yet??
|
0
|
433 end
|
|
434 end
|
|
435 end
|
|
436 end
|
|
437 end
|
|
438 end
|
|
439 end
|
|
440 end
|
|
441 end
|
|
442 end
|
|
443 end
|
|
444 end
|
|
445 end
|
|
446 end
|
|
447 end
|
|
448 end
|
|
449 end
|
|
450 end
|
|
451
|
272
|
452 document pobj
|
|
453 Usage: pobj lisp_object
|
|
454 Print the internal C structure of a underlying Lisp Object.
|
0
|
455 end
|
337
|
456
|
|
457 # -------------------------------------------------------------
|
|
458 # functions to test the debugging support itself.
|
|
459 # If you change this file, make sure the following still work...
|
|
460 # -------------------------------------------------------------
|
|
461 define test_xtype
|
|
462 printf "Vemacs_major_version: "
|
|
463 xtype Vemacs_major_version
|
|
464 printf "Vhelp_char: "
|
|
465 xtype Vhelp_char
|
|
466 printf "Qnil: "
|
|
467 xtype Qnil
|
|
468 printf "Qunbound: "
|
|
469 xtype Qunbound
|
|
470 printf "Vobarray: "
|
|
471 xtype Vobarray
|
|
472 printf "Vall_weak_lists: "
|
|
473 xtype Vall_weak_lists
|
|
474 printf "Vxemacs_codename: "
|
|
475 xtype Vxemacs_codename
|
|
476 end
|
|
477
|
|
478 define test_pobj
|
|
479 printf "Vemacs_major_version: "
|
|
480 pobj Vemacs_major_version
|
|
481 printf "Vhelp_char: "
|
|
482 pobj Vhelp_char
|
|
483 printf "Qnil: "
|
|
484 pobj Qnil
|
|
485 printf "Qunbound: "
|
|
486 pobj Qunbound
|
|
487 printf "Vobarray: "
|
|
488 pobj Vobarray
|
|
489 printf "Vall_weak_lists: "
|
|
490 pobj Vall_weak_lists
|
365
|
491 printf "Vall_weak_hashtables: "
|
|
492 pobj Vall_weak_hashtables
|
337
|
493 printf "Vxemacs_codename: "
|
|
494 pobj Vxemacs_codename
|
|
495 end
|
|
496
|