(fit-window-to-buffer): Adjust point of the window buffer, not that of
[bpt/emacs.git] / src / .gdbinit
CommitLineData
7faa0236
RS
1# Force loading of symbols, enough to give us gdb_valbits etc.
2set main
3
39d10e52
RS
4# Find lwlib source files too.
5dir ../lwlib
3266f62b 6dir /gd/gnu/lesstif-0.89.9/lib/Xm
39d10e52 7
056515d8
KH
8# Don't enter GDB when user types C-g to quit.
9# This has one unfortunate effect: you can't type C-c
10# at the GDB to stop Emacs, when using X.
11# However, C-z works just as well in that case.
12handle 2 noprint pass
13
3266f62b
GM
14# Don't pass SIGALRM to Emacs. This makes problems when
15# debugging.
16handle SIGALRM ignore
17
056515d8 18# Set up a mask to use.
b8d3c872
RS
19# This should be EMACS_INT, but in some cases that is a macro.
20# long ought to work in all cases right now.
21set $valmask = ((long)1 << gdb_valbits) - 1
b74f15c6
KH
22set $nonvalbits = gdb_emacs_intbits - gdb_valbits
23
a6ffc6a2
JB
24# Set up something to print out s-expressions.
25define pr
36fa5981 26set debug_print ($)
a6ffc6a2 27end
a6ffc6a2
JB
28document pr
29Print the emacs s-expression which is $.
30Works only when an inferior emacs is executing.
31end
32
33define xtype
b74f15c6 34output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7)
3fe8bda5 35echo \n
b74f15c6 36output ((($ >> gdb_valbits) & 0x7) == Lisp_Misc ? (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type) : (($ >> gdb_valbits) & 0x7) == Lisp_Vectorlike ? ($size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size, (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)) : 0)
ef15f270 37echo \n
a6ffc6a2 38end
e065a56e 39document xtype
ba1e23bf 40Print the type of $, assuming it is an Emacs Lisp value.
3fe8bda5
RS
41If the first type printed is Lisp_Vector or Lisp_Misc,
42the second line gives the more precise type.
43Otherwise the second line doesn't mean anything.
44end
45
46define xvectype
b74f15c6 47set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size
3fe8bda5
RS
48output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
49echo \n
50end
51document xvectype
52Print the vector subtype of $, assuming it is a vector or pseudovector.
53end
54
55define xmisctype
b74f15c6 56output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type)
3fe8bda5
RS
57echo \n
58end
59document xmisctype
60Print the specific type of $, assuming it is some misc type.
e065a56e 61end
a6ffc6a2
JB
62
63define xint
b74f15c6 64print (($ & $valmask) << $nonvalbits) >> $nonvalbits
a6ffc6a2 65end
e065a56e 66document xint
ba1e23bf 67Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
e065a56e 68end
a6ffc6a2
JB
69
70define xptr
b74f15c6 71print (void *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 72end
e065a56e 73document xptr
ba1e23bf 74Print the pointer portion of $, assuming it is an Emacs Lisp value.
e065a56e 75end
a6ffc6a2 76
a6ffc6a2 77define xmarker
b74f15c6 78print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 79end
e065a56e 80document xmarker
ba1e23bf 81Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
e065a56e 82end
a6ffc6a2 83
a6a3acf0 84define xoverlay
b74f15c6 85print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
86end
87document xoverlay
88Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
89end
90
91define xmiscfree
b74f15c6 92print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
93end
94document xmiscfree
95Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
96end
97
98define xintfwd
b74f15c6 99print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
100end
101document xintfwd
102Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
103end
104
105define xboolfwd
b74f15c6 106print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
107end
108document xboolfwd
109Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
110end
111
112define xobjfwd
b74f15c6 113print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
114end
115document xobjfwd
116Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
117end
118
029c56f6 119define xbufobjfwd
b74f15c6 120print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 121end
029c56f6 122document xbufobjfwd
a6a3acf0
KH
123Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
124end
125
a0371857 126define xkbobjfwd
b74f15c6 127print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
cd39e946 128end
a0371857
KH
129document xkbobjfwd
130Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
cd39e946
KH
131end
132
029c56f6 133define xbuflocal
b74f15c6 134print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 135end
029c56f6 136document xbuflocal
a6a3acf0
KH
137Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
138end
139
a6ffc6a2 140define xsymbol
b74f15c6 141print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
24b4d1bc 142output (char*)$->name->data
ef15f270 143echo \n
a6ffc6a2 144end
e065a56e
JB
145document xsymbol
146Print the name and address of the symbol $.
ba1e23bf 147This command assumes that $ is an Emacs Lisp symbol value.
e065a56e 148end
a6ffc6a2
JB
149
150define xstring
b74f15c6 151print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits)
14a8902a 152output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte)
ef15f270 153echo \n
a6ffc6a2 154end
a6ffc6a2 155document xstring
e065a56e 156Print the contents and address of the string $.
ba1e23bf 157This command assumes that $ is an Emacs Lisp string value.
a6ffc6a2
JB
158end
159
160define xvector
b74f15c6 161print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
4ea0847a 162output ($->size > 50) ? 0 : ($->contents[0])@($->size)
ef15f270 163echo \n
a6ffc6a2 164end
a6ffc6a2 165document xvector
e065a56e 166Print the contents and address of the vector $.
ba1e23bf 167This command assumes that $ is an Emacs Lisp vector value.
a6ffc6a2
JB
168end
169
14a8902a
RS
170define xprocess
171print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits)
172output *$
173echo \n
174end
175document xprocess
176Print the address of the struct Lisp_process which the Lisp_Object $ points to.
177end
178
ec558adc 179define xframe
b74f15c6 180print (struct frame *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 181end
ec558adc 182document xframe
ba1e23bf 183Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
e065a56e 184end
a6ffc6a2 185
14a8902a
RS
186define xcompiled
187print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
188output ($->contents[0])@($->size & 0xff)
189end
190document xcompiled
191Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
192end
193
194define xwindow
195print (struct window *) (($ & $valmask) | gdb_data_seg_bits)
196printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
197end
198document xwindow
199Print $ as a window pointer, assuming it is an Emacs Lisp window value.
200Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
201end
202
029c56f6 203define xwinconfig
b74f15c6 204print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 205end
029c56f6 206document xwinconfig
a6a3acf0
KH
207Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
208end
209
14a8902a
RS
210define xsubr
211print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits)
212output *$
213echo \n
a6a3acf0 214end
14a8902a
RS
215document xsubr
216Print the address of the subr which the Lisp_Object $ points to.
217end
218
219define xchartable
220print (struct Lisp_Char_Table *) (($ & $valmask) | gdb_data_seg_bits)
221printf "Purpose: "
222output (char*)&((struct Lisp_Symbol *) ((((int) $->purpose) & $valmask) | gdb_data_seg_bits))->name->data
223printf " %d extra slots", ($->size & 0x1ff) - 388
224echo \n
225end
226document xchartable
227Print the address of the char-table $, and its purpose.
228This command assumes that $ is an Emacs Lisp char-table value.
229end
230
231define xboolvector
232print (struct Lisp_Bool_Vector *) (($ & $valmask) | gdb_data_seg_bits)
233output ($->size > 256) ? 0 : ($->data[0])@(($->size + 7)/ 8)
234echo \n
235end
236document xboolvector
237Print the contents and address of the bool-vector $.
238This command assumes that $ is an Emacs Lisp bool-vector value.
239end
240
241define xbuffer
242print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits)
243output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data
244echo \n
245end
246document xbuffer
247Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
248Print the name of the buffer.
a6a3acf0
KH
249end
250
3266f62b
GM
251define xhashtable
252print (struct Lisp_Hash_Table *) (($ & $valmask) | gdb_data_seg_bits)
253end
254document xhashtable
255Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
256end
257
a6ffc6a2 258define xcons
b74f15c6 259print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits)
6f493884 260output/x *$
ef15f270 261echo \n
a6ffc6a2 262end
e065a56e 263document xcons
ba1e23bf 264Print the contents of $, assuming it is an Emacs Lisp cons.
e065a56e 265end
a6ffc6a2 266
6f493884
RS
267define nextcons
268p $.cdr
269xcons
270end
271document nextcons
272Print the contents of the next cell in a list.
273This assumes that the last thing you printed was a cons cell contents
274(type struct Lisp_Cons) or a pointer to one.
275end
a6ffc6a2 276define xcar
de2436ef 277print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0)
a6ffc6a2 278end
e065a56e 279document xcar
ba1e23bf 280Print the car of $, assuming it is an Emacs Lisp pair.
e065a56e 281end
a6ffc6a2
JB
282
283define xcdr
de2436ef 284print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0)
a6ffc6a2 285end
e065a56e 286document xcdr
ba1e23bf 287Print the cdr of $, assuming it is an Emacs Lisp pair.
e065a56e 288end
a6ffc6a2 289
df86e57e 290define xfloat
b74f15c6 291print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data
df86e57e
JB
292end
293document xfloat
294Print $ assuming it is a lisp floating-point number.
295end
296
b2367490 297define xscrollbar
b74f15c6 298print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits)
b2367490
JB
299output *$
300echo \n
301end
dec5f4e3 302document xscrollbar
b2367490
JB
303Print $ as a scrollbar pointer.
304end
305
24b4d1bc
GM
306define xprintsym
307 set $sym = (struct Lisp_Symbol *) ((((int) $arg0) & $valmask) | gdb_data_seg_bits)
308 output (char*)$sym->name->data
309 echo \n
310end
311document xprintsym
312 Print argument as a symbol.
313end
314
315define xbacktrace
316 set $bt = backtrace_list
317 while $bt
318 xprintsym *$bt->function
319 set $bt = $bt->next
320 end
321end
322document xbacktrace
323 Print a backtrace of Lisp function calls from backtrace_list.
324 Set a breakpoint at Fsignal and call this to see from where
325 an error was signalled.
326end
327
328define xreload
329 set $valmask = ((long)1 << gdb_valbits) - 1
330 set $nonvalbits = gdb_emacs_intbits - gdb_valbits
331end
332document xreload
333 When starting Emacs a second time in the same gdb session under
334 FreeBSD 2.2.5, gdb 4.13, $valmask and $nonvalbits have lost
c71ea231
DL
335 their values. (The same happens on GNU/Linux with gdb 5.0.)
336 This function reloads them.
24b4d1bc
GM
337end
338
e065a56e 339set print pretty on
df86e57e 340set print sevenbit-strings
a6ffc6a2 341
e5d77022 342show environment DISPLAY
6f5d1a4f 343show environment TERM
6f5d1a4f 344set args -geometry 80x40+0+0
e5d77022 345
a6ffc6a2 346# Don't let abort actually run, as it will make
7f692070 347# stdio stop working and therefore the `pr' command above as well.
a6ffc6a2
JB
348break abort
349
350# If we are running in synchronous mode, we want a chance to look around
351# before Emacs exits. Perhaps we should put the break somewhere else
352# instead...
998ee976 353break x_error_quitter