(fix_submap_inheritance, get_keyelt, store_in_keymap,
[bpt/emacs.git] / src / .gdbinit
1 # Force loading of symbols, enough to give us gdb_valbits etc.
2 set main
3
4 # Find lwlib source files too.
5 dir ../lwlib
6
7 # Don't enter GDB when user types C-g to quit.
8 # This has one unfortunate effect: you can't type C-c
9 # at the GDB to stop Emacs, when using X.
10 # However, C-z works just as well in that case.
11 handle 2 noprint pass
12
13 # Set up a mask to use.
14 # This should be EMACS_INT, but in some cases that is a macro.
15 # long ought to work in all cases right now.
16 set $valmask = ((long)1 << gdb_valbits) - 1
17 set $nonvalbits = gdb_emacs_intbits - gdb_valbits
18
19 # Set up something to print out s-expressions.
20 define pr
21 set debug_print ($)
22 end
23 document pr
24 Print the emacs s-expression which is $.
25 Works only when an inferior emacs is executing.
26 end
27
28 define xtype
29 output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7)
30 echo \n
31 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)
32 echo \n
33 end
34 document xtype
35 Print the type of $, assuming it is an Emacs Lisp value.
36 If the first type printed is Lisp_Vector or Lisp_Misc,
37 the second line gives the more precise type.
38 Otherwise the second line doesn't mean anything.
39 end
40
41 define xvectype
42 set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size
43 output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
44 echo \n
45 end
46 document xvectype
47 Print the vector subtype of $, assuming it is a vector or pseudovector.
48 end
49
50 define xmisctype
51 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type)
52 echo \n
53 end
54 document xmisctype
55 Print the specific type of $, assuming it is some misc type.
56 end
57
58 define xint
59 print (($ & $valmask) << $nonvalbits) >> $nonvalbits
60 end
61 document xint
62 Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
63 end
64
65 define xptr
66 print (void *) (($ & $valmask) | gdb_data_seg_bits)
67 end
68 document xptr
69 Print the pointer portion of $, assuming it is an Emacs Lisp value.
70 end
71
72 define xwindow
73 print (struct window *) (($ & $valmask) | gdb_data_seg_bits)
74 printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
75 end
76 document xwindow
77 Print $ as a window pointer, assuming it is an Emacs Lisp window value.
78 Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
79 end
80
81 define xmarker
82 print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits)
83 end
84 document xmarker
85 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
86 end
87
88 define xoverlay
89 print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits)
90 end
91 document xoverlay
92 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
93 end
94
95 define xmiscfree
96 print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits)
97 end
98 document xmiscfree
99 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
100 end
101
102 define xintfwd
103 print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits)
104 end
105 document xintfwd
106 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
107 end
108
109 define xboolfwd
110 print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits)
111 end
112 document xboolfwd
113 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
114 end
115
116 define xobjfwd
117 print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
118 end
119 document xobjfwd
120 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
121 end
122
123 define xbufobjfwd
124 print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
125 end
126 document xbufobjfwd
127 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
128 end
129
130 define xkbobjfwd
131 print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
132 end
133 document xkbobjfwd
134 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
135 end
136
137 define xbuflocal
138 print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits)
139 end
140 document xbuflocal
141 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
142 end
143
144 define xbuffer
145 print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits)
146 output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data
147 echo \n
148 end
149 document xbuffer
150 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
151 Print the name of the buffer.
152 end
153
154 define xsymbol
155 print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
156 output (char*)&$->name->data
157 echo \n
158 end
159 document xsymbol
160 Print the name and address of the symbol $.
161 This command assumes that $ is an Emacs Lisp symbol value.
162 end
163
164 define xstring
165 print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits)
166 output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte)
167 echo \n
168 end
169 document xstring
170 Print the contents and address of the string $.
171 This command assumes that $ is an Emacs Lisp string value.
172 end
173
174 define xvector
175 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
176 output ($->size > 50) ? 0 : ($->contents[0])@($->size)
177 echo \n
178 end
179 document xvector
180 Print the contents and address of the vector $.
181 This command assumes that $ is an Emacs Lisp vector value.
182 end
183
184 define xframe
185 print (struct frame *) (($ & $valmask) | gdb_data_seg_bits)
186 end
187 document xframe
188 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
189 end
190
191 define xwinconfig
192 print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits)
193 end
194 document xwinconfig
195 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
196 end
197
198 define xcompiled
199 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
200 output ($->contents[0])@($->size & 0xff)
201 end
202 document xcompiled
203 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
204 end
205
206 define xcons
207 print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits)
208 output/x *$
209 echo \n
210 end
211 document xcons
212 Print the contents of $, assuming it is an Emacs Lisp cons.
213 end
214
215 define nextcons
216 p $.cdr
217 xcons
218 end
219 document nextcons
220 Print the contents of the next cell in a list.
221 This assumes that the last thing you printed was a cons cell contents
222 (type struct Lisp_Cons) or a pointer to one.
223 end
224 define xcar
225 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0)
226 end
227 document xcar
228 Print the car of $, assuming it is an Emacs Lisp pair.
229 end
230
231 define xcdr
232 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0)
233 end
234 document xcdr
235 Print the cdr of $, assuming it is an Emacs Lisp pair.
236 end
237
238 define xsubr
239 print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits)
240 output *$
241 echo \n
242 end
243 document xsubr
244 Print the address of the subr which the Lisp_Object $ points to.
245 end
246
247 define xprocess
248 print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits)
249 output *$
250 echo \n
251 end
252 document xprocess
253 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
254 end
255
256 define xfloat
257 print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data
258 end
259 document xfloat
260 Print $ assuming it is a lisp floating-point number.
261 end
262
263 define xscrollbar
264 print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits)
265 output *$
266 echo \n
267 end
268 document xscrollbar
269 Print $ as a scrollbar pointer.
270 end
271
272 set print pretty on
273 set print sevenbit-strings
274
275 show environment DISPLAY
276 show environment TERM
277 set args -geometry 80x40+0+0
278
279 # Don't let abort actually run, as it will make
280 # stdio stop working and therefore the `pr' command above as well.
281 break abort
282
283 # If we are running in synchronous mode, we want a chance to look around
284 # before Emacs exits. Perhaps we should put the break somewhere else
285 # instead...
286 break x_error_quitter