Update FSF's address.
[bpt/emacs.git] / src / .gdbinit
1 # Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 2000, 01, 2004
2 # Free Software Foundation, Inc.
3 #
4 # This file is part of GNU Emacs.
5 #
6 # GNU Emacs 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 2, or (at your option)
9 # any later version.
10 #
11 # GNU Emacs 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.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Emacs; see the file COPYING. If not, write to the
18 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 # Boston, MA 02110-1301, USA.
20
21 # Force loading of symbols, enough to give us gdb_valbits etc.
22 set main
23
24 # Find lwlib source files too.
25 dir ../lwlib
26 #dir /gd/gnu/lesstif-0.89.9/lib/Xm
27
28 # Don't enter GDB when user types C-g to quit.
29 # This has one unfortunate effect: you can't type C-c
30 # at the GDB to stop Emacs, when using X.
31 # However, C-z works just as well in that case.
32 handle 2 noprint pass
33
34 # Don't pass SIGALRM to Emacs. This makes problems when
35 # debugging.
36 handle SIGALRM ignore
37
38 # $valmask and $tagmask are mask values set up by the xreload macro below.
39
40 # Use $bugfix so that the value isn't a constant.
41 # Using a constant runs into GDB bugs sometimes.
42 define xgetptr
43 set $bugfix = $arg0
44 set $ptr = (gdb_use_union ? $bugfix.u.val : $bugfix & $valmask) | gdb_data_seg_bits
45 end
46
47 define xgetint
48 set $bugfix = $arg0
49 set $int = gdb_use_union ? $bugfix.s.val : (gdb_use_lsb ? $bugfix : $bugfix << gdb_gctypebits) >> gdb_gctypebits
50 end
51
52 define xgettype
53 set $bugfix = $arg0
54 set $type = gdb_use_union ? $bugfix.s.type : (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits)
55 end
56
57 # Set up something to print out s-expressions.
58 define pr
59 set debug_print ($)
60 end
61 document pr
62 Print the emacs s-expression which is $.
63 Works only when an inferior emacs is executing.
64 end
65
66 # Print out s-expressions
67 define pp
68 set $tmp = $arg0
69 set debug_print ($tmp)
70 end
71 document pp
72 Print the argument as an emacs s-expression
73 Works only when an inferior emacs is executing.
74 end
75
76 # Print out current buffer point and boundaries
77 define ppt
78 set $b = current_buffer
79 set $t = $b->text
80 printf "BUF PT: %d", $b->pt
81 if ($b->pt != $b->pt_byte)
82 printf "[%d]", $b->pt_byte
83 end
84 printf " of 1..%d", $t->z
85 if ($t->z != $t->z_byte)
86 printf "[%d]", $t->z_byte
87 end
88 if ($b->begv != 1 || $b->zv != $t->z)
89 printf " NARROW=%d..%d", $b->begv, $b->zv
90 if ($b->begv != $b->begv_byte || $b->zv != $b->zv_byte)
91 printf " [%d..%d]", $b->begv_byte, $b->zv_byte
92 end
93 end
94 printf " GAP: %d", $t->gpt
95 if ($t->gpt != $t->gpt_byte)
96 printf "[%d]", $t->gpt_byte
97 end
98 printf " SZ=%d\n", $t->gap_size
99 end
100 document ppt
101 Print point, beg, end, narrow, and gap for current buffer.
102 end
103
104 # Print out iterator given as first arg
105 define pitx
106 set $it = $arg0
107 printf "cur=%d", $it->current.pos.charpos
108 if ($it->current.pos.charpos != $it->current.pos.bytepos)
109 printf "[%d]", $it->current.pos.bytepos
110 end
111 printf " start=%d", $it->start.pos.charpos
112 if ($it->start.pos.charpos != $it->start.pos.bytepos)
113 printf "[%d]", $it->start.pos.bytepos
114 end
115 printf " end=%d", $it->end_charpos
116 printf " stop=%d", $it->stop_charpos
117 printf " face=%d", $it->face_id
118 if ($it->multibyte_p)
119 printf " MB"
120 end
121 if ($it->header_line_p)
122 printf " HL"
123 end
124 if ($it->n_overlay_strings > 0)
125 printf " nov=%d"
126 end
127 if ($it->sp != 0)
128 printf " sp=%d", $it->sp
129 end
130 if ($it->what == IT_CHARACTER)
131 if ($it->len == 1 && $it->c >= ' ' && it->c < 255)
132 printf "ch='%c'", $it->c
133 else
134 printf "ch=[%d,%d]", $it->c, $it->len
135 end
136 else
137 if ($it->what == IT_IMAGE)
138 printf "IMAGE=%d", $it->image_id
139 else
140 output $it->what
141 end
142 end
143 if ($it->method != GET_FROM_BUFFER)
144 printf " next="
145 output $it->method
146 end
147 printf "\n"
148 if ($it->region_beg_charpos >= 0)
149 printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos
150 end
151 printf "vpos=%d hpos=%d", $it->vpos, $it->hpos,
152 printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y
153 printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x
154 printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent
155 printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent
156 printf "\n"
157 end
158 document pitx
159 Pretty print a display iterator.
160 Take one arg, an iterator object or pointer.
161 end
162
163 define pit
164 pitx it
165 end
166 document pit
167 Pretty print the display iterator it.
168 end
169
170 define prowx
171 set $row = $arg0
172 printf "y=%d x=%d pwid=%d", $row->y, $row->x, $row->pixel_width
173 printf " a+d=%d+%d=%d", $row->ascent, $row->height-$row->ascent, $row->height
174 printf " phys=%d+%d=%d", $row->phys_ascent, $row->phys_height-$row->phys_ascent, $row->phys_height
175 printf " vis=%d", $row->visible_height
176 printf " L=%d T=%d R=%d", $row->used[0], $row->used[1], $row->used[2]
177 printf "\n"
178 printf "start=%d end=%d", $row->start.pos.charpos, $row->end.pos.charpos
179 if ($row->enabled_p)
180 printf " ENA"
181 end
182 if ($row->displays_text_p)
183 printf " DISP"
184 end
185 if ($row->mode_line_p)
186 printf " MODEL"
187 end
188 if ($row->continued_p)
189 printf " CONT"
190 end
191 if ($row-> truncated_on_left_p)
192 printf " TRUNC:L"
193 end
194 if ($row-> truncated_on_right_p)
195 printf " TRUNC:R"
196 end
197 if ($row->starts_in_middle_of_char_p)
198 printf " STARTMID"
199 end
200 if ($row->ends_in_middle_of_char_p)
201 printf " ENDMID"
202 end
203 if ($row->ends_in_newline_from_string_p)
204 printf " ENDNLFS"
205 end
206 if ($row->ends_at_zv_p)
207 printf " ENDZV"
208 end
209 if ($row->overlapped_p)
210 printf " OLAPD"
211 end
212 if ($row->overlapping_p)
213 printf " OLAPNG"
214 end
215 printf "\n"
216 end
217 document prowx
218 Pretty print information about glyph_row.
219 Takes one argument, a row object or pointer.
220 end
221
222 define prow
223 prowx row
224 end
225 document prow
226 Pretty print information about glyph_row in row.
227 end
228
229
230 define pcursorx
231 set $cp = $arg0
232 printf "y=%d x=%d vpos=%d hpos=%d", $cp->y, $cp->x, $cp->vpos, $cp->hpos
233 end
234 document pcursorx
235 Pretty print a window cursor
236 end
237
238 define pcursor
239 printf "output: "
240 pcursorx output_cursor
241 printf "\n"
242 end
243 document pcursor
244 Pretty print the output_cursor
245 end
246
247 define pwinx
248 set $w = $arg0
249 xgetint $w->sequence_number
250 if ($w->mini_p != Qnil)
251 printf "Mini "
252 end
253 printf "Window %d ", $int
254 xgetptr $w->buffer
255 set $tem = (struct buffer *) $ptr
256 xgetptr $tem->name
257 printf "%s", ((struct Lisp_String *) $ptr)->data
258 printf "\n"
259 xgetptr $w->start
260 set $tem = (struct Lisp_Marker *) $ptr
261 printf "start=%d end:", $tem->charpos
262 if ($w->window_end_valid != Qnil)
263 xgetint $w->window_end_pos
264 printf "pos=%d", $int
265 xgetint $w->window_end_vpos
266 printf " vpos=%d", $int
267 else
268 printf "invalid"
269 end
270 printf " vscroll=%d", $w->vscroll
271 if ($w->force_start != Qnil)
272 printf " FORCE_START"
273 end
274 if ($w->must_be_updated_p)
275 printf " MUST_UPD"
276 end
277 printf "\n"
278 printf "cursor: "
279 pcursorx $w->cursor
280 printf " phys: "
281 pcursorx $w->phys_cursor
282 if ($w->phys_cursor_on_p)
283 printf " ON"
284 else
285 printf " OFF"
286 end
287 printf " blk="
288 if ($w->last_cursor_off_p != $w->cursor_off_p)
289 if ($w->last_cursor_off_p)
290 printf "ON->"
291 else
292 printf "OFF->"
293 end
294 end
295 if ($w->cursor_off_p)
296 printf "ON"
297 else
298 printf "OFF"
299 end
300 printf "\n"
301 end
302 document pwinx
303 Pretty print a window structure.
304 Takes one argument, a pointer to a window structure
305 end
306
307 define pwin
308 pwinx w
309 end
310 document pwin
311 Pretty print window structure w.
312 end
313
314
315 define xtype
316 xgettype $
317 output $type
318 echo \n
319 if $type == Lisp_Misc
320 xmisctype
321 else
322 if $type == Lisp_Vectorlike
323 xvectype
324 end
325 end
326 end
327 document xtype
328 Print the type of $, assuming it is an Emacs Lisp value.
329 If the first type printed is Lisp_Vector or Lisp_Misc,
330 a second line gives the more precise type.
331 end
332
333 define xvectype
334 xgetptr $
335 set $size = ((struct Lisp_Vector *) $ptr)->size
336 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
337 echo \n
338 end
339 document xvectype
340 Print the size or vector subtype of $, assuming it is a vector or pseudovector.
341 end
342
343 define xmisctype
344 xgetptr $
345 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
346 echo \n
347 end
348 document xmisctype
349 Print the specific type of $, assuming it is some misc type.
350 end
351
352 define xint
353 xgetint $
354 print $int
355 end
356 document xint
357 Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
358 end
359
360 define xptr
361 xgetptr $
362 print (void *) $ptr
363 end
364 document xptr
365 Print the pointer portion of $, assuming it is an Emacs Lisp value.
366 end
367
368 define xmarker
369 xgetptr $
370 print (struct Lisp_Marker *) $ptr
371 end
372 document xmarker
373 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
374 end
375
376 define xoverlay
377 xgetptr $
378 print (struct Lisp_Overlay *) $ptr
379 end
380 document xoverlay
381 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
382 end
383
384 define xmiscfree
385 xgetptr $
386 print (struct Lisp_Free *) $ptr
387 end
388 document xmiscfree
389 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
390 end
391
392 define xintfwd
393 xgetptr $
394 print (struct Lisp_Intfwd *) $ptr
395 end
396 document xintfwd
397 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
398 end
399
400 define xboolfwd
401 xgetptr $
402 print (struct Lisp_Boolfwd *) $ptr
403 end
404 document xboolfwd
405 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
406 end
407
408 define xobjfwd
409 xgetptr $
410 print (struct Lisp_Objfwd *) $ptr
411 end
412 document xobjfwd
413 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
414 end
415
416 define xbufobjfwd
417 xgetptr $
418 print (struct Lisp_Buffer_Objfwd *) $ptr
419 end
420 document xbufobjfwd
421 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
422 end
423
424 define xkbobjfwd
425 xgetptr $
426 print (struct Lisp_Kboard_Objfwd *) $ptr
427 end
428 document xkbobjfwd
429 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
430 end
431
432 define xbuflocal
433 xgetptr $
434 print (struct Lisp_Buffer_Local_Value *) $ptr
435 end
436 document xbuflocal
437 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
438 end
439
440 define xsymbol
441 set $sym = $
442 xgetptr $sym
443 print (struct Lisp_Symbol *) $ptr
444 xprintsym $sym
445 echo \n
446 end
447 document xsymbol
448 Print the name and address of the symbol $.
449 This command assumes that $ is an Emacs Lisp symbol value.
450 end
451
452 define xstring
453 xgetptr $
454 print (struct Lisp_String *) $ptr
455 xprintstr $
456 echo \n
457 end
458 document xstring
459 Print the contents and address of the string $.
460 This command assumes that $ is an Emacs Lisp string value.
461 end
462
463 define xvector
464 xgetptr $
465 print (struct Lisp_Vector *) $ptr
466 output ($->size > 50) ? 0 : ($->contents[0])@($->size & ~gdb_array_mark_flag)
467 echo \n
468 end
469 document xvector
470 Print the contents and address of the vector $.
471 This command assumes that $ is an Emacs Lisp vector value.
472 end
473
474 define xprocess
475 xgetptr $
476 print (struct Lisp_Process *) $ptr
477 output *$
478 echo \n
479 end
480 document xprocess
481 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
482 end
483
484 define xframe
485 xgetptr $
486 print (struct frame *) $ptr
487 end
488 document xframe
489 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
490 end
491
492 define xcompiled
493 xgetptr $
494 print (struct Lisp_Vector *) $ptr
495 output ($->contents[0])@($->size & 0xff)
496 end
497 document xcompiled
498 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
499 end
500
501 define xwindow
502 xgetptr $
503 print (struct window *) $ptr
504 printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
505 end
506 document xwindow
507 Print $ as a window pointer, assuming it is an Emacs Lisp window value.
508 Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
509 end
510
511 define xwinconfig
512 xgetptr $
513 print (struct save_window_data *) $ptr
514 end
515 document xwinconfig
516 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
517 end
518
519 define xsubr
520 xgetptr $
521 print (struct Lisp_Subr *) $ptr
522 output *$
523 echo \n
524 end
525 document xsubr
526 Print the address of the subr which the Lisp_Object $ points to.
527 end
528
529 define xchartable
530 xgetptr $
531 print (struct Lisp_Char_Table *) $ptr
532 printf "Purpose: "
533 xprintsym $->purpose
534 printf " %d extra slots", ($->size & 0x1ff) - 388
535 echo \n
536 end
537 document xchartable
538 Print the address of the char-table $, and its purpose.
539 This command assumes that $ is an Emacs Lisp char-table value.
540 end
541
542 define xboolvector
543 xgetptr $
544 print (struct Lisp_Bool_Vector *) $ptr
545 output ($->size > 256) ? 0 : ($->data[0])@((($->size & ~gdb_array_mark_flag) + 7)/ 8)
546 echo \n
547 end
548 document xboolvector
549 Print the contents and address of the bool-vector $.
550 This command assumes that $ is an Emacs Lisp bool-vector value.
551 end
552
553 define xbuffer
554 xgetptr $
555 print (struct buffer *) $ptr
556 xgetptr $->name
557 output ((struct Lisp_String *) $ptr)->data
558 echo \n
559 end
560 document xbuffer
561 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
562 Print the name of the buffer.
563 end
564
565 define xhashtable
566 xgetptr $
567 print (struct Lisp_Hash_Table *) $ptr
568 end
569 document xhashtable
570 Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
571 end
572
573 define xcons
574 xgetptr $
575 print (struct Lisp_Cons *) $ptr
576 output/x *$
577 echo \n
578 end
579 document xcons
580 Print the contents of $, assuming it is an Emacs Lisp cons.
581 end
582
583 define nextcons
584 p $.cdr
585 xcons
586 end
587 document nextcons
588 Print the contents of the next cell in a list.
589 This assumes that the last thing you printed was a cons cell contents
590 (type struct Lisp_Cons) or a pointer to one.
591 end
592 define xcar
593 xgetptr $
594 xgettype $
595 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0)
596 end
597 document xcar
598 Print the car of $, assuming it is an Emacs Lisp pair.
599 end
600
601 define xcdr
602 xgetptr $
603 xgettype $
604 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->cdr : 0)
605 end
606 document xcdr
607 Print the cdr of $, assuming it is an Emacs Lisp pair.
608 end
609
610 define xfloat
611 xgetptr $
612 print ((struct Lisp_Float *) $ptr)->data
613 end
614 document xfloat
615 Print $ assuming it is a lisp floating-point number.
616 end
617
618 define xscrollbar
619 xgetptr $
620 print (struct scrollbar *) $ptr
621 output *$
622 echo \n
623 end
624 document xscrollbar
625 Print $ as a scrollbar pointer.
626 end
627
628 define xprintstr
629 set $data = $arg0->data
630 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
631 end
632
633 define xprintsym
634 xgetptr $arg0
635 set $sym = (struct Lisp_Symbol *) $ptr
636 xgetptr $sym->xname
637 set $sym_name = (struct Lisp_String *) $ptr
638 xprintstr $sym_name
639 end
640 document xprintsym
641 Print argument as a symbol.
642 end
643
644 define xbacktrace
645 set $bt = backtrace_list
646 while $bt
647 xgettype (*$bt->function)
648 if $type == Lisp_Symbol
649 xprintsym (*$bt->function)
650 echo \n
651 else
652 printf "0x%x ", *$bt->function
653 if $type == Lisp_Vectorlike
654 xgetptr (*$bt->function)
655 set $size = ((struct Lisp_Vector *) $ptr)->size
656 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
657 else
658 printf "Lisp type %d", $type
659 end
660 echo \n
661 end
662 set $bt = $bt->next
663 end
664 end
665 document xbacktrace
666 Print a backtrace of Lisp function calls from backtrace_list.
667 Set a breakpoint at Fsignal and call this to see from where
668 an error was signaled.
669 end
670
671 define xreload
672 set $tagmask = (((long)1 << gdb_gctypebits) - 1)
673 set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1
674 end
675 document xreload
676 When starting Emacs a second time in the same gdb session under
677 FreeBSD 2.2.5, gdb 4.13, $valmask have lost
678 their values. (The same happens on current (2000) versions of GNU/Linux
679 with gdb 5.0.)
680 This function reloads them.
681 end
682 xreload
683
684 # Flush display (X only)
685 define ff
686 set x_flush (0)
687 end
688 document ff
689 Flush pending X window display updates to screen.
690 Works only when an inferior emacs is executing.
691 end
692
693
694 define hook-run
695 xreload
696 end
697
698 # Call xreload if a new Emacs executable is loaded.
699 define hookpost-run
700 xreload
701 end
702
703 set print pretty on
704 set print sevenbit-strings
705
706 show environment DISPLAY
707 show environment TERM
708 set args -geometry 80x40+0+0
709
710 # Don't let abort actually run, as it will make
711 # stdio stop working and therefore the `pr' command above as well.
712 break abort
713
714 # If we are running in synchronous mode, we want a chance to look around
715 # before Emacs exits. Perhaps we should put the break somewhere else
716 # instead...
717 break x_error_quitter
718
719 # arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe