(Fstring_as_multibyte): Escape backslashes in the
[emacs.git] / src / .gdbinit
blobea1ac2ef666337b52118088aece6b15abddada1e
1 # Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 2000, 01, 2004
2 #   Free Software Foundation, Inc.
4 # This file is part of GNU Emacs.
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.
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.
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.
21 # Force loading of symbols, enough to give us gdb_valbits etc.
22 set main
24 # Find lwlib source files too.
25 dir ../lwlib
26 #dir /gd/gnu/lesstif-0.89.9/lib/Xm
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
34 # Don't pass SIGALRM to Emacs.  This makes problems when
35 # debugging.
36 handle SIGALRM ignore
38 # $valmask and $tagmask are mask values set up by the xreload macro below.
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
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
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
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
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
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.
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       printf " "
141       output $it->what
142     end
143   end
144   if ($it->method != GET_FROM_BUFFER)
145     printf " next="
146     output $it->method
147     if ($it->method == GET_FROM_STRING)
148       printf "[%d]", $it->current.string_pos.charpos
149     end
150   end
151   printf "\n"
152   if ($it->region_beg_charpos >= 0)
153     printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos
154   end
155   printf "vpos=%d hpos=%d", $it->vpos, $it->hpos,
156   printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y
157   printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x
158   printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent
159   printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent
160   printf "\n"
162 document pitx
163 Pretty print a display iterator.
164 Take one arg, an iterator object or pointer.
167 define pit
168   pitx it
170 document pit
171 Pretty print the display iterator it.
174 define prowx
175   set $row = $arg0
176   printf "y=%d x=%d pwid=%d", $row->y, $row->x, $row->pixel_width
177   printf " a+d=%d+%d=%d", $row->ascent, $row->height-$row->ascent, $row->height
178   printf " phys=%d+%d=%d", $row->phys_ascent, $row->phys_height-$row->phys_ascent, $row->phys_height
179   printf " vis=%d", $row->visible_height
180   printf "  L=%d T=%d R=%d", $row->used[0], $row->used[1], $row->used[2]
181   printf "\n"
182   printf "start=%d end=%d", $row->start.pos.charpos, $row->end.pos.charpos
183   if ($row->enabled_p)
184     printf " ENA"
185   end
186   if ($row->displays_text_p)
187     printf " DISP"
188   end
189   if ($row->mode_line_p)
190     printf " MODEL"
191   end
192   if ($row->continued_p)
193     printf " CONT"
194   end
195   if ($row-> truncated_on_left_p)
196     printf " TRUNC:L"
197   end
198   if ($row-> truncated_on_right_p)
199     printf " TRUNC:R"
200   end
201   if ($row->starts_in_middle_of_char_p)
202     printf " STARTMID"
203   end
204   if ($row->ends_in_middle_of_char_p)
205     printf " ENDMID"
206   end
207   if ($row->ends_in_newline_from_string_p)
208     printf " ENDNLFS"
209   end
210   if ($row->ends_at_zv_p)
211     printf " ENDZV"
212   end
213   if ($row->overlapped_p)
214     printf " OLAPD"
215   end
216   if ($row->overlapping_p)
217     printf " OLAPNG"
218   end
219   printf "\n"
221 document prowx
222 Pretty print information about glyph_row.
223 Takes one argument, a row object or pointer.
226 define prow
227   prowx row
229 document prow
230 Pretty print information about glyph_row in row.
234 define pcursorx
235   set $cp = $arg0
236   printf "y=%d x=%d vpos=%d hpos=%d", $cp->y, $cp->x, $cp->vpos, $cp->hpos
238 document pcursorx
239 Pretty print a window cursor
242 define pcursor
243   printf "output: "
244   pcursorx output_cursor
245   printf "\n"
247 document pcursor
248 Pretty print the output_cursor
251 define pwinx
252   set $w = $arg0
253   xgetint $w->sequence_number
254   if ($w->mini_p != Qnil)
255     printf "Mini "
256   end
257   printf "Window %d ", $int
258   xgetptr $w->buffer
259   set $tem = (struct buffer *) $ptr
260   xgetptr $tem->name
261   printf "%s", ((struct Lisp_String *) $ptr)->data
262   printf "\n"
263   xgetptr $w->start
264   set $tem = (struct Lisp_Marker *) $ptr
265   printf "start=%d end:", $tem->charpos
266   if ($w->window_end_valid != Qnil)
267     xgetint $w->window_end_pos
268     printf "pos=%d", $int
269     xgetint $w->window_end_vpos
270     printf " vpos=%d", $int
271   else
272     printf "invalid"
273   end
274   printf " vscroll=%d", $w->vscroll
275   if ($w->force_start != Qnil)
276     printf " FORCE_START"
277   end
278   if ($w->must_be_updated_p)
279     printf " MUST_UPD"
280   end
281   printf "\n"
282   printf "cursor: "
283   pcursorx $w->cursor
284   printf "  phys: "
285   pcursorx $w->phys_cursor
286   if ($w->phys_cursor_on_p)
287     printf " ON"
288   else
289     printf " OFF"
290   end
291   printf " blk="
292   if ($w->last_cursor_off_p != $w->cursor_off_p)
293     if ($w->last_cursor_off_p)
294       printf "ON->"
295     else
296       printf "OFF->"
297     end
298   end
299   if ($w->cursor_off_p)
300     printf "ON"
301   else
302     printf "OFF"
303   end
304   printf "\n"
306 document pwinx
307 Pretty print a window structure.
308 Takes one argument, a pointer to a window structure
311 define pwin
312   pwinx w
314 document pwin
315 Pretty print window structure w.
319 define xtype
320   xgettype $
321   output $type
322   echo \n
323   if $type == Lisp_Misc
324     xmisctype
325   else
326     if $type == Lisp_Vectorlike
327       xvectype
328     end
329   end
331 document xtype
332 Print the type of $, assuming it is an Emacs Lisp value.
333 If the first type printed is Lisp_Vector or Lisp_Misc,
334 a second line gives the more precise type.
337 define xvectype
338   xgetptr $
339   set $size = ((struct Lisp_Vector *) $ptr)->size
340   output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
341   echo \n
343 document xvectype
344 Print the size or vector subtype of $, assuming it is a vector or pseudovector.
347 define xmisctype
348   xgetptr $
349   output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
350   echo \n
352 document xmisctype
353 Print the specific type of $, assuming it is some misc type.
356 define xint
357   xgetint $
358   print $int
360 document xint
361 Print $, assuming it is an Emacs Lisp integer.  This gets the sign right.
364 define xptr
365   xgetptr $
366   print (void *) $ptr
368 document xptr
369 Print the pointer portion of $, assuming it is an Emacs Lisp value.
372 define xmarker
373   xgetptr $
374   print (struct Lisp_Marker *) $ptr
376 document xmarker
377 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
380 define xoverlay
381   xgetptr $
382   print (struct Lisp_Overlay *) $ptr
384 document xoverlay
385 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
388 define xmiscfree
389   xgetptr $
390   print (struct Lisp_Free *) $ptr
392 document xmiscfree
393 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
396 define xintfwd
397   xgetptr $
398   print (struct Lisp_Intfwd *) $ptr
400 document xintfwd
401 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
404 define xboolfwd
405   xgetptr $
406   print (struct Lisp_Boolfwd *) $ptr
408 document xboolfwd
409 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
412 define xobjfwd
413   xgetptr $
414   print (struct Lisp_Objfwd *) $ptr
416 document xobjfwd
417 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
420 define xbufobjfwd
421   xgetptr $
422   print (struct Lisp_Buffer_Objfwd *) $ptr
424 document xbufobjfwd
425 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
428 define xkbobjfwd
429   xgetptr $
430   print (struct Lisp_Kboard_Objfwd *) $ptr
432 document xkbobjfwd
433 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
436 define xbuflocal
437   xgetptr $
438   print (struct Lisp_Buffer_Local_Value *) $ptr
440 document xbuflocal
441 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
444 define xsymbol
445   set $sym = $
446   xgetptr $sym
447   print (struct Lisp_Symbol *) $ptr
448   xprintsym $sym
449   echo \n
451 document xsymbol
452 Print the name and address of the symbol $.
453 This command assumes that $ is an Emacs Lisp symbol value.
456 define xstring
457   xgetptr $
458   print (struct Lisp_String *) $ptr
459   xprintstr $
460   echo \n
462 document xstring
463 Print the contents and address of the string $.
464 This command assumes that $ is an Emacs Lisp string value.
467 define xvector
468   xgetptr $
469   print (struct Lisp_Vector *) $ptr
470   output ($->size > 50) ? 0 : ($->contents[0])@($->size & ~gdb_array_mark_flag)
471 echo \n
473 document xvector
474 Print the contents and address of the vector $.
475 This command assumes that $ is an Emacs Lisp vector value.
478 define xprocess
479   xgetptr $
480   print (struct Lisp_Process *) $ptr
481   output *$
482   echo \n
484 document xprocess
485 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
488 define xframe
489   xgetptr $
490   print (struct frame *) $ptr
492 document xframe
493 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
496 define xcompiled
497   xgetptr $
498   print (struct Lisp_Vector *) $ptr
499   output ($->contents[0])@($->size & 0xff)
501 document xcompiled
502 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
505 define xwindow
506   xgetptr $
507   print (struct window *) $ptr
508   printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
510 document xwindow
511 Print $ as a window pointer, assuming it is an Emacs Lisp window value.
512 Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
515 define xwinconfig
516   xgetptr $
517   print (struct save_window_data *) $ptr
519 document xwinconfig
520 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
523 define xsubr
524   xgetptr $
525   print (struct Lisp_Subr *) $ptr
526   output *$
527   echo \n
529 document xsubr
530 Print the address of the subr which the Lisp_Object $ points to.
533 define xchartable
534   xgetptr $
535   print (struct Lisp_Char_Table *) $ptr
536   printf "Purpose: "
537   xprintsym $->purpose
538   printf "  %d extra slots", ($->size & 0x1ff) - 388
539   echo \n
541 document xchartable
542 Print the address of the char-table $, and its purpose.
543 This command assumes that $ is an Emacs Lisp char-table value.
546 define xboolvector
547   xgetptr $
548   print (struct Lisp_Bool_Vector *) $ptr
549   output ($->size > 256) ? 0 : ($->data[0])@((($->size & ~gdb_array_mark_flag) + 7)/ 8)
550   echo \n
552 document xboolvector
553 Print the contents and address of the bool-vector $.
554 This command assumes that $ is an Emacs Lisp bool-vector value.
557 define xbuffer
558   xgetptr $
559   print (struct buffer *) $ptr
560   xgetptr $->name
561   output ((struct Lisp_String *) $ptr)->data
562   echo \n
564 document xbuffer
565 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
566 Print the name of the buffer.
569 define xhashtable
570   xgetptr $
571   print (struct Lisp_Hash_Table *) $ptr
573 document xhashtable
574 Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
577 define xcons
578   xgetptr $
579   print (struct Lisp_Cons *) $ptr
580   output/x *$
581   echo \n
583 document xcons
584 Print the contents of $, assuming it is an Emacs Lisp cons.
587 define nextcons
588   p $.cdr
589   xcons
591 document nextcons
592 Print the contents of the next cell in a list.
593 This assumes that the last thing you printed was a cons cell contents
594 (type struct Lisp_Cons) or a pointer to one.
596 define xcar
597   xgetptr $
598   xgettype $
599   print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0)
601 document xcar
602 Print the car of $, assuming it is an Emacs Lisp pair.
605 define xcdr
606   xgetptr $
607   xgettype $
608   print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->cdr : 0)
610 document xcdr
611 Print the cdr of $, assuming it is an Emacs Lisp pair.
614 define xfloat
615   xgetptr $
616   print ((struct Lisp_Float *) $ptr)->data
618 document xfloat
619 Print $ assuming it is a lisp floating-point number.
622 define xscrollbar
623   xgetptr $
624   print (struct scrollbar *) $ptr
625 output *$
626 echo \n
628 document xscrollbar
629 Print $ as a scrollbar pointer.
632 define xprintstr
633   set $data = $arg0->data
634   output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
637 define xprintsym
638   xgetptr $arg0
639   set $sym = (struct Lisp_Symbol *) $ptr
640   xgetptr $sym->xname
641   set $sym_name = (struct Lisp_String *) $ptr
642   xprintstr $sym_name
644 document xprintsym
645   Print argument as a symbol.
648 define xbacktrace
649   set $bt = backtrace_list
650   while $bt
651     xgettype (*$bt->function)
652     if $type == Lisp_Symbol
653       xprintsym (*$bt->function)
654       echo \n
655     else
656       printf "0x%x ", *$bt->function
657       if $type == Lisp_Vectorlike
658         xgetptr (*$bt->function)
659         set $size = ((struct Lisp_Vector *) $ptr)->size
660         output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
661       else
662         printf "Lisp type %d", $type
663       end
664       echo \n
665     end
666     set $bt = $bt->next
667   end
669 document xbacktrace
670   Print a backtrace of Lisp function calls from backtrace_list.
671   Set a breakpoint at Fsignal and call this to see from where
672   an error was signaled.
675 define xreload
676   set $tagmask = (((long)1 << gdb_gctypebits) - 1)
677   set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1
679 document xreload
680   When starting Emacs a second time in the same gdb session under
681   FreeBSD 2.2.5, gdb 4.13, $valmask have lost
682   their values.  (The same happens on current (2000) versions of GNU/Linux
683   with gdb 5.0.)
684   This function reloads them.
686 xreload
688 # Flush display (X only)
689 define ff
690   set x_flush (0)
692 document ff
693 Flush pending X window display updates to screen.
694 Works only when an inferior emacs is executing.
698 define hook-run
699   xreload
702 # Call xreload if a new Emacs executable is loaded.
703 define hookpost-run
704   xreload
707 set print pretty on
708 set print sevenbit-strings
710 show environment DISPLAY
711 show environment TERM
712 set args -geometry 80x40+0+0
714 # Don't let abort actually run, as it will make
715 # stdio stop working and therefore the `pr' command above as well.
716 break abort
718 # If we are running in synchronous mode, we want a chance to look around
719 # before Emacs exits.  Perhaps we should put the break somewhere else
720 # instead...
721 break x_error_quitter
723 # arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe