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