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