]> code.delx.au - gnu-emacs/blob - src/.gdbinit
(x_draw_glyph_string_box): Fix last_x for full width rows.
[gnu-emacs] / src / .gdbinit
1 # Copyright (C) 1992, 93, 94, 95, 96, 97, 1998, 2000, 01, 2004
2 # Free Software Foundation, Inc.
3 #
4 # This file is part of GNU Emacs.
5 #
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)
9 # any later version.
10 #
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.
15 #
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.
20
21 # Force loading of symbols, enough to give us gdb_valbits etc.
22 set main
23
24 # Find lwlib source files too.
25 dir ../lwlib
26 #dir /gd/gnu/lesstif-0.89.9/lib/Xm
27
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.
32 handle 2 noprint pass
33
34 # Don't pass SIGALRM to Emacs. This makes problems when
35 # debugging.
36 handle SIGALRM ignore
37
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
42 define xgetptr
43 set $ptr = (gdb_use_union ? $arg0.u.val : $arg0 & $valmask) | gdb_data_seg_bits
44 end
45
46 define xgetint
47 set $int = gdb_use_union ? $arg0.s.val : (gdb_use_lsb ? $arg0 : $arg0 << gdb_gctypebits) >> gdb_gctypebits
48 end
49
50 define xgettype
51 set $type = gdb_use_union ? $arg0.s.type : (enum Lisp_Type) (gdb_use_lsb ? $arg0 & $tagmask : $arg0 >> gdb_valbits)
52 end
53
54 # Set up something to print out s-expressions.
55 define pr
56 set debug_print ($)
57 end
58 document pr
59 Print the emacs s-expression which is $.
60 Works only when an inferior emacs is executing.
61 end
62
63 # Print out s-expressions
64 define pp
65 set $tmp = $arg0
66 set debug_print ($tmp)
67 end
68 document pp
69 Print the argument as an emacs s-expression
70 Works only when an inferior emacs is executing.
71 end
72
73 # Print out current buffer point and boundaries
74 define ppt
75 set $b = current_buffer
76 set $t = $b->text
77 printf "BUF PT: %d", $b->pt
78 if ($b->pt != $b->pt_byte)
79 printf "[%d]", $b->pt_byte
80 end
81 printf " of 1..%d", $t->z
82 if ($t->z != $t->z_byte)
83 printf "[%d]", $t->z_byte
84 end
85 if ($b->begv != 1 || $b->zv != $t->z)
86 printf " NARROW=%d..%d", $b->begv, $b->zv
87 if ($b->begv != $b->begv_byte || $b->zv != $b->zv_byte)
88 printf " [%d..%d]", $b->begv_byte, $b->zv_byte
89 end
90 end
91 printf " GAP: %d", $t->gpt
92 if ($t->gpt != $t->gpt_byte)
93 printf "[%d]", $t->gpt_byte
94 end
95 printf " SZ=%d\n", $t->gap_size
96 end
97 document ppt
98 Print point, beg, end, narrow, and gap for current buffer.
99 end
100
101 define xtype
102 xgettype $
103 output $type
104 echo \n
105 if $type == Lisp_Misc
106 xmisctype
107 else
108 if $type == Lisp_Vectorlike
109 xvectype
110 end
111 end
112 end
113 document xtype
114 Print the type of $, assuming it is an Emacs Lisp value.
115 If the first type printed is Lisp_Vector or Lisp_Misc,
116 a second line gives the more precise type.
117 end
118
119 define xvectype
120 xgetptr $
121 set $size = ((struct Lisp_Vector *) $ptr)->size
122 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
123 echo \n
124 end
125 document xvectype
126 Print the size or vector subtype of $, assuming it is a vector or pseudovector.
127 end
128
129 define xmisctype
130 xgetptr $
131 output (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
132 echo \n
133 end
134 document xmisctype
135 Print the specific type of $, assuming it is some misc type.
136 end
137
138 define xint
139 xgetint $
140 print $int
141 end
142 document xint
143 Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
144 end
145
146 define xptr
147 xgetptr $
148 print (void *) $ptr
149 end
150 document xptr
151 Print the pointer portion of $, assuming it is an Emacs Lisp value.
152 end
153
154 define xmarker
155 xgetptr $
156 print (struct Lisp_Marker *) $ptr
157 end
158 document xmarker
159 Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
160 end
161
162 define xoverlay
163 xgetptr $
164 print (struct Lisp_Overlay *) $ptr
165 end
166 document xoverlay
167 Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
168 end
169
170 define xmiscfree
171 xgetptr $
172 print (struct Lisp_Free *) $ptr
173 end
174 document xmiscfree
175 Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
176 end
177
178 define xintfwd
179 xgetptr $
180 print (struct Lisp_Intfwd *) $ptr
181 end
182 document xintfwd
183 Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
184 end
185
186 define xboolfwd
187 xgetptr $
188 print (struct Lisp_Boolfwd *) $ptr
189 end
190 document xboolfwd
191 Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
192 end
193
194 define xobjfwd
195 xgetptr $
196 print (struct Lisp_Objfwd *) $ptr
197 end
198 document xobjfwd
199 Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
200 end
201
202 define xbufobjfwd
203 xgetptr $
204 print (struct Lisp_Buffer_Objfwd *) $ptr
205 end
206 document xbufobjfwd
207 Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
208 end
209
210 define xkbobjfwd
211 xgetptr $
212 print (struct Lisp_Kboard_Objfwd *) $ptr
213 end
214 document xkbobjfwd
215 Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
216 end
217
218 define xbuflocal
219 xgetptr $
220 print (struct Lisp_Buffer_Local_Value *) $ptr
221 end
222 document xbuflocal
223 Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
224 end
225
226 define xsymbol
227 set $sym = $
228 xgetptr $sym
229 print (struct Lisp_Symbol *) $ptr
230 xprintsym $sym
231 echo \n
232 end
233 document xsymbol
234 Print the name and address of the symbol $.
235 This command assumes that $ is an Emacs Lisp symbol value.
236 end
237
238 define xstring
239 xgetptr $
240 print (struct Lisp_String *) $ptr
241 xprintstr $
242 echo \n
243 end
244 document xstring
245 Print the contents and address of the string $.
246 This command assumes that $ is an Emacs Lisp string value.
247 end
248
249 define xvector
250 xgetptr $
251 print (struct Lisp_Vector *) $ptr
252 output ($->size > 50) ? 0 : ($->contents[0])@($->size & ~gdb_array_mark_flag)
253 echo \n
254 end
255 document xvector
256 Print the contents and address of the vector $.
257 This command assumes that $ is an Emacs Lisp vector value.
258 end
259
260 define xprocess
261 xgetptr $
262 print (struct Lisp_Process *) $ptr
263 output *$
264 echo \n
265 end
266 document xprocess
267 Print the address of the struct Lisp_process which the Lisp_Object $ points to.
268 end
269
270 define xframe
271 xgetptr $
272 print (struct frame *) $ptr
273 end
274 document xframe
275 Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
276 end
277
278 define xcompiled
279 xgetptr $
280 print (struct Lisp_Vector *) $ptr
281 output ($->contents[0])@($->size & 0xff)
282 end
283 document xcompiled
284 Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
285 end
286
287 define xwindow
288 xgetptr $
289 print (struct window *) $ptr
290 printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
291 end
292 document xwindow
293 Print $ as a window pointer, assuming it is an Emacs Lisp window value.
294 Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
295 end
296
297 define xwinconfig
298 xgetptr $
299 print (struct save_window_data *) $ptr
300 end
301 document xwinconfig
302 Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
303 end
304
305 define xsubr
306 xgetptr $
307 print (struct Lisp_Subr *) $ptr
308 output *$
309 echo \n
310 end
311 document xsubr
312 Print the address of the subr which the Lisp_Object $ points to.
313 end
314
315 define xchartable
316 xgetptr $
317 print (struct Lisp_Char_Table *) $ptr
318 printf "Purpose: "
319 xprintsym $->purpose
320 printf " %d extra slots", ($->size & 0x1ff) - 388
321 echo \n
322 end
323 document xchartable
324 Print the address of the char-table $, and its purpose.
325 This command assumes that $ is an Emacs Lisp char-table value.
326 end
327
328 define xboolvector
329 xgetptr $
330 print (struct Lisp_Bool_Vector *) $ptr
331 output ($->size > 256) ? 0 : ($->data[0])@((($->size & ~gdb_array_mark_flag) + 7)/ 8)
332 echo \n
333 end
334 document xboolvector
335 Print the contents and address of the bool-vector $.
336 This command assumes that $ is an Emacs Lisp bool-vector value.
337 end
338
339 define xbuffer
340 xgetptr $
341 print (struct buffer *) $ptr
342 xgetptr $->name
343 output ((struct Lisp_String *) $ptr)->data
344 echo \n
345 end
346 document xbuffer
347 Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
348 Print the name of the buffer.
349 end
350
351 define xhashtable
352 xgetptr $
353 print (struct Lisp_Hash_Table *) $ptr
354 end
355 document xhashtable
356 Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
357 end
358
359 define xcons
360 xgetptr $
361 print (struct Lisp_Cons *) $ptr
362 output/x *$
363 echo \n
364 end
365 document xcons
366 Print the contents of $, assuming it is an Emacs Lisp cons.
367 end
368
369 define nextcons
370 p $.cdr
371 xcons
372 end
373 document nextcons
374 Print the contents of the next cell in a list.
375 This assumes that the last thing you printed was a cons cell contents
376 (type struct Lisp_Cons) or a pointer to one.
377 end
378 define xcar
379 xgetptr $
380 xgettype $
381 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->car : 0)
382 end
383 document xcar
384 Print the car of $, assuming it is an Emacs Lisp pair.
385 end
386
387 define xcdr
388 xgetptr $
389 xgettype $
390 print/x ($type == Lisp_Cons ? ((struct Lisp_Cons *) $ptr)->cdr : 0)
391 end
392 document xcdr
393 Print the cdr of $, assuming it is an Emacs Lisp pair.
394 end
395
396 define xfloat
397 xgetptr $
398 print ((struct Lisp_Float *) $ptr)->data
399 end
400 document xfloat
401 Print $ assuming it is a lisp floating-point number.
402 end
403
404 define xscrollbar
405 xgetptr $
406 print (struct scrollbar *) $ptr
407 output *$
408 echo \n
409 end
410 document xscrollbar
411 Print $ as a scrollbar pointer.
412 end
413
414 define xprintstr
415 set $data = $arg0->data
416 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
417 end
418
419 define xprintsym
420 xgetptr $arg0
421 set $sym = (struct Lisp_Symbol *) $ptr
422 xgetptr $sym->xname
423 set $sym_name = (struct Lisp_String *) $ptr
424 xprintstr $sym_name
425 end
426 document xprintsym
427 Print argument as a symbol.
428 end
429
430 define xbacktrace
431 set $bt = backtrace_list
432 while $bt
433 xgettype (*$bt->function)
434 if $type == Lisp_Symbol
435 xprintsym (*$bt->function)
436 echo \n
437 else
438 printf "0x%x ", *$bt->function
439 if $type == Lisp_Vectorlike
440 xgetptr (*$bt->function)
441 set $size = ((struct Lisp_Vector *) $ptr)->size
442 output ($size & PVEC_FLAG) ? (enum pvec_type) ($size & PVEC_TYPE_MASK) : $size & ~gdb_array_mark_flag
443 else
444 printf "Lisp type %d", $type
445 end
446 echo \n
447 end
448 set $bt = $bt->next
449 end
450 end
451 document xbacktrace
452 Print a backtrace of Lisp function calls from backtrace_list.
453 Set a breakpoint at Fsignal and call this to see from where
454 an error was signaled.
455 end
456
457 define xreload
458 set $tagmask = (((long)1 << gdb_gctypebits) - 1)
459 set $valmask = gdb_use_lsb ? ~($tagmask) : ((long)1 << gdb_valbits) - 1
460 end
461 document xreload
462 When starting Emacs a second time in the same gdb session under
463 FreeBSD 2.2.5, gdb 4.13, $valmask have lost
464 their values. (The same happens on current (2000) versions of GNU/Linux
465 with gdb 5.0.)
466 This function reloads them.
467 end
468 xreload
469
470 # Flush display (X only)
471 define ff
472 set x_flush (0)
473 end
474 document ff
475 Flush pending X window display updates to screen.
476 Works only when an inferior emacs is executing.
477 end
478
479
480 define hook-run
481 xreload
482 end
483
484 # Call xreload if a new Emacs executable is loaded.
485 define hookpost-run
486 xreload
487 end
488
489 set print pretty on
490 set print sevenbit-strings
491
492 show environment DISPLAY
493 show environment TERM
494 set args -geometry 80x40+0+0
495
496 # Don't let abort actually run, as it will make
497 # stdio stop working and therefore the `pr' command above as well.
498 break abort
499
500 # If we are running in synchronous mode, we want a chance to look around
501 # before Emacs exits. Perhaps we should put the break somewhere else
502 # instead...
503 break x_error_quitter
504
505 # arch-tag: 12f34321-7bfa-4240-b77a-3cd3a1696dfe