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.
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.
28 # See also the question of the XEmacs FAQ, titled
29 # "How to Debug an XEmacs problem with a debugger".
31 # This can be used to debug XEmacs no matter how the following are
36 # USE_INDEXED_LRECORD_IMPLEMENTATION
37 # LRECORD_(SYMBOL|STRING|VECTOR)
39 # (the above all have configure equivalents)
41 # Some functions defined here require a running process, but most
42 # don't. Considerable effort has been expended to this end.
44 # See the dbg_ C support code in src/alloc.c that allows the functions
45 # defined in this file to work correctly.
51 set $obj = (unsigned long) $arg0
52 if dbg_USE_MINIMAL_TAGBITS
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 # not dbg_USE_MINIMAL_TAGBITS
68 set $val = $obj & dbg_valmask
69 set $type = ($obj & dbg_typemask) >> (dbg_valbits + 1)
72 if $type == Lisp_Type_Record
73 set $lheader = (struct lrecord_header *) $val
74 if dbg_USE_INDEXED_LRECORD_IMPLEMENTATION
75 set $imp = lrecord_implementations_table[$lheader->type]
77 set $imp = $lheader->implementation
84 document decode_object
85 Usage: decode_object lisp_object
86 Extract implementation information from a Lisp Object.
87 Defines variables $val, $type and $imp.
97 if $type == Lisp_Type_Int
100 if $type == Lisp_Type_Char
103 if $type == Lisp_Type_Symbol
106 if $type == Lisp_Type_String
109 if $type == Lisp_Type_Vector
112 if $type == Lisp_Type_Cons
115 printf "record type: %s\n", $imp->name
126 run -batch -vanilla -f list-load-path-shadows
129 document lisp-shadows
131 Run xemacs to check for lisp shadows
134 define environment-to-run-temacs
135 unset env EMACSLOADPATH
136 set env EMACSBOOTSTRAPLOADPATH=../lisp/:..
137 set env EMACSBOOTSTRAPMODULEPATH=../modules/:..
141 environment-to-run-temacs
142 run -batch -l ../lisp/loadup.el run-temacs -q
147 Run temacs interactively, like xemacs.
148 Use this with debugging tools (like purify) that cannot deal with dumping,
149 or when temacs builds successfully, but xemacs does not.
153 environment-to-run-temacs
154 run -batch -l ../lisp/update-elc.el
159 Run the core lisp byte compilation part of the build procedure.
160 Use when debugging temacs, not xemacs!
161 Use this when temacs builds successfully, but xemacs does not.
165 environment-to-run-temacs
166 run -batch -l ../lisp/loadup.el dump
171 Run the dumping part of the build procedure.
172 Use when debugging temacs, not xemacs!
173 Use this when temacs builds successfully, but xemacs does not.
176 # if you use Purify, do this:
177 # export PURIFYOPTIONS='-pointer-mask=0x0fffffff'
180 printf "%s", "Lisp => "
181 call debug_print($arg0)
185 Usage: ldp lisp_object
186 Print a Lisp Object value using the Lisp printer.
187 Requires a running xemacs process.
191 call debug_backtrace()
196 Print the current Lisp stack trace.
197 Requires a running xemacs process.
202 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
207 Eval a lisp expression.
208 Requires a running xemacs process.
211 (gdb) leval "(+ 1 2)"
217 print $arg0->core.widget_class->core_class.class_name
221 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
224 # GDB's command language makes you want to ...
227 set $xstruct = (struct $arg0 *) $val
234 if $type == Lisp_Type_Int
235 printf "Integer: %d\n", $val
237 if $type == Lisp_Type_Char
238 if $val > 32 && $val < 128
239 printf "Char: %c\n", $val
241 printf "Char: %d\n", $val
244 if $type == Lisp_Type_String || $imp == lrecord_string
247 if $type == Lisp_Type_Cons || $imp == lrecord_cons
250 if $type == Lisp_Type_Symbol || $imp == lrecord_symbol
252 printf "Symbol name: %s\n", $xstruct->name->data
254 if $type == Lisp_Type_Vector || $imp == lrecord_vector
256 printf "Vector of length %d\n", $xstruct->size
257 #print *($xstruct->data) @ $xstruct->size
259 if $imp == lrecord_bit_vector
260 pstruct Lisp_Bit_Vector
262 if $imp == lrecord_buffer
265 if $imp == lrecord_char_table
266 pstruct Lisp_Char_Table
268 if $imp == lrecord_char_table_entry
269 pstruct Lisp_Char_Table_Entry
271 if $imp == lrecord_charset
274 if $imp == lrecord_coding_system
275 pstruct Lisp_Coding_System
277 if $imp == lrecord_color_instance
278 pstruct Lisp_Color_Instance
280 if $imp == lrecord_command_builder
281 pstruct command_builder
283 if $imp == lrecord_compiled_function
284 pstruct Lisp_Compiled_Function
286 if $imp == lrecord_console
289 if $imp == lrecord_database
290 pstruct Lisp_Database
292 if $imp == lrecord_device
295 if $imp == lrecord_event
298 if $imp == lrecord_extent
301 if $imp == lrecord_extent_auxiliary
302 pstruct extent_auxiliary
304 if $imp == lrecord_extent_info
307 if $imp == lrecord_face
310 if $imp == lrecord_float
313 if $imp == lrecord_font_instance
314 pstruct Lisp_Font_Instance
316 if $imp == lrecord_frame
319 if $imp == lrecord_glyph
322 if $imp == lrecord_hash_table
323 pstruct Lisp_Hash_Table
325 if $imp == lrecord_image_instance
326 pstruct Lisp_Image_Instance
328 if $imp == lrecord_keymap
331 if $imp == lrecord_lcrecord_list
332 pstruct lcrecord_list
334 if $imp == lrecord_lstream
337 if $imp == lrecord_marker
340 if $imp == lrecord_opaque
343 if $imp == lrecord_opaque_list
344 pstruct Lisp_Opaque_List
346 if $imp == lrecord_popup_data
349 if $imp == lrecord_process
352 if $imp == lrecord_range_table
353 pstruct Lisp_Range_Table
355 if $imp == lrecord_specifier
356 pstruct Lisp_Specifier
358 if $imp == lrecord_subr
361 if $imp == lrecord_symbol_value_buffer_local
362 pstruct symbol_value_buffer_local
364 if $imp == lrecord_symbol_value_forward
365 pstruct symbol_value_forward
367 if $imp == lrecord_symbol_value_lisp_magic
368 pstruct symbol_value_lisp_magic
370 if $imp == lrecord_symbol_value_varalias
371 pstruct symbol_value_varalias
373 if $imp == lrecord_toolbar_button
374 pstruct toolbar_button
376 if $imp == lrecord_tooltalk_message
377 pstruct Lisp_Tooltalk_Message
379 if $imp == lrecord_tooltalk_pattern
380 pstruct Lisp_Tooltalk_Pattern
382 if $imp == lrecord_weak_list
385 if $imp == lrecord_window
388 if $imp == lrecord_window_configuration
389 pstruct window_config
391 echo Unknown Lisp Object type\n
409 # Repeat after me... gdb sux, gdb sux, gdb sux...
428 # Are we having fun yet??
449 Usage: pobj lisp_object
450 Print the internal C structure of a underlying Lisp Object.
453 # -------------------------------------------------------------
454 # functions to test the debugging support itself.
455 # If you change this file, make sure the following still work...
456 # -------------------------------------------------------------
458 printf "Vemacs_major_version: "
459 xtype Vemacs_major_version
460 printf "Vhelp_char: "
468 printf "Vall_weak_lists: "
469 xtype Vall_weak_lists
470 printf "Vxemacs_codename: "
471 xtype Vxemacs_codename
475 printf "Vemacs_major_version: "
476 pobj Vemacs_major_version
477 printf "Vhelp_char: "
485 printf "Vall_weak_lists: "
487 printf "Vxemacs_codename: "
488 pobj Vxemacs_codename