Commit | Line | Data |
---|---|---|
7faa0236 RS |
1 | # Force loading of symbols, enough to give us gdb_valbits etc. |
2 | set main | |
3 | ||
39d10e52 RS |
4 | # Find lwlib source files too. |
5 | dir ../lwlib | |
6 | ||
056515d8 KH |
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. | |
b8d3c872 RS |
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 | |
b74f15c6 KH |
17 | set $nonvalbits = gdb_emacs_intbits - gdb_valbits |
18 | ||
a6ffc6a2 JB |
19 | # Set up something to print out s-expressions. |
20 | define pr | |
36fa5981 | 21 | set debug_print ($) |
a6ffc6a2 | 22 | end |
a6ffc6a2 JB |
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 | |
b74f15c6 | 29 | output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7) |
3fe8bda5 | 30 | echo \n |
b74f15c6 | 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) |
ef15f270 | 32 | echo \n |
a6ffc6a2 | 33 | end |
e065a56e | 34 | document xtype |
ba1e23bf | 35 | Print the type of $, assuming it is an Emacs Lisp value. |
3fe8bda5 RS |
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 | |
b74f15c6 | 42 | set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size |
3fe8bda5 RS |
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 | |
b74f15c6 | 51 | output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type) |
3fe8bda5 RS |
52 | echo \n |
53 | end | |
54 | document xmisctype | |
55 | Print the specific type of $, assuming it is some misc type. | |
e065a56e | 56 | end |
a6ffc6a2 JB |
57 | |
58 | define xint | |
b74f15c6 | 59 | print (($ & $valmask) << $nonvalbits) >> $nonvalbits |
a6ffc6a2 | 60 | end |
e065a56e | 61 | document xint |
ba1e23bf | 62 | Print $, assuming it is an Emacs Lisp integer. This gets the sign right. |
e065a56e | 63 | end |
a6ffc6a2 JB |
64 | |
65 | define xptr | |
b74f15c6 | 66 | print (void *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 67 | end |
e065a56e | 68 | document xptr |
ba1e23bf | 69 | Print the pointer portion of $, assuming it is an Emacs Lisp value. |
e065a56e | 70 | end |
a6ffc6a2 | 71 | |
a6ffc6a2 | 72 | define xmarker |
b74f15c6 | 73 | print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 74 | end |
e065a56e | 75 | document xmarker |
ba1e23bf | 76 | Print $ as a marker pointer, assuming it is an Emacs Lisp marker value. |
e065a56e | 77 | end |
a6ffc6a2 | 78 | |
a6a3acf0 | 79 | define xoverlay |
b74f15c6 | 80 | print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 87 | print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 94 | print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 101 | print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 108 | print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
109 | end |
110 | document xobjfwd | |
111 | Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
112 | end | |
113 | ||
029c56f6 | 114 | define xbufobjfwd |
b74f15c6 | 115 | print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 116 | end |
029c56f6 | 117 | document xbufobjfwd |
a6a3acf0 KH |
118 | Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. |
119 | end | |
120 | ||
a0371857 | 121 | define xkbobjfwd |
b74f15c6 | 122 | print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
cd39e946 | 123 | end |
a0371857 KH |
124 | document xkbobjfwd |
125 | Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
cd39e946 KH |
126 | end |
127 | ||
029c56f6 | 128 | define xbuflocal |
b74f15c6 | 129 | print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 130 | end |
029c56f6 | 131 | document xbuflocal |
a6a3acf0 KH |
132 | Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value. |
133 | end | |
134 | ||
a6ffc6a2 | 135 | define xsymbol |
b74f15c6 | 136 | print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits) |
4a9ee005 | 137 | output (char*)&$->name->data |
ef15f270 | 138 | echo \n |
a6ffc6a2 | 139 | end |
e065a56e JB |
140 | document xsymbol |
141 | Print the name and address of the symbol $. | |
ba1e23bf | 142 | This command assumes that $ is an Emacs Lisp symbol value. |
e065a56e | 143 | end |
a6ffc6a2 JB |
144 | |
145 | define xstring | |
b74f15c6 | 146 | print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits) |
14a8902a | 147 | output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte) |
ef15f270 | 148 | echo \n |
a6ffc6a2 | 149 | end |
a6ffc6a2 | 150 | document xstring |
e065a56e | 151 | Print the contents and address of the string $. |
ba1e23bf | 152 | This command assumes that $ is an Emacs Lisp string value. |
a6ffc6a2 JB |
153 | end |
154 | ||
155 | define xvector | |
b74f15c6 | 156 | print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits) |
4ea0847a | 157 | output ($->size > 50) ? 0 : ($->contents[0])@($->size) |
ef15f270 | 158 | echo \n |
a6ffc6a2 | 159 | end |
a6ffc6a2 | 160 | document xvector |
e065a56e | 161 | Print the contents and address of the vector $. |
ba1e23bf | 162 | This command assumes that $ is an Emacs Lisp vector value. |
a6ffc6a2 JB |
163 | end |
164 | ||
14a8902a RS |
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 | ||
ec558adc | 174 | define xframe |
b74f15c6 | 175 | print (struct frame *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 176 | end |
ec558adc | 177 | document xframe |
ba1e23bf | 178 | Print $ as a frame pointer, assuming it is an Emacs Lisp frame value. |
e065a56e | 179 | end |
a6ffc6a2 | 180 | |
14a8902a RS |
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 | ||
029c56f6 | 198 | define xwinconfig |
b74f15c6 | 199 | print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 200 | end |
029c56f6 | 201 | document xwinconfig |
a6a3acf0 KH |
202 | Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value. |
203 | end | |
204 | ||
14a8902a RS |
205 | define xsubr |
206 | print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits) | |
207 | output *$ | |
208 | echo \n | |
a6a3acf0 | 209 | end |
14a8902a RS |
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. | |
a6a3acf0 KH |
244 | end |
245 | ||
a6ffc6a2 | 246 | define xcons |
b74f15c6 | 247 | print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits) |
6f493884 | 248 | output/x *$ |
ef15f270 | 249 | echo \n |
a6ffc6a2 | 250 | end |
e065a56e | 251 | document xcons |
ba1e23bf | 252 | Print the contents of $, assuming it is an Emacs Lisp cons. |
e065a56e | 253 | end |
a6ffc6a2 | 254 | |
6f493884 RS |
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 | |
a6ffc6a2 | 264 | define xcar |
de2436ef | 265 | print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0) |
a6ffc6a2 | 266 | end |
e065a56e | 267 | document xcar |
ba1e23bf | 268 | Print the car of $, assuming it is an Emacs Lisp pair. |
e065a56e | 269 | end |
a6ffc6a2 JB |
270 | |
271 | define xcdr | |
de2436ef | 272 | print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0) |
a6ffc6a2 | 273 | end |
e065a56e | 274 | document xcdr |
ba1e23bf | 275 | Print the cdr of $, assuming it is an Emacs Lisp pair. |
e065a56e | 276 | end |
a6ffc6a2 | 277 | |
df86e57e | 278 | define xfloat |
b74f15c6 | 279 | print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data |
df86e57e JB |
280 | end |
281 | document xfloat | |
282 | Print $ assuming it is a lisp floating-point number. | |
283 | end | |
284 | ||
b2367490 | 285 | define xscrollbar |
b74f15c6 | 286 | print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits) |
b2367490 JB |
287 | output *$ |
288 | echo \n | |
289 | end | |
dec5f4e3 | 290 | document xscrollbar |
b2367490 JB |
291 | Print $ as a scrollbar pointer. |
292 | end | |
293 | ||
e065a56e | 294 | set print pretty on |
df86e57e | 295 | set print sevenbit-strings |
a6ffc6a2 | 296 | |
e5d77022 | 297 | show environment DISPLAY |
6f5d1a4f | 298 | show environment TERM |
6f5d1a4f | 299 | set args -geometry 80x40+0+0 |
e5d77022 | 300 | |
a6ffc6a2 | 301 | # Don't let abort actually run, as it will make |
7f692070 | 302 | # stdio stop working and therefore the `pr' command above as well. |
a6ffc6a2 JB |
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... | |
998ee976 | 308 | break x_error_quitter |