repl.scm relies on `display-backtrace' to do everything, some naming tweaks
[bpt/guile.git] / gdbinit
CommitLineData
5e390de6
AW
1# -*- GDB-Script -*-
2
ff1592a1
AW
3define newline
4 call (void)scm_newline (scm_current_error_port ())
5end
6
5e390de6
AW
7define pp
8 call (void)scm_call_1 (scm_variable_ref (scm_c_module_lookup (scm_c_resolve_module ("ice-9 pretty-print"), "pretty-print")), $arg0)
9end
10
ff1592a1
AW
11define gdisplay
12 call (void)scm_display ($arg0, scm_current_error_port ())
13 newline
14end
15
16define gwrite
17 call (void)scm_write ($arg0, scm_current_error_port ())
18 newline
19end
20
21define sputs
22 call (void)scm_puts ($arg0, scm_current_error_port ())
23end
24
25define gslot
26 print ((SCM**)$arg0)[1][$arg1]
27end
28
29define pslot
30 gslot $arg0 $arg1
31 gwrite $
32end
33
34define lforeach
35 set $l=$arg0
36 while $l != 0x404
37 set $x=scm_car($l)
38 $arg1 $x
39 set $l = scm_cdr($l)
40 end
41end
42
43define modsum
44 modname $arg0
45 gslot $arg0 1
46 set $uses=$
47 output "uses:\n"
48 lforeach $uses modname
49end
50
51define moduses
52 pslot $arg0 1
53end
54
55define modname
56 pslot $arg0 5
57end
58
59define modkind
60 pslot $arg0 6
61end
62
63define car
64 call scm_car ($arg0)
65end
66
67define cdr
68 call scm_cdr ($arg0)
69end
70
71define smobwordtox
72 set $x=((SCM*)$arg0)[$arg1]
73end
74
75define smobdatatox
76 smobwordtox $arg0 1
77end
78
79define program
80 smobdatatox $arg0
81 p *(struct scm_program*)$x
82end
83
84define proglocals
85 set $i=bp->nlocs
86 while $i > 0
87 set $i=$i-1
88 gwrite fp[bp->nargs+$i]
89 end
90end
91
92define progstack
93 set $x=sp
94 while $x > stack_base
95 gwrite *$x
96 set $x=$x-1
97 end
98end
99
100define tc16
101 p ((scm_t_bits)$arg0) & 0xffff
102end
103
104define smobdescriptor
105 p scm_smobs[0xff & (((scm_t_bits)$arg0) >> 8)]
106end
107
887ce75a 108define vmstackinit
ff1592a1
AW
109 set $vmsp=sp
110 set $vmstack_base=stack_base
111 set $vmfp=fp
112 set $vmbp=bp
113 set $vmframe=0
887ce75a
AW
114end
115
116define nextframe
117 set $orig_vmsp=$vmsp
118 while $vmsp > $vmstack_base
119 output $orig_vmsp - $vmsp
ff1592a1 120 sputs "\t"
ff1592a1
AW
121 output $vmsp
122 sputs "\t"
123 gwrite *$vmsp
124 set $vmsp=$vmsp-1
887ce75a
AW
125 end
126 newline
127 sputs "Frame "
128 output $vmframe
129 newline
130 sputs "ra:\t"
131 output $vmsp
132 sputs "\t"
133 output (SCM*)*$vmsp
134 set $vmsp=$vmsp-1
135 newline
136 sputs "mvra:\t"
137 output $vmsp
138 sputs "\t"
139 output (SCM*)*$vmsp
140 set $vmsp=$vmsp-1
141 newline
142 sputs "dl:\t"
143 output $vmsp
144 sputs "\t"
145 set $vmdl=(SCM*)(*$vmsp)
146 output $vmdl
147 newline
148 set $vmsp=$vmsp-1
149 sputs "hl:\t"
150 output $vmsp
151 sputs "\t"
152 gwrite *$vmsp
153 set $vmsp=$vmsp-1
154 sputs "el:\t"
155 output $vmsp
156 sputs "\t"
157 gwrite *$vmsp
158 set $vmsp=$vmsp-1
159 set $vmnlocs=(int)$vmbp->nlocs
160 while $vmnlocs > 0
161 sputs "loc #"
162 output $vmnlocs
163 sputs ":\t"
ff1592a1
AW
164 output $vmsp
165 sputs "\t"
166 gwrite *$vmsp
167 set $vmsp=$vmsp-1
887ce75a
AW
168 set $vmnlocs=$vmnlocs-1
169 end
170 set $vmnargs=(int)$vmbp->nargs
171 while $vmnargs > 0
172 sputs "arg #"
173 output $vmnargs
174 sputs ":\t"
ff1592a1
AW
175 output $vmsp
176 sputs "\t"
177 gwrite *$vmsp
178 set $vmsp=$vmsp-1
887ce75a
AW
179 set $vmnargs=$vmnargs-1
180 end
181 sputs "prog:\t"
182 output $vmsp
183 sputs "\t"
184 gwrite *$vmsp
185 set $vmsp=$vmsp-1
186 newline
187 if !$vmdl
188 loop_break
189 end
190 set $vmfp=$vmdl
191 set $vmbp=(struct scm_program*)(((SCM*)($vmfp[-1]))[1])
192 set $vmstack_base=$vmfp+$vmbp->nargs+$vmbp->nlocs+4
193 set $vmframe=$vmframe+1
194 newline
195end
196
197define vmstack
198 vmstackinit
199 while $vmsp > vp->stack_base
200 nextframe
ff1592a1
AW
201 end
202end
5e390de6
AW
203
204define inst
205 p scm_instruction_table[$arg0]
206end