Avoid long futile looping on a TTY under huge values of hscroll.
[bpt/emacs.git] / src / .gdbinit
CommitLineData
acaf905b 1# Copyright (C) 1992-1998, 2000-2012 Free Software Foundation, Inc.
e3efab9c
GM
2#
3# This file is part of GNU Emacs.
4#
5# GNU Emacs is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
684d6f5b 7# the Free Software Foundation; either version 3, or (at your option)
e3efab9c
GM
8# any later version.
9#
10# GNU Emacs is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with GNU Emacs; see the file COPYING. If not, write to the
4fc5845f
LK
17# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18# Boston, MA 02110-1301, USA.
e3efab9c 19
7faa0236
RS
20# Force loading of symbols, enough to give us gdb_valbits etc.
21set main
2d4018aa
EZ
22# With some compilers, we need this to give us struct Lisp_Symbol etc.:
23set Fmake_symbol
7faa0236 24
39d10e52
RS
25# Find lwlib source files too.
26dir ../lwlib
892d8fcd 27#dir /gd/gnu/lesstif-0.89.9/lib/Xm
39d10e52 28
056515d8
KH
29# Don't enter GDB when user types C-g to quit.
30# This has one unfortunate effect: you can't type C-c
31# at the GDB to stop Emacs, when using X.
32# However, C-z works just as well in that case.
33handle 2 noprint pass
34
19b9d1de
NR
35# Make it work like SIGINT normally does.
36handle SIGTSTP nopass
37
6a7d16fe
KS
38# Pass on user signals
39handle SIGUSR1 noprint pass
40handle SIGUSR2 noprint pass
41
3266f62b
GM
42# Don't pass SIGALRM to Emacs. This makes problems when
43# debugging.
44handle SIGALRM ignore
45
0e73312b 46# $valmask and $tagmask are mask values set up by the xreload macro below.
6b61353c 47
0e73312b
RS
48# Use $bugfix so that the value isn't a constant.
49# Using a constant runs into GDB bugs sometimes.
6b61353c 50define xgetptr
0e73312b 51 set $bugfix = $arg0
646b5f55
AS
52 if gdb_use_struct
53 set $bugfix = $bugfix.i
54 end
55 set $ptr = $bugfix & $valmask | gdb_data_seg_bits
6b61353c
KH
56end
57
58define xgetint
0e73312b 59 set $bugfix = $arg0
646b5f55
AS
60 if gdb_use_struct
61 set $bugfix = $bugfix.i
62 end
e93864f9 63 set $int = gdb_use_lsb ? $bugfix >> (gdb_gctypebits - 1) : $bugfix << (gdb_gctypebits - 1) >> (gdb_gctypebits - 1)
6b61353c
KH
64end
65
66define xgettype
0e73312b 67 set $bugfix = $arg0
646b5f55
AS
68 if gdb_use_struct
69 set $bugfix = $bugfix.i
70 end
71 set $type = (enum Lisp_Type) (gdb_use_lsb ? $bugfix & $tagmask : $bugfix >> gdb_valbits)
6b61353c 72end
b74f15c6 73
a6ffc6a2 74# Set up something to print out s-expressions.
4fccedb5
EZ
75# We save and restore print_output_debug_flag to prevent the w32 port
76# from calling OutputDebugString, which causes GDB to display each
77# character twice (yuk!).
a6ffc6a2 78define pr
3723ec07 79 pp $
a6ffc6a2 80end
a6ffc6a2
JB
81document pr
82Print the emacs s-expression which is $.
83Works only when an inferior emacs is executing.
84end
85
6c5d0c52
KS
86# Print out s-expressions
87define pp
88 set $tmp = $arg0
4fccedb5
EZ
89 set $output_debug = print_output_debug_flag
90 set print_output_debug_flag = 0
1609a963 91 set safe_debug_print ($tmp)
4fccedb5 92 set print_output_debug_flag = $output_debug
6c5d0c52
KS
93end
94document pp
95Print the argument as an emacs s-expression
96Works only when an inferior emacs is executing.
97end
98
1609a963
KS
99# Print value of lisp variable
100define pv
1609a963 101 set $tmp = "$arg0"
4fccedb5
EZ
102 set $output_debug = print_output_debug_flag
103 set print_output_debug_flag = 0
1609a963 104 set safe_debug_print (find_symbol_value (intern ($tmp)))
4fccedb5 105 set print_output_debug_flag = $output_debug
1609a963 106end
3723ec07 107document pv
1609a963
KS
108Print the value of the lisp variable given as argument.
109Works only when an inferior emacs is executing.
1609a963
KS
110end
111
decf4020
KS
112# Print out current buffer point and boundaries
113define ppt
114 set $b = current_buffer
115 set $t = $b->text
116 printf "BUF PT: %d", $b->pt
117 if ($b->pt != $b->pt_byte)
118 printf "[%d]", $b->pt_byte
119 end
120 printf " of 1..%d", $t->z
121 if ($t->z != $t->z_byte)
122 printf "[%d]", $t->z_byte
123 end
124 if ($b->begv != 1 || $b->zv != $t->z)
125 printf " NARROW=%d..%d", $b->begv, $b->zv
126 if ($b->begv != $b->begv_byte || $b->zv != $b->zv_byte)
127 printf " [%d..%d]", $b->begv_byte, $b->zv_byte
128 end
129 end
130 printf " GAP: %d", $t->gpt
131 if ($t->gpt != $t->gpt_byte)
132 printf "[%d]", $t->gpt_byte
133 end
134 printf " SZ=%d\n", $t->gap_size
135end
136document ppt
2d5ed88d
EZ
137Print current buffer's point and boundaries.
138Prints values of point, beg, end, narrow, and gap for current buffer.
decf4020
KS
139end
140
be996d82
EZ
141define pitmethod
142 set $itmethod = $arg0
143 # output $itmethod
144 if ($itmethod == 0)
145 printf "GET_FROM_BUFFER"
146 end
147 if ($itmethod == 1)
148 printf "GET_FROM_DISPLAY_VECTOR"
149 end
150 if ($itmethod == 2)
151 printf "GET_FROM_STRING"
152 end
153 if ($itmethod == 3)
154 printf "GET_FROM_C_STRING"
155 end
156 if ($itmethod == 4)
157 printf "GET_FROM_IMAGE"
158 end
159 if ($itmethod == 5)
160 printf "GET_FROM_STRETCH"
161 end
162 if ($itmethod < 0 || $itmethod > 5)
163 output $itmethod
164 end
165end
166document pitmethod
167Pretty print it->method given as first arg
168end
169
afca296c
KS
170# Print out iterator given as first arg
171define pitx
172 set $it = $arg0
173 printf "cur=%d", $it->current.pos.charpos
174 if ($it->current.pos.charpos != $it->current.pos.bytepos)
175 printf "[%d]", $it->current.pos.bytepos
176 end
82d59cb0
KS
177 printf " pos=%d", $it->position.charpos
178 if ($it->position.charpos != $it->position.bytepos)
179 printf "[%d]", $it->position.bytepos
180 end
afca296c
KS
181 printf " start=%d", $it->start.pos.charpos
182 if ($it->start.pos.charpos != $it->start.pos.bytepos)
183 printf "[%d]", $it->start.pos.bytepos
184 end
2fde1500
KS
185 printf " end=%d", $it->end_charpos
186 printf " stop=%d", $it->stop_charpos
187 printf " face=%d", $it->face_id
188 if ($it->multibyte_p)
189 printf " MB"
190 end
191 if ($it->header_line_p)
192 printf " HL"
193 end
194 if ($it->n_overlay_strings > 0)
338fa84a 195 printf " nov=%d", $it->n_overlay_strings
2fde1500
KS
196 end
197 if ($it->sp != 0)
198 printf " sp=%d", $it->sp
199 end
2d20eee3
EZ
200 # IT_CHARACTER
201 if ($it->what == 0)
afca296c 202 if ($it->len == 1 && $it->c >= ' ' && it->c < 255)
501b66fa 203 printf " ch='%c'", $it->c
afca296c 204 else
501b66fa 205 printf " ch=[%d,%d]", $it->c, $it->len
2fde1500
KS
206 end
207 else
1e99743b 208 printf " "
be996d82
EZ
209 # output $it->what
210 if ($it->what == 0)
211 printf "IT_CHARACTER"
212 end
213 if ($it->what == 1)
214 printf "IT_COMPOSITION"
215 end
216 if ($it->what == 2)
217 printf "IT_IMAGE"
218 end
219 if ($it->what == 3)
220 printf "IT_STRETCH"
221 end
222 if ($it->what == 4)
223 printf "IT_EOB"
224 end
225 if ($it->what == 5)
226 printf "IT_TRUNCATION"
227 end
228 if ($it->what == 6)
229 printf "IT_CONTINUATION"
230 end
231 if ($it->what < 0 || $it->what > 6)
232 output $it->what
233 end
afca296c 234 end
2d20eee3
EZ
235 if ($it->method != 0)
236 # !GET_FROM_BUFFER
2fde1500 237 printf " next="
be996d82 238 pitmethod $it->method
2d20eee3
EZ
239 if ($it->method == 2)
240 # GET_FROM_STRING
501b66fa
KS
241 printf "[%d]", $it->current.string_pos.charpos
242 end
2d20eee3
EZ
243 if ($it->method == 4)
244 # GET_FROM_IMAGE
1e99743b
KS
245 printf "[%d]", $it->image_id
246 end
2fde1500 247 end
afca296c 248 printf "\n"
241ab1c1
EZ
249 if ($it->bidi_p)
250 printf "BIDI: base_stop=%d prev_stop=%d level=%d\n", $it->base_level_stop, $it->prev_stop, $it->bidi_it.resolved_level
251 end
2fde1500
KS
252 if ($it->region_beg_charpos >= 0)
253 printf "reg=%d-%d ", $it->region_beg_charpos, $it->region_end_charpos
254 end
afca296c
KS
255 printf "vpos=%d hpos=%d", $it->vpos, $it->hpos,
256 printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y
2fde1500 257 printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x
28c1e1ca 258 printf " w=%d", $it->pixel_width
afca296c
KS
259 printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent
260 printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent
261 printf "\n"
0058964e 262 set $i = 0
82d59cb0 263 while ($i < $it->sp && $i < 4)
0058964e
KS
264 set $e = $it->stack[$i]
265 printf "stack[%d]: ", $i
3eb49e71
EZ
266 pitmethod $e.method
267 printf "[%d]", $e.position.charpos
0058964e
KS
268 printf "\n"
269 set $i = $i + 1
270 end
afca296c
KS
271end
272document pitx
273Pretty print a display iterator.
274Take one arg, an iterator object or pointer.
275end
276
277define pit
278 pitx it
279end
280document pit
281Pretty print the display iterator it.
282end
283
284define prowx
285 set $row = $arg0
286 printf "y=%d x=%d pwid=%d", $row->y, $row->x, $row->pixel_width
287 printf " a+d=%d+%d=%d", $row->ascent, $row->height-$row->ascent, $row->height
288 printf " phys=%d+%d=%d", $row->phys_ascent, $row->phys_height-$row->phys_ascent, $row->phys_height
b12cd789
EZ
289 printf " vis=%d\n", $row->visible_height
290 printf "used=(LMargin=%d,Text=%d,RMargin=%d) Hash=%d\n", $row->used[0], $row->used[1], $row->used[2], $row->hash
afca296c
KS
291 printf "start=%d end=%d", $row->start.pos.charpos, $row->end.pos.charpos
292 if ($row->enabled_p)
293 printf " ENA"
294 end
295 if ($row->displays_text_p)
296 printf " DISP"
297 end
298 if ($row->mode_line_p)
299 printf " MODEL"
300 end
301 if ($row->continued_p)
302 printf " CONT"
303 end
304 if ($row-> truncated_on_left_p)
305 printf " TRUNC:L"
306 end
307 if ($row-> truncated_on_right_p)
308 printf " TRUNC:R"
309 end
310 if ($row->starts_in_middle_of_char_p)
311 printf " STARTMID"
312 end
313 if ($row->ends_in_middle_of_char_p)
314 printf " ENDMID"
315 end
316 if ($row->ends_in_newline_from_string_p)
317 printf " ENDNLFS"
318 end
319 if ($row->ends_at_zv_p)
320 printf " ENDZV"
321 end
322 if ($row->overlapped_p)
323 printf " OLAPD"
324 end
325 if ($row->overlapping_p)
326 printf " OLAPNG"
327 end
328 printf "\n"
329end
330document prowx
331Pretty print information about glyph_row.
332Takes one argument, a row object or pointer.
333end
334
335define prow
336 prowx row
337end
338document prow
339Pretty print information about glyph_row in row.
340end
341
342
343define pcursorx
344 set $cp = $arg0
345 printf "y=%d x=%d vpos=%d hpos=%d", $cp->y, $cp->x, $cp->vpos, $cp->hpos
346end
347document pcursorx
89955f2e 348Pretty print a window cursor.
afca296c
KS
349end
350
351define pcursor
352 printf "output: "
353 pcursorx output_cursor
354 printf "\n"
355end
356document pcursor
89955f2e 357Pretty print the output_cursor.
afca296c
KS
358end
359
360define pwinx
361 set $w = $arg0
362 xgetint $w->sequence_number
363 if ($w->mini_p != Qnil)
364 printf "Mini "
365 end
366 printf "Window %d ", $int
367 xgetptr $w->buffer
368 set $tem = (struct buffer *) $ptr
c40f8d15 369 xgetptr $tem->name_
afca296c
KS
370 printf "%s", ((struct Lisp_String *) $ptr)->data
371 printf "\n"
372 xgetptr $w->start
373 set $tem = (struct Lisp_Marker *) $ptr
374 printf "start=%d end:", $tem->charpos
375 if ($w->window_end_valid != Qnil)
376 xgetint $w->window_end_pos
377 printf "pos=%d", $int
378 xgetint $w->window_end_vpos
379 printf " vpos=%d", $int
380 else
381 printf "invalid"
382 end
383 printf " vscroll=%d", $w->vscroll
384 if ($w->force_start != Qnil)
385 printf " FORCE_START"
386 end
387 if ($w->must_be_updated_p)
388 printf " MUST_UPD"
389 end
390 printf "\n"
391 printf "cursor: "
392 pcursorx $w->cursor
393 printf " phys: "
394 pcursorx $w->phys_cursor
395 if ($w->phys_cursor_on_p)
396 printf " ON"
397 else
398 printf " OFF"
399 end
400 printf " blk="
401 if ($w->last_cursor_off_p != $w->cursor_off_p)
402 if ($w->last_cursor_off_p)
403 printf "ON->"
404 else
405 printf "OFF->"
406 end
407 end
408 if ($w->cursor_off_p)
409 printf "ON"
410 else
411 printf "OFF"
412 end
413 printf "\n"
414end
415document pwinx
416Pretty print a window structure.
89955f2e 417Takes one argument, a pointer to a window structure.
afca296c
KS
418end
419
420define pwin
421 pwinx w
422end
423document pwin
424Pretty print window structure w.
425end
426
bc5a45f3 427define pbiditype
9443b3c7
EZ
428 if ($arg0 == 0)
429 printf "UNDEF"
430 end
bc5a45f3
EZ
431 if ($arg0 == 1)
432 printf "L"
433 end
434 if ($arg0 == 2)
435 printf "R"
436 end
437 if ($arg0 == 3)
438 printf "EN"
439 end
440 if ($arg0 == 4)
441 printf "AN"
442 end
443 if ($arg0 == 5)
444 printf "BN"
445 end
446 if ($arg0 == 6)
447 printf "B"
448 end
9443b3c7 449 if ($arg0 < 0 || $arg0 > 6)
bc5a45f3
EZ
450 printf "%d??", $arg0
451 end
452end
453document pbiditype
454Print textual description of bidi type given as first argument.
455end
456
1e99743b
KS
457define pgx
458 set $g = $arg0
be996d82 459 # CHAR_GLYPH
a1674f0b
EZ
460 if ($g.type == 0)
461 if ($g.u.ch >= ' ' && $g.u.ch < 127)
462 printf "CHAR[%c]", $g.u.ch
1e99743b 463 else
a1674f0b 464 printf "CHAR[0x%x]", $g.u.ch
1e99743b
KS
465 end
466 end
be996d82 467 # COMPOSITE_GLYPH
a1674f0b
EZ
468 if ($g.type == 1)
469 printf "COMP[%d (%d..%d)]", $g.u.cmp.id, $g.slice.cmp.from, $g.slice.cmp.to
1e99743b 470 end
0eb025fb 471 # GLYPHLESS_GLYPH
a1674f0b 472 if ($g.type == 2)
0eb025fb 473 printf "GLYPHLESS["
a1674f0b 474 if ($g.u.glyphless.method == 0)
0eb025fb
EZ
475 printf "THIN]"
476 end
a1674f0b 477 if ($g.u.glyphless.method == 1)
0eb025fb
EZ
478 printf "EMPTY]"
479 end
a1674f0b 480 if ($g.u.glyphless.method == 2)
0eb025fb
EZ
481 printf "ACRO]"
482 end
a1674f0b 483 if ($g.u.glyphless.method == 3)
0eb025fb
EZ
484 printf "HEX]"
485 end
486 end
487 # IMAGE_GLYPH
a1674f0b
EZ
488 if ($g.type == 3)
489 printf "IMAGE[%d]", $g.u.img_id
1e99743b 490 end
be996d82 491 # STRETCH_GLYPH
a1674f0b
EZ
492 if ($g.type == 4)
493 printf "STRETCH[%d+%d]", $g.u.stretch.height, $g.u.stretch.ascent
1e99743b 494 end
a1674f0b 495 xgettype ($g.object)
1e99743b 496 if ($type == Lisp_String)
a1674f0b 497 printf " str=%x[%d]", $g.object, $g.charpos
1e99743b 498 else
a1674f0b 499 printf " pos=%d", $g.charpos
1e99743b 500 end
bc5a45f3 501 # For characters, print their resolved level and bidi type
a1674f0b
EZ
502 if ($g.type == 0)
503 printf " blev=%d,btyp=", $g.resolved_level
504 pbiditype $g.bidi_type
bc5a45f3 505 end
a1674f0b 506 printf " w=%d a+d=%d+%d", $g.pixel_width, $g.ascent, $g.descent
be996d82 507 # If not DEFAULT_FACE_ID
a1674f0b
EZ
508 if ($g.face_id != 0)
509 printf " face=%d", $g.face_id
1e99743b 510 end
a1674f0b
EZ
511 if ($g.voffset)
512 printf " vof=%d", $g.voffset
1e99743b 513 end
a1674f0b 514 if ($g.multibyte_p)
1e99743b
KS
515 printf " MB"
516 end
a1674f0b 517 if ($g.padding_p)
1e99743b
KS
518 printf " PAD"
519 end
a1674f0b 520 if ($g.glyph_not_available_p)
1e99743b
KS
521 printf " N/A"
522 end
a1674f0b 523 if ($g.overlaps_vertically_p)
1e99743b
KS
524 printf " OVL"
525 end
a1674f0b 526 if ($g.avoid_cursor_p)
cb4545ad
EZ
527 printf " AVOID"
528 end
a1674f0b 529 if ($g.left_box_line_p)
1e99743b
KS
530 printf " ["
531 end
a1674f0b 532 if ($g.right_box_line_p)
1e99743b
KS
533 printf " ]"
534 end
a1674f0b
EZ
535 if ($g.slice.img.x || $g.slice.img.y || $g.slice.img.width || $g.slice.img.height)
536 printf " slice=%d,%d,%d,%d" ,$g.slice.img.x, $g.slice.img.y, $g.slice.img.width, $g.slice.img.height
1e99743b
KS
537 end
538 printf "\n"
539end
540document pgx
541Pretty print a glyph structure.
89955f2e 542Takes one argument, a pointer to a glyph structure.
1e99743b
KS
543end
544
545define pg
546 set $pgidx = 0
547 pgx glyph
548end
549document pg
550Pretty print glyph structure glyph.
551end
552
553define pgi
554 set $pgidx = $arg0
555 pgx (&glyph[$pgidx])
556end
557document pgi
558Pretty print glyph structure glyph[I].
559Takes one argument, a integer I.
560end
561
562define pgn
563 set $pgidx = $pgidx + 1
564 pgx (&glyph[$pgidx])
565end
566document pgn
567Pretty print next glyph structure.
568end
569
570define pgrowx
571 set $row = $arg0
572 set $area = 0
573 set $xofs = $row->x
574 while ($area < 3)
575 set $used = $row->used[$area]
576 if ($used > 0)
577 set $gl0 = $row->glyphs[$area]
578 set $pgidx = 0
579 printf "%s: %d glyphs\n", ($area == 0 ? "LEFT" : $area == 2 ? "RIGHT" : "TEXT"), $used
580 while ($pgidx < $used)
581 printf "%3d %4d: ", $pgidx, $xofs
582 pgx $gl0[$pgidx]
583 set $xofs = $xofs + $gl0[$pgidx]->pixel_width
584 set $pgidx = $pgidx + 1
585 end
586 end
587 set $area = $area + 1
588 end
589end
590document pgrowx
591Pretty print all glyphs in a row structure.
592Takes one argument, a pointer to a row structure.
593end
594
595define pgrow
596 pgrowx row
597end
598document pgrow
599Pretty print all glyphs in row structure row.
600end
afca296c 601
be996d82
EZ
602define pgrowit
603 pgrowx it->glyph_row
604end
605document pgrowit
606Pretty print all glyphs in it->glyph_row.
607end
608
f866d742 609define prowlims
0416466c 610 printf "edges=(%d,%d),r2l=%d,cont=%d,trunc=(%d,%d),at_zv=%d\n", $arg0->minpos.charpos, $arg0->maxpos.charpos, $arg0->reversed_p, $arg0->continued_p, $arg0->truncated_on_left_p, $arg0->truncated_on_right_p, $arg0->ends_at_zv_p
f866d742
EZ
611end
612document prowlims
613Print important attributes of a glyph_row structure.
614Takes one argument, a pointer to a glyph_row structure.
615end
616
617define pmtxrows
618 set $mtx = $arg0
619 set $gl = $mtx->rows
0416466c
EZ
620 set $glend = $mtx->rows + $mtx->nrows - 1
621 set $i = 0
f866d742 622 while ($gl < $glend)
0416466c 623 printf "%d: ", $i
f866d742
EZ
624 prowlims $gl
625 set $gl = $gl + 1
0416466c 626 set $i = $i + 1
f866d742
EZ
627 end
628end
629document pmtxrows
630Print data about glyph rows in a glyph matrix.
631Takes one argument, a pointer to a glyph_matrix structure.
632end
633
a6ffc6a2 634define xtype
6b61353c
KH
635 xgettype $
636 output $type
637 echo \n
638 if $type == Lisp_Misc
639 xmisctype
640 else
641 if $type == Lisp_Vectorlike
642 xvectype
643 end
644 end
a6ffc6a2 645end
e065a56e 646document xtype
ba1e23bf 647Print the type of $, assuming it is an Emacs Lisp value.
3fe8bda5 648If the first type printed is Lisp_Vector or Lisp_Misc,
6b61353c 649a second line gives the more precise type.
3fe8bda5
RS
650end
651
652define xvectype
6b61353c 653 xgetptr $
cc7245e4 654 set $size = ((struct Lisp_Vector *) $ptr)->header.size
fc80da24 655 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
6b61353c 656 echo \n
3fe8bda5
RS
657end
658document xvectype
89955f2e
NR
659Print the size or vector subtype of $.
660This command assumes that $ is a vector or pseudovector.
3fe8bda5
RS
661end
662
663define xmisctype
6b61353c
KH
664 xgetptr $
665 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
666 echo \n
3fe8bda5
RS
667end
668document xmisctype
2d5ed88d 669Assume that $ is some misc type and print its specific type.
e065a56e 670end
a6ffc6a2
JB
671
672define xint
6b61353c
KH
673 xgetint $
674 print $int
a6ffc6a2 675end
e065a56e 676document xint
2d5ed88d 677Print $ as an Emacs Lisp integer. This gets the sign right.
e065a56e 678end
a6ffc6a2
JB
679
680define xptr
6b61353c
KH
681 xgetptr $
682 print (void *) $ptr
a6ffc6a2 683end
e065a56e 684document xptr
2d5ed88d 685Print the pointer portion of an Emacs Lisp value in $.
e065a56e 686end
a6ffc6a2 687
a6ffc6a2 688define xmarker
6b61353c
KH
689 xgetptr $
690 print (struct Lisp_Marker *) $ptr
a6ffc6a2 691end
e065a56e 692document xmarker
2d5ed88d
EZ
693Print $ as a marker pointer.
694This command assumes that $ is an Emacs Lisp marker value.
e065a56e 695end
a6ffc6a2 696
a6a3acf0 697define xoverlay
6b61353c
KH
698 xgetptr $
699 print (struct Lisp_Overlay *) $ptr
a6a3acf0
KH
700end
701document xoverlay
89955f2e
NR
702Print $ as a overlay pointer.
703This command assumes that $ is an Emacs Lisp overlay value.
a6a3acf0
KH
704end
705
706define xmiscfree
6b61353c
KH
707 xgetptr $
708 print (struct Lisp_Free *) $ptr
a6a3acf0
KH
709end
710document xmiscfree
89955f2e
NR
711Print $ as a misc free-cell pointer.
712This command assumes that $ is an Emacs Lisp Misc value.
a6a3acf0
KH
713end
714
a6ffc6a2 715define xsymbol
cfcde636
KS
716 set $sym = $
717 xgetptr $sym
6b61353c 718 print (struct Lisp_Symbol *) $ptr
cfcde636 719 xprintsym $sym
6b61353c 720 echo \n
a6ffc6a2 721end
e065a56e
JB
722document xsymbol
723Print the name and address of the symbol $.
ba1e23bf 724This command assumes that $ is an Emacs Lisp symbol value.
e065a56e 725end
a6ffc6a2
JB
726
727define xstring
6b61353c
KH
728 xgetptr $
729 print (struct Lisp_String *) $ptr
0001e968 730 xprintstr $
6b61353c 731 echo \n
a6ffc6a2 732end
a6ffc6a2 733document xstring
e065a56e 734Print the contents and address of the string $.
ba1e23bf 735This command assumes that $ is an Emacs Lisp string value.
a6ffc6a2
JB
736end
737
738define xvector
6b61353c
KH
739 xgetptr $
740 print (struct Lisp_Vector *) $ptr
cc7245e4 741 output ($->header.size > 50) ? 0 : ($->contents[0])@($->header.size & ~gdb_array_mark_flag)
ef15f270 742echo \n
a6ffc6a2 743end
a6ffc6a2 744document xvector
e065a56e 745Print the contents and address of the vector $.
ba1e23bf 746This command assumes that $ is an Emacs Lisp vector value.
a6ffc6a2
JB
747end
748
14a8902a 749define xprocess
6b61353c
KH
750 xgetptr $
751 print (struct Lisp_Process *) $ptr
752 output *$
753 echo \n
14a8902a
RS
754end
755document xprocess
89955f2e
NR
756Print the address of the struct Lisp_process to which $ points.
757This command assumes that $ is a Lisp_Object.
14a8902a
RS
758end
759
ec558adc 760define xframe
6b61353c
KH
761 xgetptr $
762 print (struct frame *) $ptr
28c1e1ca
KS
763 xgetptr $->name
764 set $ptr = (struct Lisp_String *) $ptr
765 xprintstr $ptr
766 echo \n
a6ffc6a2 767end
ec558adc 768document xframe
2d5ed88d
EZ
769Print $ as a frame pointer.
770This command assumes $ is an Emacs Lisp frame value.
e065a56e 771end
a6ffc6a2 772
14a8902a 773define xcompiled
6b61353c
KH
774 xgetptr $
775 print (struct Lisp_Vector *) $ptr
cc7245e4 776 output ($->contents[0])@($->header.size & 0xff)
14a8902a
RS
777end
778document xcompiled
89955f2e
NR
779Print $ as a compiled function pointer.
780This command assumes that $ is an Emacs Lisp compiled value.
14a8902a
RS
781end
782
783define xwindow
6b61353c
KH
784 xgetptr $
785 print (struct window *) $ptr
25d34643
RS
786 set $window = (struct window *) $ptr
787 xgetint $window->total_cols
788 set $width=$int
789 xgetint $window->total_lines
790 set $height=$int
791 xgetint $window->left_col
792 set $left=$int
793 xgetint $window->top_line
794 set $top=$int
795 printf "%dx%d+%d+%d\n", $width, $height, $left, $top
14a8902a
RS
796end
797document xwindow
798Print $ as a window pointer, assuming it is an Emacs Lisp window value.
799Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
800end
801
029c56f6 802define xwinconfig
6b61353c
KH
803 xgetptr $
804 print (struct save_window_data *) $ptr
a6a3acf0 805end
029c56f6 806document xwinconfig
89955f2e
NR
807Print $ as a window configuration pointer.
808This command assumes that $ is an Emacs Lisp window configuration value.
a6a3acf0
KH
809end
810
14a8902a 811define xsubr
6b61353c
KH
812 xgetptr $
813 print (struct Lisp_Subr *) $ptr
814 output *$
815 echo \n
a6a3acf0 816end
14a8902a
RS
817document xsubr
818Print the address of the subr which the Lisp_Object $ points to.
819end
820
821define xchartable
6b61353c
KH
822 xgetptr $
823 print (struct Lisp_Char_Table *) $ptr
824 printf "Purpose: "
825 xprintsym $->purpose
cc7245e4 826 printf " %d extra slots", ($->header.size & 0x1ff) - 68
6b61353c 827 echo \n
14a8902a
RS
828end
829document xchartable
830Print the address of the char-table $, and its purpose.
831This command assumes that $ is an Emacs Lisp char-table value.
832end
833
d1da276f
EZ
834define xsubchartable
835 xgetptr $
836 print (struct Lisp_Sub_Char_Table *) $ptr
837 xgetint $->depth
838 set $depth = $int
839 xgetint $->min_char
840 printf "Depth: %d, Min char: %d (0x%x)\n", $depth, $int, $int
841end
842document xsubchartable
843Print the address of the sub-char-table $, its depth and min-char.
844This command assumes that $ is an Emacs Lisp sub-char-table value.
845end
846
14a8902a 847define xboolvector
6b61353c
KH
848 xgetptr $
849 print (struct Lisp_Bool_Vector *) $ptr
cc7245e4 850 output ($->header.size > 256) ? 0 : ($->data[0])@((($->header.size & ~gdb_array_mark_flag) + 7)/ 8)
6b61353c 851 echo \n
14a8902a
RS
852end
853document xboolvector
854Print the contents and address of the bool-vector $.
855This command assumes that $ is an Emacs Lisp bool-vector value.
856end
857
858define xbuffer
6b61353c
KH
859 xgetptr $
860 print (struct buffer *) $ptr
c40f8d15 861 xgetptr $->name_
6b61353c
KH
862 output ((struct Lisp_String *) $ptr)->data
863 echo \n
14a8902a
RS
864end
865document xbuffer
2d5ed88d
EZ
866Set $ as a buffer pointer and the name of the buffer.
867This command assumes $ is an Emacs Lisp buffer value.
a6a3acf0
KH
868end
869
3266f62b 870define xhashtable
6b61353c
KH
871 xgetptr $
872 print (struct Lisp_Hash_Table *) $ptr
3266f62b
GM
873end
874document xhashtable
89955f2e
NR
875Set $ as a hash table pointer.
876This command assumes that $ is an Emacs Lisp hash table value.
3266f62b
GM
877end
878
a6ffc6a2 879define xcons
6b61353c
KH
880 xgetptr $
881 print (struct Lisp_Cons *) $ptr
882 output/x *$
883 echo \n
a6ffc6a2 884end
e065a56e 885document xcons
2d5ed88d 886Print the contents of $ as an Emacs Lisp cons.
e065a56e 887end
a6ffc6a2 888
6f493884 889define nextcons
b4483658 890 p $.u.cdr
6b61353c 891 xcons
6f493884
RS
892end
893document nextcons
894Print the contents of the next cell in a list.
89955f2e 895This command assumes that the last thing you printed was a cons cell contents
6f493884
RS
896(type struct Lisp_Cons) or a pointer to one.
897end
a6ffc6a2 898define xcar
6b61353c
KH
899 xgetptr $
900 xgettype $
901 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0)
a6ffc6a2 902end
e065a56e 903document xcar
2d5ed88d 904Assume that $ is an Emacs Lisp pair and print its car.
e065a56e 905end
a6ffc6a2
JB
906
907define xcdr
6b61353c
KH
908 xgetptr $
909 xgettype $
b4483658 910 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->u.cdr : 0)
a6ffc6a2 911end
e065a56e 912document xcdr
2d5ed88d 913Assume that $ is an Emacs Lisp pair and print its cdr.
e065a56e 914end
a6ffc6a2 915
28c1e1ca
KS
916define xlist
917 xgetptr $
918 set $cons = (struct Lisp_Cons *) $ptr
919 xgetptr Qnil
920 set $nil = $ptr
921 set $i = 0
922 while $cons != $nil && $i < 10
923 p/x $cons->car
924 xpr
925 xgetptr $cons->u.cdr
926 set $cons = (struct Lisp_Cons *) $ptr
927 set $i = $i + 1
928 printf "---\n"
929 end
930 if $cons == $nil
931 printf "nil\n"
932 else
933 printf "...\n"
934 p $ptr
935 end
936end
937document xlist
938Print $ assuming it is a list.
939end
940
df86e57e 941define xfloat
6b61353c 942 xgetptr $
b4483658 943 print ((struct Lisp_Float *) $ptr)->u.data
df86e57e
JB
944end
945document xfloat
946Print $ assuming it is a lisp floating-point number.
947end
948
b2367490 949define xscrollbar
6b61353c
KH
950 xgetptr $
951 print (struct scrollbar *) $ptr
b2367490
JB
952output *$
953echo \n
954end
dec5f4e3 955document xscrollbar
b2367490
JB
956Print $ as a scrollbar pointer.
957end
958
28c1e1ca
KS
959define xpr
960 xtype
646b5f55
AS
961 if $type == Lisp_Int0 || $type == Lisp_Int1
962 xint
28c1e1ca
KS
963 end
964 if $type == Lisp_Symbol
965 xsymbol
966 end
967 if $type == Lisp_String
968 xstring
969 end
970 if $type == Lisp_Cons
971 xcons
972 end
973 if $type == Lisp_Float
974 xfloat
975 end
976 if $type == Lisp_Misc
977 set $misc = (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
978 if $misc == Lisp_Misc_Free
979 xmiscfree
980 end
28c1e1ca
KS
981 if $misc == Lisp_Misc_Marker
982 xmarker
983 end
28c1e1ca
KS
984 if $misc == Lisp_Misc_Overlay
985 xoverlay
986 end
28c1e1ca
KS
987# if $misc == Lisp_Misc_Save_Value
988# xsavevalue
989# end
990 end
991 if $type == Lisp_Vectorlike
cc7245e4 992 set $size = ((struct Lisp_Vector *) $ptr)->header.size
28c1e1ca
KS
993 if ($size & PVEC_FLAG)
994 set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK)
995 if $vec == PVEC_NORMAL_VECTOR
996 xvector
997 end
998 if $vec == PVEC_PROCESS
999 xprocess
1000 end
1001 if $vec == PVEC_FRAME
1002 xframe
1003 end
1004 if $vec == PVEC_COMPILED
1005 xcompiled
1006 end
1007 if $vec == PVEC_WINDOW
1008 xwindow
1009 end
1010 if $vec == PVEC_WINDOW_CONFIGURATION
1011 xwinconfig
1012 end
1013 if $vec == PVEC_SUBR
1014 xsubr
1015 end
1016 if $vec == PVEC_CHAR_TABLE
1017 xchartable
1018 end
1019 if $vec == PVEC_BOOL_VECTOR
1020 xboolvector
1021 end
1022 if $vec == PVEC_BUFFER
1023 xbuffer
1024 end
1025 if $vec == PVEC_HASH_TABLE
1026 xhashtable
1027 end
1028 else
1029 xvector
1030 end
1031 end
1032end
1033document xpr
1034Print $ as a lisp object of any type.
1035end
1036
0001e968 1037define xprintstr
d3332249 1038 set $data = (char *) $arg0->data
0001e968
SM
1039 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
1040end
1041
24b4d1bc 1042define xprintsym
6b61353c
KH
1043 xgetptr $arg0
1044 set $sym = (struct Lisp_Symbol *) $ptr
1045 xgetptr $sym->xname
1046 set $sym_name = (struct Lisp_String *) $ptr
0001e968 1047 xprintstr $sym_name
24b4d1bc
GM
1048end
1049document xprintsym
1050 Print argument as a symbol.
1051end
1052
d5fb9ac8
KH
1053define xcoding
1054 set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & $valmask) | gdb_data_seg_bits)
1055 set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits)
1056 set $name = $tmp->contents[$arg0 * 2]
1057 print $name
1058 pr
1059 print $tmp->contents[$arg0 * 2 + 1]
1060 pr
1061end
1062document xcoding
8f924df7 1063 Print the name and attributes of coding system that has ID (argument).
d5fb9ac8
KH
1064end
1065
1066define xcharset
1067 set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & $valmask) | gdb_data_seg_bits)
1068 set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits)
af800dc0 1069 p $tmp->contents[charset_table[$arg0].hash_index * 2]
d5fb9ac8
KH
1070 pr
1071end
1072document xcharset
8f924df7 1073 Print the name of charset that has ID (argument).
d5fb9ac8
KH
1074end
1075
9e067dbc
KH
1076define xfontset
1077 xgetptr $
1078 set $tbl = (struct Lisp_Char_Table *) $ptr
1079 print $tbl
1080 xgetint $tbl->extras[0]
1081 printf " ID:%d", $int
1082 xgettype $tbl->extras[1]
1083 xgetptr $tbl->extras[1]
1084 if $type == Lisp_String
1085 set $ptr = (struct Lisp_String *) $ptr
1086 printf " Name:"
1087 xprintstr $ptr
1088 else
1089 xgetptr $tbl->extras[2]
1090 set $ptr = (struct Lisp_Char_Table *) $ptr
1091 xgetptr $ptr->extras[1]
1092 set $ptr = (struct Lisp_String *) $ptr
1093 printf " Realized from:"
1094 xprintstr $ptr
1095 end
1096 echo \n
1097end
1098
322081f1
KH
1099define xfont
1100 xgetptr $
cc7245e4 1101 set $size = (((struct Lisp_Vector *) $ptr)->header.size & 0x1FF)
322081f1
KH
1102 if $size == FONT_SPEC_MAX
1103 print (struct font_spec *) $ptr
1104 else
1105 if $size == FONT_ENTITY_MAX
1106 print (struct font_entity *) $ptr
1107 else
1108 print (struct font *) $ptr
1109 end
1110 end
1111end
1112document xfont
1113Print $ assuming it is a list font (font-spec, font-entity, or font-object).
1114end
1115
24b4d1bc
GM
1116define xbacktrace
1117 set $bt = backtrace_list
177c0ea7 1118 while $bt
6b61353c 1119 xgettype (*$bt->function)
3176a27e 1120 if $type == Lisp_Symbol
6b61353c 1121 xprintsym (*$bt->function)
c51842ec 1122 printf " (0x%x)\n", $bt->args
3176a27e 1123 else
cf07311b
SM
1124 xgetptr *$bt->function
1125 printf "0x%x ", $ptr
3176a27e 1126 if $type == Lisp_Vectorlike
6b61353c 1127 xgetptr (*$bt->function)
cc7245e4 1128 set $size = ((struct Lisp_Vector *) $ptr)->header.size
fc80da24 1129 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
3176a27e
GM
1130 else
1131 printf "Lisp type %d", $type
1132 end
1133 echo \n
1134 end
24b4d1bc
GM
1135 set $bt = $bt->next
1136 end
1137end
1138document xbacktrace
1139 Print a backtrace of Lisp function calls from backtrace_list.
177c0ea7 1140 Set a breakpoint at Fsignal and call this to see from where
3176a27e 1141 an error was signaled.
24b4d1bc
GM
1142end
1143
8b058d44
EZ
1144define xprintbytestr
1145 set $data = (char *) $arg0->data
1146 printf "Bytecode: "
1147 output/u ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
1148end
1149document xprintbytestr
1150 Print a string of byte code.
1151end
1152
1153define xwhichsymbols
1154 set $output_debug = print_output_debug_flag
1155 set print_output_debug_flag = 0
1156 set safe_debug_print (which_symbols ($arg0, $arg1))
1157 set print_output_debug_flag = $output_debug
28c1e1ca 1158end
8b058d44 1159document xwhichsymbols
89955f2e 1160 Print symbols which references a given lisp object
28c1e1ca 1161 either as its symbol value or symbol function.
8b058d44
EZ
1162 Call with two arguments: the lisp object and the
1163 maximum number of symbols referencing it to produce.
28c1e1ca
KS
1164end
1165
1166define xbytecode
1167 set $bt = byte_stack_list
1168 while $bt
8b058d44
EZ
1169 xgetptr $bt->byte_string
1170 set $ptr = (struct Lisp_String *) $ptr
1171 xprintbytestr $ptr
1172 printf "\n0x%x => ", $bt->byte_string
1173 xwhichsymbols $bt->byte_string 5
28c1e1ca
KS
1174 set $bt = $bt->next
1175 end
1176end
1177document xbytecode
1178 Print a backtrace of the byte code stack.
1179end
1180
338fa84a
KS
1181# Show Lisp backtrace after normal backtrace.
1182define hookpost-backtrace
1183 set $bt = backtrace_list
1184 if $bt
1185 echo \n
1186 echo Lisp Backtrace:\n
1187 xbacktrace
1188 end
1189end
1190
24b4d1bc 1191define xreload
e93864f9 1192 set $tagmask = ((1 << gdb_gctypebits) - 1)
cb3a28cc
PE
1193 # The consing_since_gc business widens the 1 to EMACS_INT,
1194 # a symbol not directly visible to GDB.
1195 set $valmask = gdb_use_lsb ? ~($tagmask) : ((consing_since_gc - consing_since_gc + 1) << gdb_valbits) - 1
24b4d1bc
GM
1196end
1197document xreload
1198 When starting Emacs a second time in the same gdb session under
6b61353c 1199 FreeBSD 2.2.5, gdb 4.13, $valmask have lost
be9e8331
DL
1200 their values. (The same happens on current (2000) versions of GNU/Linux
1201 with gdb 5.0.)
c71ea231 1202 This function reloads them.
24b4d1bc 1203end
6b61353c 1204xreload
24b4d1bc 1205
6c5d0c52
KS
1206# Flush display (X only)
1207define ff
1208 set x_flush (0)
1209end
1210document ff
1211Flush pending X window display updates to screen.
1212Works only when an inferior emacs is executing.
1213end
1214
1215
be9e8331
DL
1216define hook-run
1217 xreload
1218end
1219
e869a29d
RS
1220# Call xreload if a new Emacs executable is loaded.
1221define hookpost-run
1222 xreload
1223end
1224
e065a56e 1225set print pretty on
df86e57e 1226set print sevenbit-strings
a6ffc6a2 1227
e5d77022 1228show environment DISPLAY
6f5d1a4f 1229show environment TERM
e5d77022 1230
c2c50958 1231# People get bothered when they see messages about non-existent functions...
2787bba3 1232xgetptr globals.f_Vsystem_type
ea5f3ad4
EZ
1233# $ptr is NULL in temacs
1234if ($ptr != 0)
1235 set $tem = (struct Lisp_Symbol *) $ptr
1236 xgetptr $tem->xname
1237 set $tem = (struct Lisp_String *) $ptr
1238 set $tem = (char *) $tem->data
1239
1240 # Don't let abort actually run, as it will make stdio stop working and
1241 # therefore the `pr' command above as well.
1242 if $tem[0] == 'w' && $tem[1] == 'i' && $tem[2] == 'n' && $tem[3] == 'd'
1243 # The windows-nt build replaces abort with its own function.
1244 break w32_abort
1245 else
1246 break abort
1247 end
feaf060a 1248end
dd878ee1 1249
feaf060a
EZ
1250# x_error_quitter is defined only on X. But window-system is set up
1251# only at run time, during Emacs startup, so we need to defer setting
1252# the breakpoint. init_sys_modes is the first function called on
1253# every platform after init_display, where window-system is set.
1254tbreak init_sys_modes
1255commands
1256 silent
2787bba3 1257 xgetptr globals.f_Vinitial_window_system
913645cd
EZ
1258 set $tem = (struct Lisp_Symbol *) $ptr
1259 xgetptr $tem->xname
1260 set $tem = (struct Lisp_String *) $ptr
1261 set $tem = (char *) $tem->data
feaf060a
EZ
1262 # If we are running in synchronous mode, we want a chance to look
1263 # around before Emacs exits. Perhaps we should put the break
1264 # somewhere else instead...
913645cd 1265 if $tem[0] == 'x' && $tem[1] == '\0'
2d90e492 1266 break x_error_quitter
913645cd 1267 end
feaf060a 1268 continue
dd878ee1 1269end