(Qsignal): Declare here.
[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
82d59cb0
KS
167 printf " pos=%d", $it->position.charpos
168 if ($it->position.charpos != $it->position.bytepos)
169 printf "[%d]", $it->position.bytepos
170 end
afca296c
KS
171 printf " start=%d", $it->start.pos.charpos
172 if ($it->start.pos.charpos != $it->start.pos.bytepos)
173 printf "[%d]", $it->start.pos.bytepos
174 end
2fde1500
KS
175 printf " end=%d", $it->end_charpos
176 printf " stop=%d", $it->stop_charpos
177 printf " face=%d", $it->face_id
178 if ($it->multibyte_p)
179 printf " MB"
180 end
181 if ($it->header_line_p)
182 printf " HL"
183 end
184 if ($it->n_overlay_strings > 0)
338fa84a 185 printf " nov=%d", $it->n_overlay_strings
2fde1500
KS
186 end
187 if ($it->sp != 0)
188 printf " sp=%d", $it->sp
189 end
afca296c
KS
190 if ($it->what == IT_CHARACTER)
191 if ($it->len == 1 && $it->c >= ' ' && it->c < 255)
501b66fa 192 printf " ch='%c'", $it->c
afca296c 193 else
501b66fa 194 printf " ch=[%d,%d]", $it->c, $it->len
2fde1500
KS
195 end
196 else
1e99743b
KS
197 printf " "
198 output $it->what
afca296c 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
1e99743b
KS
206 if ($it->method == GET_FROM_IMAGE)
207 printf "[%d]", $it->image_id
208 end
209 if ($it->method == GET_FROM_COMPOSITION)
210 printf "[%d,%d,%d]", $it->cmp_id, $it->len, $it->cmp_len
211 end
2fde1500 212 end
afca296c 213 printf "\n"
2fde1500
KS
214 if ($it->region_beg_charpos >= 0)
215 printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos
216 end
afca296c
KS
217 printf "vpos=%d hpos=%d", $it->vpos, $it->hpos,
218 printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y
2fde1500 219 printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x
28c1e1ca 220 printf " w=%d", $it->pixel_width
afca296c
KS
221 printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent
222 printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent
223 printf "\n"
0058964e 224 set $i = 0
82d59cb0 225 while ($i < $it->sp && $i < 4)
0058964e
KS
226 set $e = $it->stack[$i]
227 printf "stack[%d]: ", $i
228 output $e->method
229 printf "[%d]", $e->position.charpos
230 printf "\n"
231 set $i = $i + 1
232 end
afca296c
KS
233end
234document pitx
235Pretty print a display iterator.
236Take one arg, an iterator object or pointer.
237end
238
239define pit
240 pitx it
241end
242document pit
243Pretty print the display iterator it.
244end
245
246define prowx
247 set $row = $arg0
248 printf "y=%d x=%d pwid=%d", $row->y, $row->x, $row->pixel_width
249 printf " a+d=%d+%d=%d", $row->ascent, $row->height-$row->ascent, $row->height
250 printf " phys=%d+%d=%d", $row->phys_ascent, $row->phys_height-$row->phys_ascent, $row->phys_height
251 printf " vis=%d", $row->visible_height
252 printf " L=%d T=%d R=%d", $row->used[0], $row->used[1], $row->used[2]
253 printf "\n"
254 printf "start=%d end=%d", $row->start.pos.charpos, $row->end.pos.charpos
255 if ($row->enabled_p)
256 printf " ENA"
257 end
258 if ($row->displays_text_p)
259 printf " DISP"
260 end
261 if ($row->mode_line_p)
262 printf " MODEL"
263 end
264 if ($row->continued_p)
265 printf " CONT"
266 end
267 if ($row-> truncated_on_left_p)
268 printf " TRUNC:L"
269 end
270 if ($row-> truncated_on_right_p)
271 printf " TRUNC:R"
272 end
273 if ($row->starts_in_middle_of_char_p)
274 printf " STARTMID"
275 end
276 if ($row->ends_in_middle_of_char_p)
277 printf " ENDMID"
278 end
279 if ($row->ends_in_newline_from_string_p)
280 printf " ENDNLFS"
281 end
282 if ($row->ends_at_zv_p)
283 printf " ENDZV"
284 end
285 if ($row->overlapped_p)
286 printf " OLAPD"
287 end
288 if ($row->overlapping_p)
289 printf " OLAPNG"
290 end
291 printf "\n"
292end
293document prowx
294Pretty print information about glyph_row.
295Takes one argument, a row object or pointer.
296end
297
298define prow
299 prowx row
300end
301document prow
302Pretty print information about glyph_row in row.
303end
304
305
306define pcursorx
307 set $cp = $arg0
308 printf "y=%d x=%d vpos=%d hpos=%d", $cp->y, $cp->x, $cp->vpos, $cp->hpos
309end
310document pcursorx
311Pretty print a window cursor
312end
313
314define pcursor
315 printf "output: "
316 pcursorx output_cursor
317 printf "\n"
318end
319document pcursor
320Pretty print the output_cursor
321end
322
323define pwinx
324 set $w = $arg0
325 xgetint $w->sequence_number
326 if ($w->mini_p != Qnil)
327 printf "Mini "
328 end
329 printf "Window %d ", $int
330 xgetptr $w->buffer
331 set $tem = (struct buffer *) $ptr
332 xgetptr $tem->name
333 printf "%s", ((struct Lisp_String *) $ptr)->data
334 printf "\n"
335 xgetptr $w->start
336 set $tem = (struct Lisp_Marker *) $ptr
337 printf "start=%d end:", $tem->charpos
338 if ($w->window_end_valid != Qnil)
339 xgetint $w->window_end_pos
340 printf "pos=%d", $int
341 xgetint $w->window_end_vpos
342 printf " vpos=%d", $int
343 else
344 printf "invalid"
345 end
346 printf " vscroll=%d", $w->vscroll
347 if ($w->force_start != Qnil)
348 printf " FORCE_START"
349 end
350 if ($w->must_be_updated_p)
351 printf " MUST_UPD"
352 end
353 printf "\n"
354 printf "cursor: "
355 pcursorx $w->cursor
356 printf " phys: "
357 pcursorx $w->phys_cursor
358 if ($w->phys_cursor_on_p)
359 printf " ON"
360 else
361 printf " OFF"
362 end
363 printf " blk="
364 if ($w->last_cursor_off_p != $w->cursor_off_p)
365 if ($w->last_cursor_off_p)
366 printf "ON->"
367 else
368 printf "OFF->"
369 end
370 end
371 if ($w->cursor_off_p)
372 printf "ON"
373 else
374 printf "OFF"
375 end
376 printf "\n"
377end
378document pwinx
379Pretty print a window structure.
380Takes one argument, a pointer to a window structure
381end
382
383define pwin
384 pwinx w
385end
386document pwin
387Pretty print window structure w.
388end
389
1e99743b
KS
390define pgx
391 set $g = $arg0
392 if ($g->type == CHAR_GLYPH)
393 if ($g->u.ch >= ' ' && $g->u.ch < 127)
394 printf "CHAR[%c]", $g->u.ch
395 else
396 printf "CHAR[0x%x]", $g->u.ch
397 end
398 end
399 if ($g->type == COMPOSITE_GLYPH)
400 printf "COMP[%d]", $g->u.cmp_id
401 end
402 if ($g->type == IMAGE_GLYPH)
403 printf "IMAGE[%d]", $g->u.img_id
404 end
405 if ($g->type == STRETCH_GLYPH)
406 printf "STRETCH[%d+%d]", $g->u.stretch.height, $g->u.stretch.ascent
407 end
408 xgettype ($g->object)
409 if ($type == Lisp_String)
410 printf " str=%x[%d]", $g->object, $g->charpos
411 else
412 printf " pos=%d", $g->charpos
413 end
414 printf " w=%d a+d=%d+%d", $g->pixel_width, $g->ascent, $g->descent
415 if ($g->face_id != DEFAULT_FACE_ID)
416 printf " face=%d", $g->face_id
417 end
418 if ($g->voffset)
419 printf " vof=%d", $g->voffset
420 end
421 if ($g->multibyte_p)
422 printf " MB"
423 end
424 if ($g->padding_p)
425 printf " PAD"
426 end
427 if ($g->glyph_not_available_p)
428 printf " N/A"
429 end
430 if ($g->overlaps_vertically_p)
431 printf " OVL"
432 end
433 if ($g->left_box_line_p)
434 printf " ["
435 end
436 if ($g->right_box_line_p)
437 printf " ]"
438 end
439 if ($g->slice.x || $g->slice.y || $g->slice.width || $g->slice.height)
440 printf " slice=%d,%d,%d,%d" ,$g->slice.x, $g->slice.y, $g->slice.width, $g->slice.height
441 end
442 printf "\n"
443end
444document pgx
445Pretty print a glyph structure.
446Takes one argument, a pointer to a glyph structure
447end
448
449define pg
450 set $pgidx = 0
451 pgx glyph
452end
453document pg
454Pretty print glyph structure glyph.
455end
456
457define pgi
458 set $pgidx = $arg0
459 pgx (&glyph[$pgidx])
460end
461document pgi
462Pretty print glyph structure glyph[I].
463Takes one argument, a integer I.
464end
465
466define pgn
467 set $pgidx = $pgidx + 1
468 pgx (&glyph[$pgidx])
469end
470document pgn
471Pretty print next glyph structure.
472end
473
474define pgrowx
475 set $row = $arg0
476 set $area = 0
477 set $xofs = $row->x
478 while ($area < 3)
479 set $used = $row->used[$area]
480 if ($used > 0)
481 set $gl0 = $row->glyphs[$area]
482 set $pgidx = 0
483 printf "%s: %d glyphs\n", ($area == 0 ? "LEFT" : $area == 2 ? "RIGHT" : "TEXT"), $used
484 while ($pgidx < $used)
485 printf "%3d %4d: ", $pgidx, $xofs
486 pgx $gl0[$pgidx]
487 set $xofs = $xofs + $gl0[$pgidx]->pixel_width
488 set $pgidx = $pgidx + 1
489 end
490 end
491 set $area = $area + 1
492 end
493end
494document pgrowx
495Pretty print all glyphs in a row structure.
496Takes one argument, a pointer to a row structure.
497end
498
499define pgrow
500 pgrowx row
501end
502document pgrow
503Pretty print all glyphs in row structure row.
504end
afca296c 505
a6ffc6a2 506define xtype
329aa188
SM
507 xgettype $
508 output $type
509 echo \n
510 if $type == Lisp_Misc
511 xmisctype
512 else
513 if $type == Lisp_Vectorlike
514 xvectype
515 end
516 end
a6ffc6a2 517end
e065a56e 518document xtype
ba1e23bf 519Print the type of $, assuming it is an Emacs Lisp value.
3fe8bda5 520If the first type printed is Lisp_Vector or Lisp_Misc,
329aa188 521a second line gives the more precise type.
3fe8bda5
RS
522end
523
524define xvectype
329aa188
SM
525 xgetptr $
526 set $size = ((struct Lisp_Vector *) $ptr)->size
fc80da24 527 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
329aa188 528 echo \n
3fe8bda5
RS
529end
530document xvectype
329aa188 531Print the size or vector subtype of $, assuming it is a vector or pseudovector.
3fe8bda5
RS
532end
533
534define xmisctype
329aa188
SM
535 xgetptr $
536 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
537 echo \n
3fe8bda5
RS
538end
539document xmisctype
540Print the specific type of $, assuming it is some misc type.
e065a56e 541end
a6ffc6a2
JB
542
543define xint
329aa188
SM
544 xgetint $
545 print $int
a6ffc6a2 546end
e065a56e 547document xint
ba1e23bf 548Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
e065a56e 549end
a6ffc6a2
JB
550
551define xptr
329aa188
SM
552 xgetptr $
553 print (void *) $ptr
a6ffc6a2 554end
e065a56e 555document xptr
ba1e23bf 556Print the pointer portion of $, assuming it is an Emacs Lisp value.
e065a56e 557end
a6ffc6a2 558
a6ffc6a2 559define xmarker
329aa188
SM
560 xgetptr $
561 print (struct Lisp_Marker *) $ptr
a6ffc6a2 562end
e065a56e 563document xmarker
ba1e23bf 564Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
e065a56e 565end
a6ffc6a2 566
a6a3acf0 567define xoverlay
329aa188
SM
568 xgetptr $
569 print (struct Lisp_Overlay *) $ptr
a6a3acf0
KH
570end
571document xoverlay
572Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
573end
574
575define xmiscfree
329aa188
SM
576 xgetptr $
577 print (struct Lisp_Free *) $ptr
a6a3acf0
KH
578end
579document xmiscfree
580Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
581end
582
583define xintfwd
329aa188
SM
584 xgetptr $
585 print (struct Lisp_Intfwd *) $ptr
a6a3acf0
KH
586end
587document xintfwd
588Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
589end
590
591define xboolfwd
329aa188
SM
592 xgetptr $
593 print (struct Lisp_Boolfwd *) $ptr
a6a3acf0
KH
594end
595document xboolfwd
596Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
597end
598
599define xobjfwd
329aa188
SM
600 xgetptr $
601 print (struct Lisp_Objfwd *) $ptr
a6a3acf0
KH
602end
603document xobjfwd
604Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
605end
606
029c56f6 607define xbufobjfwd
329aa188
SM
608 xgetptr $
609 print (struct Lisp_Buffer_Objfwd *) $ptr
a6a3acf0 610end
029c56f6 611document xbufobjfwd
a6a3acf0
KH
612Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
613end
614
a0371857 615define xkbobjfwd
329aa188
SM
616 xgetptr $
617 print (struct Lisp_Kboard_Objfwd *) $ptr
cd39e946 618end
a0371857
KH
619document xkbobjfwd
620Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
cd39e946
KH
621end
622
029c56f6 623define xbuflocal
329aa188
SM
624 xgetptr $
625 print (struct Lisp_Buffer_Local_Value *) $ptr
a6a3acf0 626end
029c56f6 627document xbuflocal
a6a3acf0
KH
628Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
629end
630
a6ffc6a2 631define xsymbol
cfcde636
KS
632 set $sym = $
633 xgetptr $sym
329aa188 634 print (struct Lisp_Symbol *) $ptr
cfcde636 635 xprintsym $sym
329aa188 636 echo \n
a6ffc6a2 637end
e065a56e
JB
638document xsymbol
639Print the name and address of the symbol $.
ba1e23bf 640This command assumes that $ is an Emacs Lisp symbol value.
e065a56e 641end
a6ffc6a2
JB
642
643define xstring
329aa188
SM
644 xgetptr $
645 print (struct Lisp_String *) $ptr
0001e968 646 xprintstr $
329aa188 647 echo \n
a6ffc6a2 648end
a6ffc6a2 649document xstring
e065a56e 650Print the contents and address of the string $.
ba1e23bf 651This command assumes that $ is an Emacs Lisp string value.
a6ffc6a2
JB
652end
653
654define xvector
329aa188
SM
655 xgetptr $
656 print (struct Lisp_Vector *) $ptr
fc80da24 657 output ($->size > 50) ? 0 : ($->contents[0])@($->size & ~gdb_array_mark_flag)
ef15f270 658echo \n
a6ffc6a2 659end
a6ffc6a2 660document xvector
e065a56e 661Print the contents and address of the vector $.
ba1e23bf 662This command assumes that $ is an Emacs Lisp vector value.
a6ffc6a2
JB
663end
664
14a8902a 665define xprocess
329aa188
SM
666 xgetptr $
667 print (struct Lisp_Process *) $ptr
668 output *$
669 echo \n
14a8902a
RS
670end
671document xprocess
672Print the address of the struct Lisp_process which the Lisp_Object $ points to.
673end
674
ec558adc 675define xframe
329aa188
SM
676 xgetptr $
677 print (struct frame *) $ptr
28c1e1ca
KS
678 xgetptr $->name
679 set $ptr = (struct Lisp_String *) $ptr
680 xprintstr $ptr
681 echo \n
a6ffc6a2 682end
ec558adc 683document xframe
ba1e23bf 684Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
e065a56e 685end
a6ffc6a2 686
14a8902a 687define xcompiled
329aa188
SM
688 xgetptr $
689 print (struct Lisp_Vector *) $ptr
690 output ($->contents[0])@($->size & 0xff)
14a8902a
RS
691end
692document xcompiled
693Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
694end
695
696define xwindow
329aa188
SM
697 xgetptr $
698 print (struct window *) $ptr
25d34643
RS
699 set $window = (struct window *) $ptr
700 xgetint $window->total_cols
701 set $width=$int
702 xgetint $window->total_lines
703 set $height=$int
704 xgetint $window->left_col
705 set $left=$int
706 xgetint $window->top_line
707 set $top=$int
708 printf "%dx%d+%d+%d\n", $width, $height, $left, $top
14a8902a
RS
709end
710document xwindow
711Print $ as a window pointer, assuming it is an Emacs Lisp window value.
712Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
713end
714
029c56f6 715define xwinconfig
329aa188
SM
716 xgetptr $
717 print (struct save_window_data *) $ptr
a6a3acf0 718end
029c56f6 719document xwinconfig
a6a3acf0
KH
720Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
721end
722
14a8902a 723define xsubr
329aa188
SM
724 xgetptr $
725 print (struct Lisp_Subr *) $ptr
726 output *$
727 echo \n
a6a3acf0 728end
14a8902a
RS
729document xsubr
730Print the address of the subr which the Lisp_Object $ points to.
731end
732
733define xchartable
329aa188
SM
734 xgetptr $
735 print (struct Lisp_Char_Table *) $ptr
736 printf "Purpose: "
737 xprintsym $->purpose
738 printf " %d extra slots", ($->size & 0x1ff) - 388
739 echo \n
14a8902a
RS
740end
741document xchartable
742Print the address of the char-table $, and its purpose.
743This command assumes that $ is an Emacs Lisp char-table value.
744end
745
746define xboolvector
329aa188
SM
747 xgetptr $
748 print (struct Lisp_Bool_Vector *) $ptr
fc80da24 749 output ($->size > 256) ? 0 : ($->data[0])@((($->size & ~gdb_array_mark_flag) + 7)/ 8)
329aa188 750 echo \n
14a8902a
RS
751end
752document xboolvector
753Print the contents and address of the bool-vector $.
754This command assumes that $ is an Emacs Lisp bool-vector value.
755end
756
757define xbuffer
329aa188
SM
758 xgetptr $
759 print (struct buffer *) $ptr
760 xgetptr $->name
761 output ((struct Lisp_String *) $ptr)->data
762 echo \n
14a8902a
RS
763end
764document xbuffer
765Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
766Print the name of the buffer.
a6a3acf0
KH
767end
768
3266f62b 769define xhashtable
329aa188
SM
770 xgetptr $
771 print (struct Lisp_Hash_Table *) $ptr
3266f62b
GM
772end
773document xhashtable
774Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
775end
776
a6ffc6a2 777define xcons
329aa188
SM
778 xgetptr $
779 print (struct Lisp_Cons *) $ptr
780 output/x *$
781 echo \n
a6ffc6a2 782end
e065a56e 783document xcons
ba1e23bf 784Print the contents of $, assuming it is an Emacs Lisp cons.
e065a56e 785end
a6ffc6a2 786
6f493884 787define nextcons
b4483658 788 p $.u.cdr
329aa188 789 xcons
6f493884
RS
790end
791document nextcons
792Print the contents of the next cell in a list.
793This assumes that the last thing you printed was a cons cell contents
794(type struct Lisp_Cons) or a pointer to one.
795end
a6ffc6a2 796define xcar
329aa188
SM
797 xgetptr $
798 xgettype $
799 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0)
a6ffc6a2 800end
e065a56e 801document xcar
ba1e23bf 802Print the car of $, assuming it is an Emacs Lisp pair.
e065a56e 803end
a6ffc6a2
JB
804
805define xcdr
329aa188
SM
806 xgetptr $
807 xgettype $
b4483658 808 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->u.cdr : 0)
a6ffc6a2 809end
e065a56e 810document xcdr
ba1e23bf 811Print the cdr of $, assuming it is an Emacs Lisp pair.
e065a56e 812end
a6ffc6a2 813
28c1e1ca
KS
814define xlist
815 xgetptr $
816 set $cons = (struct Lisp_Cons *) $ptr
817 xgetptr Qnil
818 set $nil = $ptr
819 set $i = 0
820 while $cons != $nil && $i < 10
821 p/x $cons->car
822 xpr
823 xgetptr $cons->u.cdr
824 set $cons = (struct Lisp_Cons *) $ptr
825 set $i = $i + 1
826 printf "---\n"
827 end
828 if $cons == $nil
829 printf "nil\n"
830 else
831 printf "...\n"
832 p $ptr
833 end
834end
835document xlist
836Print $ assuming it is a list.
837end
838
df86e57e 839define xfloat
329aa188 840 xgetptr $
b4483658 841 print ((struct Lisp_Float *) $ptr)->u.data
df86e57e
JB
842end
843document xfloat
844Print $ assuming it is a lisp floating-point number.
845end
846
b2367490 847define xscrollbar
329aa188
SM
848 xgetptr $
849 print (struct scrollbar *) $ptr
b2367490
JB
850output *$
851echo \n
852end
dec5f4e3 853document xscrollbar
b2367490
JB
854Print $ as a scrollbar pointer.
855end
856
28c1e1ca
KS
857define xpr
858 xtype
859 if $type == Lisp_Int
860 xint
861 end
862 if $type == Lisp_Symbol
863 xsymbol
864 end
865 if $type == Lisp_String
866 xstring
867 end
868 if $type == Lisp_Cons
869 xcons
870 end
871 if $type == Lisp_Float
872 xfloat
873 end
874 if $type == Lisp_Misc
875 set $misc = (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
876 if $misc == Lisp_Misc_Free
877 xmiscfree
878 end
879 if $misc == Lisp_Misc_Boolfwd
880 xboolfwd
881 end
882 if $misc == Lisp_Misc_Marker
883 xmarker
884 end
885 if $misc == Lisp_Misc_Intfwd
886 xintfwd
887 end
888 if $misc == Lisp_Misc_Boolfwd
889 xboolfwd
890 end
891 if $misc == Lisp_Misc_Objfwd
892 xobjfwd
893 end
894 if $misc == Lisp_Misc_Buffer_Objfwd
895 xbufobjfwd
896 end
897 if $misc == Lisp_Misc_Buffer_Local_Value
898 xbuflocal
899 end
900# if $misc == Lisp_Misc_Some_Buffer_Local_Value
901# xvalue
902# end
903 if $misc == Lisp_Misc_Overlay
904 xoverlay
905 end
906 if $misc == Lisp_Misc_Kboard_Objfwd
907 xkbobjfwd
908 end
909# if $misc == Lisp_Misc_Save_Value
910# xsavevalue
911# end
912 end
913 if $type == Lisp_Vectorlike
914 set $size = ((struct Lisp_Vector *) $ptr)->size
915 if ($size & PVEC_FLAG)
916 set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK)
917 if $vec == PVEC_NORMAL_VECTOR
918 xvector
919 end
920 if $vec == PVEC_PROCESS
921 xprocess
922 end
923 if $vec == PVEC_FRAME
924 xframe
925 end
926 if $vec == PVEC_COMPILED
927 xcompiled
928 end
929 if $vec == PVEC_WINDOW
930 xwindow
931 end
932 if $vec == PVEC_WINDOW_CONFIGURATION
933 xwinconfig
934 end
935 if $vec == PVEC_SUBR
936 xsubr
937 end
938 if $vec == PVEC_CHAR_TABLE
939 xchartable
940 end
941 if $vec == PVEC_BOOL_VECTOR
942 xboolvector
943 end
944 if $vec == PVEC_BUFFER
945 xbuffer
946 end
947 if $vec == PVEC_HASH_TABLE
948 xhashtable
949 end
950 else
951 xvector
952 end
953 end
954end
955document xpr
956Print $ as a lisp object of any type.
957end
958
0001e968
SM
959define xprintstr
960 set $data = $arg0->data
961 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
962end
963
24b4d1bc 964define xprintsym
329aa188
SM
965 xgetptr $arg0
966 set $sym = (struct Lisp_Symbol *) $ptr
967 xgetptr $sym->xname
968 set $sym_name = (struct Lisp_String *) $ptr
0001e968 969 xprintstr $sym_name
24b4d1bc
GM
970end
971document xprintsym
972 Print argument as a symbol.
973end
974
975define xbacktrace
976 set $bt = backtrace_list
177c0ea7 977 while $bt
329aa188 978 xgettype (*$bt->function)
3176a27e 979 if $type == Lisp_Symbol
329aa188 980 xprintsym (*$bt->function)
28c1e1ca 981 printf " (0x%x)\n", *$bt->args
3176a27e
GM
982 else
983 printf "0x%x ", *$bt->function
984 if $type == Lisp_Vectorlike
329aa188
SM
985 xgetptr (*$bt->function)
986 set $size = ((struct Lisp_Vector *) $ptr)->size
fc80da24 987 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
3176a27e
GM
988 else
989 printf "Lisp type %d", $type
990 end
991 echo \n
992 end
24b4d1bc
GM
993 set $bt = $bt->next
994 end
995end
996document xbacktrace
997 Print a backtrace of Lisp function calls from backtrace_list.
177c0ea7 998 Set a breakpoint at Fsignal and call this to see from where
3176a27e 999 an error was signaled.
24b4d1bc
GM
1000end
1001
28c1e1ca
KS
1002define which
1003 set debug_print (which_symbols ($arg0))
1004end
1005document which
1006 Print symbols which references a given lisp object,
1007 either as its symbol value or symbol function.
1008end
1009
1010define xbytecode
1011 set $bt = byte_stack_list
1012 while $bt
1013 xgettype ($bt->byte_string)
1014 printf "0x%x => ", $bt->byte_string
1015 which $bt->byte_string
1016 set $bt = $bt->next
1017 end
1018end
1019document xbytecode
1020 Print a backtrace of the byte code stack.
1021end
1022
338fa84a
KS
1023# Show Lisp backtrace after normal backtrace.
1024define hookpost-backtrace
1025 set $bt = backtrace_list
1026 if $bt
1027 echo \n
1028 echo Lisp Backtrace:\n
1029 xbacktrace
1030 end
1031end
1032
24b4d1bc 1033define xreload
329aa188
SM
1034 set $tagmask = (((long)1 << gdb_gctypebits) - 1)
1035 set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1
24b4d1bc
GM
1036end
1037document xreload
1038 When starting Emacs a second time in the same gdb session under
329aa188 1039 FreeBSD 2.2.5, gdb 4.13, $valmask have lost
be9e8331
DL
1040 their values. (The same happens on current (2000) versions of GNU/Linux
1041 with gdb 5.0.)
c71ea231 1042 This function reloads them.
24b4d1bc 1043end
329aa188 1044xreload
24b4d1bc 1045
6c5d0c52
KS
1046# Flush display (X only)
1047define ff
1048 set x_flush (0)
1049end
1050document ff
1051Flush pending X window display updates to screen.
1052Works only when an inferior emacs is executing.
1053end
1054
1055
be9e8331
DL
1056define hook-run
1057 xreload
1058end
1059
e869a29d
RS
1060# Call xreload if a new Emacs executable is loaded.
1061define hookpost-run
1062 xreload
1063end
1064
e065a56e 1065set print pretty on
df86e57e 1066set print sevenbit-strings
a6ffc6a2 1067
e5d77022 1068show environment DISPLAY
6f5d1a4f 1069show environment TERM
8175bfa9 1070set args -geometry 80x40+0+0
e5d77022 1071
c2c50958 1072# People get bothered when they see messages about non-existent functions...
dd878ee1 1073xgetptr Vsystem_type
ea5f3ad4
EZ
1074# $ptr is NULL in temacs
1075if ($ptr != 0)
1076 set $tem = (struct Lisp_Symbol *) $ptr
1077 xgetptr $tem->xname
1078 set $tem = (struct Lisp_String *) $ptr
1079 set $tem = (char *) $tem->data
1080
1081 # Don't let abort actually run, as it will make stdio stop working and
1082 # therefore the `pr' command above as well.
1083 if $tem[0] == 'w' && $tem[1] == 'i' && $tem[2] == 'n' && $tem[3] == 'd'
1084 # The windows-nt build replaces abort with its own function.
1085 break w32_abort
1086 else
1087 break abort
1088 end
feaf060a 1089end
dd878ee1 1090
feaf060a
EZ
1091# x_error_quitter is defined only on X. But window-system is set up
1092# only at run time, during Emacs startup, so we need to defer setting
1093# the breakpoint. init_sys_modes is the first function called on
1094# every platform after init_display, where window-system is set.
1095tbreak init_sys_modes
1096commands
1097 silent
913645cd
EZ
1098 xgetptr Vwindow_system
1099 set $tem = (struct Lisp_Symbol *) $ptr
1100 xgetptr $tem->xname
1101 set $tem = (struct Lisp_String *) $ptr
1102 set $tem = (char *) $tem->data
feaf060a
EZ
1103 # If we are running in synchronous mode, we want a chance to look
1104 # around before Emacs exits. Perhaps we should put the break
1105 # somewhere else instead...
913645cd 1106 if $tem[0] == 'x' && $tem[1] == '\0'
2d90e492 1107 break x_error_quitter
913645cd 1108 end
feaf060a 1109 continue
dd878ee1 1110end
ab5796a9 1111# arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe