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 # (the above all have configure equivalents)
38 # Some functions defined here require a running process, but most
39 # don't. Considerable effort has been expended to this end.
41 # See the dbg_ C support code in src/alloc.c that allows the functions
42 # defined in this file to work correctly.
48 set $obj = (unsigned long) $arg0
52 set $type = Lisp_Type_Int
54 set $type = $obj & dbg_typemask
55 if $type == Lisp_Type_Char
56 set $val = ($obj & dbg_valmask) >> dbg_gctypebits
58 # It's a record pointer
63 if $type == Lisp_Type_Record
64 set $lheader = (struct lrecord_header *) $val
65 set $imp = lrecord_implementations_table[$lheader->type]
71 document decode_object
72 Usage: decode_object lisp_object
73 Extract implementation information from a Lisp Object.
74 Defines variables $val, $type and $imp.
84 if $type == Lisp_Type_Int
87 if $type == Lisp_Type_Char
90 if $type == Lisp_Type_Symbol
93 if $type == Lisp_Type_String
96 if $type == Lisp_Type_Vector
99 if $type == Lisp_Type_Cons
102 printf "record type: %s\n", $imp->name
113 run -batch -vanilla -f list-load-path-shadows
116 document lisp-shadows
118 Run xemacs to check for lisp shadows
121 define environment-to-run-temacs
122 unset env EMACSLOADPATH
123 set env EMACSBOOTSTRAPLOADPATH=../lisp/:..
124 set env EMACSBOOTSTRAPMODULEPATH=../modules/:..
128 environment-to-run-temacs
129 run -batch -l ../lisp/loadup.el run-temacs -q
134 Run temacs interactively, like xemacs.
135 Use this with debugging tools (like purify) that cannot deal with dumping,
136 or when temacs builds successfully, but xemacs does not.
140 environment-to-run-temacs
141 run -batch -l ../lisp/update-elc.el
146 Run the core lisp byte compilation part of the build procedure.
147 Use when debugging temacs, not xemacs!
148 Use this when temacs builds successfully, but xemacs does not.
152 environment-to-run-temacs
153 run -batch -l ../lisp/loadup.el dump
158 Run the dumping part of the build procedure.
159 Use when debugging temacs, not xemacs!
160 Use this when temacs builds successfully, but xemacs does not.
163 # if you use Purify, do this:
164 # export PURIFYOPTIONS='-pointer-mask=0x0fffffff'
167 printf "%s", "Lisp => "
168 call debug_print($arg0)
172 Usage: ldp lisp_object
173 Print a Lisp Object value using the Lisp printer.
174 Requires a running xemacs process.
178 call debug_backtrace()
183 Print the current Lisp stack trace.
184 Requires a running xemacs process.
189 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
194 Eval a lisp expression.
195 Requires a running xemacs process.
198 (gdb) leval "(+ 1 2)"
204 print $arg0->core.widget_class->core_class.class_name
208 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
211 # GDB's command language makes you want to ...
214 set $xstruct = (struct $arg0 *) $val
221 if $type == Lisp_Type_Int
222 printf "Integer: %d\n", $val
224 if $type == Lisp_Type_Char
225 if $val > 32 && $val < 128
226 printf "Char: %c\n", $val
228 printf "Char: %d\n", $val
231 if $type == Lisp_Type_String || $imp == &lrecord_string
234 if $type == Lisp_Type_Cons || $imp == &lrecord_cons
237 if $type == Lisp_Type_Symbol || $imp == &lrecord_symbol
239 printf "Symbol name: %s\n", $xstruct->name->data
241 if $type == Lisp_Type_Vector || $imp == &lrecord_vector
243 printf "Vector of length %d\n", $xstruct->size
244 #print *($xstruct->data) @ $xstruct->size
246 if $imp == &lrecord_bit_vector
247 pstruct Lisp_Bit_Vector
249 if $imp == &lrecord_buffer
252 if $imp == &lrecord_char_table
253 pstruct Lisp_Char_Table
255 if $imp == &lrecord_char_table_entry
256 pstruct Lisp_Char_Table_Entry
258 if $imp == &lrecord_charset
261 if $imp == &lrecord_coding_system
262 pstruct Lisp_Coding_System
264 if $imp == &lrecord_color_instance
265 pstruct Lisp_Color_Instance
267 if $imp == &lrecord_command_builder
268 pstruct command_builder
270 if $imp == &lrecord_compiled_function
271 pstruct Lisp_Compiled_Function
273 if $imp == &lrecord_console
276 if $imp == &lrecord_database
277 pstruct Lisp_Database
279 if $imp == &lrecord_device
282 if $imp == &lrecord_event
285 if $imp == &lrecord_extent
288 if $imp == &lrecord_extent_auxiliary
289 pstruct extent_auxiliary
291 if $imp == &lrecord_extent_info
294 if $imp == &lrecord_face
297 if $imp == &lrecord_float
300 if $imp == &lrecord_font_instance
301 pstruct Lisp_Font_Instance
303 if $imp == &lrecord_frame
306 if $imp == &lrecord_glyph
309 if $imp == &lrecord_hash_table
310 pstruct Lisp_Hash_Table
312 if $imp == &lrecord_image_instance
313 pstruct Lisp_Image_Instance
315 if $imp == &lrecord_keymap
318 if $imp == &lrecord_lcrecord_list
319 pstruct lcrecord_list
321 if $imp == &lrecord_lstream
324 if $imp == &lrecord_marker
327 if $imp == &lrecord_opaque
330 if $imp == &lrecord_opaque_list
331 pstruct Lisp_Opaque_List
333 if $imp == &lrecord_popup_data
336 if $imp == &lrecord_process
339 if $imp == &lrecord_range_table
340 pstruct Lisp_Range_Table
342 if $imp == &lrecord_specifier
343 pstruct Lisp_Specifier
345 if $imp == &lrecord_subr
348 if $imp == &lrecord_symbol_value_buffer_local
349 pstruct symbol_value_buffer_local
351 if $imp == &lrecord_symbol_value_forward
352 pstruct symbol_value_forward
354 if $imp == &lrecord_symbol_value_lisp_magic
355 pstruct symbol_value_lisp_magic
357 if $imp == &lrecord_symbol_value_varalias
358 pstruct symbol_value_varalias
360 if $imp == &lrecord_toolbar_button
361 pstruct toolbar_button
363 if $imp == &lrecord_tooltalk_message
364 pstruct Lisp_Tooltalk_Message
366 if $imp == &lrecord_tooltalk_pattern
367 pstruct Lisp_Tooltalk_Pattern
369 if $imp == &lrecord_weak_list
372 if $imp == &lrecord_window
375 if $imp == &lrecord_window_configuration
376 pstruct window_config
378 echo Unknown Lisp Object type\n
396 # Repeat after me... gdb sux, gdb sux, gdb sux...
415 # Are we having fun yet??
436 Usage: pobj lisp_object
437 Print the internal C structure of a underlying Lisp Object.
440 # -------------------------------------------------------------
441 # functions to test the debugging support itself.
442 # If you change this file, make sure the following still work...
443 # -------------------------------------------------------------
445 printf "Vemacs_major_version: "
446 xtype Vemacs_major_version
447 printf "Vhelp_char: "
455 printf "Vall_weak_lists: "
456 xtype Vall_weak_lists
457 printf "Vxemacs_codename: "
458 xtype Vxemacs_codename
462 printf "Vemacs_major_version: "
463 pobj Vemacs_major_version
464 printf "Vhelp_char: "
472 printf "Vall_weak_lists: "
474 printf "Vxemacs_codename: "
475 pobj Vxemacs_codename