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