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