(define-charset): New args :min-code and :max-code.
[bpt/emacs.git] / src / .gdbinit
CommitLineData
e3efab9c
GM
1# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001
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
7faa0236
RS
21# Force loading of symbols, enough to give us gdb_valbits etc.
22set main
23
39d10e52
RS
24# Find lwlib source files too.
25dir ../lwlib
892d8fcd 26#dir /gd/gnu/lesstif-0.89.9/lib/Xm
39d10e52 27
056515d8
KH
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.
32handle 2 noprint pass
33
3266f62b
GM
34# Don't pass SIGALRM to Emacs. This makes problems when
35# debugging.
36handle SIGALRM ignore
37
056515d8 38# Set up a mask to use.
b8d3c872
RS
39# This should be EMACS_INT, but in some cases that is a macro.
40# long ought to work in all cases right now.
41set $valmask = ((long)1 << gdb_valbits) - 1
b74f15c6
KH
42set $nonvalbits = gdb_emacs_intbits - gdb_valbits
43
a6ffc6a2
JB
44# Set up something to print out s-expressions.
45define pr
36fa5981 46set debug_print ($)
a6ffc6a2 47end
a6ffc6a2
JB
48document pr
49Print the emacs s-expression which is $.
50Works only when an inferior emacs is executing.
51end
52
53define xtype
b74f15c6 54output (enum Lisp_Type) (($ >> gdb_valbits) & 0x7)
3fe8bda5 55echo \n
b74f15c6 56output ((($ >> 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 57echo \n
a6ffc6a2 58end
e065a56e 59document xtype
ba1e23bf 60Print the type of $, assuming it is an Emacs Lisp value.
3fe8bda5
RS
61If the first type printed is Lisp_Vector or Lisp_Misc,
62the second line gives the more precise type.
63Otherwise the second line doesn't mean anything.
64end
65
66define xvectype
b74f15c6 67set $size = ((struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits))->size
3fe8bda5
RS
68output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
69echo \n
70end
71document xvectype
72Print the vector subtype of $, assuming it is a vector or pseudovector.
73end
74
75define xmisctype
b74f15c6 76output (enum Lisp_Misc_Type) (((struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits))->type)
3fe8bda5
RS
77echo \n
78end
79document xmisctype
80Print the specific type of $, assuming it is some misc type.
e065a56e 81end
a6ffc6a2
JB
82
83define xint
b74f15c6 84print (($ & $valmask) << $nonvalbits) >> $nonvalbits
a6ffc6a2 85end
e065a56e 86document xint
ba1e23bf 87Print $, assuming it is an Emacs Lisp integer. This gets the sign right.
e065a56e 88end
a6ffc6a2
JB
89
90define xptr
b74f15c6 91print (void *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 92end
e065a56e 93document xptr
ba1e23bf 94Print the pointer portion of $, assuming it is an Emacs Lisp value.
e065a56e 95end
a6ffc6a2 96
a6ffc6a2 97define xmarker
b74f15c6 98print (struct Lisp_Marker *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 99end
e065a56e 100document xmarker
ba1e23bf 101Print $ as a marker pointer, assuming it is an Emacs Lisp marker value.
e065a56e 102end
a6ffc6a2 103
a6a3acf0 104define xoverlay
b74f15c6 105print (struct Lisp_Overlay *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
106end
107document xoverlay
108Print $ as a overlay pointer, assuming it is an Emacs Lisp overlay value.
109end
110
111define xmiscfree
b74f15c6 112print (struct Lisp_Free *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
113end
114document xmiscfree
115Print $ as a misc free-cell pointer, assuming it is an Emacs Lisp Misc value.
116end
117
118define xintfwd
b74f15c6 119print (struct Lisp_Intfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
120end
121document xintfwd
122Print $ as an integer forwarding pointer, assuming it is an Emacs Lisp Misc value.
123end
124
125define xboolfwd
b74f15c6 126print (struct Lisp_Boolfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
127end
128document xboolfwd
129Print $ as a boolean forwarding pointer, assuming it is an Emacs Lisp Misc value.
130end
131
132define xobjfwd
b74f15c6 133print (struct Lisp_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0
KH
134end
135document xobjfwd
136Print $ as an object forwarding pointer, assuming it is an Emacs Lisp Misc value.
137end
138
029c56f6 139define xbufobjfwd
b74f15c6 140print (struct Lisp_Buffer_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 141end
029c56f6 142document xbufobjfwd
a6a3acf0
KH
143Print $ as a buffer-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
144end
145
a0371857 146define xkbobjfwd
b74f15c6 147print (struct Lisp_Kboard_Objfwd *) (($ & $valmask) | gdb_data_seg_bits)
cd39e946 148end
a0371857
KH
149document xkbobjfwd
150Print $ as a kboard-local object forwarding pointer, assuming it is an Emacs Lisp Misc value.
cd39e946
KH
151end
152
029c56f6 153define xbuflocal
b74f15c6 154print (struct Lisp_Buffer_Local_Value *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 155end
029c56f6 156document xbuflocal
a6a3acf0
KH
157Print $ as a buffer-local-value pointer, assuming it is an Emacs Lisp Misc value.
158end
159
a6ffc6a2 160define xsymbol
b74f15c6 161print (struct Lisp_Symbol *) ((((int) $) & $valmask) | gdb_data_seg_bits)
24b4d1bc 162output (char*)$->name->data
ef15f270 163echo \n
a6ffc6a2 164end
e065a56e
JB
165document xsymbol
166Print the name and address of the symbol $.
ba1e23bf 167This command assumes that $ is an Emacs Lisp symbol value.
e065a56e 168end
a6ffc6a2
JB
169
170define xstring
b74f15c6 171print (struct Lisp_String *) (($ & $valmask) | gdb_data_seg_bits)
14a8902a 172output ($->size > 1000) ? 0 : ($->data[0])@($->size_byte < 0 ? $->size : $->size_byte)
ef15f270 173echo \n
a6ffc6a2 174end
a6ffc6a2 175document xstring
e065a56e 176Print the contents and address of the string $.
ba1e23bf 177This command assumes that $ is an Emacs Lisp string value.
a6ffc6a2
JB
178end
179
180define xvector
b74f15c6 181print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
4ea0847a 182output ($->size > 50) ? 0 : ($->contents[0])@($->size)
ef15f270 183echo \n
a6ffc6a2 184end
a6ffc6a2 185document xvector
e065a56e 186Print the contents and address of the vector $.
ba1e23bf 187This command assumes that $ is an Emacs Lisp vector value.
a6ffc6a2
JB
188end
189
14a8902a
RS
190define xprocess
191print (struct Lisp_Process *) (($ & $valmask) | gdb_data_seg_bits)
192output *$
193echo \n
194end
195document xprocess
196Print the address of the struct Lisp_process which the Lisp_Object $ points to.
197end
198
ec558adc 199define xframe
b74f15c6 200print (struct frame *) (($ & $valmask) | gdb_data_seg_bits)
a6ffc6a2 201end
ec558adc 202document xframe
ba1e23bf 203Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
e065a56e 204end
a6ffc6a2 205
14a8902a
RS
206define xcompiled
207print (struct Lisp_Vector *) (($ & $valmask) | gdb_data_seg_bits)
208output ($->contents[0])@($->size & 0xff)
209end
210document xcompiled
211Print $ as a compiled function pointer, assuming it is an Emacs Lisp compiled value.
212end
213
214define xwindow
215print (struct window *) (($ & $valmask) | gdb_data_seg_bits)
216printf "%dx%d+%d+%d\n", $->width, $->height, $->left, $->top
217end
218document xwindow
219Print $ as a window pointer, assuming it is an Emacs Lisp window value.
220Print the window's position as "WIDTHxHEIGHT+LEFT+TOP".
221end
222
029c56f6 223define xwinconfig
b74f15c6 224print (struct save_window_data *) (($ & $valmask) | gdb_data_seg_bits)
a6a3acf0 225end
029c56f6 226document xwinconfig
a6a3acf0
KH
227Print $ as a window configuration pointer, assuming it is an Emacs Lisp window configuration value.
228end
229
14a8902a
RS
230define xsubr
231print (struct Lisp_Subr *) (($ & $valmask) | gdb_data_seg_bits)
232output *$
233echo \n
a6a3acf0 234end
14a8902a
RS
235document xsubr
236Print the address of the subr which the Lisp_Object $ points to.
237end
238
239define xchartable
240print (struct Lisp_Char_Table *) (($ & $valmask) | gdb_data_seg_bits)
241printf "Purpose: "
d5fb9ac8
KH
242output (char*)((struct Lisp_Symbol *) ((((int) $->purpose) & $valmask) | gdb_data_seg_bits))->name->data
243printf " %d extra slots", ($->size & 0x1ff) - 68
14a8902a
RS
244echo \n
245end
246document xchartable
247Print the address of the char-table $, and its purpose.
248This command assumes that $ is an Emacs Lisp char-table value.
249end
250
d5fb9ac8
KH
251define xsubchartable
252print (struct Lisp_Sub_Char_Table *) (($ & $valmask) | gdb_data_seg_bits)
253end
254document xsubchartable
255Print the address of the sub-char-table $.
256This command assumes that $ is an Emacs Lisp sub-char-table value.
257end
258
14a8902a
RS
259define xboolvector
260print (struct Lisp_Bool_Vector *) (($ & $valmask) | gdb_data_seg_bits)
261output ($->size > 256) ? 0 : ($->data[0])@(($->size + 7)/ 8)
262echo \n
263end
264document xboolvector
265Print the contents and address of the bool-vector $.
266This command assumes that $ is an Emacs Lisp bool-vector value.
267end
268
269define xbuffer
270print (struct buffer *) (($ & $valmask) | gdb_data_seg_bits)
9f696a00 271output ((struct Lisp_String *) ((($->name) & $valmask) | gdb_data_seg_bits))->data
14a8902a
RS
272echo \n
273end
274document xbuffer
275Set $ as a buffer pointer, assuming it is an Emacs Lisp buffer value.
276Print the name of the buffer.
a6a3acf0
KH
277end
278
3266f62b
GM
279define xhashtable
280print (struct Lisp_Hash_Table *) (($ & $valmask) | gdb_data_seg_bits)
281end
282document xhashtable
283Set $ as a hash table pointer, assuming it is an Emacs Lisp hash table value.
284end
285
a6ffc6a2 286define xcons
b74f15c6 287print (struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits)
6f493884 288output/x *$
ef15f270 289echo \n
a6ffc6a2 290end
e065a56e 291document xcons
ba1e23bf 292Print the contents of $, assuming it is an Emacs Lisp cons.
e065a56e 293end
a6ffc6a2 294
6f493884
RS
295define nextcons
296p $.cdr
297xcons
298end
299document nextcons
300Print the contents of the next cell in a list.
301This assumes that the last thing you printed was a cons cell contents
302(type struct Lisp_Cons) or a pointer to one.
303end
a6ffc6a2 304define xcar
de2436ef 305print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->car : 0)
a6ffc6a2 306end
e065a56e 307document xcar
ba1e23bf 308Print the car of $, assuming it is an Emacs Lisp pair.
e065a56e 309end
a6ffc6a2
JB
310
311define xcdr
de2436ef 312print/x ((($ >> gdb_valbits) & 0xf) == Lisp_Cons ? ((struct Lisp_Cons *) (($ & $valmask) | gdb_data_seg_bits))->cdr : 0)
a6ffc6a2 313end
e065a56e 314document xcdr
ba1e23bf 315Print the cdr of $, assuming it is an Emacs Lisp pair.
e065a56e 316end
a6ffc6a2 317
df86e57e 318define xfloat
b74f15c6 319print ((struct Lisp_Float *) (($ & $valmask) | gdb_data_seg_bits))->data
df86e57e
JB
320end
321document xfloat
322Print $ assuming it is a lisp floating-point number.
323end
324
b2367490 325define xscrollbar
b74f15c6 326print (struct scrollbar *) (($ & $valmask) | gdb_data_seg_bits)
b2367490
JB
327output *$
328echo \n
329end
dec5f4e3 330document xscrollbar
b2367490
JB
331Print $ as a scrollbar pointer.
332end
333
24b4d1bc
GM
334define xprintsym
335 set $sym = (struct Lisp_Symbol *) ((((int) $arg0) & $valmask) | gdb_data_seg_bits)
336 output (char*)$sym->name->data
337 echo \n
338end
339document xprintsym
340 Print argument as a symbol.
341end
342
d5fb9ac8
KH
343define xcoding
344 set $tmp = (struct Lisp_Hash_Table *) ((Vcoding_system_hash_table & $valmask) | gdb_data_seg_bits)
345 set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits)
346 set $name = $tmp->contents[$arg0 * 2]
347 print $name
348 pr
349 print $tmp->contents[$arg0 * 2 + 1]
350 pr
351end
352document xcoding
353 Print a coding system whose id is the argument.
354end
355
356define xcharset
357 set $tmp = (struct Lisp_Hash_Table *) ((Vcharset_hash_table & $valmask) | gdb_data_seg_bits)
358 set $tmp = (struct Lisp_Vector *) (($tmp->key_and_value & $valmask) | gdb_data_seg_bits)
359 p $tmp->contents[$arg0->hash_index * 2]
360 pr
361end
362document xcharset
363 Print a charset name whose id is the argument.
364end
365
366define xcurbuf
367 echo GAPSIZE:
368 output current_buffer->text->gap_size
369 echo \nGPT:
370 output current_buffer->text->gpt
371 echo /
372 output current_buffer->text->gpt_byte
373 echo \nZ:
374 output current_buffer->text->z
375 echo /
376 output current_buffer->text->z_byte
377 echo \nTEXT:
378 if current_buffer->text->gpt > 1
379 print current_buffer->text->beg[0]@80
380 else
381 print current_buffer->text->beg[current_buffer->text->gpt_byte-1]@80
382 end
383end
384
24b4d1bc
GM
385define xbacktrace
386 set $bt = backtrace_list
387 while $bt
3176a27e
GM
388 set $type = (enum Lisp_Type) ((*$bt->function >> gdb_valbits) & 0x7)
389 if $type == Lisp_Symbol
390 xprintsym *$bt->function
391 else
392 printf "0x%x ", *$bt->function
393 if $type == Lisp_Vectorlike
394 set $size = ((struct Lisp_Vector *) ((*$bt->function & $valmask) | gdb_data_seg_bits))->size
395 output (enum pvec_type) (($size & PVEC_FLAG) ? $size & PVEC_TYPE_MASK : 0)
396 else
397 printf "Lisp type %d", $type
398 end
399 echo \n
400 end
24b4d1bc
GM
401 set $bt = $bt->next
402 end
403end
404document xbacktrace
405 Print a backtrace of Lisp function calls from backtrace_list.
406 Set a breakpoint at Fsignal and call this to see from where
3176a27e 407 an error was signaled.
24b4d1bc
GM
408end
409
410define xreload
411 set $valmask = ((long)1 << gdb_valbits) - 1
412 set $nonvalbits = gdb_emacs_intbits - gdb_valbits
413end
414document xreload
415 When starting Emacs a second time in the same gdb session under
416 FreeBSD 2.2.5, gdb 4.13, $valmask and $nonvalbits have lost
be9e8331
DL
417 their values. (The same happens on current (2000) versions of GNU/Linux
418 with gdb 5.0.)
c71ea231 419 This function reloads them.
24b4d1bc
GM
420end
421
be9e8331
DL
422define hook-run
423 xreload
424end
425
e869a29d
RS
426# Call xreload if a new Emacs executable is loaded.
427define hookpost-run
428 xreload
429end
430
e065a56e 431set print pretty on
df86e57e 432set print sevenbit-strings
a6ffc6a2 433
e5d77022 434show environment DISPLAY
6f5d1a4f 435show environment TERM
6f5d1a4f 436set args -geometry 80x40+0+0
e5d77022 437
a6ffc6a2 438# Don't let abort actually run, as it will make
7f692070 439# stdio stop working and therefore the `pr' command above as well.
a6ffc6a2
JB
440break abort
441
442# If we are running in synchronous mode, we want a chance to look around
443# before Emacs exits. Perhaps we should put the break somewhere else
444# instead...
998ee976 445break x_error_quitter