Commit | Line | Data |
---|---|---|
b74f15c6 KH |
1 | # Set up a mask to use. |
2 | ||
7faa0236 RS |
3 | # Force loading of symbols, enough to give us gdb_valbits etc. |
4 | set main | |
5 | ||
b8d3c872 RS |
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 | |
b74f15c6 KH |
9 | set $nonvalbits = gdb_emacs_intbits - gdb_valbits |
10 | ||
a6ffc6a2 JB |
11 | # Set up something to print out s-expressions. |
12 | define pr | |
36fa5981 | 13 | set debug_print ($) |
a6ffc6a2 | 14 | end |
a6ffc6a2 JB |
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 | |
b74f15c6 | 21 | output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7) |
3fe8bda5 | 22 | echo \n |
b74f15c6 | 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) |
ef15f270 | 24 | echo \n |
a6ffc6a2 | 25 | end |
e065a56e | 26 | document xtype |
ba1e23bf | 27 | Print the type of $, assuming it is an Emacs Lisp value. |
3fe8bda5 RS |
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 | |
b74f15c6 | 34 | set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size |
3fe8bda5 RS |
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 | |
b74f15c6 | 43 | output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type) |
3fe8bda5 RS |
44 | echo \n |
45 | end | |
46 | document xmisctype | |
47 | Print the specific type of $, assuming it is some misc type. | |
e065a56e | 48 | end |
a6ffc6a2 JB |
49 | |
50 | define xint | |
b74f15c6 | 51 | print (($ & $valmask) << $nonvalbits) >> $nonvalbits |
a6ffc6a2 | 52 | end |
e065a56e | 53 | document xint |
ba1e23bf | 54 | Print $, assuming it is an Emacs Lisp integer. This gets the sign right. |
e065a56e | 55 | end |
a6ffc6a2 JB |
56 | |
57 | define xptr | |
b74f15c6 | 58 | print (void *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 59 | end |
e065a56e | 60 | document xptr |
ba1e23bf | 61 | Print the pointer portion of $, assuming it is an Emacs Lisp value. |
e065a56e | 62 | end |
a6ffc6a2 JB |
63 | |
64 | define xwindow | |
b74f15c6 | 65 | print (struct window *) (($ & $valmask) | gdb_data_seg_bits) |
ef15f270 | 66 | printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top |
a6ffc6a2 | 67 | end |
e065a56e | 68 | document xwindow |
ba1e23bf | 69 | Print $ as a window pointer, assuming it is an Emacs Lisp window value. |
ef15f270 | 70 | Print the window's position as "WIDTHxHEIGHT+LEFT+TOP". |
e065a56e | 71 | end |
a6ffc6a2 JB |
72 | |
73 | define xmarker | |
b74f15c6 | 74 | print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 75 | end |
e065a56e | 76 | document xmarker |
ba1e23bf | 77 | Print $ as a marker pointer, assuming it is an Emacs Lisp marker value. |
e065a56e | 78 | end |
a6ffc6a2 | 79 | |
a6a3acf0 | 80 | define xoverlay |
b74f15c6 | 81 | print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 88 | print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 95 | print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 102 | print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | |
b74f15c6 | 109 | print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
110 | end |
111 | document xobjfwd | |
112 | Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
113 | end | |
114 | ||
029c56f6 | 115 | define xbufobjfwd |
b74f15c6 | 116 | print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 117 | end |
029c56f6 | 118 | document xbufobjfwd |
a6a3acf0 KH |
119 | Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. |
120 | end | |
121 | ||
a0371857 | 122 | define xkbobjfwd |
b74f15c6 | 123 | print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits) |
cd39e946 | 124 | end |
a0371857 KH |
125 | document xkbobjfwd |
126 | Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value. | |
cd39e946 KH |
127 | end |
128 | ||
029c56f6 | 129 | define xbuflocal |
b74f15c6 | 130 | print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 131 | end |
029c56f6 | 132 | document xbuflocal |
a6a3acf0 KH |
133 | Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value. |
134 | end | |
135 | ||
a6ffc6a2 | 136 | define xbuffer |
b74f15c6 KH |
137 | print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits) |
138 | output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data | |
ef15f270 | 139 | echo \n |
a6ffc6a2 | 140 | end |
e065a56e | 141 | document xbuffer |
ba1e23bf | 142 | Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value. |
daa37602 | 143 | Print the name of the buffer. |
e065a56e | 144 | end |
a6ffc6a2 JB |
145 | |
146 | define xsymbol | |
b74f15c6 | 147 | print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits) |
4a9ee005 | 148 | output (char*)&$->name->data |
ef15f270 | 149 | echo \n |
a6ffc6a2 | 150 | end |
e065a56e JB |
151 | document xsymbol |
152 | Print the name and address of the symbol $. | |
ba1e23bf | 153 | This command assumes that $ is an Emacs Lisp symbol value. |
e065a56e | 154 | end |
a6ffc6a2 JB |
155 | |
156 | define xstring | |
b74f15c6 | 157 | print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits) |
4ea0847a | 158 | output ($->size > 1000) ? 0 : ($->data[0])@($->size) |
ef15f270 | 159 | echo \n |
a6ffc6a2 | 160 | end |
a6ffc6a2 | 161 | document xstring |
e065a56e | 162 | Print the contents and address of the string $. |
ba1e23bf | 163 | This command assumes that $ is an Emacs Lisp string value. |
a6ffc6a2 JB |
164 | end |
165 | ||
166 | define xvector | |
b74f15c6 | 167 | print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits) |
4ea0847a | 168 | output ($->size > 50) ? 0 : ($->contents[0])@($->size) |
ef15f270 | 169 | echo \n |
a6ffc6a2 | 170 | end |
a6ffc6a2 | 171 | document xvector |
e065a56e | 172 | Print the contents and address of the vector $. |
ba1e23bf | 173 | This command assumes that $ is an Emacs Lisp vector value. |
a6ffc6a2 JB |
174 | end |
175 | ||
ec558adc | 176 | define xframe |
b74f15c6 | 177 | print (struct frame *) (($ & $valmask) | gdb_data_seg_bits) |
a6ffc6a2 | 178 | end |
ec558adc | 179 | document xframe |
ba1e23bf | 180 | Print $ as a frame pointer, assuming it is an Emacs Lisp frame value. |
e065a56e | 181 | end |
a6ffc6a2 | 182 | |
029c56f6 | 183 | define xwinconfig |
b74f15c6 | 184 | print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 | 185 | end |
029c56f6 | 186 | document xwinconfig |
a6a3acf0 KH |
187 | Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value. |
188 | end | |
189 | ||
190 | define xcompiled | |
b74f15c6 | 191 | print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits) |
a6a3acf0 KH |
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 | ||
a6ffc6a2 | 198 | define xcons |
b74f15c6 | 199 | print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits) |
cac29370 | 200 | output *$ |
ef15f270 | 201 | echo \n |
a6ffc6a2 | 202 | end |
e065a56e | 203 | document xcons |
ba1e23bf | 204 | Print the contents of $, assuming it is an Emacs Lisp cons. |
e065a56e | 205 | end |
a6ffc6a2 JB |
206 | |
207 | define xcar | |
b74f15c6 | 208 | print ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0) |
a6ffc6a2 | 209 | end |
e065a56e | 210 | document xcar |
ba1e23bf | 211 | Print the car of $, assuming it is an Emacs Lisp pair. |
e065a56e | 212 | end |
a6ffc6a2 JB |
213 | |
214 | define xcdr | |
b74f15c6 | 215 | print ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0) |
a6ffc6a2 | 216 | end |
e065a56e | 217 | document xcdr |
ba1e23bf | 218 | Print the cdr of $, assuming it is an Emacs Lisp pair. |
e065a56e | 219 | end |
a6ffc6a2 | 220 | |
ec558adc | 221 | define xsubr |
b74f15c6 | 222 | print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits) |
ec558adc JB |
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 | ||
8dd926ca | 230 | define xprocess |
b74f15c6 | 231 | print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits) |
8dd926ca JB |
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 | ||
df86e57e | 239 | define xfloat |
b74f15c6 | 240 | print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data |
df86e57e JB |
241 | end |
242 | document xfloat | |
243 | Print $ assuming it is a lisp floating-point number. | |
244 | end | |
245 | ||
b2367490 | 246 | define xscrollbar |
b74f15c6 | 247 | print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits) |
b2367490 JB |
248 | output *$ |
249 | echo \n | |
250 | end | |
dec5f4e3 | 251 | document xscrollbar |
b2367490 JB |
252 | Print $ as a scrollbar pointer. |
253 | end | |
254 | ||
e065a56e | 255 | set print pretty on |
df86e57e | 256 | set print sevenbit-strings |
a6ffc6a2 | 257 | |
e5d77022 | 258 | show environment DISPLAY |
6f5d1a4f | 259 | show environment TERM |
6f5d1a4f | 260 | set args -geometry 80x40+0+0 |
e5d77022 | 261 | |
a6ffc6a2 | 262 | # Don't let abort actually run, as it will make |
7f692070 | 263 | # stdio stop working and therefore the `pr' command above as well. |
a6ffc6a2 JB |
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... | |
998ee976 | 269 | break x_error_quitter |