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