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 = ((struct lrecord_implementation *) lrecord_implementations_table[(int) $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 -nd -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 -nd -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 -nd -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 -nd -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.
182 printf "%s", "Lisp => "
183 call debug_print($arg0)
187 Usage: ldp lisp_object
188 Print a Lisp Object value using the Lisp printer.
189 Requires a running xemacs process.
193 call debug_backtrace()
198 Print the current Lisp stack trace.
199 Requires a running xemacs process.
204 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
209 Eval a lisp expression.
210 Requires a running xemacs process.
213 (gdb) leval "(+ 1 2)"
219 print $arg0->core.widget_class->core_class.class_name
223 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
226 # GDB's command language makes you want to ...
229 set $type_ptr = ($arg0 *) $val
235 set $type_ptr = (struct $arg0 *) $val
242 if $type == $Lisp_Type_Int
243 printf "Integer: %d\n", $val
245 if $type == Lisp_Type_Char
246 if $val > 32 && $val < 128
247 printf "Char: %c\n", $val
249 printf "Char: %d\n", $val
252 if $lrecord_type == lrecord_type_string
255 if $lrecord_type == lrecord_type_cons
258 if $lrecord_type == lrecord_type_symbol
260 printf "Symbol name: %s\n", $type_ptr->name->data
262 if $lrecord_type == lrecord_type_vector
264 printf "Vector of length %d\n", $type_ptr->size
265 #print *($type_ptr->data) @ $type_ptr->size
267 if $lrecord_type == lrecord_type_bit_vector
268 ptype Lisp_Bit_Vector
270 if $lrecord_type == lrecord_type_buffer
273 if $lrecord_type == lrecord_type_char_table
274 ptype Lisp_Char_Table
276 if $lrecord_type == lrecord_type_char_table_entry
277 ptype Lisp_Char_Table_Entry
279 if $lrecord_type == lrecord_type_charset
282 if $lrecord_type == lrecord_type_coding_system
283 ptype Lisp_Coding_System
285 if $lrecord_type == lrecord_type_color_instance
286 ptype Lisp_Color_Instance
288 if $lrecord_type == lrecord_type_command_builder
289 ptype command_builder
291 if $lrecord_type == lrecord_type_compiled_function
292 ptype Lisp_Compiled_Function
294 if $lrecord_type == lrecord_type_console
297 if $lrecord_type == lrecord_type_database
300 if $lrecord_type == lrecord_type_device
303 if $lrecord_type == lrecord_type_event
306 if $lrecord_type == lrecord_type_extent
309 if $lrecord_type == lrecord_type_extent_auxiliary
310 pstructtype extent_auxiliary
312 if $lrecord_type == lrecord_type_extent_info
313 pstructtype extent_info
315 if $lrecord_type == lrecord_type_face
318 if $lrecord_type == lrecord_type_float
321 if $lrecord_type == lrecord_type_font_instance
322 ptype Lisp_Font_Instance
324 if $lrecord_type == lrecord_type_frame
327 if $lrecord_type == lrecord_type_glyph
330 if $lrecord_type == lrecord_type_gui_item
333 if $lrecord_type == lrecord_type_hash_table
334 ptype Lisp_Hash_Table
336 if $lrecord_type == lrecord_type_image_instance
337 ptype Lisp_Image_Instance
339 if $lrecord_type == lrecord_type_keymap
342 if $lrecord_type == lrecord_type_lcrecord_list
343 pstructtype lcrecord_list
345 if $lrecord_type == lrecord_type_ldap
348 if $lrecord_type == lrecord_type_lstream
351 if $lrecord_type == lrecord_type_marker
354 if $lrecord_type == lrecord_type_opaque
357 if $lrecord_type == lrecord_type_opaque_ptr
358 ptype Lisp_Opaque_Ptr
360 if $lrecord_type == lrecord_type_popup_data
363 if $lrecord_type == lrecord_type_process
366 if $lrecord_type == lrecord_type_range_table
367 ptype Lisp_Range_Table
369 if $lrecord_type == lrecord_type_specifier
372 if $lrecord_type == lrecord_type_subr
375 if $lrecord_type == lrecord_type_symbol_value_buffer_local
376 pstructtype symbol_value_buffer_local
378 if $lrecord_type == lrecord_type_symbol_value_forward
379 pstructtype symbol_value_forward
381 if $lrecord_type == lrecord_type_symbol_value_lisp_magic
382 pstructtype symbol_value_lisp_magic
384 if $lrecord_type == lrecord_type_symbol_value_varalias
385 pstructtype symbol_value_varalias
387 if $lrecord_type == lrecord_type_timeout
390 if $lrecord_type == lrecord_type_toolbar_button
391 pstructtype toolbar_button
393 if $lrecord_type == lrecord_type_tooltalk_message
394 ptype Lisp_Tooltalk_Message
396 if $lrecord_type == lrecord_type_tooltalk_pattern
397 ptype Lisp_Tooltalk_Pattern
399 if $lrecord_type == lrecord_type_weak_list
400 pstructtype weak_list
402 if $lrecord_type == lrecord_type_window
405 if $lrecord_type == lrecord_type_window_configuration
406 pstructtype window_config
408 echo Unknown Lisp Object type\n
428 # Repeat after me... gdb sux, gdb sux, gdb sux...
447 # Are we having fun yet??
469 Usage: pobj lisp_object
470 Print the internal C representation of a Lisp Object.
473 # -------------------------------------------------------------
474 # functions to test the debugging support itself.
475 # If you change this file, make sure the following still work...
476 # -------------------------------------------------------------
478 printf "Vemacs_major_version: "
479 xtype Vemacs_major_version
480 printf "Vhelp_char: "
488 printf "Vall_weak_lists: "
489 xtype Vall_weak_lists
490 printf "Vxemacs_codename: "
491 xtype Vxemacs_codename
495 printf "Vemacs_major_version: "
496 pobj Vemacs_major_version
497 printf "Vhelp_char: "
505 printf "Vall_weak_lists: "
507 printf "Vxemacs_codename: "
508 pobj Vxemacs_codename