(xstring): Handle unibyte strings.
[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 xmarker
73 print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits)
74 end
75 document xmarker
76 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
77 end
78
79 define xoverlay
80 print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits)
81 end
82 document xoverlay
83 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
84 end
85
86 define xmiscfree
87 print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits)
88 end
89 document xmiscfree
90 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
91 end
92
93 define xintfwd
94 print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits)
95 end
96 document xintfwd
97 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
98 end
99
100 define xboolfwd
101 print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits)
102 end
103 document xboolfwd
104 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
105 end
106
107 define xobjfwd
108 print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
109 end
110 document xobjfwd
111 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
112 end
113
114 define xbufobjfwd
115 print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
116 end
117 document xbufobjfwd
118 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
119 end
120
121 define xkbobjfwd
122 print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
123 end
124 document xkbobjfwd
125 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
126 end
127
128 define xbuflocal
129 print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits)
130 end
131 document xbuflocal
132 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
133 end
134
135 define xsymbol
136 print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
137 output (char*)&$->name->data
138 echo \n
139 end
140 document xsymbol
141 Print the name and address of the symbol $.
142 This command assumes that $ is an Emacs Lisp symbol value.
143 end
144
145 define xstring
146 print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits)
147 output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte)
148 echo \n
149 end
150 document xstring
151 Print the contents and address of the string $.
152 This command assumes that $ is an Emacs Lisp string value.
153 end
154
155 define xvector
156 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
157 output ($->size > 50) ? 0 : ($->contents[0])@($->size)
158 echo \n
159 end
160 document xvector
161 Print the contents and address of the vector $.
162 This command assumes that $ is an Emacs Lisp vector value.
163 end
164
165 define xprocess
166 print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits)
167 output *$
168 echo \n
169 end
170 document xprocess
171 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
172 end
173
174 define xframe
175 print (struct frame *) (($ & $valmask) | gdb_data_seg_bits)
176 end
177 document xframe
178 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
179 end
180
181 define xcompiled
182 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
183 output ($->contents[0])@($->size & 0xff)
184 end
185 document xcompiled
186 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
187 end
188
189 define xwindow
190 print (struct window *) (($ & $valmask) | gdb_data_seg_bits)
191 printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
192 end
193 document xwindow
194 Print $ as a window pointer, assuming it is an Emacs Lisp window value.
195 Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
196 end
197
198 define xwinconfig
199 print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits)
200 end
201 document xwinconfig
202 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
203 end
204
205 define xsubr
206 print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits)
207 output *$
208 echo \n
209 end
210 document xsubr
211 Print the address of the subr which the Lisp_Object $ points to.
212 end
213
214 define xchartable
215 print (struct Lisp_Char_Table *) (($ & $valmask) | gdb_data_seg_bits)
216 printf "Purpose: "
217 output (char*)&((struct Lisp_Symbol *) ((((int) $->purpose) & $valmask) | gdb_data_seg_bits))->name->data
218 printf " %d extra slots", ($->size & 0x1ff) - 388
219 echo \n
220 end
221 document xchartable
222 Print the address of the char-table $, and its purpose.
223 This command assumes that $ is an Emacs Lisp char-table value.
224 end
225
226 define xboolvector
227 print (struct Lisp_Bool_Vector *) (($ & $valmask) | gdb_data_seg_bits)
228 output ($->size > 256) ? 0 : ($->data[0])@(($->size + 7)/ 8)
229 echo \n
230 end
231 document xboolvector
232 Print the contents and address of the bool-vector $.
233 This command assumes that $ is an Emacs Lisp bool-vector value.
234 end
235
236 define xbuffer
237 print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits)
238 output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data
239 echo \n
240 end
241 document xbuffer
242 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
243 Print the name of the buffer.
244 end
245
246 define xcons
247 print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits)
248 output/x *$
249 echo \n
250 end
251 document xcons
252 Print the contents of $, assuming it is an Emacs Lisp cons.
253 end
254
255 define nextcons
256 p $.cdr
257 xcons
258 end
259 document nextcons
260 Print the contents of the next cell in a list.
261 This assumes that the last thing you printed was a cons cell contents
262 (type struct Lisp_Cons) or a pointer to one.
263 end
264 define xcar
265 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0)
266 end
267 document xcar
268 Print the car of $, assuming it is an Emacs Lisp pair.
269 end
270
271 define xcdr
272 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0)
273 end
274 document xcdr
275 Print the cdr of $, assuming it is an Emacs Lisp pair.
276 end
277
278 define xfloat
279 print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data
280 end
281 document xfloat
282 Print $ assuming it is a lisp floating-point number.
283 end
284
285 define xscrollbar
286 print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits)
287 output *$
288 echo \n
289 end
290 document xscrollbar
291 Print $ as a scrollbar pointer.
292 end
293
294 set print pretty on
295 set print sevenbit-strings
296
297 show environment DISPLAY
298 show environment TERM
299 set args -geometry 80x40+0+0
300
301 # Don't let abort actually run, as it will make
302 # stdio stop working and therefore the `pr' command above as well.
303 break abort
304
305 # If we are running in synchronous mode, we want a chance to look around
306 # before Emacs exits. Perhaps we should put the break somewhere else
307 # instead...
308 break x_error_quitter