Commit | Line | Data |
---|---|---|
329aa188 | 1 | # Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 2000, 01, 2004 |
e3efab9c GM |
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. | |
329aa188 SM |
41 | |
42 | define xgetptr | |
43 | set $ptr = (gdb_use_union ? $arg0.u.val : $arg0 & $valmask) | gdb_data_seg_bits | |
44 | end | |
45 | ||
46 | define xgetint | |
47 | set $int = gdb_use_union ? $arg0.s.val : (gdb_use_lsb ? $arg0 : $arg0 << gdb_gctypebits) >> gdb_gctypebits | |
48 | end | |
49 | ||
50 | define xgettype | |
51 | set $type = gdb_use_union ? $arg0.s.type : (enum Lisp_Type) (gdb_use_lsb ? $arg0 & $tagmask : $arg0 >> gdb_valbits) | |
52 | end | |
b74f15c6 | 53 | |
a6ffc6a2 JB |
54 | # Set up something to print out s-expressions. |
55 | define pr | |
329aa188 | 56 | set debug_print ($) |
a6ffc6a2 | 57 | end |
a6ffc6a2 JB |
58 | document pr |
59 | Print the emacs s-expression which is $. | |
60 | Works only when an inferior emacs is executing. | |
61 | end | |
62 | ||
63 | define xtype | |
329aa188 SM |
64 | xgettype $ |
65 | output $type | |
66 | echo \n | |
67 | if $type == Lisp_Misc | |
68 | xmisctype | |
69 | else | |
70 | if $type == Lisp_Vectorlike | |
71 | xvectype | |
72 | end | |
73 | end | |
a6ffc6a2 | 74 | end |
e065a56e | 75 | document xtype |
ba1e23bf | 76 | Print the type of $, assuming it is an Emacs Lisp value. |
3fe8bda5 | 77 | If the first type printed is Lisp_Vector or Lisp_Misc, |
329aa188 | 78 | a second line gives the more precise type. |
3fe8bda5 RS |
79 | end |
80 | ||
81 | define xvectype | |
329aa188 SM |
82 | xgetptr $ |
83 | set $size = ((struct Lisp_Vector *) $ptr)->size | |
fc80da24 | 84 | output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag |
329aa188 | 85 | echo \n |
3fe8bda5 RS |
86 | end |
87 | document xvectype | |
329aa188 | 88 | Print the size or vector subtype of $, assuming it is a vector or pseudovector. |
3fe8bda5 RS |
89 | end |
90 | ||
91 | define xmisctype | |
329aa188 SM |
92 | xgetptr $ |
93 | output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type) | |
94 | echo \n | |
3fe8bda5 RS |
95 | end |
96 | document xmisctype | |
97 | Print the specific type of $, assuming it is some misc type. | |
e065a56e | 98 | end |
a6ffc6a2 JB |
99 | |
100 | define xint | |
329aa188 SM |
101 | xgetint $ |
102 | print $int | |
a6ffc6a2 | 103 | end |
e065a56e | 104 | document xint |
ba1e23bf | 105 | Print $, assuming it is an Emacs Lisp integer. This gets the sign right. |
e065a56e | 106 | end |
a6ffc6a2 JB |
107 | |
108 | define xptr | |
329aa188 SM |
109 | xgetptr $ |
110 | print (void *) $ptr | |
a6ffc6a2 | 111 | end |
e065a56e | 112 | document xptr |
ba1e23bf | 113 | Print the pointer portion of $, assuming it is an Emacs Lisp value. |
e065a56e | 114 | end |
a6ffc6a2 | 115 | |
a6ffc6a2 | 116 | define xmarker |
329aa188 SM |
117 | xgetptr $ |
118 | print (struct Lisp_Marker *) $ptr | |
a6ffc6a2 | 119 | end |
e065a56e | 120 | document xmarker |
ba1e23bf | 121 | Print $ as a marker pointer, assuming it is an Emacs Lisp marker value. |
e065a56e | 122 | end |
a6ffc6a2 | 123 | |
a6a3acf0 | 124 | define xoverlay |
329aa188 SM |
125 | xgetptr $ |
126 | print (struct Lisp_Overlay *) $ptr | |
a6a3acf0 KH |
127 | end |
128 | document xoverlay | |
129 | Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value. | |
130 | end | |
131 | ||
132 | define xmiscfree | |
329aa188 SM |
133 | xgetptr $ |
134 | print (struct Lisp_Free *) $ptr | |
a6a3acf0 KH |
135 | end |
136 | document xmiscfree | |
137 | Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value. | |
138 | end | |
139 | ||
140 | define xintfwd | |
329aa188 SM |
141 | xgetptr $ |
142 | print (struct Lisp_Intfwd *) $ptr | |
a6a3acf0 KH |
143 | end |
144 | document xintfwd | |
145 | Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
146 | end | |
147 | ||
148 | define xboolfwd | |
329aa188 SM |
149 | xgetptr $ |
150 | print (struct Lisp_Boolfwd *) $ptr | |
a6a3acf0 KH |
151 | end |
152 | document xboolfwd | |
153 | Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
154 | end | |
155 | ||
156 | define xobjfwd | |
329aa188 SM |
157 | xgetptr $ |
158 | print (struct Lisp_Objfwd *) $ptr | |
a6a3acf0 KH |
159 | end |
160 | document xobjfwd | |
161 | Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
162 | end | |
163 | ||
029c56f6 | 164 | define xbufobjfwd |
329aa188 SM |
165 | xgetptr $ |
166 | print (struct Lisp_Buffer_Objfwd *) $ptr | |
a6a3acf0 | 167 | end |
029c56f6 | 168 | document xbufobjfwd |
a6a3acf0 KH |
169 | Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. |
170 | end | |
171 | ||
a0371857 | 172 | define xkbobjfwd |
329aa188 SM |
173 | xgetptr $ |
174 | print (struct Lisp_Kboard_Objfwd *) $ptr | |
cd39e946 | 175 | end |
a0371857 KH |
176 | document xkbobjfwd |
177 | Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
cd39e946 KH |
178 | end |
179 | ||
029c56f6 | 180 | define xbuflocal |
329aa188 SM |
181 | xgetptr $ |
182 | print (struct Lisp_Buffer_Local_Value *) $ptr | |
a6a3acf0 | 183 | end |
029c56f6 | 184 | document xbuflocal |
a6a3acf0 KH |
185 | Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value. |
186 | end | |
187 | ||
a6ffc6a2 | 188 | define xsymbol |
329aa188 SM |
189 | xgetptr $ |
190 | print (struct Lisp_Symbol *) $ptr | |
191 | xprintsym $ | |
192 | echo \n | |
a6ffc6a2 | 193 | end |
e065a56e JB |
194 | document xsymbol |
195 | Print the name and address of the symbol $. | |
ba1e23bf | 196 | This command assumes that $ is an Emacs Lisp symbol value. |
e065a56e | 197 | end |
a6ffc6a2 JB |
198 | |
199 | define xstring | |
329aa188 SM |
200 | xgetptr $ |
201 | print (struct Lisp_String *) $ptr | |
0001e968 | 202 | xprintstr $ |
329aa188 | 203 | echo \n |
a6ffc6a2 | 204 | end |
a6ffc6a2 | 205 | document xstring |
e065a56e | 206 | Print the contents and address of the string $. |
ba1e23bf | 207 | This command assumes that $ is an Emacs Lisp string value. |
a6ffc6a2 JB |
208 | end |
209 | ||
210 | define xvector | |
329aa188 SM |
211 | xgetptr $ |
212 | print (struct Lisp_Vector *) $ptr | |
fc80da24 | 213 | output ($->size > 50) ? 0 : ($->contents[0])@($->size & ~gdb_array_mark_flag) |
ef15f270 | 214 | echo \n |
a6ffc6a2 | 215 | end |
a6ffc6a2 | 216 | document xvector |
e065a56e | 217 | Print the contents and address of the vector $. |
ba1e23bf | 218 | This command assumes that $ is an Emacs Lisp vector value. |
a6ffc6a2 JB |
219 | end |
220 | ||
14a8902a | 221 | define xprocess |
329aa188 SM |
222 | xgetptr $ |
223 | print (struct Lisp_Process *) $ptr | |
224 | output *$ | |
225 | echo \n | |
14a8902a RS |
226 | end |
227 | document xprocess | |
228 | Print the address of the struct Lisp_process which the Lisp_Object $ points to. | |
229 | end | |
230 | ||
ec558adc | 231 | define xframe |
329aa188 SM |
232 | xgetptr $ |
233 | print (struct frame *) $ptr | |
a6ffc6a2 | 234 | end |
ec558adc | 235 | document xframe |
ba1e23bf | 236 | Print $ as a frame pointer, assuming it is an Emacs Lisp frame value. |
e065a56e | 237 | end |
a6ffc6a2 | 238 | |
14a8902a | 239 | define xcompiled |
329aa188 SM |
240 | xgetptr $ |
241 | print (struct Lisp_Vector *) $ptr | |
242 | output ($->contents[0])@($->size & 0xff) | |
14a8902a RS |
243 | end |
244 | document xcompiled | |
245 | Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value. | |
246 | end | |
247 | ||
248 | define xwindow | |
329aa188 SM |
249 | xgetptr $ |
250 | print (struct window *) $ptr | |
251 | printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top | |
14a8902a RS |
252 | end |
253 | document xwindow | |
254 | Print $ as a window pointer, assuming it is an Emacs Lisp window value. | |
255 | Print the window's position as "WIDTHxHEIGHT+LEFT+TOP". | |
256 | end | |
257 | ||
029c56f6 | 258 | define xwinconfig |
329aa188 SM |
259 | xgetptr $ |
260 | print (struct save_window_data *) $ptr | |
a6a3acf0 | 261 | end |
029c56f6 | 262 | document xwinconfig |
a6a3acf0 KH |
263 | Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value. |
264 | end | |
265 | ||
14a8902a | 266 | define xsubr |
329aa188 SM |
267 | xgetptr $ |
268 | print (struct Lisp_Subr *) $ptr | |
269 | output *$ | |
270 | echo \n | |
a6a3acf0 | 271 | end |
14a8902a RS |
272 | document xsubr |
273 | Print the address of the subr which the Lisp_Object $ points to. | |
274 | end | |
275 | ||
276 | define xchartable | |
329aa188 SM |
277 | xgetptr $ |
278 | print (struct Lisp_Char_Table *) $ptr | |
279 | printf "Purpose: " | |
280 | xprintsym $->purpose | |
281 | printf " %d extra slots", ($->size & 0x1ff) - 388 | |
282 | echo \n | |
14a8902a RS |
283 | end |
284 | document xchartable | |
285 | Print the address of the char-table $, and its purpose. | |
286 | This command assumes that $ is an Emacs Lisp char-table value. | |
287 | end | |
288 | ||
289 | define xboolvector | |
329aa188 SM |
290 | xgetptr $ |
291 | print (struct Lisp_Bool_Vector *) $ptr | |
fc80da24 | 292 | output ($->size > 256) ? 0 : ($->data[0])@((($->size & ~gdb_array_mark_flag) + 7)/ 8) |
329aa188 | 293 | echo \n |
14a8902a RS |
294 | end |
295 | document xboolvector | |
296 | Print the contents and address of the bool-vector $. | |
297 | This command assumes that $ is an Emacs Lisp bool-vector value. | |
298 | end | |
299 | ||
300 | define xbuffer | |
329aa188 SM |
301 | xgetptr $ |
302 | print (struct buffer *) $ptr | |
303 | xgetptr $->name | |
304 | output ((struct Lisp_String *) $ptr)->data | |
305 | echo \n | |
14a8902a RS |
306 | end |
307 | document xbuffer | |
308 | Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value. | |
309 | Print the name of the buffer. | |
a6a3acf0 KH |
310 | end |
311 | ||
3266f62b | 312 | define xhashtable |
329aa188 SM |
313 | xgetptr $ |
314 | print (struct Lisp_Hash_Table *) $ptr | |
3266f62b GM |
315 | end |
316 | document xhashtable | |
317 | Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value. | |
318 | end | |
319 | ||
a6ffc6a2 | 320 | define xcons |
329aa188 SM |
321 | xgetptr $ |
322 | print (struct Lisp_Cons *) $ptr | |
323 | output/x *$ | |
324 | echo \n | |
a6ffc6a2 | 325 | end |
e065a56e | 326 | document xcons |
ba1e23bf | 327 | Print the contents of $, assuming it is an Emacs Lisp cons. |
e065a56e | 328 | end |
a6ffc6a2 | 329 | |
6f493884 | 330 | define nextcons |
329aa188 SM |
331 | p $.cdr |
332 | xcons | |
6f493884 RS |
333 | end |
334 | document nextcons | |
335 | Print the contents of the next cell in a list. | |
336 | This assumes that the last thing you printed was a cons cell contents | |
337 | (type struct Lisp_Cons) or a pointer to one. | |
338 | end | |
a6ffc6a2 | 339 | define xcar |
329aa188 SM |
340 | xgetptr $ |
341 | xgettype $ | |
342 | print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0) | |
a6ffc6a2 | 343 | end |
e065a56e | 344 | document xcar |
ba1e23bf | 345 | Print the car of $, assuming it is an Emacs Lisp pair. |
e065a56e | 346 | end |
a6ffc6a2 JB |
347 | |
348 | define xcdr | |
329aa188 SM |
349 | xgetptr $ |
350 | xgettype $ | |
351 | print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->cdr : 0) | |
a6ffc6a2 | 352 | end |
e065a56e | 353 | document xcdr |
ba1e23bf | 354 | Print the cdr of $, assuming it is an Emacs Lisp pair. |
e065a56e | 355 | end |
a6ffc6a2 | 356 | |
df86e57e | 357 | define xfloat |
329aa188 SM |
358 | xgetptr $ |
359 | print ((struct Lisp_Float *) $ptr)->data | |
df86e57e JB |
360 | end |
361 | document xfloat | |
362 | Print $ assuming it is a lisp floating-point number. | |
363 | end | |
364 | ||
b2367490 | 365 | define xscrollbar |
329aa188 SM |
366 | xgetptr $ |
367 | print (struct scrollbar *) $ptr | |
b2367490 JB |
368 | output *$ |
369 | echo \n | |
370 | end | |
dec5f4e3 | 371 | document xscrollbar |
b2367490 JB |
372 | Print $ as a scrollbar pointer. |
373 | end | |
374 | ||
0001e968 SM |
375 | define xprintstr |
376 | set $data = $arg0->data | |
377 | output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) | |
378 | end | |
379 | ||
24b4d1bc | 380 | define xprintsym |
329aa188 SM |
381 | xgetptr $arg0 |
382 | set $sym = (struct Lisp_Symbol *) $ptr | |
383 | xgetptr $sym->xname | |
384 | set $sym_name = (struct Lisp_String *) $ptr | |
0001e968 | 385 | xprintstr $sym_name |
24b4d1bc GM |
386 | end |
387 | document xprintsym | |
388 | Print argument as a symbol. | |
389 | end | |
390 | ||
391 | define xbacktrace | |
392 | set $bt = backtrace_list | |
177c0ea7 | 393 | while $bt |
329aa188 | 394 | xgettype (*$bt->function) |
3176a27e | 395 | if $type == Lisp_Symbol |
329aa188 SM |
396 | xprintsym (*$bt->function) |
397 | echo \n | |
3176a27e GM |
398 | else |
399 | printf "0x%x ", *$bt->function | |
400 | if $type == Lisp_Vectorlike | |
329aa188 SM |
401 | xgetptr (*$bt->function) |
402 | set $size = ((struct Lisp_Vector *) $ptr)->size | |
fc80da24 | 403 | output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag |
3176a27e GM |
404 | else |
405 | printf "Lisp type %d", $type | |
406 | end | |
407 | echo \n | |
408 | end | |
24b4d1bc GM |
409 | set $bt = $bt->next |
410 | end | |
411 | end | |
412 | document xbacktrace | |
413 | Print a backtrace of Lisp function calls from backtrace_list. | |
177c0ea7 | 414 | Set a breakpoint at Fsignal and call this to see from where |
3176a27e | 415 | an error was signaled. |
24b4d1bc GM |
416 | end |
417 | ||
418 | define xreload | |
329aa188 SM |
419 | set $tagmask = (((long)1 << gdb_gctypebits) - 1) |
420 | set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1 | |
24b4d1bc GM |
421 | end |
422 | document xreload | |
423 | When starting Emacs a second time in the same gdb session under | |
329aa188 | 424 | FreeBSD 2.2.5, gdb 4.13, $valmask have lost |
be9e8331 DL |
425 | their values. (The same happens on current (2000) versions of GNU/Linux |
426 | with gdb 5.0.) | |
c71ea231 | 427 | This function reloads them. |
24b4d1bc | 428 | end |
329aa188 | 429 | xreload |
24b4d1bc | 430 | |
be9e8331 DL |
431 | define hook-run |
432 | xreload | |
433 | end | |
434 | ||
e869a29d RS |
435 | # Call xreload if a new Emacs executable is loaded. |
436 | define hookpost-run | |
437 | xreload | |
438 | end | |
439 | ||
e065a56e | 440 | set print pretty on |
df86e57e | 441 | set print sevenbit-strings |
a6ffc6a2 | 442 | |
e5d77022 | 443 | show environment DISPLAY |
6f5d1a4f | 444 | show environment TERM |
6f5d1a4f | 445 | set args -geometry 80x40+0+0 |
e5d77022 | 446 | |
a6ffc6a2 | 447 | # Don't let abort actually run, as it will make |
7f692070 | 448 | # stdio stop working and therefore the `pr' command above as well. |
a6ffc6a2 JB |
449 | break abort |
450 | ||
451 | # If we are running in synchronous mode, we want a chance to look around | |
452 | # before Emacs exits. Perhaps we should put the break somewhere else | |
453 | # instead... | |
998ee976 | 454 | break x_error_quitter |
ab5796a9 MB |
455 | |
456 | # arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe |