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