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