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