DebuggingGhcCrashes: .gdbinit

File .gdbinit, 2.8 KB (added by simonmar, 8 years ago)

gdb macros for debugging GHC-compiled code

Line 
1# Change $r13 to whatever BaseReg is mapped to
2define pregs
3print *(StgRegTable *)$r13
4end
5
6define ptso
7print *((StgRegTable*)$r13)->rCurrentTSO
8end
9
10define pR1
11print (((StgRegTable)MainRegTable).rR1)
12end
13define pR2
14print (((StgRegTable)MainRegTable).rR2)
15end
16define pR3
17print (((StgRegTable)MainRegTable).rR3)
18end
19define pR4
20print (((StgRegTable)MainRegTable).rR4)
21end
22define pR5
23print (((StgRegTable)MainRegTable).rR5)
24end
25define pR6
26print (((StgRegTable)MainRegTable).rR6)
27end
28define pR7
29print (((StgRegTable)MainRegTable).rR7)
30end
31define pR8
32print (((StgRegTable)MainRegTable).rR8)
33end
34define pFlt1
35print (StgFloat) (((StgRegTable)MainRegTable).rFlt1)
36end
37define pDbl1
38print (StgDouble) (((StgRegTable)MainRegTable).rDbl1)
39end
40
41define pSp
42print (((StgRegTable)MainRegTable).rSp)
43end
44define pSu
45print (((StgRegTable)MainRegTable).rSu)
46end
47define pSpLim
48print (((StgRegTable)MainRegTable).rSpLim)
49end
50
51define pHp
52print (((StgRegTable)MainRegTable).rHp)
53end
54define pHpLim
55print (((StgRegTable)MainRegTable).rHpLim)
56end
57
58# Change $rbp to whatever Sp is mapped to
59define pstk
60pmem $ebp 16
61end
62
63define pstk_gc
64pmem MainTSO->sp 16
65end
66
67define pmem
68set $i = $arg1
69while $i > 0
70set $i = $i - 1
71x/1a (((long *)$arg0) +$i)
72end
73end
74
75define p4
76pmem $arg0 4
77end
78
79define p8
80pmem $arg0 8
81end
82
83define p16
84pmem $arg0 16
85end
86
87define pmem_forwards
88set $i = 0
89while $i < $arg1
90x/1a (((int *)$arg0) + $i)
91set $i = $i + 1
92end
93end
94
95define pheap
96pmem $edi-16 16
97end
98
99define dpc
100display /i $pc
101end
102
103define pinfo
104p *((StgInfoTable *)$arg0-1)
105end
106
107define prinfo
108p *((StgRetInfoTable *)$arg0-1)
109end
110
111define pfinfo
112p *((StgFunInfoTable *)$arg0-1)
113end
114
115define pbdescr
116p * ((bdescr *)((($arg0 & 0xfff00000) | (($arg0 & 0xff000) >> 7)) & 0xffffffe0))
117end
118
119define pbdescr64
120p * ((bdescr *)((($arg0 & 0xfffffffffff00000) | (($arg0 & 0xff000) >> 6)) & 0xffffffffffffffc0))
121end
122
123define pgen
124p generations[((bdescr *)((($arg0 & 0xfff00000) | (($arg0 & 0xff000) >> 7)) & 0xffffffe0))->gen_no]
125p * ((bdescr *)((($arg0 & 0xfff00000) | (($arg0 & 0xff000) >> 7)) & 0xffffffe0))->step
126end
127
128define getmark
129set $bd = (bdescr *)((($arg0 & 0xfff00000) | (($arg0 & 0xff000) >> 7)) & 0xffffffe0)
130set $offset = (StgPtr)$arg0 - $bd->start
131set $bitmap_word = $bd->u.bitmap + ($offset / 32)
132set $mask = 1 << ($offset & 31)
133p (*$bitmap_word & $mask) != 0
134end
135
136define getmark64
137set $bd = (bdescr *)((($arg0 & 0xfffffffffff00000) | (($arg0 & 0xff000) >> 6)) & 0xffffffffffffffc0)
138set $offset = (StgPtr)$arg0 - $bd->start
139set $bitmap_word = $bd->u.bitmap + ($offset / 64)
140set $mask = 1 << ($offset & 63)
141p (*$bitmap_word & $mask) != 0
142end
143
144# ignore SIGPIPEs
145handle SIGPIPE nostop noprint ignore
146
147define debug1
148p RtsFlags.DebugFlags.interpreter=1
149p RtsFlags.DebugFlags.apply=1
150p RtsFlags.DebugFlags.sanity=1
151end
152
153define debug2
154p RtsFlags.DebugFlags.interpreter=1
155p RtsFlags.DebugFlags.sanity=1
156end
157
158define sanity
159p RtsFlags.DebugFlags.sanity=1
160end