2 # Copyright (C) 1998 Free Software Foundation, Inc.
4 # This file is part of SXEmacs
6 # SXEmacs is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # SXEmacs is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Author: Martin Buchholz
21 # Some useful commands for debugging emacs with gdb 4.16 or better.
23 # Since this file is called `.gdbinit', it will be read by gdb
24 # automatically when gdb is run in the build directory, which is where
25 # developers usually debug their SXEmacs. You can also source this
26 # file from your ~/.gdbinit, if you like.
28 # Configure SXEmacs with --debug, and compile with -g.
30 # See also the question of the SXEmacs FAQ, titled
31 # "How to Debug a SXEmacs problem with a debugger".
33 # Some functions defined here require a running process, but most
34 # don't. Considerable effort has been expended to this end.
36 # See the dbg_ C support code in src/alloc.c that allows the functions
37 # defined in this file to work correctly.
42 set $Lisp_Type_Int = -2
45 set $obj = (unsigned long) $arg0
49 set $type = $Lisp_Type_Int
51 set $type = $obj & dbg_typemask
52 if $type == Lisp_Type_Char
53 set $val = ($obj & dbg_valmask) >> dbg_gctypebits
55 # It's a record pointer
60 if $type == Lisp_Type_Record
61 set $lheader = ((struct lrecord_header *) $val)
62 set $lrecord_type = ($lheader->type)
63 set $imp = ((struct lrecord_implementation *) lrecord_implementations_table[(int) $lrecord_type])
65 set $lrecord_type = -1
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 printf "record type: %s\n", $imp->name
96 Usage: xtype lisp_object
97 Print the Lisp type of a lisp object.
101 run -batch -vanilla -f list-load-path-shadows
104 document lisp-shadows
106 Run SXEmacs to check for lisp shadows
109 define environment-to-run-temacs
110 unset env EMACSLOADPATH
111 set env EMACSBOOTSTRAPLOADPATH=@abs_top_srcdir@/lisp/
112 set env EMACSBOOTSTRAPMODULEPATH=@abs_top_srcdir@/modules/
116 environment-to-run-temacs
117 run -nd -batch -l @abs_top_srcdir@/lisp/loadup.el run-temacs -q
122 Run temacs interactively, like SXEmacs.
123 Use this with debugging tools (like purify) that cannot deal with dumping,
124 or when temacs builds successfully, but SXEmacs does not.
128 run -batch -l @abs_top_srcdir@/tests/automated/test-harness.el -f batch-test-emacs @abs_top_srcdir@/tests/automated
131 document check-sxemacs
133 Run the test suite. Equivalent to 'make check'.
137 environment-to-run-temacs
138 run -nd -batch -l @abs_top_srcdir@/lisp/loadup.el run-temacs -q -batch -l @abs_top_srcdir@/tests/automated/test-harness.el -f batch-test-emacs @abs_top_srcdir@/tests/automated
141 document check-temacs
143 Run the test suite on temacs. Equivalent to 'make check-temacs'.
144 Use this with debugging tools (like purify) that cannot deal with dumping,
145 or when temacs builds successfully, but SXEmacs does not.
149 environment-to-run-temacs
150 run -nd -batch -l @abs_top_srcdir@/lisp/update-elc.el
155 Run the core lisp byte compilation part of the build procedure.
156 Use when debugging temacs, not SXEmacs!
157 Use this when temacs builds successfully, but SXEmacs does not.
161 environment-to-run-temacs
162 run -nd -batch -l @abs_top_srcdir@/lisp/loadup.el dump
167 Run the dumping part of the build procedure.
168 Use when debugging temacs, not SXEmacs!
169 Use this when temacs builds successfully, but SXEmacs does not.
173 printf "%s", "Lisp => "
174 call debug_print($arg0)
178 Usage: ldp lisp_object
179 Print a Lisp Object value using the Lisp printer.
180 Requires a running SXEmacs process.
184 call debug_backtrace()
189 Print the current Lisp stack trace.
190 Requires a running SXEmacs process.
195 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
200 Eval a lisp expression.
201 Requires a running SXEmacs process.
204 (gdb) leval "(+ 1 2)"
210 print $arg0->core.widget_class->core_class.class_name
214 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
217 # GDB's command language makes you want to ...
220 # set $type_ptr = ($arg0 *) $val
226 set $type_ptr = (struct $arg0 *) $val
233 if $type == $Lisp_Type_Int
234 printf "Integer: %d\n", $val
236 if $type == Lisp_Type_Char
237 if $val > 32 && $val < 128
238 printf "Char: %c\n", $val
240 printf "Char: %d\n", $val
243 if $lrecord_type == lrecord_type_string
246 if $lrecord_type == lrecord_type_cons
249 if $lrecord_type == lrecord_type_symbol
251 printf "Symbol name: %s\n", $type_ptr->name->data
253 if $lrecord_type == lrecord_type_vector
255 printf "Vector of length %d\n", $type_ptr->size
256 #print *($type_ptr->data) @ $type_ptr->size
258 if $lrecord_type == lrecord_type_bit_vector
259 ptype Lisp_Bit_Vector
261 if $lrecord_type == lrecord_type_buffer
264 if $lrecord_type == lrecord_type_char_table
265 ptype Lisp_Char_Table
267 if $lrecord_type == lrecord_type_char_table_entry
268 ptype Lisp_Char_Table_Entry
270 if $lrecord_type == lrecord_type_charset
273 if $lrecord_type == lrecord_type_coding_system
274 ptype Lisp_Coding_System
276 if $lrecord_type == lrecord_type_color_instance
277 ptype Lisp_Color_Instance
279 if $lrecord_type == lrecord_type_command_builder
280 ptype command_builder
282 if $lrecord_type == lrecord_type_compiled_function
283 ptype Lisp_Compiled_Function
285 if $lrecord_type == lrecord_type_console
288 if $lrecord_type == lrecord_type_database
291 if $lrecord_type == lrecord_type_device
294 if $lrecord_type == lrecord_type_event
297 if $lrecord_type == lrecord_type_extent
300 if $lrecord_type == lrecord_type_extent_auxiliary
301 pstructtype extent_auxiliary
303 if $lrecord_type == lrecord_type_extent_info
304 pstructtype extent_info
306 if $lrecord_type == lrecord_type_face
309 if $lrecord_type == lrecord_type_float
312 if $lrecord_type == lrecord_type_font_instance
313 ptype Lisp_Font_Instance
315 if $lrecord_type == lrecord_type_frame
318 if $lrecord_type == lrecord_type_glyph
321 if $lrecord_type == lrecord_type_gui_item
324 if $lrecord_type == lrecord_type_hash_table
325 ptype Lisp_Hash_Table
327 if $lrecord_type == lrecord_type_image_instance
328 ptype Lisp_Image_Instance
330 if $lrecord_type == lrecord_type_keymap
333 if $lrecord_type == lrecord_type_lcrecord_list
334 pstructtype lcrecord_list
336 if $lrecord_type == lrecord_type_ldap
339 if $lrecord_type == lrecord_type_lstream
342 if $lrecord_type == lrecord_type_marker
345 if $lrecord_type == lrecord_type_opaque
348 if $lrecord_type == lrecord_type_opaque_ptr
349 ptype Lisp_Opaque_Ptr
351 if $lrecord_type == lrecord_type_popup_data
354 if $lrecord_type == lrecord_type_process
357 if $lrecord_type == lrecord_type_range_table
358 ptype Lisp_Range_Table
360 if $lrecord_type == lrecord_type_specifier
363 if $lrecord_type == lrecord_type_subr
366 if $lrecord_type == lrecord_type_symbol_value_buffer_local
367 pstructtype symbol_value_buffer_local
369 if $lrecord_type == lrecord_type_symbol_value_forward
370 pstructtype symbol_value_forward
372 if $lrecord_type == lrecord_type_symbol_value_lisp_magic
373 pstructtype symbol_value_lisp_magic
375 if $lrecord_type == lrecord_type_symbol_value_varalias
376 pstructtype symbol_value_varalias
378 if $lrecord_type == lrecord_type_timeout
381 if $lrecord_type == lrecord_type_toolbar_button
382 pstructtype toolbar_button
384 if $lrecord_type == lrecord_type_weak_list
385 pstructtype weak_list
387 if $lrecord_type == lrecord_type_window
390 if $lrecord_type == lrecord_type_window_configuration
391 pstructtype window_config
393 echo Unknown Lisp Object type\n
413 # Repeat after me... gdb sux, gdb sux, gdb sux...
432 # Are we having fun yet??
454 Usage: pobj lisp_object
455 Print the internal C representation of a Lisp Object.
458 # -------------------------------------------------------------
459 # functions to test the debugging support itself.
460 # If you change this file, make sure the following still work...
461 # -------------------------------------------------------------
463 printf "Vemacs_major_version: "
464 xtype Vemacs_major_version
465 printf "Vhelp_char: "
473 printf "Vall_weak_lists: "
474 xtype Vall_weak_lists
475 printf "Vsxemacs_codename: "
476 xtype Vsxemacs_codename
480 printf "Vemacs_major_version: "
481 pobj Vemacs_major_version
482 printf "Vhelp_char: "
490 printf "Vall_weak_lists: "
492 printf "Vsxemacs_codename: "
493 pobj Vsxemacs_codename