comparison src/gdbinit @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children c5d627a313b1
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 # Some useful commands for debugging emacs with gdb 4.14.* or better.
2 # Install this as your .gdbinit file in your home directory.
3 # If you have an older version of gdb 4.x, consider using the
4 # file "gdbinit.pre-4.14" in the XEmacs src directory.
5 # If you're one of the few who has an XEmacs compiled with
6 # --use-union-type, you'll need to use the file "gdbinit.union".
7 # Currently that file is of the pre-4.14 variety, but it should
8 # be easy to update it to 4.14+, along the same lines as this file.
9 #
10 # See also question 2.1.15 of the XEmacs FAQ, titled
11 # "How to Debug an XEmacs problem with a debugger".
12
13 set print union off
14 set print pretty off
15
16 define temacs
17 run -batch -l loadup.el run-temacs -q
18 end
19
20 echo \n>>> Use the `temacs' command to run temacs\n\n
21
22 # if you use Purify, do this:
23 # set env PURIFYOPTIONS -pointer-mask=0x0fffffff
24
25 ################ Print using the Lisp printer
26
27 define p1
28 call debug_print ($arg0)
29 printf "\n"
30 end
31
32 define lbt
33 # "&" to compensate for GDB struct-passing bug
34 # but I've removed the &'s because it doesn't work with my GDB,
35 # and not having them works fine.
36 call Fbacktrace (Qexternal_debugging_output, Qt)
37 end
38
39 ################ Print using GDB built-ins
40
41 define xint
42 print ((int)($arg0 << 4))>>4
43 end
44
45 define xbitvec
46 print (struct Lisp_Bit_Vector *) ($arg0 & 0xFFFFFFF)
47 end
48
49 define xbuffer
50 print (struct buffer *) ($arg0 & 0xFFFFFFF)
51 end
52
53 define xbytecode
54 print (struct Lisp_Bytecode *) ($arg0 & 0xFFFFFFF)
55 end
56
57 define xcharset
58 print (struct Lisp_Charset *) ($arg0 & 0xFFFFFFF)
59 end
60
61 define xchartab
62 print (struct Lisp_Char_Table *) ($arg0 & 0xFFFFFFF)
63 end
64
65 define xchartabentry
66 print (struct Lisp_Char_Table_Entry *) ($arg0 & 0xFFFFFFF)
67 end
68
69 define xcodesys
70 print (struct Lisp_Coding_System *) ($arg0 & 0xFFFFFFF)
71 end
72
73 define xcolorinst
74 print (struct Lisp_Color_Instance *) ($arg0 & 0xFFFFFFF)
75 end
76
77 define xcons
78 print (struct Lisp_Cons *) ($arg0 & 0xFFFFFFF)
79 end
80
81 define xdevice
82 print (struct device *) ($arg0 & 0xFFFFFFF)
83 end
84
85 define xevent
86 print (struct Lisp_Event *) ($arg0 & 0xFFFFFFF)
87 end
88
89 define xextent
90 print (struct extent *) ($arg0 & 0xFFFFFFF)
91 end
92
93 define xextentaux
94 print (struct extent_auxiliary *) ($arg0 & 0xFFFFFFF)
95 end
96
97 define xextentinfo
98 print (struct extent_info *) ($arg0 & 0xFFFFFFF)
99 end
100
101 define xfloat
102 print (struct Lisp_Float *) ($arg0 & 0xFFFFFFF)
103 output (double) $arg0->data.d
104 echo \n
105 end
106
107 define xfontinst
108 print (struct Lisp_Font_Instance *) ($arg0 & 0xFFFFFFF)
109 end
110
111 define xframe
112 print (struct frame *) ($arg0 & 0xFFFFFFF)
113 end
114
115 define xglyph
116 print (struct Lisp_Glyph *) ($arg0 & 0xFFFFFFF)
117 end
118
119 define xhashtable
120 print (struct hashtable_struct *) ($arg0 & 0xFFFFFFF)
121 end
122
123 define ximageinst
124 print (struct Lisp_Image_Instance *) ($arg0 & 0xFFFFFFF)
125 end
126
127 define xkeymap
128 print (struct keymap *) ($arg0 & 0xFFFFFFF)
129 end
130
131 define xlstream
132 print (struct lstream *) ($arg0 & 0xFFFFFFF)
133 end
134
135 define xmarker
136 print (struct Lisp_Marker *) ($arg0 & 0xFFFFFFF)
137 end
138
139 define xmenubardata
140 print (struct menubar_data *) ($arg0 & 0xFFFFFFF)
141 end
142
143 define xopaque
144 print (struct Lisp_Opaque *) ($arg0 & 0xFFFFFFF)
145 end
146
147 define xprocess
148 print (struct Lisp_Process *) ($arg0 & 0xFFFFFFF)
149 end
150
151 define xrangetab
152 print (struct Lisp_Range_Table *) ($arg0 & 0xFFFFFFF)
153 end
154
155 define xspec
156 print (struct Lisp_Specifier *) ($arg0 & 0xFFFFFFF)
157 end
158
159 define xstring
160 print (struct Lisp_String *) ($arg0 & 0xFFFFFFF)
161 output (char *) $arg0->_data
162 echo \n
163 end
164
165 define xsubr
166 print (struct Lisp_Subr *) ($arg0 & 0xFFFFFFF)
167 end
168
169 define xsubwindow
170 print (struct Lisp_Subwindow *) ($arg0 & 0xFFFFFFF)
171 end
172
173 define xsymbol
174 set $tem = (struct Lisp_Symbol *) ($arg0 & 0xFFFFFFF)
175 output $tem->name->_data
176 printf "\n"
177 print $tem
178 end
179
180 define xtoolbarbutton
181 print (struct toolbar_button *) ($arg0 & 0xFFFFFFF)
182 end
183
184 define xtoolbardata
185 print (struct toolbar_data *) ($arg0 & 0xFFFFFFF)
186 end
187
188 define xtooltalkmess
189 print (struct Lisp_Tooltalk_Message *) ($arg0 & 0xFFFFFFF)
190 end
191
192 define xtooltalkpatt
193 print (struct Lisp_Tooltalk_Pattern *) ($arg0 & 0xFFFFFFF)
194 end
195
196 define xvector
197 print (struct Lisp_Vector *) ($arg0 & 0xFFFFFFF)
198 end
199
200 define xwindow
201 print (struct window *) ($arg0 & 0xFFFFFFF)
202 end
203
204 define xwindowconfig
205 print (struct window_config *) ($arg0 & 0xFFFFFFF)
206 end
207
208 define xrecord
209 print ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))
210 output (((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation->name)
211 echo \n
212 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_symbol
213 xsymbol $arg0
214 else
215 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_extent
216 xextent $arg0
217 else
218 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_marker
219 xmarker $arg0
220 else
221 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_event
222 xevent $arg0
223 else
224 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_buffer
225 xbuffer $arg0
226 else
227 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_window
228 xwindow $arg0
229 else
230 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_frame
231 xframe $arg0
232 else
233 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_device
234 xdevice $arg0
235 else
236 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_console
237 xconsole $arg0
238 else
239 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_process
240 xprocess $arg0
241 else
242 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_subr
243 xsubr $arg0
244 else
245 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_compiled_function
246 xbytecode $arg0
247 else
248 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_window_configuration
249 xwindowconfig $arg0
250 else
251 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_float
252 xfloat $arg0
253 else
254 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_opaque
255 xopaque $arg0
256 else
257 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_glyph
258 xglyph $arg0
259 else
260 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_keymap
261 xkeymap $arg0
262 else
263 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_lstream
264 xlstream $arg0
265 else
266 if ((struct lrecord_header *) ($arg0 & 0xFFFFFFF))->implementation == lrecord_bit_vector
267 xbitvec $arg0
268 end
269 end
270 end
271 end
272 end
273 end
274 end
275 end
276 end
277 end
278 end
279 end
280 end
281 end
282 end
283 end
284 end
285 end
286 end
287 end
288
289 define frob
290 if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Int
291 xint $arg0
292 else
293 if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_String
294 xstring $arg0
295 else
296 if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Cons
297 xcons $arg0
298 else
299 if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Vector
300 xvector $arg0
301 else
302 if (enum Lisp_Type) (($arg0 >> 28) & 7) == Lisp_Record
303 xrecord $arg0
304 else
305 printf "Unknown type?\n"
306 end
307 end
308 end
309 end
310 end
311 end
312
313 ################ Miscellaneous
314
315 define xtype
316 # this is really xgctype, as we mask off the mark bit
317 output (enum Lisp_Type) (($arg0 >> 28) & 7)
318 echo \n
319 end
320
321 define xmarkbit
322 print ($arg0 >> 31)
323 end
324
325 define nilp
326 print $arg0 == Qnil
327 end
328
329 define xcar
330 frob ((struct Lisp_Cons *) ($arg0 & 0xFFFFFFF))->car
331 end
332
333 define xcdr
334 frob ((struct Lisp_Cons *) ($arg0 & 0xFFFFFFF))->cdr
335 end
336
337 set $vector_length_mask = ~(1<<31)
338
339 define string-length
340 print ((struct Lisp_String *) ($arg0 & 0xFFFFFFF))->_size & $vector_length_mask
341 end
342
343 define string-contents
344 print (char *) ((struct Lisp_String *) ($ & 0xFFFFFFF))->_data
345 end
346
347 define vector-length
348 print ((struct Lisp_Vector *) ($ & 0xFFFFFFF))->size & $vector_length_mask
349 end
350
351 define vector-contents
352 set $tem = (struct Lisp_Vector *) ($ & 0xFFFFFFF)
353 print *($tem->contents) @ ($tem->size & $vector_length_mask)
354 set $ = $tem->contents
355 end
356
357 define symbol-name
358 set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->name
359 # output *($tem->_data) @ ($tem->_size & $vector_length_mask)
360 output ($tem->_data)
361 echo \n
362 set $type = Lisp_String
363 echo \n
364 end
365
366 define symbol-value
367 set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->value
368 end
369
370 define symbol-function
371 set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->function
372 end
373
374 define symbol-plist
375 set $tem = ((struct Lisp_Symbol *) ($ & 0xFFFFFFF))->plist
376 end
377
378 define wtype
379 p $->core.widget_class->core_class.class_name
380 end
381
382 define xtname
383 print XrmQuarkToString(((Object)($))->object.xrm_name)
384 end
385
386 #
387 # GDB, with the losing command-line parser that it has,
388 # cannot handle nested blocks.
389 #
390 define breaks
391
392 br Fsignal
393 # command
394 # bt 3
395 # p sig
396 # xsymbol
397 # end
398
399 br Fkill_emacs
400 # command
401 # bt 3
402 # end
403
404 br assertion_failed
405 # command
406 # bt 3
407 # end
408
409 end