]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/debugscripts/gdbinit.vinum
Include the config name in the log file name.
[FreeBSD/FreeBSD.git] / tools / debugscripts / gdbinit.vinum
1 # $FreeBSD$
2 # gdb macros for debugging Vinum.
3 # This file gets included from the .gdbinit files in 
4 # the kernel build directory and /var/crash.
5 # Normally you won't need to include it directly.
6 # see gdbinit(9) for further details.
7
8 # Show information about the request pointed to by the variable rq in the current frame.
9 define rq
10 rqq rq
11 end
12 document rq
13 Show information about the request pointed to by the variable rq in the current frame.
14 end
15
16 # Show information about the request (struct rq) pointed at by the parameter
17 define rqq
18 set $rq = (struct request *) $arg0
19 printf "Request: \n" 
20 output/x *$rq
21 printf "\n"
22 bpp $rq->bp
23 set $rqg = $rq->rqg
24 while ($rqg != 0)
25   printf "\nRequest group at %x:\n", $rqg
26   output/x *$rqg
27   printf "\n"
28   set $rqno = 0
29   while ($rqno < $rqg->count)
30     printf "rqg->rqe [%d]: ", $rqno
31     rrqe &$rqg->rqe[$rqno]
32     set $rqno = $rqno + 1
33     end
34   set $rqg = $rqg->next
35   end
36 end
37 document rqq
38 Show information about the request (struct rq) pointed at by the parameter
39 end
40
41 # Show information about the request element pointed to by the variable rqe in the current frame.
42 define rqe
43 rrqe rqe
44 end
45 document rqe
46 Show information about the request element pointed to by the variable rqe in the current frame.
47 end
48
49 # Show information about the request element (struct rqe) pointed at by the parameter.
50 define rrqe
51 set $rqe = (struct rqelement *) $arg0
52     printf "sdoffset 0x%x, useroffset 0x%x, dataoffset 0x%x, datalen 0x%x, groupoffset 0x%x, grouplen 0x%x, buflen 0x%x\n", \
53       $rqe->sdoffset, \
54       $rqe->useroffset, \
55       $rqe->dataoffset, \
56       $rqe->datalen, \
57       $rqe->groupoffset, \
58       $rqe->grouplen, \
59       $rqe->buflen
60     printf "  Flags 0x%x,  Subdisk %d  Drive %d\n", \
61       $rqe->flags, \
62       $rqe->sdno, \
63       $rqe->driveno
64     bpp &$rqe->b
65 end
66 document rrqe
67 Show information about the request element (struct rqe) pointed at by the parameter.
68 end
69
70 define rqq0
71 printf "rq->prq [0].rqe[0].sdno: " 
72 output/x rq->prq[0].rqe[0].sdno
73 printf "\nBuffer: device: " 
74 output/x rq->prq[0].rqe[0].b.b_dev
75 printf " data: " 
76 output/x rq->prq[0].rqe[0].b.b_data
77 printf " length: " 
78 output/x rq->prq[0].rqe[0].b.b_bcount
79 printf " drive offset: " 
80 output/x rq->prq[0].rqe[0].b.b_blkno
81 printf " subdisk offset: " 
82 output/x rq->prq[0].rqe[0].sdoffset
83 printf "\nFlags: " 
84 if (rq->prq[0].rqe[0].b.b_flags & 0x10)
85 printf "busy "
86 end
87 if (rq->prq[0].rqe[0].b.b_flags & 0x200)
88 printf "done "
89 end
90 if (rq->prq[0].rqe[0].b.b_flags & 0x800)
91 printf "error "
92 end
93 if (rq->prq[0].rqe[0].b.b_flags & 0x100000)
94 printf "read "
95 end
96 output/x rq->prq[0].rqe[0].b.b_flags
97 printf "\nrq->prq [0].rqe[1].sdno: " 
98 output/x rq->prq[0].rqe[1].sdno
99 printf "\nBuffer: device: " 
100 output/x rq->prq[0].rqe[1].b.b_dev
101 printf " data: " 
102 output/x rq->prq[0].rqe[1].b.b_data
103 printf " length: " 
104 output/x rq->prq[0].rqe[1].b.b_bcount
105 printf " drive offset: " 
106 output/x rq->prq[0].rqe[1].b.b_blkno
107 printf " subdisk offset: " 
108 output/x rq->prq[0].rqe[1].sdoffset
109 printf "\nFlags: " 
110 output/x rq->prq[0].rqe[1].b.b_flags
111 echo \n
112 end
113 document rqq0
114 Print important information on Vinum request structures.
115 end
116
117 define rqq1
118 printf "\nrq->prq [1].rqe[0].sdno: " 
119 output/x rq->prq[1].rqe[0].sdno
120 printf "\nBuffer: device: " 
121 output/x rq->prq[1].rqe[0].b.b_dev
122 printf " data: " 
123 output/x rq->prq[1].rqe[0].b.b_data
124 printf " length: " 
125 output/x rq->prq[1].rqe[0].b.b_bcount
126 printf " drive offset: " 
127 output/x rq->prq[1].rqe[0].b.b_blkno
128 printf " subdisk offset: " 
129 output/x rq->prq[1].rqe[0].sdoffset
130 printf "\nFlags: " 
131 output/x rq->prq[1].rqe[0].b.b_flags
132 printf "\nrq->prq [1].rqe[1].sdno: " 
133 output/x rq->prq[1].rqe[1].sdno
134 printf "\nBuffer: device: " 
135 output/x rq->prq[1].rqe[1].b.b_dev
136 printf " data: 0x%x  length 0x%x  drive offset 0x%x  sd offset 0x%x\n" rq->prq[1].rqe[1].b.b_data,
137  rq->prq[1].rqe[1].b.b_bcount,
138  rq->prq[1].rqe[1].b.b_blkno,
139  rq->prq[1].rqe[1].sdoffset
140 printf "\nFlags: " 
141 output/x rq->prq[1].rqe[1].b.b_flags
142 echo \n
143 end
144 document rqq1
145 Print important information on Vinum request structures.
146 end
147
148 # kernel equivalent of 'info -V'
149 define rqi
150    set $rqipe = rqip
151    set $rqip = $rqipe + 1
152    set $rqend  = rqinfo + 128
153    if ($rqip == $rqend)
154       set $rqip = rqinfo
155    end
156    set $done = 0
157    while ($done == 0)
158      if ($rqip->bp != 0)
159         printf "%X:\t%d.%06d\tUBP: %x\t", $rqip, $rqip->timestamp.tv_sec, $rqip->timestamp.tv_usec, $rqip->bp
160         p $rqip->type
161         printf " user  "
162         bpp $rqip->bp
163         if ($rqip->type < loginfo_rqe)
164            printf " copied"
165            bpp &$rqip->info
166         else 
167            rrqe &$rqip->info
168         end
169       end
170       set $rqip = $rqip + 1
171       if ($rqip == $rqipe)
172          set $done = 1
173       end
174       if ($rqip == $rqend)
175          set $rqip = rqinfo
176       end
177    end
178 end
179 document rqi
180 Print out the same information as 'vinum info -V'.
181 end
182
183 define rqinfo
184    set $rqipe = rqip
185    set $rqip = $rqipe + 1
186    set $rqend  = rqinfo + 128
187    if ($rqip == $rqend)
188       set $rqip = rqinfo
189    end
190    set $done = 0
191    printf "\nTime\t\t\t Event\t\t     Buf\tDev\t  Offset\tBytes\tSD\tSDoff\tDoffset\tGoffset\n\n"
192    while ($done == 0)
193      if ($rqip->bp != 0)
194         printf "%d.%06d\t", $rqip->timestamp.tv_sec, $rqip->timestamp.tv_usec
195         if ($rqip->type ==  loginfo_user_bp)
196           if ($rqip->info.b.b_flags & 0x00100000)
197             printf "1VS Read"
198           else
199             printf "1VS Write"
200           end
201         printf "\t%p\t%d.%d\t0x%-9x\t%ld\n", $rqip->bp, $rqip->devmajor, $rqip->devminor & 0xff, $rqip->info.b.b_blkno, $rqip->info.b.b_bcount
202         end
203         
204       if ($rqip->type == loginfo_user_bpl)
205           if ($rqip->info.b.b_flags & 0x00100000)
206             printf "2LR Read"
207           else
208             printf "2LR Write"
209           end
210         printf "\t%p\t%d.%d\t0x%-9x\t%ld\n", $rqip->bp, $rqip->devmajor, $rqip->devminor & 0xff, $rqip->info.b.b_blkno, $rqip->info.b.b_bcount
211         end
212          
213       if ($rqip->type == loginfo_rqe)
214           if ($rqip->info.b.b_flags & 0x00100000)
215             printf "3RQ Read"
216           else
217             printf "3RQ Write"
218           end
219         printf "\t%p\t%d.%d\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n", $rqip->bp, $rqip->devmajor, $rqip->devminor & 0xff, $rqip->info.rqe.b.b_blkno, $rqip->info.rqe.b.b_bcount, $rqip->info.rqe.sdno, $rqip->info.rqe.sdoffset, $rqip->info.rqe.dataoffset, $rqip->info.rqe.groupoffset
220         end
221         
222       if ($rqip->type == loginfo_iodone)
223           if ($rqip->info.b.b_flags & 0x00100000)
224             printf "4DN Read"
225           else
226             printf "4DN Write"
227           end
228         printf "\t%p\t%d.%d\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n", $rqip->bp, $rqip->devmajor, $rqip->devminor & 0xff, $rqip->info.rqe.b.b_blkno, $rqip->info.rqe.b.b_bcount, $rqip->info.rqe.sdno, $rqip->info.rqe.sdoffset, $rqip->info.rqe.dataoffset, $rqip->info.rqe.groupoffset
229         end
230         
231       if ($rqip->type == loginfo_raid5_data)
232           if ($rqip->info.b.b_flags & 0x00100000)
233             printf "5RD Read"
234           else
235             printf "5RD Write"
236           end
237         printf "\t%p\t%d.%d\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n", $rqip->bp, $rqip->devmajor, $rqip->devminor & 0xff, $rqip->info.rqe.b.b_blkno, $rqip->info.rqe.b.b_bcount, $rqip->info.rqe.sdno, $rqip->info.rqe.sdoffset, $rqip->info.rqe.dataoffset, $rqip->info.rqe.groupoffset
238         end
239         
240       if ($rqip->type == loginfo_raid5_parity)
241           if ($rqip->info.b.b_flags & 0x00100000)
242             printf "6RP Read"
243           else
244             printf "6RP Write"
245           end
246         printf "\t%p\t%d.%d\t0x%-9x\t%ld\t%d\t%x\t%x\t%x\n", $rqip->bp, $rqip->devmajor, $rqip->devminor & 0xff, $rqip->info.rqe.b.b_blkno, $rqip->info.rqe.b.b_bcount, $rqip->info.rqe.sdno, $rqip->info.rqe.sdoffset, $rqip->info.rqe.dataoffset, $rqip->info.rqe.groupoffset
247         end
248
249       if ($rqip->type == loginfo_sdio)
250           if ($rqip->info.b.b_flags & 0x00100000)
251             printf "7VS Read"
252           else
253             printf "7VS Write"
254           end
255         printf "\t%p\t\t  0x%-9x\t%ld\t%d\n", $rqip->bp, $rqip->info.b.b_blkno, $rqip->info.b.b_bcount, $rqip->devminor & 0xff
256         end
257
258       if ($rqip->type == loginfo_sdiol)
259           if ($rqip->info.b.b_flags & 0x00100000)
260             printf "8LR Read"
261           else
262             printf "8LR Write"
263           end
264         printf "\t%p\t%d.%d\t0x%-9x\t%ld\n", $rqip->bp, $rqip->devmajor, $rqip->devminor & 0xff, $rqip->info.b.b_blkno, $rqip->info.b.b_bcount
265         end
266          
267       if ($rqip->type == loginfo_lockwait)
268         printf "Lockwait  %p\t%d\t  0x%x\n", $rqip->bp, $rqip->info.lockinfo.plexno, $rqip->info.lockinfo.stripe
269         end
270
271       if ($rqip->type == loginfo_lock)
272         printf "Lock      \t%p\t%d\t  0x%x\n", $rqip->bp, $rqip->info.lockinfo.plexno, $rqip->info.lockinfo.stripe
273         end
274
275       if ($rqip->type == loginfo_unlock)
276         printf "Unlock    \t%p\t%d\t  0x%x\n", $rqip->bp, $rqip->info.lockinfo.plexno, $rqip->info.lockinfo.stripe
277         end
278
279         if ($rqip->type == loginfo_sdiodone)
280           if ($rqip->info.b.b_flags & 0x00100000)
281             printf "9DN Read"
282           else
283             printf "9DN Write"
284           end
285         printf "\t%p\t\t  0x%-9x\t%ld\t%d\n", $rqip->bp, $rqip->info.b.b_blkno, $rqip->info.b.b_bcount, $rqip->devminor
286         end
287
288         end
289       set $rqip = $rqip + 1
290       if ($rqip == $rqipe)
291          set $done = 1
292       end
293       if ($rqip == $rqend)
294          set $rqip = rqinfo
295       end
296    end
297 end 
298 document rqinfo
299 Show the Vinum request log buffer like 'vinum info -V'
300 end
301 define meminfo
302 printf "Block\t\tTime\t\tSequence\t  size\t  address\t  line\t\tfile\n"
303 set $i = 0
304 while $i < malloccount
305   printf "%6d\t%10d.%06d\t%6d\t\t%6d\t0x%08x\t%6d\t\t%s\n", $i, malloced [$i].time.tv_sec, malloced [$i].time.tv_usec, malloced [$i].seq, malloced[$i].size, malloced[$i].address, malloced[$i].line, &malloced[$i].file
306   set $i = $i + 1
307 end
308 end
309 document meminfo
310 Equivalent of 'vinum info -v' command
311 end
312 define finfo
313 printf "Block\t\tTime\t\tSequence\t  size\t  address\t  line\t\tfile\n"
314 set $i = lastfree
315 set $j = 0
316 while $j < 64
317   if $i == 64
318     set $i = 0
319   end
320   if freeinfo[$i].line != 0
321     printf "%6d\t%10d.%06d\t%6d\t\t%6d\t0x%08x\t%6d\t\t%s\n", $i, freeinfo [$i].time.tv_sec, freeinfo [$i].time.tv_usec, freeinfo [$i].seq, freeinfo[$i].size, freeinfo[$i].address, freeinfo[$i].line, &freeinfo[$i].file
322   end
323   set $i = $i + 1
324   set $j = $j + 1
325 end
326 end
327 document finfo
328 Show recently freed Vinum memory blocks.
329 end