1 # Force loading of symbols, enough to give us gdb_valbits etc.
4 # Find lwlib source files too.
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.
13 # Set up a mask to use.
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
17 set $nonvalbits = gdb_emacs_intbits - gdb_valbits
19 # Set up something to print out s-expressions.
24 Print the emacs s-expression which is $.
25 Works only when an inferior emacs is executing.
29 output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7)
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)
35 Print the type of $, assuming it is an Emacs Lisp value.
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.
42 set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size
43 output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
47 Print the vector subtype of $, assuming it is a vector or pseudovector.
51 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type)
55 Print the specific type of $, assuming it is some misc type.
59 print (($ & $valmask) << $nonvalbits) >> $nonvalbits
62 Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
66 print (void *) (($ & $valmask) | gdb_data_seg_bits)
69 Print the pointer portion of $, assuming it is an Emacs Lisp value.
73 print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits)
76 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
80 print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits)
83 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
87 print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits)
90 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
94 print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits)
97 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
101 print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits)
104 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
108 print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
111 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
115 print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
118 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
122 print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
125 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
129 print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits)
132 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
136 print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
137 output (char*)$->name->data
141 Print the name and address of the symbol $.
142 This command assumes that $ is an Emacs Lisp symbol value.
146 print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits)
147 output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte)
151 Print the contents and address of the string $.
152 This command assumes that $ is an Emacs Lisp string value.
156 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
157 output ($->size > 50) ? 0 : ($->contents[0])@($->size)
161 Print the contents and address of the vector $.
162 This command assumes that $ is an Emacs Lisp vector value.
166 print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits)
171 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
175 print (struct frame *) (($ & $valmask) | gdb_data_seg_bits)
178 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
182 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
183 output ($->contents[0])@($->size & 0xff)
186 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
190 print (struct window *) (($ & $valmask) | gdb_data_seg_bits)
191 printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
194 Print $ as a window pointer, assuming it is an Emacs Lisp window value.
195 Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
199 print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits)
202 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
206 print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits)
211 Print the address of the subr which the Lisp_Object $ points to.
215 print (struct Lisp_Char_Table *) (($ & $valmask) | gdb_data_seg_bits)
217 output (char*)&((struct Lisp_Symbol *) ((((int) $->purpose) & $valmask) | gdb_data_seg_bits))->name->data
218 printf " %d extra slots", ($->size & 0x1ff) - 388
222 Print the address of the char-table $, and its purpose.
223 This command assumes that $ is an Emacs Lisp char-table value.
227 print (struct Lisp_Bool_Vector *) (($ & $valmask) | gdb_data_seg_bits)
228 output ($->size > 256) ? 0 : ($->data[0])@(($->size + 7)/ 8)
232 Print the contents and address of the bool-vector $.
233 This command assumes that $ is an Emacs Lisp bool-vector value.
237 print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits)
238 output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data
242 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
243 Print the name of the buffer.
247 print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits)
252 Print the contents of $, assuming it is an Emacs Lisp cons.
260 Print the contents of the next cell in a list.
261 This assumes that the last thing you printed was a cons cell contents
262 (type struct Lisp_Cons) or a pointer to one.
265 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0)
268 Print the car of $, assuming it is an Emacs Lisp pair.
272 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0)
275 Print the cdr of $, assuming it is an Emacs Lisp pair.
279 print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data
282 Print $ assuming it is a lisp floating-point number.
286 print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits)
291 Print $ as a scrollbar pointer.
295 set $sym = (struct Lisp_Symbol *) ((((int) $arg0) & $valmask) | gdb_data_seg_bits)
296 output (char*)$sym->name->data
300 Print argument as a symbol.
304 set $bt = backtrace_list
306 xprintsym *$bt->function
311 Print a backtrace of Lisp function calls from backtrace_list.
312 Set a breakpoint at Fsignal and call this to see from where
313 an error was signalled.
317 set $valmask = ((long)1 << gdb_valbits) - 1
318 set $nonvalbits = gdb_emacs_intbits - gdb_valbits
321 When starting Emacs a second time in the same gdb session under
322 FreeBSD 2.2.5, gdb 4.13, $valmask and $nonvalbits have lost
323 their values. This function reloads them.
327 set print sevenbit-strings
329 show environment DISPLAY
330 show environment TERM
331 set args -geometry 80x40+0+0
333 # Don't let abort actually run, as it will make
334 # stdio stop working and therefore the `pr' command above as well.
337 # If we are running in synchronous mode, we want a chance to look around
338 # before Emacs exits. Perhaps we should put the break somewhere else
340 break x_error_quitter