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