Mercurial > hg > xemacs-beta
annotate etc/gdbinit.in @ 4833:4dd2389173fc
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sun, 10 Jan 2010 01:06:15 -0600 |
parents | e9ccbc62f7e7 |
children | 7ef913bf3c9a |
rev | line source |
---|---|
3418 | 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 | |
4643
e9ccbc62f7e7
Don't rely on GDB understanding the Lisp_Type_{Record,Char} enums, gdbinit.in
Aidan Kehoe <kehoea@parhasard.net>
parents:
3934
diff
changeset
|
74 set $Lisp_Type_Record = 0 |
e9ccbc62f7e7
Don't rely on GDB understanding the Lisp_Type_{Record,Char} enums, gdbinit.in
Aidan Kehoe <kehoea@parhasard.net>
parents:
3934
diff
changeset
|
75 set $Lisp_Type_Char = 2 |
3418 | 76 |
77 define decode_object | |
78 set $obj = (unsigned long) $arg0 | |
79 if $obj & 1 | |
80 ## It's an int | |
81 set $val = $obj >> 1 | |
82 set $type = $Lisp_Type_Int | |
83 else | |
84 set $type = $obj & dbg_typemask | |
4643
e9ccbc62f7e7
Don't rely on GDB understanding the Lisp_Type_{Record,Char} enums, gdbinit.in
Aidan Kehoe <kehoea@parhasard.net>
parents:
3934
diff
changeset
|
85 if $type == $Lisp_Type_Char |
3418 | 86 set $val = ($obj & dbg_valmask) >> dbg_gctypebits |
87 else | |
88 ## It's a record pointer | |
89 set $val = $obj | |
90 end | |
91 end | |
92 | |
4643
e9ccbc62f7e7
Don't rely on GDB understanding the Lisp_Type_{Record,Char} enums, gdbinit.in
Aidan Kehoe <kehoea@parhasard.net>
parents:
3934
diff
changeset
|
93 if $type == $Lisp_Type_Record |
3418 | 94 set $lheader = ((struct lrecord_header *) $val) |
95 set $lrecord_type = ($lheader->type) | |
96 set $imp = ((struct lrecord_implementation *) lrecord_implementations_table[(int) $lrecord_type]) | |
97 else | |
98 set $lrecord_type = -1 | |
99 set $lheader = -1 | |
100 set $imp = -1 | |
101 end | |
102 end | |
103 | |
104 document decode_object | |
105 Usage: decode_object lisp_object | |
106 Extract implementation information from a Lisp Object. | |
107 Defines variables $val, $type and $imp. | |
108 end | |
109 | |
110 define xint | |
111 decode_object $arg0 | |
112 print ((long) $val) | |
113 end | |
114 | |
115 define xtype | |
116 decode_object $arg0 | |
117 if $type == $Lisp_Type_Int | |
118 echo int\n | |
119 else | |
4643
e9ccbc62f7e7
Don't rely on GDB understanding the Lisp_Type_{Record,Char} enums, gdbinit.in
Aidan Kehoe <kehoea@parhasard.net>
parents:
3934
diff
changeset
|
120 if $type == $Lisp_Type_Char |
3418 | 121 echo char\n |
122 else | |
123 printf "record type: %s\n", $imp->name | |
124 end | |
125 end | |
126 end | |
127 | |
128 document xtype | |
129 Usage: xtype lisp_object | |
130 Print the Lisp type of a lisp object. | |
131 end | |
132 | |
133 define lisp-shadows | |
134 run -batch -vanilla -f list-load-path-shadows | |
135 end | |
136 | |
137 document lisp-shadows | |
138 Usage: lisp-shadows | |
139 Run xemacs to check for lisp shadows | |
140 end | |
141 | |
142 define environment-to-run-temacs | |
143 unset env EMACSLOADPATH | |
144 set env EMACSBOOTSTRAPLOADPATH=../lisp/:.. | |
145 set env EMACSBOOTSTRAPMODULEPATH=../modules/:.. | |
146 end | |
147 | |
148 define run-temacs | |
149 environment-to-run-temacs | |
150 run -nd -batch -l ../lisp/loadup.el run-temacs -q | |
151 end | |
152 | |
153 document run-temacs | |
154 Usage: run-temacs | |
155 Run temacs interactively, like xemacs. | |
156 Use this with debugging tools (like purify) that cannot deal with dumping, | |
157 or when temacs builds successfully, but xemacs does not. | |
158 end | |
159 | |
160 define check-xemacs | |
161 run -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated | |
162 end | |
163 | |
164 document check-xemacs | |
165 Usage: check-xemacs | |
166 Run the test suite. Equivalent to 'make check'. | |
167 end | |
168 | |
169 define check-temacs | |
170 environment-to-run-temacs | |
171 run -nd -batch -l ../lisp/loadup.el run-temacs -q -batch -l ../tests/automated/test-harness.el -f batch-test-emacs ../tests/automated | |
172 end | |
173 | |
174 document check-temacs | |
175 Usage: check-temacs | |
176 Run the test suite on temacs. Equivalent to 'make check-temacs'. | |
177 Use this with debugging tools (like purify) that cannot deal with dumping, | |
178 or when temacs builds successfully, but xemacs does not. | |
179 end | |
180 | |
181 define update-elc | |
182 environment-to-run-temacs | |
183 run -nd -batch -l ../lisp/update-elc.el | |
184 end | |
185 | |
186 document update-elc | |
187 Usage: update-elc | |
188 Run the core lisp byte compilation part of the build procedure. | |
189 Use when debugging temacs, not xemacs! | |
190 Use this when temacs builds successfully, but xemacs does not. | |
191 end | |
192 | |
193 define dmp | |
194 environment-to-run-temacs | |
195 run -nd -batch -l ../lisp/loadup.el dump | |
196 end | |
197 | |
198 document dmp | |
199 Usage: dmp | |
200 Run the dumping part of the build procedure. | |
201 Use when debugging temacs, not xemacs! | |
202 Use this when temacs builds successfully, but xemacs does not. | |
203 end | |
204 | |
205 define ldp | |
206 printf "%s", "Lisp => " | |
207 call debug_print($arg0) | |
208 end | |
209 | |
210 document ldp | |
211 Usage: ldp lisp_object | |
212 Print a Lisp Object value using the Lisp printer. | |
213 Requires a running xemacs process. | |
214 end | |
215 | |
216 define lbt | |
217 call debug_backtrace() | |
218 end | |
219 | |
220 document lbt | |
221 Usage: lbt | |
222 Print the current Lisp stack trace. | |
223 Requires a running xemacs process. | |
224 end | |
225 | |
226 | |
227 define leval | |
228 ldp Feval(Fcar(Fread_from_string(build_string($arg0),Qnil,Qnil))) | |
229 end | |
230 | |
231 document leval | |
232 Usage: leval "SEXP" | |
233 Eval a lisp expression. | |
234 Requires a running xemacs process. | |
235 | |
236 Example: | |
237 (gdb) leval "(+ 1 2)" | |
238 Lisp ==> 3 | |
239 end | |
240 | |
241 | |
242 define wtype | |
243 print $arg0->core.widget_class->core_class.class_name | |
244 end | |
245 | |
246 define xtname | |
247 print XrmQuarkToString(((Object)($arg0))->object.xrm_name) | |
248 end | |
249 | |
250 ## GDB's command language makes you want to ... | |
251 | |
252 define pptype | |
253 set $type_ptr = ($arg0 *) $val | |
254 print $type_ptr | |
255 print *$type_ptr | |
256 end | |
257 | |
258 define pstructtype | |
259 set $type_ptr = (struct $arg0 *) $val | |
260 print $type_ptr | |
261 print *$type_ptr | |
262 end | |
263 | |
264 define pobj | |
265 decode_object $arg0 | |
266 if $type == $Lisp_Type_Int | |
267 printf "Integer: %d\n", $val | |
268 else | |
4643
e9ccbc62f7e7
Don't rely on GDB understanding the Lisp_Type_{Record,Char} enums, gdbinit.in
Aidan Kehoe <kehoea@parhasard.net>
parents:
3934
diff
changeset
|
269 if $type == $Lisp_Type_Char |
3418 | 270 if $val > 32 && $val < 128 |
271 printf "Char: %c\n", $val | |
272 else | |
273 printf "Char: %d\n", $val | |
274 end | |
275 else | |
276 if $lrecord_type == lrecord_type_string | |
277 pptype Lisp_String | |
278 else | |
279 if $lrecord_type == lrecord_type_cons | |
280 pptype Lisp_Cons | |
281 else | |
282 if $lrecord_type == lrecord_type_symbol | |
283 pptype Lisp_Symbol | |
284 printf "Symbol name: %s\n", ((Lisp_String *)$type_ptr->name)->data_ | |
285 else | |
286 if $lrecord_type == lrecord_type_vector | |
287 pptype Lisp_Vector | |
288 printf "Vector of length %d\n", $type_ptr->size | |
289 ##print *($type_ptr->data) @ $type_ptr->size | |
290 else | |
291 if $lrecord_type == lrecord_type_bit_vector | |
292 pptype Lisp_Bit_Vector | |
293 else | |
294 if $lrecord_type == lrecord_type_buffer | |
295 pstructtype buffer | |
296 else | |
297 if $lrecord_type == lrecord_type_char_table | |
298 pptype Lisp_Char_Table | |
299 else | |
300 if $lrecord_type == lrecord_type_char_table_entry | |
301 pptype Lisp_Char_Table_Entry | |
302 else | |
303 if $lrecord_type == lrecord_type_charset | |
304 pptype Lisp_Charset | |
305 else | |
306 if $lrecord_type == lrecord_type_coding_system | |
307 pptype Lisp_Coding_System | |
308 else | |
309 if $lrecord_type == lrecord_type_color_instance | |
310 pptype Lisp_Color_Instance | |
311 else | |
312 if $lrecord_type == lrecord_type_command_builder | |
313 pptype command_builder | |
314 else | |
315 if $lrecord_type == lrecord_type_compiled_function | |
316 pptype Lisp_Compiled_Function | |
317 else | |
318 if $lrecord_type == lrecord_type_console | |
319 pstructtype console | |
320 else | |
321 if $lrecord_type == lrecord_type_database | |
322 pptype Lisp_Database | |
323 else | |
324 if $lrecord_type == lrecord_type_device | |
325 pstructtype device | |
326 else | |
327 if $lrecord_type == lrecord_type_event | |
328 pptype Lisp_Event | |
329 else | |
330 if $lrecord_type == lrecord_type_extent | |
331 pstructtype extent | |
332 else | |
333 if $lrecord_type == lrecord_type_extent_auxiliary | |
334 pstructtype extent_auxiliary | |
335 else | |
336 if $lrecord_type == lrecord_type_extent_info | |
337 pstructtype extent_info | |
338 else | |
339 if $lrecord_type == lrecord_type_face | |
340 pptype Lisp_Face | |
341 else | |
342 if $lrecord_type == lrecord_type_float | |
343 pptype Lisp_Float | |
344 else | |
345 if $lrecord_type == lrecord_type_font_instance | |
346 pptype Lisp_Font_Instance | |
347 else | |
348 if $lrecord_type == lrecord_type_frame | |
349 pstructtype frame | |
350 else | |
351 if $lrecord_type == lrecord_type_glyph | |
352 pptype Lisp_Glyph | |
353 else | |
354 if $lrecord_type == lrecord_type_gui_item | |
355 pptype Lisp_Gui_Item | |
356 else | |
357 if $lrecord_type == lrecord_type_hash_table | |
358 pptype Lisp_Hash_Table | |
359 else | |
360 if $lrecord_type == lrecord_type_image_instance | |
361 pptype Lisp_Image_Instance | |
362 else | |
363 if $lrecord_type == lrecord_type_keymap | |
364 pptype Lisp_Keymap | |
365 else | |
366 if $lrecord_type == lrecord_type_lcrecord_list | |
367 pstructtype lcrecord_list | |
368 else | |
369 if $lrecord_type == lrecord_type_ldap | |
370 pptype Lisp_LDAP | |
371 else | |
372 if $lrecord_type == lrecord_type_lstream | |
373 pstructtype lstream | |
374 else | |
375 if $lrecord_type == lrecord_type_marker | |
376 pptype Lisp_Marker | |
377 else | |
378 if $lrecord_type == lrecord_type_opaque | |
379 pptype Lisp_Opaque | |
380 else | |
381 if $lrecord_type == lrecord_type_opaque_ptr | |
382 pptype Lisp_Opaque_Ptr | |
383 else | |
384 if $lrecord_type == lrecord_type_popup_data | |
385 pptype popup_data | |
386 else | |
387 if $lrecord_type == lrecord_type_process | |
388 pptype Lisp_Process | |
389 else | |
390 if $lrecord_type == lrecord_type_range_table | |
391 pptype Lisp_Range_Table | |
392 else | |
393 if $lrecord_type == lrecord_type_specifier | |
394 pptype Lisp_Specifier | |
395 else | |
396 if $lrecord_type == lrecord_type_subr | |
397 pptype Lisp_Subr | |
398 else | |
399 if $lrecord_type == lrecord_type_symbol_value_buffer_local | |
400 pstructtype symbol_value_buffer_local | |
401 else | |
402 if $lrecord_type == lrecord_type_symbol_value_forward | |
403 pstructtype symbol_value_forward | |
404 else | |
405 if $lrecord_type == lrecord_type_symbol_value_lisp_magic | |
406 pstructtype symbol_value_lisp_magic | |
407 else | |
408 if $lrecord_type == lrecord_type_symbol_value_varalias | |
409 pstructtype symbol_value_varalias | |
410 else | |
411 if $lrecord_type == lrecord_type_timeout | |
412 pptype Lisp_Timeout | |
413 else | |
414 if $lrecord_type == lrecord_type_toolbar_button | |
415 pstructtype toolbar_button | |
416 else | |
417 if $lrecord_type == lrecord_type_tooltalk_message | |
418 pptype Lisp_Tooltalk_Message | |
419 else | |
420 if $lrecord_type == lrecord_type_tooltalk_pattern | |
421 pptype Lisp_Tooltalk_Pattern | |
422 else | |
423 if $lrecord_type == lrecord_type_weak_list | |
424 pstructtype weak_list | |
425 else | |
426 if $lrecord_type == lrecord_type_window | |
427 pstructtype window | |
428 else | |
429 if $lrecord_type == lrecord_type_window_configuration | |
430 pstructtype window_config | |
431 else | |
432 if $lrecord_type == lrecord_type_fc_pattern | |
433 pstructtype fc_pattern | |
434 else | |
3934 | 435 if $lrecord_type == lrecord_type_fc_config |
436 pstructtype fc_config | |
3418 | 437 else |
438 echo Unknown Lisp Object type\n | |
439 print $arg0 | |
440 ## Barf, gag, retch | |
441 end | |
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 ## Repeat after me... gdb sux, gdb sux, gdb sux... | |
461 end | |
462 end | |
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 ## Are we having fun yet?? | |
480 end | |
481 end | |
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 | |
500 document pobj | |
501 Usage: pobj lisp_object | |
502 Print the internal C representation of a Lisp Object. | |
503 end | |
504 | |
505 ## ------------------------------------------------------------- | |
506 ## functions to test the debugging support itself. | |
507 ## If you change this file, make sure the following still work... | |
508 ## ------------------------------------------------------------- | |
509 define test_xtype | |
510 printf "Vemacs_major_version: " | |
511 xtype Vemacs_major_version | |
512 printf "Vhelp_char: " | |
513 xtype Vhelp_char | |
514 printf "Qnil: " | |
515 xtype Qnil | |
516 printf "Qunbound: " | |
517 xtype Qunbound | |
518 printf "Vobarray: " | |
519 xtype Vobarray | |
520 printf "Vall_weak_lists: " | |
521 xtype Vall_weak_lists | |
522 printf "Vxemacs_codename: " | |
523 xtype Vxemacs_codename | |
524 end | |
525 | |
526 define test_pobj | |
527 printf "Vemacs_major_version: " | |
528 pobj Vemacs_major_version | |
529 printf "Vhelp_char: " | |
530 pobj Vhelp_char | |
531 printf "Qnil: " | |
532 pobj Qnil | |
533 printf "Qunbound: " | |
534 pobj Qunbound | |
535 printf "Vobarray: " | |
536 pobj Vobarray | |
537 printf "Vall_weak_lists: " | |
538 pobj Vall_weak_lists | |
539 printf "Vxemacs_codename: " | |
540 pobj Vxemacs_codename | |
541 end | |
542 |