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