This commit was generated by cvs2svn to compensate for changes in r6453,
[chise/xemacs-chise.git.1] / src / gdbinit
1 # -*- ksh -*-
2 # Copyright (C) 1998 Free Software Foundation, Inc.
3
4 # This file is part of XEmacs.
5
6 # XEmacs is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by the
8 # Free Software Foundation; either version 2, or (at your option) any
9 # later version.
10
11 # XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 # for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with XEmacs; see the file COPYING.  If not, write to
18 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20
21 # Author: Martin Buchholz
22
23 # Some useful commands for debugging emacs with gdb 4.16 or better.
24 # Install this as your .gdbinit file in your home directory,
25 # or source this file from your .gdbinit
26 # Configure xemacs with --debug, and compile with -g.
27 #
28 # See also the question of the XEmacs FAQ, titled
29 # "How to Debug an XEmacs problem with a debugger".
30 #
31 # This can be used to debug XEmacs no matter how the following are
32 # specified:
33
34 # USE_UNION_TYPE
35 # USE_MINIMAL_TAGBITS
36 # USE_INDEXED_LRECORD_IMPLEMENTATION
37 # LRECORD_(SYMBOL|STRING|VECTOR)
38
39 # (the above all have configure equivalents)
40
41 # Some functions defined here require a running process, but most
42 # don't.  Considerable effort has been expended to this end.
43
44 # See the dbg_ C support code in src/alloc.c that allows the functions
45 # defined in this file to work correctly.
46
47 set print union off
48 set print pretty off
49
50 define decode_object
51   set $obj = (unsigned long) $arg0
52   if dbg_USE_MINIMAL_TAGBITS
53     if $obj & 1
54     # It's an int
55       set $val = $obj >> 1
56       set $type = dbg_Lisp_Type_Int
57     else
58       set $type = $obj & dbg_typemask
59       if $type == dbg_Lisp_Type_Char
60         set $val = ($obj & dbg_valmask) >> dbg_gctypebits
61       else
62         # It's a record pointer
63         set $val = $obj
64       end
65     end
66   else
67     # not dbg_USE_MINIMAL_TAGBITS
68     set $val = $obj & dbg_valmask
69     set $type = ($obj & dbg_typemask) >> (dbg_valbits + 1)
70   end
71
72   if $type == dbg_Lisp_Type_Record
73     set $lheader = (struct lrecord_header *) $val
74     if dbg_USE_INDEXED_LRECORD_IMPLEMENTATION
75       set $imp = lrecord_implementations_table[$lheader->type]
76     else
77       set $imp = $lheader->implementation
78     end
79   else
80     set $imp = -1
81   end
82 end
83
84 document decode_object
85 Usage: decode_object lisp_object
86 Extract implementation information from a Lisp Object.
87 Defines variables $val, $type and $imp.
88 end
89
90 define xint
91 decode_object $arg0
92 print ((long) $val)
93 end
94
95 define xtype
96   decode_object $arg0
97   if $type == dbg_Lisp_Type_Int
98     echo int\n
99   else
100   if $type == dbg_Lisp_Type_Char
101     echo char\n
102   else
103   if $type == dbg_Lisp_Type_Symbol
104     echo symbol\n
105   else
106   if $type == dbg_Lisp_Type_String
107     echo string\n
108   else
109   if $type == dbg_Lisp_Type_Vector
110     echo vector\n
111   else
112   if $type == dbg_Lisp_Type_Cons
113     echo cons\n
114   else
115     printf "record type: %s\n", $imp->name
116   # barf
117   end
118   end
119   end
120   end
121   end
122   end
123 end
124
125 define run-temacs
126   unset env EMACSLOADPATH
127   set env EMACSBOOTSTRAPLOADPATH ../lisp/:..
128   run -batch -l ../lisp/loadup.el run-temacs -q
129 end
130
131 document run-temacs
132 Usage: run-temacs
133 Run temacs interactively, like xemacs.
134 Use this with debugging tools (like purify) that cannot deal with dumping,
135 or when temacs builds successfully, but xemacs does not.
136 end
137
138 define update-elc
139   unset env EMACSLOADPATH
140   set env EMACSBOOTSTRAPLOADPATH ../lisp/:..
141   run -batch -l ../lisp/update-elc.el
142 end
143
144 document update-elc
145 Usage: update-elc
146 Run the core lisp byte compilation part of the build procedure.
147 Use when debugging temacs, not xemacs!
148 Use this when temacs builds successfully, but xemacs does not.
149 end
150
151 define dump-temacs
152   unset env EMACSLOADPATH
153   set env EMACSBOOTSTRAPLOADPATH ../lisp/:..
154   run -batch -l ../lisp/loadup.el dump
155 end
156
157 document dump-temacs
158 Usage: dump-temacs
159 Run the dumping part of the build procedure.
160 Use when debugging temacs, not xemacs!
161 Use this when temacs builds successfully, but xemacs does not.
162 end
163
164 # if you use Purify, do this:
165 # export PURIFYOPTIONS='-pointer-mask=0x0fffffff'
166
167 define ldp
168   printf "%s", "Lisp => "
169   call debug_print($arg0)
170 end
171
172 document ldp
173 Usage: ldp lisp_object
174 Print a Lisp Object value using the Lisp printer.
175 Requires a running xemacs process.
176 end
177
178 define lbt
179 call debug_backtrace()
180 end
181
182 document lbt
183 Usage: lbt
184 Print the current Lisp stack trace.
185 Requires a running xemacs process.
186 end
187
188 define wtype
189 print $arg0->core.widget_class->core_class.class_name
190 end
191
192 define xtname
193 print XrmQuarkToString(((Object)($arg0))->object.xrm_name)
194 end
195
196 # GDB's command language makes you want to ...
197
198 define pstruct
199   set $xstruct = (struct $arg0 *) $val
200   print $xstruct
201   print *$xstruct
202 end
203
204 define pobj
205   decode_object $arg0
206   if $type == dbg_Lisp_Type_Int
207     printf "Integer: %d\n", $val
208   else
209   if $type == dbg_Lisp_Type_Char
210     if $val < 128
211       printf "Char: %c\n", $val
212     else
213       printf "Char: %d\n", $val
214     end
215   else
216   if $type == dbg_Lisp_Type_String || $imp == lrecord_string
217     pstruct Lisp_String
218   else
219   if $type == dbg_Lisp_Type_Cons   || $imp == lrecord_cons
220     pstruct Lisp_Cons
221   else
222   if $type == dbg_Lisp_Type_Symbol || $imp == lrecord_symbol
223     pstruct Lisp_Symbol
224     printf "Symbol name: %s\n", $xstruct->name->_data
225   else
226   if $type == dbg_Lisp_Type_Vector || $imp == lrecord_vector
227     pstruct Lisp_Vector
228     printf "Vector of length %d\n", $xstruct->size
229     #print *($xstruct->_data) @ $xstruct->size
230   else
231   if $imp == lrecord_bit_vector
232     pstruct Lisp_Bit_Vector
233   else
234   if $imp == lrecord_buffer
235     pstruct buffer
236   else
237   if $imp == lrecord_char_table
238     pstruct Lisp_Char_Table
239   else
240   if $imp == lrecord_char_table_entry
241     pstruct Lisp_Char_Table_Entry
242   else
243   if $imp == lrecord_charset
244     pstruct Lisp_Charset
245   else
246   if $imp == lrecord_coding_system
247     pstruct Lisp_Coding_System
248   else
249   if $imp == lrecord_color_instance
250     pstruct Lisp_Color_Instance
251   else
252   if $imp == lrecord_command_builder
253     pstruct command_builder
254   else
255   if $imp == lrecord_compiled_function
256     pstruct Lisp_Compiled_Function
257   else
258   if $imp == lrecord_console
259     pstruct console
260   else
261   if $imp == lrecord_database
262     pstruct database
263   else
264   if $imp == lrecord_device
265     pstruct device
266   else
267   if $imp == lrecord_event
268     pstruct Lisp_Event
269   else
270   if $imp == lrecord_extent
271     pstruct extent
272   else
273   if $imp == lrecord_extent_auxiliary
274     pstruct extent_auxiliary
275   else
276   if $imp == lrecord_extent_info
277     pstruct extent_info
278   else
279   if $imp == lrecord_face
280     pstruct Lisp_Face
281   else
282   if $imp == lrecord_float
283     pstruct Lisp_Float
284   else
285   if $imp == lrecord_font_instance
286     pstruct Lisp_Font_Instance
287   else
288   if $imp == lrecord_frame
289     pstruct frame
290   else
291   if $imp == lrecord_glyph
292     pstruct Lisp_Glyph
293   else
294   if $imp == lrecord_hashtable
295     pstruct hashtable
296   else
297   if $imp == lrecord_image_instance
298     pstruct Lisp_Image_Instance
299   else
300   if $imp == lrecord_keymap
301     pstruct keymap
302   else
303   if $imp == lrecord_lcrecord_list
304     pstruct lcrecord_list
305   else
306   if $imp == lrecord_lstream
307     pstruct lstream
308   else
309   if $imp == lrecord_marker
310     pstruct Lisp_Marker
311   else
312   if $imp == lrecord_opaque
313     pstruct Lisp_Opaque
314   else
315   if $imp == lrecord_opaque_list
316     pstruct Lisp_Opaque_List
317   else
318   if $imp == lrecord_popup_data
319     pstruct popup_data
320   else
321   if $imp == lrecord_process
322     pstruct Lisp_Process
323   else
324   if $imp == lrecord_range_table
325     pstruct Lisp_Range_Table
326   else
327   if $imp == lrecord_specifier
328     pstruct Lisp_Specifier
329   else
330   if $imp == lrecord_subr
331     pstruct Lisp_Subr
332   else
333   if $imp == lrecord_symbol_value_buffer_local
334     pstruct symbol_value_buffer_local
335   else
336   if $imp == lrecord_symbol_value_forward
337     pstruct symbol_value_forward
338   else
339   if $imp == lrecord_symbol_value_lisp_magic
340     pstruct symbol_value_lisp_magic
341   else
342   if $imp == lrecord_symbol_value_varalias
343     pstruct symbol_value_varalias
344   else
345   if $imp == lrecord_toolbar_button
346     pstruct toolbar_button
347   else
348   if $imp == lrecord_tooltalk_message
349     pstruct Lisp_Tooltalk_Message
350   else
351   if $imp == lrecord_tooltalk_pattern
352     pstruct Lisp_Tooltalk_Pattern
353   else
354   if $imp == lrecord_weak_list
355     pstruct weak_list
356   else
357   if $imp == lrecord_window
358     pstruct window
359   else
360   if $imp == lrecord_window_configuration
361     pstruct window_config
362   else
363     echo Unknown Lisp Object type\n
364     print $arg0
365   # Barf, gag, retch
366   end
367   end
368   end
369   end
370   end
371   end
372   end
373   end
374   end
375   end
376   end
377   end
378   end
379   end
380   end
381   end
382   end
383   end
384   end
385   end
386   end
387   end
388   end
389   end
390   end
391   end
392   end
393   end
394   end
395   end
396   end
397   end
398   end
399   end
400   end
401   end
402   end
403   end
404   end
405   end
406   end
407   end
408   end
409   end
410   end
411   end
412   end
413   end
414   end
415   end
416 end
417
418 document pobj
419 Usage: pobj lisp_object
420 Print the internal C structure of a underlying Lisp Object.
421 end