(describe-function): Call documentation just once.
[bpt/emacs.git] / src / .gdbinit
CommitLineData
b74f15c6
KH
1# Set up a mask to use.
2
b8d3c872
RS
3# This should be EMACS_INT, but in some cases that is a macro.
4# long ought to work in all cases right now.
5set $valmask = ((long)1 << gdb_valbits) - 1
b74f15c6
KH
6set $nonvalbits = gdb_emacs_intbits - gdb_valbits
7
a6ffc6a2
JB
8# Set up something to print out s-expressions.
9define pr
36fa5981 10set debug_print ($)
a6ffc6a2
JB
11echo \n
12end
a6ffc6a2
JB
13document pr
14Print the emacs s-expression which is $.
15Works only when an inferior emacs is executing.
16end
17
18define xtype
b74f15c6 19output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7)
3fe8bda5 20echo \n
b74f15c6 21output ((($ >> 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 22echo \n
a6ffc6a2 23end
e065a56e 24document xtype
ba1e23bf 25Print the type of $, assuming it is an Emacs Lisp value.
3fe8bda5
RS
26If the first type printed is Lisp_Vector or Lisp_Misc,
27the second line gives the more precise type.
28Otherwise the second line doesn't mean anything.
29end
30
31define xvectype
b74f15c6 32set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size
3fe8bda5
RS
33output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
34echo \n
35end
36document xvectype
37Print the vector subtype of $, assuming it is a vector or pseudovector.
38end
39
40define xmisctype
b74f15c6 41output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type)
3fe8bda5
RS
42echo \n
43end
44document xmisctype
45Print the specific type of $, assuming it is some misc type.
e065a56e 46end
a6ffc6a2
JB
47
48define xint
b74f15c6 49print (($ & $valmask) << $nonvalbits) >> $nonvalbits
a6ffc6a2 50end
e065a56e 51document xint
ba1e23bf 52Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
e065a56e 53end
a6ffc6a2
JB
54
55define xptr
b74f15c6 56print (void *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 57end
e065a56e 58document xptr
ba1e23bf 59Print the pointer portion of $, assuming it is an Emacs Lisp value.
e065a56e 60end
a6ffc6a2
JB
61
62define xwindow
b74f15c6 63print (struct window *) (($ & $valmask) | gdb_data_seg_bits)
ef15f270 64printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
a6ffc6a2 65end
e065a56e 66document xwindow
ba1e23bf 67Print $ as a window pointer, assuming it is an Emacs Lisp window value.
ef15f270 68Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
e065a56e 69end
a6ffc6a2
JB
70
71define xmarker
b74f15c6 72print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 73end
e065a56e 74document xmarker
ba1e23bf 75Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
e065a56e 76end
a6ffc6a2 77
a6a3acf0 78define xoverlay
b74f15c6 79print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
80end
81document xoverlay
82Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
83end
84
85define xmiscfree
b74f15c6 86print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
87end
88document xmiscfree
89Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
90end
91
92define xintfwd
b74f15c6 93print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
94end
95document xintfwd
96Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
97end
98
99define xboolfwd
b74f15c6 100print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
101end
102document xboolfwd
103Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
104end
105
106define xobjfwd
b74f15c6 107print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
108end
109document xobjfwd
110Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
111end
112
029c56f6 113define xbufobjfwd
b74f15c6 114print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 115end
029c56f6 116document xbufobjfwd
a6a3acf0
KH
117Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
118end
119
a0371857 120define xkbobjfwd
b74f15c6 121print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
cd39e946 122end
a0371857
KH
123document xkbobjfwd
124Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
cd39e946
KH
125end
126
029c56f6 127define xbuflocal
b74f15c6 128print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 129end
029c56f6 130document xbuflocal
a6a3acf0
KH
131Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
132end
133
a6ffc6a2 134define xbuffer
b74f15c6
KH
135print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits)
136output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data
ef15f270 137echo \n
a6ffc6a2 138end
e065a56e 139document xbuffer
ba1e23bf 140Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
daa37602 141Print the name of the buffer.
e065a56e 142end
a6ffc6a2
JB
143
144define xsymbol
b74f15c6 145print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
ef15f270
JB
146output &$->name->data
147echo \n
a6ffc6a2 148end
e065a56e
JB
149document xsymbol
150Print the name and address of the symbol $.
ba1e23bf 151This command assumes that $ is an Emacs Lisp symbol value.
e065a56e 152end
a6ffc6a2
JB
153
154define xstring
b74f15c6 155print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits)
4ea0847a 156output ($->size > 1000) ? 0 : ($->data[0])@($->size)
ef15f270 157echo \n
a6ffc6a2 158end
a6ffc6a2 159document xstring
e065a56e 160Print the contents and address of the string $.
ba1e23bf 161This command assumes that $ is an Emacs Lisp string value.
a6ffc6a2
JB
162end
163
164define xvector
b74f15c6 165print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
4ea0847a 166output ($->size > 50) ? 0 : ($->contents[0])@($->size)
ef15f270 167echo \n
a6ffc6a2 168end
a6ffc6a2 169document xvector
e065a56e 170Print the contents and address of the vector $.
ba1e23bf 171This command assumes that $ is an Emacs Lisp vector value.
a6ffc6a2
JB
172end
173
ec558adc 174define xframe
b74f15c6 175print (struct frame *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 176end
ec558adc 177document xframe
ba1e23bf 178Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
e065a56e 179end
a6ffc6a2 180
029c56f6 181define xwinconfig
b74f15c6 182print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 183end
029c56f6 184document xwinconfig
a6a3acf0
KH
185Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
186end
187
188define xcompiled
b74f15c6 189print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
190output ($->contents[0])@($->size & 0xff)
191end
192document xcompiled
193Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
194end
195
a6ffc6a2 196define xcons
b74f15c6 197print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits)
cac29370 198output *$
ef15f270 199echo \n
a6ffc6a2 200end
e065a56e 201document xcons
ba1e23bf 202Print the contents of $, assuming it is an Emacs Lisp cons.
e065a56e 203end
a6ffc6a2
JB
204
205define xcar
b74f15c6 206print ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0)
a6ffc6a2 207end
e065a56e 208document xcar
ba1e23bf 209Print the car of $, assuming it is an Emacs Lisp pair.
e065a56e 210end
a6ffc6a2
JB
211
212define xcdr
b74f15c6 213print ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0)
a6ffc6a2 214end
e065a56e 215document xcdr
ba1e23bf 216Print the cdr of $, assuming it is an Emacs Lisp pair.
e065a56e 217end
a6ffc6a2 218
ec558adc 219define xsubr
b74f15c6 220print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits)
ec558adc
JB
221output *$
222echo \n
223end
224document xsubr
225Print the address of the subr which the Lisp_Object $ points to.
226end
227
8dd926ca 228define xprocess
b74f15c6 229print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits)
8dd926ca
JB
230output *$
231echo \n
232end
233document xprocess
234Print the address of the struct Lisp_process which the Lisp_Object $ points to.
235end
236
df86e57e 237define xfloat
b74f15c6 238print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data
df86e57e
JB
239end
240document xfloat
241Print $ assuming it is a lisp floating-point number.
242end
243
b2367490 244define xscrollbar
b74f15c6 245print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits)
b2367490
JB
246output *$
247echo \n
248end
dec5f4e3 249document xscrollbar
b2367490
JB
250Print $ as a scrollbar pointer.
251end
252
e065a56e 253set print pretty on
df86e57e 254set print sevenbit-strings
a6ffc6a2 255
e5d77022 256show environment DISPLAY
6f5d1a4f 257show environment TERM
6f5d1a4f 258set args -geometry 80x40+0+0
e5d77022 259
a6ffc6a2 260# Don't let abort actually run, as it will make
7f692070 261# stdio stop working and therefore the `pr' command above as well.
a6ffc6a2
JB
262break abort
263
264# If we are running in synchronous mode, we want a chance to look around
265# before Emacs exits. Perhaps we should put the break somewhere else
266# instead...
998ee976 267break x_error_quitter