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.
52 set $obj = (unsigned long) $arg0
56 set $type = Lisp_Type_Int
58 set $type = $obj & dbg_typemask
59 if $type == Lisp_Type_Char
60 set $val = ($obj & dbg_valmask) >> dbg_gctypebits
62 # It's a record pointer
67 if $type == Lisp_Type_Record
68 set $lheader = (struct lrecord_header *) $val
69 set $imp = lrecord_implementations_table[$lheader->type]
75 document decode_object
76 Usage: decode_object lisp_object
77 Extract implementation information from a Lisp Object.
78 Defines variables $val, $type and $imp.
88 if $type == Lisp_Type_Int
91 if $type == Lisp_Type_Char
94 if $type == Lisp_Type_Symbol
97 if $type == Lisp_Type_String
100 if $type == Lisp_Type_Vector
103 if $type == Lisp_Type_Cons
106 printf "record type: %s\n", $imp->name
117 Usage: xtype lisp_object
118 Print the Lisp type of a lisp object.
122 run -batch -vanilla -f list-load-path-shadows
125 document lisp-shadows
127 Run xemacs to check for lisp shadows
130 define environment-to-run-temacs
131 unset env EMACSLOADPATH
132 set env EMACSBOOTSTRAPLOADPATH=../lisp/:..
133 set env EMACSBOOTSTRAPMODULEPATH=../modules/:..
137 environment-to-run-temacs
138 run -batch -l ../lisp/loadup.el run-temacs -q
143 Run temacs interactively, like xemacs.
144 Use this with debugging tools (like purify) that cannot deal with dumping,
145 or when temacs builds successfully, but xemacs does not.
149 run -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
152 document check-xemacs
154 Run the test suite. Equivalent to 'make check'.
158 environment-to-run-temacs
159 run -batch -l ../lisp/loadup.el run-temacs -q -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
162 document check-temacs
164 Run the test suite on temacs. Equivalent to 'make check-temacs'.
165 Use this with debugging tools (like purify) that cannot deal with dumping,
166 or when temacs builds successfully, but xemacs does not.
170 environment-to-run-temacs
171 run -batch -l ../lisp/update-elc.el
176 Run the core lisp byte compilation part of the build procedure.
177 Use when debugging temacs, not xemacs!
178 Use this when temacs builds successfully, but xemacs does not.
182 environment-to-run-temacs
183 run -batch -l ../lisp/loadup.el dump
188 Run the dumping part of the build procedure.
189 Use when debugging temacs, not xemacs!
190 Use this when temacs builds successfully, but xemacs does not.
193 # if you use Purify, do this:
194 # export PURIFYOPTIONS='-pointer-mask=0x0fffffff'
197 printf "%s", "Lisp => "
198 call debug_print($arg0)
202 Usage: ldp lisp_object
203 Print a Lisp Object value using the Lisp printer.
204 Requires a running xemacs process.
208 call debug_backtrace()
213 Print the current Lisp stack trace.
214 Requires a running xemacs process.
219 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
224 Eval a lisp expression.
225 Requires a running xemacs process.
228 (gdb) leval "(+ 1 2)"
234 print $arg0->core.widget_class->core_class.class_name
238 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
241 # GDB's command language makes you want to ...
244 set $xstruct = (struct $arg0 *) $val
251 if $type == Lisp_Type_Int
252 printf "Integer: %d\n", $val
254 if $type == Lisp_Type_Char
255 if $val > 32 && $val < 128
256 printf "Char: %c\n", $val
258 printf "Char: %d\n", $val
261 if $type == Lisp_Type_String || $imp == &lrecord_string
264 if $type == Lisp_Type_Cons || $imp == &lrecord_cons
267 if $type == Lisp_Type_Symbol || $imp == &lrecord_symbol
269 printf "Symbol name: %s\n", $xstruct->name->data
271 if $type == Lisp_Type_Vector || $imp == &lrecord_vector
273 printf "Vector of length %d\n", $xstruct->size
274 #print *($xstruct->data) @ $xstruct->size
276 if $imp == &lrecord_bit_vector
277 pstruct Lisp_Bit_Vector
279 if $imp == &lrecord_buffer
282 if $imp == &lrecord_char_table
283 pstruct Lisp_Char_Table
285 if $imp == &lrecord_char_table_entry
286 pstruct Lisp_Char_Table_Entry
288 if $imp == &lrecord_charset
291 if $imp == &lrecord_coding_system
292 pstruct Lisp_Coding_System
294 if $imp == &lrecord_color_instance
295 pstruct Lisp_Color_Instance
297 if $imp == &lrecord_command_builder
298 pstruct command_builder
300 if $imp == &lrecord_compiled_function
301 pstruct Lisp_Compiled_Function
303 if $imp == &lrecord_console
306 if $imp == &lrecord_database
307 pstruct Lisp_Database
309 if $imp == &lrecord_device
312 if $imp == &lrecord_event
315 if $imp == &lrecord_extent
318 if $imp == &lrecord_extent_auxiliary
319 pstruct extent_auxiliary
321 if $imp == &lrecord_extent_info
324 if $imp == &lrecord_face
327 if $imp == &lrecord_float
330 if $imp == &lrecord_font_instance
331 pstruct Lisp_Font_Instance
333 if $imp == &lrecord_frame
336 if $imp == &lrecord_glyph
339 if $imp == &lrecord_hash_table
340 pstruct Lisp_Hash_Table
342 if $imp == &lrecord_image_instance
343 pstruct Lisp_Image_Instance
345 if $imp == &lrecord_keymap
348 if $imp == &lrecord_lcrecord_list
349 pstruct lcrecord_list
351 if $imp == &lrecord_lstream
354 if $imp == &lrecord_marker
357 if $imp == &lrecord_opaque
360 if $imp == &lrecord_opaque_ptr
361 pstruct Lisp_Opaque_Ptr
363 if $imp == &lrecord_popup_data
366 if $imp == &lrecord_process
369 if $imp == &lrecord_range_table
370 pstruct Lisp_Range_Table
372 if $imp == &lrecord_specifier
373 pstruct Lisp_Specifier
375 if $imp == &lrecord_subr
378 if $imp == &lrecord_symbol_value_buffer_local
379 pstruct symbol_value_buffer_local
381 if $imp == &lrecord_symbol_value_forward
382 pstruct symbol_value_forward
384 if $imp == &lrecord_symbol_value_lisp_magic
385 pstruct symbol_value_lisp_magic
387 if $imp == &lrecord_symbol_value_varalias
388 pstruct symbol_value_varalias
390 if $imp == &lrecord_toolbar_button
391 pstruct toolbar_button
393 if $imp == &lrecord_tooltalk_message
394 pstruct Lisp_Tooltalk_Message
396 if $imp == &lrecord_tooltalk_pattern
397 pstruct Lisp_Tooltalk_Pattern
399 if $imp == &lrecord_weak_list
402 if $imp == &lrecord_window
405 if $imp == &lrecord_window_configuration
406 pstruct window_config
408 echo Unknown Lisp Object type\n
426 # Repeat after me... gdb sux, gdb sux, gdb sux...
445 # Are we having fun yet??
466 Usage: pobj lisp_object
467 Print the internal C representation of a Lisp Object.
470 # -------------------------------------------------------------
471 # functions to test the debugging support itself.
472 # If you change this file, make sure the following still work...
473 # -------------------------------------------------------------
475 printf "Vemacs_major_version: "
476 xtype Vemacs_major_version
477 printf "Vhelp_char: "
485 printf "Vall_weak_lists: "
486 xtype Vall_weak_lists
487 printf "Vxemacs_codename: "
488 xtype Vxemacs_codename
492 printf "Vemacs_major_version: "
493 pobj Vemacs_major_version
494 printf "Vhelp_char: "
502 printf "Vall_weak_lists: "
504 printf "Vxemacs_codename: "
505 pobj Vxemacs_codename