(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
[emacs.git] / src / .gdbinit
blob80ad1e249adde790eb6f9d8f0a35ba65dc010490
1 # Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 2000, 01, 2004
2 #   Free Software Foundation, Inc.
4 # This file is part of GNU Emacs.
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.
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.
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.
21 # Force loading of symbols, enough to give us gdb_valbits etc.
22 set main
24 # Find lwlib source files too.
25 dir ../lwlib
26 #dir /gd/gnu/lesstif-0.89.9/lib/Xm
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
34 # Don't pass SIGALRM to Emacs.  This makes problems when
35 # debugging.
36 handle SIGALRM ignore
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.
42 define xgetptr
43   set $ptr = (gdb_use_union ? $arg0.u.val : $arg0 & $valmask) | gdb_data_seg_bits
44 end
46 define xgetint
47   set $int = gdb_use_union ? $arg0.s.val : (gdb_use_lsb ? $arg0 : $arg0 << gdb_gctypebits) >> gdb_gctypebits
48 end
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
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
63 define xtype
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
74 end
75 document xtype
76 Print the type of $, assuming it is an Emacs Lisp value.
77 If the first type printed is Lisp_Vector or Lisp_Misc,
78 a second line gives the more precise type.
79 end
81 define xvectype
82   xgetptr $
83   set $size = ((struct Lisp_Vector *) $ptr)->size
84   output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size
85   echo \n
86 end
87 document xvectype
88 Print the size or vector subtype of $, assuming it is a vector or pseudovector.
89 end
91 define xmisctype
92   xgetptr $
93   output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
94   echo \n
95 end
96 document xmisctype
97 Print the specific type of $, assuming it is some misc type.
98 end
100 define xint
101   xgetint $
102   print $int
104 document xint
105 Print $, assuming it is an Emacs Lisp integer.  This gets the sign right.
108 define xptr
109   xgetptr $
110   print (void *) $ptr
112 document xptr
113 Print the pointer portion of $, assuming it is an Emacs Lisp value.
116 define xmarker
117   xgetptr $
118   print (struct Lisp_Marker *) $ptr
120 document xmarker
121 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
124 define xoverlay
125   xgetptr $
126   print (struct Lisp_Overlay *) $ptr
128 document xoverlay
129 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
132 define xmiscfree
133   xgetptr $
134   print (struct Lisp_Free *) $ptr
136 document xmiscfree
137 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
140 define xintfwd
141   xgetptr $
142   print (struct Lisp_Intfwd *) $ptr
144 document xintfwd
145 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
148 define xboolfwd
149   xgetptr $
150   print (struct Lisp_Boolfwd *) $ptr
152 document xboolfwd
153 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
156 define xobjfwd
157   xgetptr $
158   print (struct Lisp_Objfwd *) $ptr
160 document xobjfwd
161 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
164 define xbufobjfwd
165   xgetptr $
166   print (struct Lisp_Buffer_Objfwd *) $ptr
168 document xbufobjfwd
169 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
172 define xkbobjfwd
173   xgetptr $
174   print (struct Lisp_Kboard_Objfwd *) $ptr
176 document xkbobjfwd
177 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
180 define xbuflocal
181   xgetptr $
182   print (struct Lisp_Buffer_Local_Value *) $ptr
184 document xbuflocal
185 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
188 define xsymbol
189   xgetptr $
190   print (struct Lisp_Symbol *) $ptr
191   xprintsym $
192   echo \n
194 document xsymbol
195 Print the name and address of the symbol $.
196 This command assumes that $ is an Emacs Lisp symbol value.
199 define xstring
200   xgetptr $
201   print (struct Lisp_String *) $ptr
202   output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte)
203   echo \n
205 document xstring
206 Print the contents and address of the string $.
207 This command assumes that $ is an Emacs Lisp string value.
210 define xvector
211   xgetptr $
212   print (struct Lisp_Vector *) $ptr
213   output ($->size > 50) ? 0 : ($->contents[0])@($->size)
214 echo \n
216 document xvector
217 Print the contents and address of the vector $.
218 This command assumes that $ is an Emacs Lisp vector value.
221 define xprocess
222   xgetptr $
223   print (struct Lisp_Process *) $ptr
224   output *$
225   echo \n
227 document xprocess
228 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
231 define xframe
232   xgetptr $
233   print (struct frame *) $ptr
235 document xframe
236 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
239 define xcompiled
240   xgetptr $
241   print (struct Lisp_Vector *) $ptr
242   output ($->contents[0])@($->size & 0xff)
244 document xcompiled
245 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
248 define xwindow
249   xgetptr $
250   print (struct window *) $ptr
251   printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
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".
258 define xwinconfig
259   xgetptr $
260   print (struct save_window_data *) $ptr
262 document xwinconfig
263 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
266 define xsubr
267   xgetptr $
268   print (struct Lisp_Subr *) $ptr
269   output *$
270   echo \n
272 document xsubr
273 Print the address of the subr which the Lisp_Object $ points to.
276 define xchartable
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
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.
289 define xboolvector
290   xgetptr $
291   print (struct Lisp_Bool_Vector *) $ptr
292   output ($->size > 256) ? 0 : ($->data[0])@(($->size + 7)/ 8)
293   echo \n
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.
300 define xbuffer
301   xgetptr $
302   print (struct buffer *) $ptr
303   xgetptr $->name
304   output ((struct Lisp_String *) $ptr)->data
305   echo \n
307 document xbuffer
308 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
309 Print the name of the buffer.
312 define xhashtable
313   xgetptr $
314   print (struct Lisp_Hash_Table *) $ptr
316 document xhashtable
317 Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
320 define xcons
321   xgetptr $
322   print (struct Lisp_Cons *) $ptr
323   output/x *$
324   echo \n
326 document xcons
327 Print the contents of $, assuming it is an Emacs Lisp cons.
330 define nextcons
331   p $.cdr
332   xcons
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.
339 define xcar
340   xgetptr $
341   xgettype $
342   print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0)
344 document xcar
345 Print the car of $, assuming it is an Emacs Lisp pair.
348 define xcdr
349   xgetptr $
350   xgettype $
351   print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->cdr : 0)
353 document xcdr
354 Print the cdr of $, assuming it is an Emacs Lisp pair.
357 define xfloat
358   xgetptr $
359   print ((struct Lisp_Float *) $ptr)->data
361 document xfloat
362 Print $ assuming it is a lisp floating-point number.
365 define xscrollbar
366   xgetptr $
367   print (struct scrollbar *) $ptr
368 output *$
369 echo \n
371 document xscrollbar
372 Print $ as a scrollbar pointer.
375 define xprintsym
376   xgetptr $arg0
377   set $sym = (struct Lisp_Symbol *) $ptr
378   xgetptr $sym->xname
379   set $sym_name = (struct Lisp_String *) $ptr
380   output ($sym_name->data[0])@($sym_name->size_byte < 0 ? $sym_name->size : $sym_name->size_byte)
382 document xprintsym
383   Print argument as a symbol.
386 define xbacktrace
387   set $bt = backtrace_list
388   while $bt
389     xgettype (*$bt->function)
390     if $type == Lisp_Symbol
391       xprintsym (*$bt->function)
392       echo \n
393     else
394       printf "0x%x ", *$bt->function
395       if $type == Lisp_Vectorlike
396         xgetptr (*$bt->function)
397         set $size = ((struct Lisp_Vector *) $ptr)->size
398         output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size
399       else
400         printf "Lisp type %d", $type
401       end
402       echo \n
403     end
404     set $bt = $bt->next
405   end
407 document xbacktrace
408   Print a backtrace of Lisp function calls from backtrace_list.
409   Set a breakpoint at Fsignal and call this to see from where
410   an error was signaled.
413 define xreload
414   set $tagmask = (((long)1 << gdb_gctypebits) - 1)
415   set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1
417 document xreload
418   When starting Emacs a second time in the same gdb session under
419   FreeBSD 2.2.5, gdb 4.13, $valmask have lost
420   their values.  (The same happens on current (2000) versions of GNU/Linux
421   with gdb 5.0.)
422   This function reloads them.
424 xreload
426 define hook-run
427   xreload
430 # Call xreload if a new Emacs executable is loaded.
431 define hookpost-run
432   xreload
435 set print pretty on
436 set print sevenbit-strings
438 show environment DISPLAY
439 show environment TERM
440 set args -geometry 80x40+0+0
442 # Don't let abort actually run, as it will make
443 # stdio stop working and therefore the `pr' command above as well.
444 break abort
446 # If we are running in synchronous mode, we want a chance to look around
447 # before Emacs exits.  Perhaps we should put the break somewhere else
448 # instead...
449 break x_error_quitter
451 # arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe