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