2 # Copyright (C) 1998 Free Software Foundation, Inc.
4 # This file is part of XEmacs.
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
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
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.
21 # Author: Martin Buchholz
23 # Some useful commands for debugging emacs with gdb 4.16 or better.
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.
30 # Configure xemacs with --debug, and compile with -g.
32 # See also the question of the XEmacs FAQ, titled
33 # "How to Debug an XEmacs problem with a debugger".
35 # This can be used to debug XEmacs no matter how the following are
40 # (the above all have configure equivalents)
42 # Some functions defined here require a running process, but most
43 # don't. Considerable effort has been expended to this end.
45 # See the dbg_ C support code in src/alloc.c that allows the functions
46 # defined in this file to work correctly.
51 set $Lisp_Type_Int = -2
54 set $obj = (unsigned long) $arg0
58 set $type = $Lisp_Type_Int
60 set $type = $obj & dbg_typemask
61 if $type == Lisp_Type_Char
62 set $val = ($obj & dbg_valmask) >> dbg_gctypebits
64 # It's a record pointer
69 if $type == Lisp_Type_Record
70 set $lheader = ((struct lrecord_header *) $val)
71 set $lrecord_type = ($lheader->type)
72 set $imp = lrecord_implementations_table[$lrecord_type]
74 set $lrecord_type = -1
80 document decode_object
81 Usage: decode_object lisp_object
82 Extract implementation information from a Lisp Object.
83 Defines variables $val, $type and $imp.
93 if $type == $Lisp_Type_Int
96 if $type == Lisp_Type_Char
99 printf "record type: %s\n", $imp->name
105 Usage: xtype lisp_object
106 Print the Lisp type of a lisp object.
110 run -batch -vanilla -f list-load-path-shadows
113 document lisp-shadows
115 Run xemacs to check for lisp shadows
118 define environment-to-run-temacs
119 unset env EMACSLOADPATH
120 set env EMACSBOOTSTRAPLOADPATH=../lisp/:..
121 set env EMACSBOOTSTRAPMODULEPATH=../modules/:..
125 environment-to-run-temacs
126 run -batch -l ../lisp/loadup.el run-temacs -q
131 Run temacs interactively, like xemacs.
132 Use this with debugging tools (like purify) that cannot deal with dumping,
133 or when temacs builds successfully, but xemacs does not.
137 run -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
140 document check-xemacs
142 Run the test suite. Equivalent to 'make check'.
146 environment-to-run-temacs
147 run -batch -l ../lisp/loadup.el run-temacs -q -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
150 document check-temacs
152 Run the test suite on temacs. Equivalent to 'make check-temacs'.
153 Use this with debugging tools (like purify) that cannot deal with dumping,
154 or when temacs builds successfully, but xemacs does not.
158 environment-to-run-temacs
159 run -batch -l ../lisp/update-elc.el
164 Run the core lisp byte compilation part of the build procedure.
165 Use when debugging temacs, not xemacs!
166 Use this when temacs builds successfully, but xemacs does not.
170 environment-to-run-temacs
171 run -batch -l ../lisp/loadup.el dump
176 Run the dumping part of the build procedure.
177 Use when debugging temacs, not xemacs!
178 Use this when temacs builds successfully, but xemacs does not.
181 # if you use Purify, do this:
182 # export PURIFYOPTIONS='-pointer-mask=0x0fffffff'
185 printf "%s", "Lisp => "
186 call debug_print($arg0)
190 Usage: ldp lisp_object
191 Print a Lisp Object value using the Lisp printer.
192 Requires a running xemacs process.
196 call debug_backtrace()
201 Print the current Lisp stack trace.
202 Requires a running xemacs process.
207 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
212 Eval a lisp expression.
213 Requires a running xemacs process.
216 (gdb) leval "(+ 1 2)"
222 print $arg0->core.widget_class->core_class.class_name
226 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
229 # GDB's command language makes you want to ...
232 set $type_ptr = ($arg0 *) $val
238 set $type_ptr = (struct $arg0 *) $val
245 if $type == $Lisp_Type_Int
246 printf "Integer: %d\n", $val
248 if $type == Lisp_Type_Char
249 if $val > 32 && $val < 128
250 printf "Char: %c\n", $val
252 printf "Char: %d\n", $val
255 if $lrecord_type == lrecord_type_string
258 if $lrecord_type == lrecord_type_cons
261 if $lrecord_type == lrecord_type_symbol
263 printf "Symbol name: %s\n", $type_ptr->name->data
265 if $lrecord_type == lrecord_type_vector
267 printf "Vector of length %d\n", $type_ptr->size
268 #print *($type_ptr->data) @ $type_ptr->size
270 if $lrecord_type == lrecord_type_bit_vector
271 ptype Lisp_Bit_Vector
273 if $lrecord_type == lrecord_type_buffer
276 if $lrecord_type == lrecord_type_char_table
277 ptype Lisp_Char_Table
279 if $lrecord_type == lrecord_type_char_table_entry
280 ptype Lisp_Char_Table_Entry
282 if $lrecord_type == lrecord_type_charset
285 if $lrecord_type == lrecord_type_coding_system
286 ptype Lisp_Coding_System
288 if $lrecord_type == lrecord_type_color_instance
289 ptype Lisp_Color_Instance
291 if $lrecord_type == lrecord_type_command_builder
292 ptype command_builder
294 if $lrecord_type == lrecord_type_compiled_function
295 ptype Lisp_Compiled_Function
297 if $lrecord_type == lrecord_type_console
300 if $lrecord_type == lrecord_type_database
303 if $lrecord_type == lrecord_type_device
306 if $lrecord_type == lrecord_type_event
309 if $lrecord_type == lrecord_type_extent
312 if $lrecord_type == lrecord_type_extent_auxiliary
313 pstructtype extent_auxiliary
315 if $lrecord_type == lrecord_type_extent_info
316 pstructtype extent_info
318 if $lrecord_type == lrecord_type_face
321 if $lrecord_type == lrecord_type_float
324 if $lrecord_type == lrecord_type_font_instance
325 ptype Lisp_Font_Instance
327 if $lrecord_type == lrecord_type_frame
330 if $lrecord_type == lrecord_type_glyph
333 if $lrecord_type == lrecord_type_gui_item
336 if $lrecord_type == lrecord_type_hash_table
337 ptype Lisp_Hash_Table
339 if $lrecord_type == lrecord_type_image_instance
340 ptype Lisp_Image_Instance
342 if $lrecord_type == lrecord_type_keymap
345 if $lrecord_type == lrecord_type_lcrecord_list
346 pstructtype lcrecord_list
348 if $lrecord_type == lrecord_type_ldap
351 if $lrecord_type == lrecord_type_lstream
354 if $lrecord_type == lrecord_type_marker
357 if $lrecord_type == lrecord_type_opaque
360 if $lrecord_type == lrecord_type_opaque_ptr
361 ptype Lisp_Opaque_Ptr
363 if $lrecord_type == lrecord_type_popup_data
366 if $lrecord_type == lrecord_type_process
369 if $lrecord_type == lrecord_type_range_table
370 ptype Lisp_Range_Table
372 if $lrecord_type == lrecord_type_specifier
375 if $lrecord_type == lrecord_type_subr
378 if $lrecord_type == lrecord_type_symbol_value_buffer_local
379 pstructtype symbol_value_buffer_local
381 if $lrecord_type == lrecord_type_symbol_value_forward
382 pstructtype symbol_value_forward
384 if $lrecord_type == lrecord_type_symbol_value_lisp_magic
385 pstructtype symbol_value_lisp_magic
387 if $lrecord_type == lrecord_type_symbol_value_varalias
388 pstructtype symbol_value_varalias
390 if $lrecord_type == lrecord_type_timeout
393 if $lrecord_type == lrecord_type_toolbar_button
394 pstructtype toolbar_button
396 if $lrecord_type == lrecord_type_tooltalk_message
397 ptype Lisp_Tooltalk_Message
399 if $lrecord_type == lrecord_type_tooltalk_pattern
400 ptype Lisp_Tooltalk_Pattern
402 if $lrecord_type == lrecord_type_weak_list
403 pstructtype weak_list
405 if $lrecord_type == lrecord_type_window
408 if $lrecord_type == lrecord_type_window_configuration
409 pstructtype window_config
411 echo Unknown Lisp Object type\n
431 # Repeat after me... gdb sux, gdb sux, gdb sux...
450 # Are we having fun yet??
472 Usage: pobj lisp_object
473 Print the internal C representation of a Lisp Object.
476 # -------------------------------------------------------------
477 # functions to test the debugging support itself.
478 # If you change this file, make sure the following still work...
479 # -------------------------------------------------------------
481 printf "Vemacs_major_version: "
482 xtype Vemacs_major_version
483 printf "Vhelp_char: "
491 printf "Vall_weak_lists: "
492 xtype Vall_weak_lists
493 printf "Vxemacs_codename: "
494 xtype Vxemacs_codename
498 printf "Vemacs_major_version: "
499 pobj Vemacs_major_version
500 printf "Vhelp_char: "
508 printf "Vall_weak_lists: "
510 printf "Vxemacs_codename: "
511 pobj Vxemacs_codename