3092
|
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 ##
|
|
25 ## Since this file is called `.gdbinit', it will be read by gdb
|
|
26 ## automatically when gdb is run in the build directory, which is where
|
|
27 ## developers usually debug their xemacs. You can also source this
|
|
28 ## file from your ~/.gdbinit, if you like.
|
|
29 ##
|
|
30 ## Configure xemacs with --debug, and compile with -g.
|
|
31 ##
|
|
32 ## See also the question of the XEmacs FAQ, titled
|
|
33 ## "How to Debug an XEmacs problem with a debugger".
|
|
34 ##
|
|
35 ## This can be used to debug XEmacs no matter how the following are
|
|
36 ## specified:
|
|
37
|
|
38 ## USE_UNION_TYPE
|
|
39
|
|
40 ## (the above all have configure equivalents)
|
|
41
|
|
42 ## Some functions defined here require a running process, but most
|
|
43 ## don't. Considerable effort has been expended to this end.
|
|
44
|
|
45 ## See the dbg_ C support code in src/alloc.c that allows the functions
|
|
46 ## defined in this file to work correctly.
|
|
47
|
|
48 #define NOT_C_CODE
|
|
49 #include "config.h"
|
|
50
|
|
51 set print union off
|
|
52 set print pretty off
|
|
53
|
|
54 #ifdef VDB_POSIX
|
|
55 handle SIGSEGV SIGBUS nostop noprint
|
|
56 #endif
|
|
57
|
|
58 set $Lisp_Type_Int = -2
|
|
59
|
|
60 define decode_object
|
|
61 set $obj = (unsigned long) $arg0
|
|
62 if $obj & 1
|
|
63 ## It's an int
|
|
64 set $val = $obj >> 1
|
|
65 set $type = $Lisp_Type_Int
|
|
66 else
|
|
67 set $type = $obj & dbg_typemask
|
|
68 if $type == Lisp_Type_Char
|
|
69 set $val = ($obj & dbg_valmask) >> dbg_gctypebits
|
|
70 else
|
|
71 ## It's a record pointer
|
|
72 set $val = $obj
|
|
73 end
|
|
74 end
|
|
75
|
|
76 if $type == Lisp_Type_Record
|
|
77 set $lheader = ((struct lrecord_header *) $val)
|
|
78 set $lrecord_type = ($lheader->type)
|
|
79 set $imp = ((struct lrecord_implementation *) lrecord_implementations_table[(int) $lrecord_type])
|
|
80 else
|
|
81 set $lrecord_type = -1
|
|
82 set $lheader = -1
|
|
83 set $imp = -1
|
|
84 end
|
|
85 end
|
|
86
|
|
87 document decode_object
|
|
88 Usage: decode_object lisp_object
|
|
89 Extract implementation information from a Lisp Object.
|
|
90 Defines variables $val, $type and $imp.
|
|
91 end
|
|
92
|
|
93 define xint
|
|
94 decode_object $arg0
|
|
95 print ((long) $val)
|
|
96 end
|
|
97
|
|
98 define xtype
|
|
99 decode_object $arg0
|
|
100 if $type == $Lisp_Type_Int
|
|
101 echo int\n
|
|
102 else
|
|
103 if $type == Lisp_Type_Char
|
|
104 echo char\n
|
|
105 else
|
|
106 printf "record type: %s\n", $imp->name
|
|
107 end
|
|
108 end
|
|
109 end
|
|
110
|
|
111 document xtype
|
|
112 Usage: xtype lisp_object
|
|
113 Print the Lisp type of a lisp object.
|
|
114 end
|
|
115
|
|
116 define lisp-shadows
|
|
117 run -batch -vanilla -f list-load-path-shadows
|
|
118 end
|
|
119
|
|
120 document lisp-shadows
|
|
121 Usage: lisp-shadows
|
|
122 Run xemacs to check for lisp shadows
|
|
123 end
|
|
124
|
|
125 define environment-to-run-temacs
|
|
126 unset env EMACSLOADPATH
|
|
127 set env EMACSBOOTSTRAPLOADPATH=../lisp/:..
|
|
128 set env EMACSBOOTSTRAPMODULEPATH=../modules/:..
|
|
129 end
|
|
130
|
|
131 define run-temacs
|
|
132 environment-to-run-temacs
|
|
133 run -nd -batch -l ../lisp/loadup.el run-temacs -q
|
|
134 end
|
|
135
|
|
136 document run-temacs
|
|
137 Usage: run-temacs
|
|
138 Run temacs interactively, like xemacs.
|
|
139 Use this with debugging tools (like purify) that cannot deal with dumping,
|
|
140 or when temacs builds successfully, but xemacs does not.
|
|
141 end
|
|
142
|
|
143 define check-xemacs
|
|
144 run -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
|
|
145 end
|
|
146
|
|
147 document check-xemacs
|
|
148 Usage: check-xemacs
|
|
149 Run the test suite. Equivalent to 'make check'.
|
|
150 end
|
|
151
|
|
152 define check-temacs
|
|
153 environment-to-run-temacs
|
|
154 run -nd -batch -l ../lisp/loadup.el run-temacs -q -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
|
|
155 end
|
|
156
|
|
157 document check-temacs
|
|
158 Usage: check-temacs
|
|
159 Run the test suite on temacs. Equivalent to 'make check-temacs'.
|
|
160 Use this with debugging tools (like purify) that cannot deal with dumping,
|
|
161 or when temacs builds successfully, but xemacs does not.
|
|
162 end
|
|
163
|
|
164 define update-elc
|
|
165 environment-to-run-temacs
|
|
166 run -nd -batch -l ../lisp/update-elc.el
|
|
167 end
|
|
168
|
|
169 document update-elc
|
|
170 Usage: update-elc
|
|
171 Run the core lisp byte compilation part of the build procedure.
|
|
172 Use when debugging temacs, not xemacs!
|
|
173 Use this when temacs builds successfully, but xemacs does not.
|
|
174 end
|
|
175
|
|
176 define dmp
|
|
177 environment-to-run-temacs
|
|
178 run -nd -batch -l ../lisp/loadup.el dump
|
|
179 end
|
|
180
|
|
181 document dmp
|
|
182 Usage: dmp
|
|
183 Run the dumping part of the build procedure.
|
|
184 Use when debugging temacs, not xemacs!
|
|
185 Use this when temacs builds successfully, but xemacs does not.
|
|
186 end
|
|
187
|
|
188 define ldp
|
|
189 printf "%s", "Lisp => "
|
|
190 call debug_print($arg0)
|
|
191 end
|
|
192
|
|
193 document ldp
|
|
194 Usage: ldp lisp_object
|
|
195 Print a Lisp Object value using the Lisp printer.
|
|
196 Requires a running xemacs process.
|
|
197 end
|
|
198
|
|
199 define lbt
|
|
200 call debug_backtrace()
|
|
201 end
|
|
202
|
|
203 document lbt
|
|
204 Usage: lbt
|
|
205 Print the current Lisp stack trace.
|
|
206 Requires a running xemacs process.
|
|
207 end
|
|
208
|
|
209
|
|
210 define leval
|
|
211 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
|
|
212 end
|
|
213
|
|
214 document leval
|
|
215 Usage: leval "SEXP"
|
|
216 Eval a lisp expression.
|
|
217 Requires a running xemacs process.
|
|
218
|
|
219 Example:
|
|
220 (gdb) leval "(+ 1 2)"
|
|
221 Lisp ==> 3
|
|
222 end
|
|
223
|
|
224
|
|
225 define wtype
|
|
226 print $arg0->core.widget_class->core_class.class_name
|
|
227 end
|
|
228
|
|
229 define xtname
|
|
230 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
|
|
231 end
|
|
232
|
|
233 ## GDB's command language makes you want to ...
|
|
234
|
|
235 define pptype
|
|
236 set $type_ptr = ($arg0 *) $val
|
|
237 print $type_ptr
|
|
238 print *$type_ptr
|
|
239 end
|
|
240
|
|
241 define pstructtype
|
|
242 set $type_ptr = (struct $arg0 *) $val
|
|
243 print $type_ptr
|
|
244 print *$type_ptr
|
|
245 end
|
|
246
|
|
247 define pobj
|
|
248 decode_object $arg0
|
|
249 if $type == $Lisp_Type_Int
|
|
250 printf "Integer: %d\n", $val
|
|
251 else
|
|
252 if $type == Lisp_Type_Char
|
|
253 if $val > 32 && $val < 128
|
|
254 printf "Char: %c\n", $val
|
|
255 else
|
|
256 printf "Char: %d\n", $val
|
|
257 end
|
|
258 else
|
|
259 if $lrecord_type == lrecord_type_string
|
|
260 pptype Lisp_String
|
|
261 else
|
|
262 if $lrecord_type == lrecord_type_cons
|
|
263 pptype Lisp_Cons
|
|
264 else
|
|
265 if $lrecord_type == lrecord_type_symbol
|
|
266 pptype Lisp_Symbol
|
|
267 printf "Symbol name: %s\n", ((Lisp_String *)$type_ptr->name)->data_
|
|
268 else
|
|
269 if $lrecord_type == lrecord_type_vector
|
|
270 pptype Lisp_Vector
|
|
271 printf "Vector of length %d\n", $type_ptr->size
|
|
272 ##print *($type_ptr->data) @ $type_ptr->size
|
|
273 else
|
|
274 if $lrecord_type == lrecord_type_bit_vector
|
|
275 pptype Lisp_Bit_Vector
|
|
276 else
|
|
277 if $lrecord_type == lrecord_type_buffer
|
|
278 pstructtype buffer
|
|
279 else
|
|
280 if $lrecord_type == lrecord_type_char_table
|
|
281 pptype Lisp_Char_Table
|
|
282 else
|
|
283 if $lrecord_type == lrecord_type_char_table_entry
|
|
284 pptype Lisp_Char_Table_Entry
|
|
285 else
|
|
286 if $lrecord_type == lrecord_type_charset
|
|
287 pptype Lisp_Charset
|
|
288 else
|
|
289 if $lrecord_type == lrecord_type_coding_system
|
|
290 pptype Lisp_Coding_System
|
|
291 else
|
|
292 if $lrecord_type == lrecord_type_color_instance
|
|
293 pptype Lisp_Color_Instance
|
|
294 else
|
|
295 if $lrecord_type == lrecord_type_command_builder
|
|
296 pptype command_builder
|
|
297 else
|
|
298 if $lrecord_type == lrecord_type_compiled_function
|
|
299 pptype Lisp_Compiled_Function
|
|
300 else
|
|
301 if $lrecord_type == lrecord_type_console
|
|
302 pstructtype console
|
|
303 else
|
|
304 if $lrecord_type == lrecord_type_database
|
|
305 pptype Lisp_Database
|
|
306 else
|
|
307 if $lrecord_type == lrecord_type_device
|
|
308 pstructtype device
|
|
309 else
|
|
310 if $lrecord_type == lrecord_type_event
|
|
311 pptype Lisp_Event
|
|
312 else
|
|
313 if $lrecord_type == lrecord_type_extent
|
|
314 pstructtype extent
|
|
315 else
|
|
316 if $lrecord_type == lrecord_type_extent_auxiliary
|
|
317 pstructtype extent_auxiliary
|
|
318 else
|
|
319 if $lrecord_type == lrecord_type_extent_info
|
|
320 pstructtype extent_info
|
|
321 else
|
|
322 if $lrecord_type == lrecord_type_face
|
|
323 pptype Lisp_Face
|
|
324 else
|
|
325 if $lrecord_type == lrecord_type_float
|
|
326 pptype Lisp_Float
|
|
327 else
|
|
328 if $lrecord_type == lrecord_type_font_instance
|
|
329 pptype Lisp_Font_Instance
|
|
330 else
|
|
331 if $lrecord_type == lrecord_type_frame
|
|
332 pstructtype frame
|
|
333 else
|
|
334 if $lrecord_type == lrecord_type_glyph
|
|
335 pptype Lisp_Glyph
|
|
336 else
|
|
337 if $lrecord_type == lrecord_type_gui_item
|
|
338 pptype Lisp_Gui_Item
|
|
339 else
|
|
340 if $lrecord_type == lrecord_type_hash_table
|
|
341 pptype Lisp_Hash_Table
|
|
342 else
|
|
343 if $lrecord_type == lrecord_type_image_instance
|
|
344 pptype Lisp_Image_Instance
|
|
345 else
|
|
346 if $lrecord_type == lrecord_type_keymap
|
|
347 pptype Lisp_Keymap
|
|
348 else
|
|
349 if $lrecord_type == lrecord_type_lcrecord_list
|
|
350 pstructtype lcrecord_list
|
|
351 else
|
|
352 if $lrecord_type == lrecord_type_ldap
|
|
353 pptype Lisp_LDAP
|
|
354 else
|
|
355 if $lrecord_type == lrecord_type_lstream
|
|
356 pstructtype lstream
|
|
357 else
|
|
358 if $lrecord_type == lrecord_type_marker
|
|
359 pptype Lisp_Marker
|
|
360 else
|
|
361 if $lrecord_type == lrecord_type_opaque
|
|
362 pptype Lisp_Opaque
|
|
363 else
|
|
364 if $lrecord_type == lrecord_type_opaque_ptr
|
|
365 pptype Lisp_Opaque_Ptr
|
|
366 else
|
|
367 if $lrecord_type == lrecord_type_popup_data
|
|
368 pptype popup_data
|
|
369 else
|
|
370 if $lrecord_type == lrecord_type_process
|
|
371 pptype Lisp_Process
|
|
372 else
|
|
373 if $lrecord_type == lrecord_type_range_table
|
|
374 pptype Lisp_Range_Table
|
|
375 else
|
|
376 if $lrecord_type == lrecord_type_specifier
|
|
377 pptype Lisp_Specifier
|
|
378 else
|
|
379 if $lrecord_type == lrecord_type_subr
|
|
380 pptype Lisp_Subr
|
|
381 else
|
|
382 if $lrecord_type == lrecord_type_symbol_value_buffer_local
|
|
383 pstructtype symbol_value_buffer_local
|
|
384 else
|
|
385 if $lrecord_type == lrecord_type_symbol_value_forward
|
|
386 pstructtype symbol_value_forward
|
|
387 else
|
|
388 if $lrecord_type == lrecord_type_symbol_value_lisp_magic
|
|
389 pstructtype symbol_value_lisp_magic
|
|
390 else
|
|
391 if $lrecord_type == lrecord_type_symbol_value_varalias
|
|
392 pstructtype symbol_value_varalias
|
|
393 else
|
|
394 if $lrecord_type == lrecord_type_timeout
|
|
395 pptype Lisp_Timeout
|
|
396 else
|
|
397 if $lrecord_type == lrecord_type_toolbar_button
|
|
398 pstructtype toolbar_button
|
|
399 else
|
|
400 if $lrecord_type == lrecord_type_tooltalk_message
|
|
401 pptype Lisp_Tooltalk_Message
|
|
402 else
|
|
403 if $lrecord_type == lrecord_type_tooltalk_pattern
|
|
404 pptype Lisp_Tooltalk_Pattern
|
|
405 else
|
|
406 if $lrecord_type == lrecord_type_weak_list
|
|
407 pstructtype weak_list
|
|
408 else
|
|
409 if $lrecord_type == lrecord_type_window
|
|
410 pstructtype window
|
|
411 else
|
|
412 if $lrecord_type == lrecord_type_window_configuration
|
|
413 pstructtype window_config
|
|
414 else
|
|
415 if $lrecord_type == lrecord_type_fc_pattern
|
|
416 pstructtype fc_pattern
|
|
417 else
|
|
418 if $lrecord_type == lrecord_type_fc_objectset
|
|
419 pstructtype fc_objectset
|
|
420 else
|
|
421 if $lrecord_type == lrecord_type_fc_fontset
|
|
422 pstructtype fc_fontset
|
|
423 else
|
|
424 echo Unknown Lisp Object type\n
|
|
425 print $arg0
|
|
426 ## Barf, gag, retch
|
|
427 end
|
|
428 end
|
|
429 end
|
|
430 end
|
|
431 end
|
|
432 end
|
|
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 ## Repeat after me... gdb sux, gdb sux, gdb sux...
|
|
448 end
|
|
449 end
|
|
450 end
|
|
451 end
|
|
452 end
|
|
453 end
|
|
454 end
|
|
455 end
|
|
456 end
|
|
457 end
|
|
458 end
|
|
459 end
|
|
460 end
|
|
461 end
|
|
462 end
|
|
463 end
|
|
464 end
|
|
465 end
|
|
466 ## Are we having fun yet??
|
|
467 end
|
|
468 end
|
|
469 end
|
|
470 end
|
|
471 end
|
|
472 end
|
|
473 end
|
|
474 end
|
|
475 end
|
|
476 end
|
|
477 end
|
|
478 end
|
|
479 end
|
|
480 end
|
|
481 end
|
|
482 end
|
|
483 end
|
|
484 end
|
|
485 end
|
|
486
|
|
487 document pobj
|
|
488 Usage: pobj lisp_object
|
|
489 Print the internal C representation of a Lisp Object.
|
|
490 end
|
|
491
|
|
492 ## -------------------------------------------------------------
|
|
493 ## functions to test the debugging support itself.
|
|
494 ## If you change this file, make sure the following still work...
|
|
495 ## -------------------------------------------------------------
|
|
496 define test_xtype
|
|
497 printf "Vemacs_major_version: "
|
|
498 xtype Vemacs_major_version
|
|
499 printf "Vhelp_char: "
|
|
500 xtype Vhelp_char
|
|
501 printf "Qnil: "
|
|
502 xtype Qnil
|
|
503 printf "Qunbound: "
|
|
504 xtype Qunbound
|
|
505 printf "Vobarray: "
|
|
506 xtype Vobarray
|
|
507 printf "Vall_weak_lists: "
|
|
508 xtype Vall_weak_lists
|
|
509 printf "Vxemacs_codename: "
|
|
510 xtype Vxemacs_codename
|
|
511 end
|
|
512
|
|
513 define test_pobj
|
|
514 printf "Vemacs_major_version: "
|
|
515 pobj Vemacs_major_version
|
|
516 printf "Vhelp_char: "
|
|
517 pobj Vhelp_char
|
|
518 printf "Qnil: "
|
|
519 pobj Qnil
|
|
520 printf "Qunbound: "
|
|
521 pobj Qunbound
|
|
522 printf "Vobarray: "
|
|
523 pobj Vobarray
|
|
524 printf "Vall_weak_lists: "
|
|
525 pobj Vall_weak_lists
|
|
526 printf "Vxemacs_codename: "
|
|
527 pobj Vxemacs_codename
|
|
528 end
|
|
529
|