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