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 JB |
71 | |
72 | define xwindow | |
b74f15c6 | 73 | print (struct window *) (($ & $valmask) | gdb_data_seg_bits) |
ef15f270 | 74 | printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top |
a6ffc6a2 | 75 | end |
e065a56e | 76 | document xwindow |
ba1e23bf | 77 | Print $ as a window pointer, assuming it is an Emacs Lisp window value. |
ef15f270 | 78 | Print the window's position as "WIDTHxHEIGHT+LEFT+TOP". |
e065a56e | 79 | end |
a6ffc6a2 JB |
80 | |
81 | define xmarker | |
b74f15c6 | 82 | print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 83 | end |
e065a56e | 84 | document xmarker |
ba1e23bf | 85 | Print $ as a marker pointer, assuming it is an Emacs Lisp marker value. |
e065a56e | 86 | end |
a6ffc6a2 | 87 | |
a6a3acf0 | 88 | define xoverlay |
b74f15c6 | 89 | print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 96 | print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 103 | print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 110 | print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 117 | print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
118 | end |
119 | document xobjfwd | |
120 | Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
121 | end | |
122 | ||
029c56f6 | 123 | define xbufobjfwd |
b74f15c6 | 124 | print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 125 | end |
029c56f6 | 126 | document xbufobjfwd |
a6a3acf0 KH |
127 | Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. |
128 | end | |
129 | ||
a0371857 | 130 | define xkbobjfwd |
b74f15c6 | 131 | print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
cd39e946 | 132 | end |
a0371857 KH |
133 | document xkbobjfwd |
134 | Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
cd39e946 KH |
135 | end |
136 | ||
029c56f6 | 137 | define xbuflocal |
b74f15c6 | 138 | print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 139 | end |
029c56f6 | 140 | document xbuflocal |
a6a3acf0 KH |
141 | Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value. |
142 | end | |
143 | ||
a6ffc6a2 | 144 | define xbuffer |
b74f15c6 KH |
145 | print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits) |
146 | output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data | |
ef15f270 | 147 | echo \n |
a6ffc6a2 | 148 | end |
e065a56e | 149 | document xbuffer |
ba1e23bf | 150 | Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value. |
daa37602 | 151 | Print the name of the buffer. |
e065a56e | 152 | end |
a6ffc6a2 JB |
153 | |
154 | define xsymbol | |
b74f15c6 | 155 | print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits) |
4a9ee005 | 156 | output (char*)&$->name->data |
ef15f270 | 157 | echo \n |
a6ffc6a2 | 158 | end |
e065a56e JB |
159 | document xsymbol |
160 | Print the name and address of the symbol $. | |
ba1e23bf | 161 | This command assumes that $ is an Emacs Lisp symbol value. |
e065a56e | 162 | end |
a6ffc6a2 JB |
163 | |
164 | define xstring | |
b74f15c6 | 165 | print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits) |
79f6bf6a | 166 | output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte) |
ef15f270 | 167 | echo \n |
a6ffc6a2 | 168 | end |
a6ffc6a2 | 169 | document xstring |
e065a56e | 170 | Print the contents and address of the string $. |
ba1e23bf | 171 | This command assumes that $ is an Emacs Lisp string value. |
a6ffc6a2 JB |
172 | end |
173 | ||
174 | define xvector | |
b74f15c6 | 175 | print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits) |
4ea0847a | 176 | output ($->size > 50) ? 0 : ($->contents[0])@($->size) |
ef15f270 | 177 | echo \n |
a6ffc6a2 | 178 | end |
a6ffc6a2 | 179 | document xvector |
e065a56e | 180 | Print the contents and address of the vector $. |
ba1e23bf | 181 | This command assumes that $ is an Emacs Lisp vector value. |
a6ffc6a2 JB |
182 | end |
183 | ||
ec558adc | 184 | define xframe |
b74f15c6 | 185 | print (struct frame *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 186 | end |
ec558adc | 187 | document xframe |
ba1e23bf | 188 | Print $ as a frame pointer, assuming it is an Emacs Lisp frame value. |
e065a56e | 189 | end |
a6ffc6a2 | 190 | |
029c56f6 | 191 | define xwinconfig |
b74f15c6 | 192 | print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 193 | end |
029c56f6 | 194 | document xwinconfig |
a6a3acf0 KH |
195 | Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value. |
196 | end | |
197 | ||
198 | define xcompiled | |
b74f15c6 | 199 | print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | ||
a6ffc6a2 | 206 | define xcons |
b74f15c6 | 207 | print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits) |
6f493884 | 208 | output/x *$ |
ef15f270 | 209 | echo \n |
a6ffc6a2 | 210 | end |
e065a56e | 211 | document xcons |
ba1e23bf | 212 | Print the contents of $, assuming it is an Emacs Lisp cons. |
e065a56e | 213 | end |
a6ffc6a2 | 214 | |
6f493884 RS |
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 | |
a6ffc6a2 | 224 | define xcar |
de2436ef | 225 | print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0) |
a6ffc6a2 | 226 | end |
e065a56e | 227 | document xcar |
ba1e23bf | 228 | Print the car of $, assuming it is an Emacs Lisp pair. |
e065a56e | 229 | end |
a6ffc6a2 JB |
230 | |
231 | define xcdr | |
de2436ef | 232 | print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0) |
a6ffc6a2 | 233 | end |
e065a56e | 234 | document xcdr |
ba1e23bf | 235 | Print the cdr of $, assuming it is an Emacs Lisp pair. |
e065a56e | 236 | end |
a6ffc6a2 | 237 | |
ec558adc | 238 | define xsubr |
b74f15c6 | 239 | print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits) |
ec558adc JB |
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 | ||
8dd926ca | 247 | define xprocess |
b74f15c6 | 248 | print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits) |
8dd926ca JB |
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 | ||
df86e57e | 256 | define xfloat |
b74f15c6 | 257 | print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data |
df86e57e JB |
258 | end |
259 | document xfloat | |
260 | Print $ assuming it is a lisp floating-point number. | |
261 | end | |
262 | ||
b2367490 | 263 | define xscrollbar |
b74f15c6 | 264 | print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits) |
b2367490 JB |
265 | output *$ |
266 | echo \n | |
267 | end | |
dec5f4e3 | 268 | document xscrollbar |
b2367490 JB |
269 | Print $ as a scrollbar pointer. |
270 | end | |
271 | ||
e065a56e | 272 | set print pretty on |
df86e57e | 273 | set print sevenbit-strings |
a6ffc6a2 | 274 | |
e5d77022 | 275 | show environment DISPLAY |
6f5d1a4f | 276 | show environment TERM |
6f5d1a4f | 277 | set args -geometry 80x40+0+0 |
e5d77022 | 278 | |
a6ffc6a2 | 279 | # Don't let abort actually run, as it will make |
7f692070 | 280 | # stdio stop working and therefore the `pr' command above as well. |
a6ffc6a2 JB |
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... | |
998ee976 | 286 | break x_error_quitter |