comparison etc/gdbinit.in @ 3418:a1e20876b806

[xemacs-hg @ 2006-05-23 13:18:50 by stephent] Generate dbx/gdb rc files right. <873bf0zz31.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Tue, 23 May 2006 13:18:56 +0000
parents
children 8453b9b6286f
comparison
equal deleted inserted replaced
3417:abdb33cc1f52 3418:a1e20876b806
1 ## gdb init file for XEmacs -*- ksh -*-
2 ## This is the source for src/.gdbinit. Edit it, and rerun configure.
3 ## (Running config.status is not enough.)
4 ## The generated file depends on src/config.h (currently only in one place).
5
6 ## To insert comments that will remain in the generated file, we use the
7 ## imake XCOMM convention. Lines beginning with "XCOMM " exactly (no
8 ## leading whitespace, one trailing ASCII space, case sensitive) will be
9 ## transformed to gdb command file comments in the generated file.
10
11 XCOMM gdb init file for XEmacs
12 XCOMM AUTOMATICALLY GENERATED FROM etc/gdbinit.in BY configure -- DO NOT EDIT.
13 XCOMM See etc/gdbinit.in for licensing information and usage hints.
14 XCOMM Copyright (C) 1998 Free Software Foundation, Inc.
15
16 ## This file is part of XEmacs.
17
18 ## XEmacs is free software; you can redistribute it and/or modify it
19 ## under the terms of the GNU General Public License as published by the
20 ## Free Software Foundation; either version 2, or (at your option) any
21 ## later version.
22
23 ## XEmacs is distributed in the hope that it will be useful, but WITHOUT
24 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 ## for more details.
27
28 ## You should have received a copy of the GNU General Public License
29 ## along with XEmacs; see the file COPYING. If not, write to
30 ## the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
31 ## Boston, MA 02110-1301 USA
32
33 ## Author: Martin Buchholz
34
35 ## Other contributors you could ask for help: Ivan Golubev, Jerry James,
36 ## Stephen Turnbull.
37
38 ## Some useful commands for debugging emacs with gdb 4.16 or better.
39 ##
40 ## Since this file is called `.gdbinit', it will be read by gdb
41 ## automatically when gdb is run in the build directory, which is where
42 ## developers usually debug their xemacs. You can also source this
43 ## file from your ~/.gdbinit, if you like.
44 ##
45 ## Configure xemacs with --debug, and compile with -g.
46 ##
47 ## See also the question of the XEmacs FAQ, titled
48 ## "How to Debug an XEmacs problem with a debugger".
49 ##
50 ## This can be used to debug XEmacs no matter how the following are
51 ## specified:
52
53 ## USE_UNION_TYPE
54
55 ## (the above all have configure equivalents)
56
57 ## Some functions defined here require a running process, but most
58 ## don't. Considerable effort has been expended to this end.
59
60 ## See the dbg_ C support code in src/alloc.c that allows the functions
61 ## defined in this file to work correctly.
62
63 #define NOT_C_CODE
64 #include "config.h"
65
66 set print union off
67 set print pretty off
68
69 #ifdef VDB_POSIX
70 handle SIGSEGV SIGBUS nostop noprint
71 #endif
72
73 set $Lisp_Type_Int = -2
74
75 define decode_object
76 set $obj = (unsigned long) $arg0
77 if $obj & 1
78 ## It's an int
79 set $val = $obj >> 1
80 set $type = $Lisp_Type_Int
81 else
82 set $type = $obj & dbg_typemask
83 if $type == Lisp_Type_Char
84 set $val = ($obj & dbg_valmask) >> dbg_gctypebits
85 else
86 ## It's a record pointer
87 set $val = $obj
88 end
89 end
90
91 if $type == Lisp_Type_Record
92 set $lheader = ((struct lrecord_header *) $val)
93 set $lrecord_type = ($lheader->type)
94 set $imp = ((struct lrecord_implementation *) lrecord_implementations_table[(int) $lrecord_type])
95 else
96 set $lrecord_type = -1
97 set $lheader = -1
98 set $imp = -1
99 end
100 end
101
102 document decode_object
103 Usage: decode_object lisp_object
104 Extract implementation information from a Lisp Object.
105 Defines variables $val, $type and $imp.
106 end
107
108 define xint
109 decode_object $arg0
110 print ((long) $val)
111 end
112
113 define xtype
114 decode_object $arg0
115 if $type == $Lisp_Type_Int
116 echo int\n
117 else
118 if $type == Lisp_Type_Char
119 echo char\n
120 else
121 printf "record type: %s\n", $imp->name
122 end
123 end
124 end
125
126 document xtype
127 Usage: xtype lisp_object
128 Print the Lisp type of a lisp object.
129 end
130
131 define lisp-shadows
132 run -batch -vanilla -f list-load-path-shadows
133 end
134
135 document lisp-shadows
136 Usage: lisp-shadows
137 Run xemacs to check for lisp shadows
138 end
139
140 define environment-to-run-temacs
141 unset env EMACSLOADPATH
142 set env EMACSBOOTSTRAPLOADPATH=../lisp/:..
143 set env EMACSBOOTSTRAPMODULEPATH=../modules/:..
144 end
145
146 define run-temacs
147 environment-to-run-temacs
148 run -nd -batch -l ../lisp/loadup.el run-temacs -q
149 end
150
151 document run-temacs
152 Usage: run-temacs
153 Run temacs interactively, like xemacs.
154 Use this with debugging tools (like purify) that cannot deal with dumping,
155 or when temacs builds successfully, but xemacs does not.
156 end
157
158 define check-xemacs
159 run -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
160 end
161
162 document check-xemacs
163 Usage: check-xemacs
164 Run the test suite. Equivalent to 'make check'.
165 end
166
167 define check-temacs
168 environment-to-run-temacs
169 run -nd -batch -l ../lisp/loadup.el run-temacs -q -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated
170 end
171
172 document check-temacs
173 Usage: check-temacs
174 Run the test suite on temacs. Equivalent to 'make check-temacs'.
175 Use this with debugging tools (like purify) that cannot deal with dumping,
176 or when temacs builds successfully, but xemacs does not.
177 end
178
179 define update-elc
180 environment-to-run-temacs
181 run -nd -batch -l ../lisp/update-elc.el
182 end
183
184 document update-elc
185 Usage: update-elc
186 Run the core lisp byte compilation part of the build procedure.
187 Use when debugging temacs, not xemacs!
188 Use this when temacs builds successfully, but xemacs does not.
189 end
190
191 define dmp
192 environment-to-run-temacs
193 run -nd -batch -l ../lisp/loadup.el dump
194 end
195
196 document dmp
197 Usage: dmp
198 Run the dumping part of the build procedure.
199 Use when debugging temacs, not xemacs!
200 Use this when temacs builds successfully, but xemacs does not.
201 end
202
203 define ldp
204 printf "%s", "Lisp => "
205 call debug_print($arg0)
206 end
207
208 document ldp
209 Usage: ldp lisp_object
210 Print a Lisp Object value using the Lisp printer.
211 Requires a running xemacs process.
212 end
213
214 define lbt
215 call debug_backtrace()
216 end
217
218 document lbt
219 Usage: lbt
220 Print the current Lisp stack trace.
221 Requires a running xemacs process.
222 end
223
224
225 define leval
226 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil)))
227 end
228
229 document leval
230 Usage: leval "SEXP"
231 Eval a lisp expression.
232 Requires a running xemacs process.
233
234 Example:
235 (gdb) leval "(+ 1 2)"
236 Lisp ==> 3
237 end
238
239
240 define wtype
241 print $arg0->core.widget_class->core_class.class_name
242 end
243
244 define xtname
245 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
246 end
247
248 ## GDB's command language makes you want to ...
249
250 define pptype
251 set $type_ptr = ($arg0 *) $val
252 print $type_ptr
253 print *$type_ptr
254 end
255
256 define pstructtype
257 set $type_ptr = (struct $arg0 *) $val
258 print $type_ptr
259 print *$type_ptr
260 end
261
262 define pobj
263 decode_object $arg0
264 if $type == $Lisp_Type_Int
265 printf "Integer: %d\n", $val
266 else
267 if $type == Lisp_Type_Char
268 if $val > 32 && $val < 128
269 printf "Char: %c\n", $val
270 else
271 printf "Char: %d\n", $val
272 end
273 else
274 if $lrecord_type == lrecord_type_string
275 pptype Lisp_String
276 else
277 if $lrecord_type == lrecord_type_cons
278 pptype Lisp_Cons
279 else
280 if $lrecord_type == lrecord_type_symbol
281 pptype Lisp_Symbol
282 printf "Symbol name: %s\n", ((Lisp_String *)$type_ptr->name)->data_
283 else
284 if $lrecord_type == lrecord_type_vector
285 pptype Lisp_Vector
286 printf "Vector of length %d\n", $type_ptr->size
287 ##print *($type_ptr->data) @ $type_ptr->size
288 else
289 if $lrecord_type == lrecord_type_bit_vector
290 pptype Lisp_Bit_Vector
291 else
292 if $lrecord_type == lrecord_type_buffer
293 pstructtype buffer
294 else
295 if $lrecord_type == lrecord_type_char_table
296 pptype Lisp_Char_Table
297 else
298 if $lrecord_type == lrecord_type_char_table_entry
299 pptype Lisp_Char_Table_Entry
300 else
301 if $lrecord_type == lrecord_type_charset
302 pptype Lisp_Charset
303 else
304 if $lrecord_type == lrecord_type_coding_system
305 pptype Lisp_Coding_System
306 else
307 if $lrecord_type == lrecord_type_color_instance
308 pptype Lisp_Color_Instance
309 else
310 if $lrecord_type == lrecord_type_command_builder
311 pptype command_builder
312 else
313 if $lrecord_type == lrecord_type_compiled_function
314 pptype Lisp_Compiled_Function
315 else
316 if $lrecord_type == lrecord_type_console
317 pstructtype console
318 else
319 if $lrecord_type == lrecord_type_database
320 pptype Lisp_Database
321 else
322 if $lrecord_type == lrecord_type_device
323 pstructtype device
324 else
325 if $lrecord_type == lrecord_type_event
326 pptype Lisp_Event
327 else
328 if $lrecord_type == lrecord_type_extent
329 pstructtype extent
330 else
331 if $lrecord_type == lrecord_type_extent_auxiliary
332 pstructtype extent_auxiliary
333 else
334 if $lrecord_type == lrecord_type_extent_info
335 pstructtype extent_info
336 else
337 if $lrecord_type == lrecord_type_face
338 pptype Lisp_Face
339 else
340 if $lrecord_type == lrecord_type_float
341 pptype Lisp_Float
342 else
343 if $lrecord_type == lrecord_type_font_instance
344 pptype Lisp_Font_Instance
345 else
346 if $lrecord_type == lrecord_type_frame
347 pstructtype frame
348 else
349 if $lrecord_type == lrecord_type_glyph
350 pptype Lisp_Glyph
351 else
352 if $lrecord_type == lrecord_type_gui_item
353 pptype Lisp_Gui_Item
354 else
355 if $lrecord_type == lrecord_type_hash_table
356 pptype Lisp_Hash_Table
357 else
358 if $lrecord_type == lrecord_type_image_instance
359 pptype Lisp_Image_Instance
360 else
361 if $lrecord_type == lrecord_type_keymap
362 pptype Lisp_Keymap
363 else
364 if $lrecord_type == lrecord_type_lcrecord_list
365 pstructtype lcrecord_list
366 else
367 if $lrecord_type == lrecord_type_ldap
368 pptype Lisp_LDAP
369 else
370 if $lrecord_type == lrecord_type_lstream
371 pstructtype lstream
372 else
373 if $lrecord_type == lrecord_type_marker
374 pptype Lisp_Marker
375 else
376 if $lrecord_type == lrecord_type_opaque
377 pptype Lisp_Opaque
378 else
379 if $lrecord_type == lrecord_type_opaque_ptr
380 pptype Lisp_Opaque_Ptr
381 else
382 if $lrecord_type == lrecord_type_popup_data
383 pptype popup_data
384 else
385 if $lrecord_type == lrecord_type_process
386 pptype Lisp_Process
387 else
388 if $lrecord_type == lrecord_type_range_table
389 pptype Lisp_Range_Table
390 else
391 if $lrecord_type == lrecord_type_specifier
392 pptype Lisp_Specifier
393 else
394 if $lrecord_type == lrecord_type_subr
395 pptype Lisp_Subr
396 else
397 if $lrecord_type == lrecord_type_symbol_value_buffer_local
398 pstructtype symbol_value_buffer_local
399 else
400 if $lrecord_type == lrecord_type_symbol_value_forward
401 pstructtype symbol_value_forward
402 else
403 if $lrecord_type == lrecord_type_symbol_value_lisp_magic
404 pstructtype symbol_value_lisp_magic
405 else
406 if $lrecord_type == lrecord_type_symbol_value_varalias
407 pstructtype symbol_value_varalias
408 else
409 if $lrecord_type == lrecord_type_timeout
410 pptype Lisp_Timeout
411 else
412 if $lrecord_type == lrecord_type_toolbar_button
413 pstructtype toolbar_button
414 else
415 if $lrecord_type == lrecord_type_tooltalk_message
416 pptype Lisp_Tooltalk_Message
417 else
418 if $lrecord_type == lrecord_type_tooltalk_pattern
419 pptype Lisp_Tooltalk_Pattern
420 else
421 if $lrecord_type == lrecord_type_weak_list
422 pstructtype weak_list
423 else
424 if $lrecord_type == lrecord_type_window
425 pstructtype window
426 else
427 if $lrecord_type == lrecord_type_window_configuration
428 pstructtype window_config
429 else
430 if $lrecord_type == lrecord_type_fc_pattern
431 pstructtype fc_pattern
432 else
433 if $lrecord_type == lrecord_type_fc_objectset
434 pstructtype fc_objectset
435 else
436 if $lrecord_type == lrecord_type_fc_fontset
437 pstructtype fc_fontset
438 else
439 echo Unknown Lisp Object type\n
440 print $arg0
441 ## Barf, gag, retch
442 end
443 end
444 end
445 end
446 end
447 end
448 end
449 end
450 end
451 end
452 end
453 end
454 end
455 end
456 end
457 end
458 end
459 end
460 end
461 end
462 ## Repeat after me... gdb sux, gdb sux, gdb sux...
463 end
464 end
465 end
466 end
467 end
468 end
469 end
470 end
471 end
472 end
473 end
474 end
475 end
476 end
477 end
478 end
479 end
480 end
481 ## Are we having fun yet??
482 end
483 end
484 end
485 end
486 end
487 end
488 end
489 end
490 end
491 end
492 end
493 end
494 end
495 end
496 end
497 end
498 end
499 end
500 end
501
502 document pobj
503 Usage: pobj lisp_object
504 Print the internal C representation of a Lisp Object.
505 end
506
507 ## -------------------------------------------------------------
508 ## functions to test the debugging support itself.
509 ## If you change this file, make sure the following still work...
510 ## -------------------------------------------------------------
511 define test_xtype
512 printf "Vemacs_major_version: "
513 xtype Vemacs_major_version
514 printf "Vhelp_char: "
515 xtype Vhelp_char
516 printf "Qnil: "
517 xtype Qnil
518 printf "Qunbound: "
519 xtype Qunbound
520 printf "Vobarray: "
521 xtype Vobarray
522 printf "Vall_weak_lists: "
523 xtype Vall_weak_lists
524 printf "Vxemacs_codename: "
525 xtype Vxemacs_codename
526 end
527
528 define test_pobj
529 printf "Vemacs_major_version: "
530 pobj Vemacs_major_version
531 printf "Vhelp_char: "
532 pobj Vhelp_char
533 printf "Qnil: "
534 pobj Qnil
535 printf "Qunbound: "
536 pobj Qunbound
537 printf "Vobarray: "
538 pobj Vobarray
539 printf "Vall_weak_lists: "
540 pobj Vall_weak_lists
541 printf "Vxemacs_codename: "
542 pobj Vxemacs_codename
543 end
544