Commit | Line | Data |
---|---|---|
7faa0236 RS |
1 | # Force loading of symbols, enough to give us gdb_valbits etc. |
2 | set main | |
3 | ||
39d10e52 RS |
4 | # Find lwlib source files too. |
5 | dir ../lwlib | |
3266f62b | 6 | dir /gd/gnu/lesstif-0.89.9/lib/Xm |
39d10e52 | 7 | |
056515d8 KH |
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 | ||
3266f62b GM |
14 | # Don't pass SIGALRM to Emacs. This makes problems when |
15 | # debugging. | |
16 | handle SIGALRM ignore | |
17 | ||
056515d8 | 18 | # Set up a mask to use. |
b8d3c872 RS |
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 | |
b74f15c6 KH |
22 | set $nonvalbits = gdb_emacs_intbits - gdb_valbits |
23 | ||
a6ffc6a2 JB |
24 | # Set up something to print out s-expressions. |
25 | define pr | |
36fa5981 | 26 | set debug_print ($) |
a6ffc6a2 | 27 | end |
a6ffc6a2 JB |
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 | |
b74f15c6 | 34 | output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7) |
3fe8bda5 | 35 | echo \n |
b74f15c6 | 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) |
ef15f270 | 37 | echo \n |
a6ffc6a2 | 38 | end |
e065a56e | 39 | document xtype |
ba1e23bf | 40 | Print the type of $, assuming it is an Emacs Lisp value. |
3fe8bda5 RS |
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 | |
b74f15c6 | 47 | set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size |
3fe8bda5 RS |
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 | |
b74f15c6 | 56 | output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type) |
3fe8bda5 RS |
57 | echo \n |
58 | end | |
59 | document xmisctype | |
60 | Print the specific type of $, assuming it is some misc type. | |
e065a56e | 61 | end |
a6ffc6a2 JB |
62 | |
63 | define xint | |
b74f15c6 | 64 | print (($ & $valmask) << $nonvalbits) >> $nonvalbits |
a6ffc6a2 | 65 | end |
e065a56e | 66 | document xint |
ba1e23bf | 67 | Print $, assuming it is an Emacs Lisp integer. This gets the sign right. |
e065a56e | 68 | end |
a6ffc6a2 JB |
69 | |
70 | define xptr | |
b74f15c6 | 71 | print (void *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 72 | end |
e065a56e | 73 | document xptr |
ba1e23bf | 74 | Print the pointer portion of $, assuming it is an Emacs Lisp value. |
e065a56e | 75 | end |
a6ffc6a2 | 76 | |
a6ffc6a2 | 77 | define xmarker |
b74f15c6 | 78 | print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 79 | end |
e065a56e | 80 | document xmarker |
ba1e23bf | 81 | Print $ as a marker pointer, assuming it is an Emacs Lisp marker value. |
e065a56e | 82 | end |
a6ffc6a2 | 83 | |
a6a3acf0 | 84 | define xoverlay |
b74f15c6 | 85 | print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 92 | print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 99 | print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 106 | print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 113 | print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
114 | end |
115 | document xobjfwd | |
116 | Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
117 | end | |
118 | ||
029c56f6 | 119 | define xbufobjfwd |
b74f15c6 | 120 | print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 121 | end |
029c56f6 | 122 | document xbufobjfwd |
a6a3acf0 KH |
123 | Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. |
124 | end | |
125 | ||
a0371857 | 126 | define xkbobjfwd |
b74f15c6 | 127 | print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
cd39e946 | 128 | end |
a0371857 KH |
129 | document xkbobjfwd |
130 | Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
cd39e946 KH |
131 | end |
132 | ||
029c56f6 | 133 | define xbuflocal |
b74f15c6 | 134 | print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 135 | end |
029c56f6 | 136 | document xbuflocal |
a6a3acf0 KH |
137 | Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value. |
138 | end | |
139 | ||
a6ffc6a2 | 140 | define xsymbol |
b74f15c6 | 141 | print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits) |
24b4d1bc | 142 | output (char*)$->name->data |
ef15f270 | 143 | echo \n |
a6ffc6a2 | 144 | end |
e065a56e JB |
145 | document xsymbol |
146 | Print the name and address of the symbol $. | |
ba1e23bf | 147 | This command assumes that $ is an Emacs Lisp symbol value. |
e065a56e | 148 | end |
a6ffc6a2 JB |
149 | |
150 | define xstring | |
b74f15c6 | 151 | print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits) |
14a8902a | 152 | output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte) |
ef15f270 | 153 | echo \n |
a6ffc6a2 | 154 | end |
a6ffc6a2 | 155 | document xstring |
e065a56e | 156 | Print the contents and address of the string $. |
ba1e23bf | 157 | This command assumes that $ is an Emacs Lisp string value. |
a6ffc6a2 JB |
158 | end |
159 | ||
160 | define xvector | |
b74f15c6 | 161 | print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits) |
4ea0847a | 162 | output ($->size > 50) ? 0 : ($->contents[0])@($->size) |
ef15f270 | 163 | echo \n |
a6ffc6a2 | 164 | end |
a6ffc6a2 | 165 | document xvector |
e065a56e | 166 | Print the contents and address of the vector $. |
ba1e23bf | 167 | This command assumes that $ is an Emacs Lisp vector value. |
a6ffc6a2 JB |
168 | end |
169 | ||
14a8902a RS |
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 | ||
ec558adc | 179 | define xframe |
b74f15c6 | 180 | print (struct frame *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 181 | end |
ec558adc | 182 | document xframe |
ba1e23bf | 183 | Print $ as a frame pointer, assuming it is an Emacs Lisp frame value. |
e065a56e | 184 | end |
a6ffc6a2 | 185 | |
14a8902a RS |
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 | ||
029c56f6 | 203 | define xwinconfig |
b74f15c6 | 204 | print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 205 | end |
029c56f6 | 206 | document xwinconfig |
a6a3acf0 KH |
207 | Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value. |
208 | end | |
209 | ||
14a8902a RS |
210 | define xsubr |
211 | print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits) | |
212 | output *$ | |
213 | echo \n | |
a6a3acf0 | 214 | end |
14a8902a RS |
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. | |
a6a3acf0 KH |
249 | end |
250 | ||
3266f62b GM |
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 | ||
a6ffc6a2 | 258 | define xcons |
b74f15c6 | 259 | print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits) |
6f493884 | 260 | output/x *$ |
ef15f270 | 261 | echo \n |
a6ffc6a2 | 262 | end |
e065a56e | 263 | document xcons |
ba1e23bf | 264 | Print the contents of $, assuming it is an Emacs Lisp cons. |
e065a56e | 265 | end |
a6ffc6a2 | 266 | |
6f493884 RS |
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 | |
a6ffc6a2 | 276 | define xcar |
de2436ef | 277 | print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0) |
a6ffc6a2 | 278 | end |
e065a56e | 279 | document xcar |
ba1e23bf | 280 | Print the car of $, assuming it is an Emacs Lisp pair. |
e065a56e | 281 | end |
a6ffc6a2 JB |
282 | |
283 | define xcdr | |
de2436ef | 284 | print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0) |
a6ffc6a2 | 285 | end |
e065a56e | 286 | document xcdr |
ba1e23bf | 287 | Print the cdr of $, assuming it is an Emacs Lisp pair. |
e065a56e | 288 | end |
a6ffc6a2 | 289 | |
df86e57e | 290 | define xfloat |
b74f15c6 | 291 | print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data |
df86e57e JB |
292 | end |
293 | document xfloat | |
294 | Print $ assuming it is a lisp floating-point number. | |
295 | end | |
296 | ||
b2367490 | 297 | define xscrollbar |
b74f15c6 | 298 | print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits) |
b2367490 JB |
299 | output *$ |
300 | echo \n | |
301 | end | |
dec5f4e3 | 302 | document xscrollbar |
b2367490 JB |
303 | Print $ as a scrollbar pointer. |
304 | end | |
305 | ||
24b4d1bc GM |
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 | |
3176a27e GM |
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 | |
24b4d1bc GM |
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 | |
3176a27e | 337 | an error was signaled. |
24b4d1bc GM |
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 | |
c71ea231 DL |
347 | their values. (The same happens on GNU/Linux with gdb 5.0.) |
348 | This function reloads them. | |
24b4d1bc GM |
349 | end |
350 | ||
e065a56e | 351 | set print pretty on |
df86e57e | 352 | set print sevenbit-strings |
a6ffc6a2 | 353 | |
e5d77022 | 354 | show environment DISPLAY |
6f5d1a4f | 355 | show environment TERM |
6f5d1a4f | 356 | set args -geometry 80x40+0+0 |
e5d77022 | 357 | |
a6ffc6a2 | 358 | # Don't let abort actually run, as it will make |
7f692070 | 359 | # stdio stop working and therefore the `pr' command above as well. |
a6ffc6a2 JB |
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... | |
998ee976 | 365 | break x_error_quitter |