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