1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001
2 # Free Software Foundation, Inc.
4 # This file is part of GNU Emacs.
6 # GNU Emacs is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # GNU Emacs is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Emacs; see the file COPYING. If not, write to the
18 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
21 # Force loading of symbols, enough to give us gdb_valbits etc.
24 # Find lwlib source files too.
26 #dir /gd/gnu/lesstif-0.89.9/lib/Xm
28 # Don't enter GDB when user types C-g to quit.
29 # This has one unfortunate effect: you can't type C-c
30 # at the GDB to stop Emacs, when using X.
31 # However, C-z works just as well in that case.
34 # Don't pass SIGALRM to Emacs. This makes problems when
38 # Set up a mask to use.
39 # This should be EMACS_INT, but in some cases that is a macro.
40 # long ought to work in all cases right now.
41 set $valmask = ((long)1 << gdb_valbits) - 1
42 set $nonvalbits = gdb_emacs_intbits - gdb_valbits
44 # Set up something to print out s-expressions.
49 Print the emacs s-expression which is $.
50 Works only when an inferior emacs is executing.
54 output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7)
56 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)
60 Print the type of $, assuming it is an Emacs Lisp value.
61 If the first type printed is Lisp_Vector or Lisp_Misc,
62 the second line gives the more precise type.
63 Otherwise the second line doesn't mean anything.
67 set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size
68 output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
72 Print the vector subtype of $, assuming it is a vector or pseudovector.
76 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type)
80 Print the specific type of $, assuming it is some misc type.
84 print (($ & $valmask) << $nonvalbits) >> $nonvalbits
87 Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
91 print (void *) (($ & $valmask) | gdb_data_seg_bits)
94 Print the pointer portion of $, assuming it is an Emacs Lisp value.
98 print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits)
101 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
105 print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits)
108 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
112 print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits)
115 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
119 print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits)
122 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
126 print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits)
129 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
133 print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
136 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
140 print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
143 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
147 print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
150 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
154 print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits)
157 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
161 print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
162 output (char*)$->name->data
166 Print the name and address of the symbol $.
167 This command assumes that $ is an Emacs Lisp symbol value.
171 print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits)
172 output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte)
176 Print the contents and address of the string $.
177 This command assumes that $ is an Emacs Lisp string value.
181 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
182 output ($->size > 50) ? 0 : ($->contents[0])@($->size)
186 Print the contents and address of the vector $.
187 This command assumes that $ is an Emacs Lisp vector value.
191 print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits)
196 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
200 print (struct frame *) (($ & $valmask) | gdb_data_seg_bits)
203 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
207 print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
208 output ($->contents[0])@($->size & 0xff)
211 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
215 print (struct window *) (($ & $valmask) | gdb_data_seg_bits)
216 printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
219 Print $ as a window pointer, assuming it is an Emacs Lisp window value.
220 Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
224 print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits)
227 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
231 print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits)
236 Print the address of the subr which the Lisp_Object $ points to.
240 print (struct Lisp_Char_Table *) (($ & $valmask) | gdb_data_seg_bits)
242 output (char*)&((struct Lisp_Symbol *) ((((int) $->purpose) & $valmask) | gdb_data_seg_bits))->name->data
243 printf " %d extra slots", ($->size & 0x1ff) - 388
247 Print the address of the char-table $, and its purpose.
248 This command assumes that $ is an Emacs Lisp char-table value.
252 print (struct Lisp_Bool_Vector *) (($ & $valmask) | gdb_data_seg_bits)
253 output ($->size > 256) ? 0 : ($->data[0])@(($->size + 7)/ 8)
257 Print the contents and address of the bool-vector $.
258 This command assumes that $ is an Emacs Lisp bool-vector value.
262 print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits)
263 output &((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data
267 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
268 Print the name of the buffer.
272 print (struct Lisp_Hash_Table *) (($ & $valmask) | gdb_data_seg_bits)
275 Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
279 print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits)
284 Print the contents of $, assuming it is an Emacs Lisp cons.
292 Print the contents of the next cell in a list.
293 This assumes that the last thing you printed was a cons cell contents
294 (type struct Lisp_Cons) or a pointer to one.
297 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0)
300 Print the car of $, assuming it is an Emacs Lisp pair.
304 print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0)
307 Print the cdr of $, assuming it is an Emacs Lisp pair.
311 print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data
314 Print $ assuming it is a lisp floating-point number.
318 print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits)
323 Print $ as a scrollbar pointer.
327 set $sym = (struct Lisp_Symbol *) ((((int) $arg0) & $valmask) | gdb_data_seg_bits)
328 output (char*)$sym->name->data
332 Print argument as a symbol.
336 set $bt = backtrace_list
338 set $type = (enum Lisp_Type) ((*$bt->function >> gdb_valbits) & 0x7)
339 if $type == Lisp_Symbol
340 xprintsym *$bt->function
342 printf "0x%x ", *$bt->function
343 if $type == Lisp_Vectorlike
344 set $size = ((struct Lisp_Vector *) ((*$bt->function & $valmask) | gdb_data_seg_bits))->size
345 output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
347 printf "Lisp type %d", $type
355 Print a backtrace of Lisp function calls from backtrace_list.
356 Set a breakpoint at Fsignal and call this to see from where
357 an error was signaled.
361 set $valmask = ((long)1 << gdb_valbits) - 1
362 set $nonvalbits = gdb_emacs_intbits - gdb_valbits
365 When starting Emacs a second time in the same gdb session under
366 FreeBSD 2.2.5, gdb 4.13, $valmask and $nonvalbits have lost
367 their values. (The same happens on current (2000) versions of GNU/Linux
369 This function reloads them.
377 set print sevenbit-strings
379 show environment DISPLAY
380 show environment TERM
381 set args -geometry 80x40+0+0
383 # Don't let abort actually run, as it will make
384 # stdio stop working and therefore the `pr' command above as well.
387 # If we are running in synchronous mode, we want a chance to look around
388 # before Emacs exits. Perhaps we should put the break somewhere else
390 break x_error_quitter