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