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