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