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