*** empty log message ***
[bpt/emacs.git] / src / .gdbinit
CommitLineData
329aa188 1# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 2000, 01, 2004
e3efab9c
GM
2# Free Software Foundation, Inc.
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
18# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19# Boston, MA 02111-1307, USA.
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
3266f62b
GM
34# Don't pass SIGALRM to Emacs. This makes problems when
35# debugging.
36handle SIGALRM ignore
37
056515d8 38# Set up a mask to use.
b8d3c872
RS
39# This should be EMACS_INT, but in some cases that is a macro.
40# long ought to work in all cases right now.
329aa188
SM
41
42define xgetptr
43 set $ptr = (gdb_use_union ? $arg0.u.val : $arg0 & $valmask) | gdb_data_seg_bits
44end
45
46define xgetint
47 set $int = gdb_use_union ? $arg0.s.val : (gdb_use_lsb ? $arg0 : $arg0 << gdb_gctypebits) >> gdb_gctypebits
48end
49
50define xgettype
51 set $type = gdb_use_union ? $arg0.s.type : (enum Lisp_Type) (gdb_use_lsb ? $arg0 & $tagmask : $arg0 >> gdb_valbits)
52end
b74f15c6 53
a6ffc6a2
JB
54# Set up something to print out s-expressions.
55define pr
329aa188 56 set debug_print ($)
a6ffc6a2 57end
a6ffc6a2
JB
58document pr
59Print the emacs s-expression which is $.
60Works only when an inferior emacs is executing.
61end
62
6c5d0c52
KS
63# Print out s-expressions
64define pp
65 set $tmp = $arg0
66 set debug_print ($tmp)
67end
68document pp
69Print the argument as an emacs s-expression
70Works only when an inferior emacs is executing.
71end
72
a6ffc6a2 73define xtype
329aa188
SM
74 xgettype $
75 output $type
76 echo \n
77 if $type == Lisp_Misc
78 xmisctype
79 else
80 if $type == Lisp_Vectorlike
81 xvectype
82 end
83 end
a6ffc6a2 84end
e065a56e 85document xtype
ba1e23bf 86Print the type of $, assuming it is an Emacs Lisp value.
3fe8bda5 87If the first type printed is Lisp_Vector or Lisp_Misc,
329aa188 88a second line gives the more precise type.
3fe8bda5
RS
89end
90
91define xvectype
329aa188
SM
92 xgetptr $
93 set $size = ((struct Lisp_Vector *) $ptr)->size
fc80da24 94 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
329aa188 95 echo \n
3fe8bda5
RS
96end
97document xvectype
329aa188 98Print the size or vector subtype of $, assuming it is a vector or pseudovector.
3fe8bda5
RS
99end
100
101define xmisctype
329aa188
SM
102 xgetptr $
103 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
104 echo \n
3fe8bda5
RS
105end
106document xmisctype
107Print the specific type of $, assuming it is some misc type.
e065a56e 108end
a6ffc6a2
JB
109
110define xint
329aa188
SM
111 xgetint $
112 print $int
a6ffc6a2 113end
e065a56e 114document xint
ba1e23bf 115Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
e065a56e 116end
a6ffc6a2
JB
117
118define xptr
329aa188
SM
119 xgetptr $
120 print (void *) $ptr
a6ffc6a2 121end
e065a56e 122document xptr
ba1e23bf 123Print the pointer portion of $, assuming it is an Emacs Lisp value.
e065a56e 124end
a6ffc6a2 125
a6ffc6a2 126define xmarker
329aa188
SM
127 xgetptr $
128 print (struct Lisp_Marker *) $ptr
a6ffc6a2 129end
e065a56e 130document xmarker
ba1e23bf 131Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
e065a56e 132end
a6ffc6a2 133
a6a3acf0 134define xoverlay
329aa188
SM
135 xgetptr $
136 print (struct Lisp_Overlay *) $ptr
a6a3acf0
KH
137end
138document xoverlay
139Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
140end
141
142define xmiscfree
329aa188
SM
143 xgetptr $
144 print (struct Lisp_Free *) $ptr
a6a3acf0
KH
145end
146document xmiscfree
147Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
148end
149
150define xintfwd
329aa188
SM
151 xgetptr $
152 print (struct Lisp_Intfwd *) $ptr
a6a3acf0
KH
153end
154document xintfwd
155Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
156end
157
158define xboolfwd
329aa188
SM
159 xgetptr $
160 print (struct Lisp_Boolfwd *) $ptr
a6a3acf0
KH
161end
162document xboolfwd
163Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
164end
165
166define xobjfwd
329aa188
SM
167 xgetptr $
168 print (struct Lisp_Objfwd *) $ptr
a6a3acf0
KH
169end
170document xobjfwd
171Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
172end
173
029c56f6 174define xbufobjfwd
329aa188
SM
175 xgetptr $
176 print (struct Lisp_Buffer_Objfwd *) $ptr
a6a3acf0 177end
029c56f6 178document xbufobjfwd
a6a3acf0
KH
179Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
180end
181
a0371857 182define xkbobjfwd
329aa188
SM
183 xgetptr $
184 print (struct Lisp_Kboard_Objfwd *) $ptr
cd39e946 185end
a0371857
KH
186document xkbobjfwd
187Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
cd39e946
KH
188end
189
029c56f6 190define xbuflocal
329aa188
SM
191 xgetptr $
192 print (struct Lisp_Buffer_Local_Value *) $ptr
a6a3acf0 193end
029c56f6 194document xbuflocal
a6a3acf0
KH
195Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
196end
197
a6ffc6a2 198define xsymbol
cfcde636
KS
199 set $sym = $
200 xgetptr $sym
329aa188 201 print (struct Lisp_Symbol *) $ptr
cfcde636 202 xprintsym $sym
329aa188 203 echo \n
a6ffc6a2 204end
e065a56e
JB
205document xsymbol
206Print the name and address of the symbol $.
ba1e23bf 207This command assumes that $ is an Emacs Lisp symbol value.
e065a56e 208end
a6ffc6a2
JB
209
210define xstring
329aa188
SM
211 xgetptr $
212 print (struct Lisp_String *) $ptr
0001e968 213 xprintstr $
329aa188 214 echo \n
a6ffc6a2 215end
a6ffc6a2 216document xstring
e065a56e 217Print the contents and address of the string $.
ba1e23bf 218This command assumes that $ is an Emacs Lisp string value.
a6ffc6a2
JB
219end
220
221define xvector
329aa188
SM
222 xgetptr $
223 print (struct Lisp_Vector *) $ptr
fc80da24 224 output ($->size > 50) ? 0 : ($->contents[0])@($->size & ~gdb_array_mark_flag)
ef15f270 225echo \n
a6ffc6a2 226end
a6ffc6a2 227document xvector
e065a56e 228Print the contents and address of the vector $.
ba1e23bf 229This command assumes that $ is an Emacs Lisp vector value.
a6ffc6a2
JB
230end
231
14a8902a 232define xprocess
329aa188
SM
233 xgetptr $
234 print (struct Lisp_Process *) $ptr
235 output *$
236 echo \n
14a8902a
RS
237end
238document xprocess
239Print the address of the struct Lisp_process which the Lisp_Object $ points to.
240end
241
ec558adc 242define xframe
329aa188
SM
243 xgetptr $
244 print (struct frame *) $ptr
a6ffc6a2 245end
ec558adc 246document xframe
ba1e23bf 247Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
e065a56e 248end
a6ffc6a2 249
14a8902a 250define xcompiled
329aa188
SM
251 xgetptr $
252 print (struct Lisp_Vector *) $ptr
253 output ($->contents[0])@($->size & 0xff)
14a8902a
RS
254end
255document xcompiled
256Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
257end
258
259define xwindow
329aa188
SM
260 xgetptr $
261 print (struct window *) $ptr
262 printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
14a8902a
RS
263end
264document xwindow
265Print $ as a window pointer, assuming it is an Emacs Lisp window value.
266Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
267end
268
029c56f6 269define xwinconfig
329aa188
SM
270 xgetptr $
271 print (struct save_window_data *) $ptr
a6a3acf0 272end
029c56f6 273document xwinconfig
a6a3acf0
KH
274Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
275end
276
14a8902a 277define xsubr
329aa188
SM
278 xgetptr $
279 print (struct Lisp_Subr *) $ptr
280 output *$
281 echo \n
a6a3acf0 282end
14a8902a
RS
283document xsubr
284Print the address of the subr which the Lisp_Object $ points to.
285end
286
287define xchartable
329aa188
SM
288 xgetptr $
289 print (struct Lisp_Char_Table *) $ptr
290 printf "Purpose: "
291 xprintsym $->purpose
292 printf " %d extra slots", ($->size & 0x1ff) - 388
293 echo \n
14a8902a
RS
294end
295document xchartable
296Print the address of the char-table $, and its purpose.
297This command assumes that $ is an Emacs Lisp char-table value.
298end
299
300define xboolvector
329aa188
SM
301 xgetptr $
302 print (struct Lisp_Bool_Vector *) $ptr
fc80da24 303 output ($->size > 256) ? 0 : ($->data[0])@((($->size & ~gdb_array_mark_flag) + 7)/ 8)
329aa188 304 echo \n
14a8902a
RS
305end
306document xboolvector
307Print the contents and address of the bool-vector $.
308This command assumes that $ is an Emacs Lisp bool-vector value.
309end
310
311define xbuffer
329aa188
SM
312 xgetptr $
313 print (struct buffer *) $ptr
314 xgetptr $->name
315 output ((struct Lisp_String *) $ptr)->data
316 echo \n
14a8902a
RS
317end
318document xbuffer
319Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
320Print the name of the buffer.
a6a3acf0
KH
321end
322
3266f62b 323define xhashtable
329aa188
SM
324 xgetptr $
325 print (struct Lisp_Hash_Table *) $ptr
3266f62b
GM
326end
327document xhashtable
328Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
329end
330
a6ffc6a2 331define xcons
329aa188
SM
332 xgetptr $
333 print (struct Lisp_Cons *) $ptr
334 output/x *$
335 echo \n
a6ffc6a2 336end
e065a56e 337document xcons
ba1e23bf 338Print the contents of $, assuming it is an Emacs Lisp cons.
e065a56e 339end
a6ffc6a2 340
6f493884 341define nextcons
329aa188
SM
342 p $.cdr
343 xcons
6f493884
RS
344end
345document nextcons
346Print the contents of the next cell in a list.
347This assumes that the last thing you printed was a cons cell contents
348(type struct Lisp_Cons) or a pointer to one.
349end
a6ffc6a2 350define xcar
329aa188
SM
351 xgetptr $
352 xgettype $
353 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0)
a6ffc6a2 354end
e065a56e 355document xcar
ba1e23bf 356Print the car of $, assuming it is an Emacs Lisp pair.
e065a56e 357end
a6ffc6a2
JB
358
359define xcdr
329aa188
SM
360 xgetptr $
361 xgettype $
362 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->cdr : 0)
a6ffc6a2 363end
e065a56e 364document xcdr
ba1e23bf 365Print the cdr of $, assuming it is an Emacs Lisp pair.
e065a56e 366end
a6ffc6a2 367
df86e57e 368define xfloat
329aa188
SM
369 xgetptr $
370 print ((struct Lisp_Float *) $ptr)->data
df86e57e
JB
371end
372document xfloat
373Print $ assuming it is a lisp floating-point number.
374end
375
b2367490 376define xscrollbar
329aa188
SM
377 xgetptr $
378 print (struct scrollbar *) $ptr
b2367490
JB
379output *$
380echo \n
381end
dec5f4e3 382document xscrollbar
b2367490
JB
383Print $ as a scrollbar pointer.
384end
385
0001e968
SM
386define xprintstr
387 set $data = $arg0->data
388 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
389end
390
24b4d1bc 391define xprintsym
329aa188
SM
392 xgetptr $arg0
393 set $sym = (struct Lisp_Symbol *) $ptr
394 xgetptr $sym->xname
395 set $sym_name = (struct Lisp_String *) $ptr
0001e968 396 xprintstr $sym_name
24b4d1bc
GM
397end
398document xprintsym
399 Print argument as a symbol.
400end
401
402define xbacktrace
403 set $bt = backtrace_list
177c0ea7 404 while $bt
329aa188 405 xgettype (*$bt->function)
3176a27e 406 if $type == Lisp_Symbol
329aa188
SM
407 xprintsym (*$bt->function)
408 echo \n
3176a27e
GM
409 else
410 printf "0x%x ", *$bt->function
411 if $type == Lisp_Vectorlike
329aa188
SM
412 xgetptr (*$bt->function)
413 set $size = ((struct Lisp_Vector *) $ptr)->size
fc80da24 414 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
3176a27e
GM
415 else
416 printf "Lisp type %d", $type
417 end
418 echo \n
419 end
24b4d1bc
GM
420 set $bt = $bt->next
421 end
422end
423document xbacktrace
424 Print a backtrace of Lisp function calls from backtrace_list.
177c0ea7 425 Set a breakpoint at Fsignal and call this to see from where
3176a27e 426 an error was signaled.
24b4d1bc
GM
427end
428
429define xreload
329aa188
SM
430 set $tagmask = (((long)1 << gdb_gctypebits) - 1)
431 set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1
24b4d1bc
GM
432end
433document xreload
434 When starting Emacs a second time in the same gdb session under
329aa188 435 FreeBSD 2.2.5, gdb 4.13, $valmask have lost
be9e8331
DL
436 their values. (The same happens on current (2000) versions of GNU/Linux
437 with gdb 5.0.)
c71ea231 438 This function reloads them.
24b4d1bc 439end
329aa188 440xreload
24b4d1bc 441
6c5d0c52
KS
442# Flush display (X only)
443define ff
444 set x_flush (0)
445end
446document ff
447Flush pending X window display updates to screen.
448Works only when an inferior emacs is executing.
449end
450
451
be9e8331
DL
452define hook-run
453 xreload
454end
455
e869a29d
RS
456# Call xreload if a new Emacs executable is loaded.
457define hookpost-run
458 xreload
459end
460
e065a56e 461set print pretty on
df86e57e 462set print sevenbit-strings
a6ffc6a2 463
e5d77022 464show environment DISPLAY
6f5d1a4f 465show environment TERM
6f5d1a4f 466set args -geometry 80x40+0+0
e5d77022 467
a6ffc6a2 468# Don't let abort actually run, as it will make
7f692070 469# stdio stop working and therefore the `pr' command above as well.
a6ffc6a2
JB
470break abort
471
472# If we are running in synchronous mode, we want a chance to look around
473# before Emacs exits. Perhaps we should put the break somewhere else
474# instead...
998ee976 475break x_error_quitter
ab5796a9
MB
476
477# arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe