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