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