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