Make the entire BUF/BIO system BIO-centric instead of BUF-centric. Vnode
[dragonfly.git] / sys / dev / raid / vinum / .gdbinit.kernel
1 # $DragonFly: src/sys/dev/raid/vinum/.gdbinit.kernel,v 1.3 2006/02/17 19:18:06 dillon Exp $
2 set remotebaud 38400
3 set remotetimeout 1
4 set complaints 1
5 set print pretty
6 define xi
7 x/10i $eip
8 end
9 define xs
10 x/12x $esp
11 end
12 define xb
13 x/12x $ebp
14 end
15 define z
16 ni
17 x/1i $eip
18 end
19 define zs
20 si
21 x/1i $eip
22 end
23 define xp
24 printf "      esp: " 
25 output/x $esp
26 echo  (
27 output (((int)$ebp)-(int)$esp)/4-4
28 printf " words on stack)\n      ebp: " 
29 output/x $ebp
30 printf "\n      eip: " 
31 x/1i $eip
32 printf "Saved ebp: " 
33 output/x *(int*)$ebp
34 printf " (maximum of "  
35 output ((*(int*)$ebp)-(int)$ebp)/4-4
36 printf " parameters possible)\nSaved eip: " 
37 x/1i *(int*)($ebp+4)
38 printf "\nParm 1 at " 
39 output/x (int) ($ebp+8)
40 printf ":    " 
41 output (char*) *(int*)($ebp+8)
42 printf "\nParm 2 at " 
43 output/x (int) ($ebp+12)
44 printf ":    " 
45 output (char*) *(int*)($ebp+12)
46 printf "\nParm 3 at " 
47 output/x (int) ($ebp+16)
48 printf ":    " 
49 output (char*) *(int*)($ebp+16)
50 printf "\nParm 4 at " 
51 output/x (int) ($ebp+20)
52 printf ":    " 
53 output (char*) *(int*)($ebp+20)
54 echo \n
55 end
56 document xp
57 Show the register contents and the first four parameter
58 words of the current frame.
59 end
60 define xxp
61 printf "      esp: " 
62 output/x $esp
63 printf "\n      ebp: " 
64 output/x $ebp
65 printf "\n      eip: " 
66 x/1i $eip
67 printf "Saved ebp: " 
68 output/x *(int*)$ebp
69 printf " (maximum of "  
70 output ((*(int*)$ebp)-(int)$ebp)/4-4
71 printf " parameters possible)\nSaved eip: " 
72 x/1i *(int*)($ebp+4)
73 printf "\nParm  1 at " 
74 output/x (int) ($ebp+8)
75 printf ":    " 
76 output (char*) *(int*)($ebp+8)
77 printf "\nParm  2 at " 
78 output/x (int) ($ebp+12)
79 printf ":    " 
80 output (char*) *(int*)($ebp+12)
81 printf "\nParm  3 at " 
82 output/x (int) ($ebp+16)
83 printf ":    " 
84 output (char*) *(int*)($ebp+16)
85 printf "\nParm  4 at " 
86 output/x (int) ($ebp+20)
87 printf ":    " 
88 output (char*) *(int*)($ebp+20)
89 printf "\nParm  5 at " 
90 output/x (int) ($ebp+24)
91 printf ":    " 
92 output (char*) *(int*)($ebp+24)
93 printf "\nParm  6 at " 
94 output/x (int) ($ebp+28)
95 printf ":    " 
96 output (char*) *(int*)($ebp+28)
97 printf "\nParm  7 at " 
98 output/x (int) ($ebp+32)
99 printf ":    " 
100 output (char*) *(int*)($ebp+32)
101 printf "\nParm  8 at " 
102 output/x (int) ($ebp+36)
103 printf ":    " 
104 output (char*) *(int*)($ebp+36)
105 printf "\nParm  9 at " 
106 output/x (int) ($ebp+40)
107 printf ":    " 
108 output (char*) *(int*)($ebp+40)
109 printf "\nParm 10 at " 
110 output/x (int) ($ebp+44)
111 printf ":    " 
112 output (char*) *(int*)($ebp+44)
113 echo \n
114 end
115 document xxp
116 Show the register contents and the first ten parameter
117 words of the current frame.
118 end
119 define xp0
120 x/12x *(int*)$esp
121 p *(int*)$esp
122 p (char*)*$esp
123 end
124 define xp1
125 x/12x *(int*)($ebp+4)
126 p *(int*)($ebp+4)
127 p (char**)($ebp+4)
128 end
129 define xp2
130 x/12x *(int*)($ebp+8)
131 p *(int*)($ebp+8)
132 p *(char**)($ebp+8)
133 end
134 define xp3
135 x/12x *(int*)($ebp+12)
136 p *(int*)($ebp+12)
137 p (char**)($ebp+12)
138 end
139 define xp4
140 x/12x *(int*)($ebp+16)
141 p *(int*)($ebp+16)
142 p (char**)($ebp+16)
143 end
144 document xp0
145 Show the first parameter of current stack frame in various formats
146 end
147 document xp1
148 Show the second parameter of current stack frame in various formats
149 end
150 document xp2
151 Show the third parameter of current stack frame in various formats
152 end
153 document xp3
154 Show the fourth parameter of current stack frame in various formats
155 end
156 document xp4
157 Show the fifth parameter of current stack frame in various formats
158 end
159 define f0
160 f 0
161 xp
162 end
163 define f1
164 f 1
165 xp
166 end
167 define f2
168 f 2
169 xp
170 end
171 define f3
172 f 3
173 xp
174 end
175 define f4
176 f 4
177 xp
178 end
179 define f5
180 f 5
181 xp
182 end
183 document f0
184 Select stack frame 0 and show assembler-level details
185 end
186 document f1
187 Select stack frame 1 and show assembler-level details
188 end
189 document f2
190 Select stack frame 2 and show assembler-level details
191 end
192 document f3
193 Select stack frame 3 and show assembler-level details
194 end
195 document f4
196 Select stack frame 4 and show assembler-level details
197 end
198 document f5
199 Select stack frame 5 and show assembler-level details
200 end
201 document z
202 Single step 1 instruction (over calls) and show next instruction.
203 end
204 document zs
205 Single step 1 instruction (through calls) and show next instruction.
206 end
207 document xi
208 List the next 10 instructions from the current IP value
209 end
210 document xs
211 Show the last 12 words on stack in hex
212 end
213 document xb
214 Show 12 words starting at current BP value in hex
215 end
216 define tr
217 target remote /dev/cuaa1
218 end
219 document tr
220 Attach to a remote kernel via /dev/cuaa0
221 end
222 set output-radix 16
223 define pname
224 p (char *)curproc->p_comm
225 end 
226 document pname
227 Print the command name of the current process
228 end
229 define bpp
230 set $bp = (struct buf *) $arg0
231     if $bp->b_dev
232       printf "  Buffer at 0x%x: dev 0x%x  data 0x%x  bcount 0x%x  blkno 0x%x resid 0x%x\n", \
233         $bp, \
234         $bp->b_dev->si_udev, \
235         $bp->b_data, \
236         $bp->b_bcount, \
237         $bp->b_bio->bio_blkno, \
238         $bp->b_resid
239     else
240       printf "  Buffer at 0x%x: dev (none) data 0x%x  bcount 0x%x  blkno 0x%x resid 0x%x\n", \
241         $bp, \
242         $bp->b_data, \
243         $bp->b_bcount, \
244         $bp->b_bio->bio_blkno, \
245         $bp->b_resid
246     end
247     printf "   flags 0x%x: ", $bp->b_flags
248       if $bp->b_flags & 0x10
249         printf "busy "
250       end
251       if $bp->b_flags & 0x40
252         printf "call "
253       end
254       if $bp->b_flags & 0x200
255         printf "done "
256       end
257       if $bp->b_flags & 0x800
258         printf "error "
259       end
260       if $bp->b_flags & 0x40000
261         printf "phys "
262       end
263       if $bp->b_flags & 0x100000
264         printf "read "
265       end
266     printf "\n"
267 end
268 define bpl
269 set $bp = (struct buf *) $arg0
270 printf "b_proc: "
271 output $bp->b_proc
272 printf "\nb_flags:      "
273 output $bp->b_flags
274 printf "\nb_qindex:     "
275 output $bp->b_qindex
276 printf "\nb_usecount:   "
277 output $bp->b_usecount
278 printf "\nb_error:      "
279 output $bp->b_error
280 printf "\nb_bufsize:    "
281 output $bp->b_bufsize
282 printf "\nb_bcount:     "
283 output $bp->b_bcount
284 printf "\nb_resid:      "
285 output $bp->b_resid
286 printf "\nb_dev:        "
287 output $bp->b_dev
288 printf "\nb_data:       "
289 output $bp->b_data
290 printf "\nb_kvasize:    "
291 output $bp->b_kvasize
292 printf "\nb_lblkno:     "
293 output $bp->b_lblkno
294 printf "\nb_blkno:      "
295 output $bp->b_bio->bio_blkno
296 printf "\nb_iodone:     "
297 output $bp->b_bio->bio_done
298 printf "\nb_vp: "
299 output $bp->b_vp
300 printf "\nb_dirtyoff:   "
301 output $bp->b_dirtyoff
302 printf "\nb_dirtyend:   "
303 output $bp->b_dirtyend
304 printf "\nb_generation: "
305 output $bp->b_generation
306 printf "\nb_validoff:   "
307 output $bp->b_validoff
308 printf "\nb_validend:   "
309 output $bp->b_validend
310 printf "\nb_pblkno:     "
311 output $bp->b_pblkno
312 printf "\nb_saveaddr:   "
313 output $bp->b_saveaddr
314 printf "\nb_savekva:    "
315 output $bp->b_savekva
316 printf "\nb_driver1:    "
317 output $bp->b_driver1
318 printf "\nb_driver2:    "
319 output $bp->b_driver2
320 printf "\nb_spc:        "
321 output $bp->b_spc
322 printf "\nb_npages:     "
323 output $bp->b_npages
324 printf "\n"
325 end
326 define bp
327 bpp bp
328 end
329 define bpd
330     printf "Buffer data:\n%s", (char *) bp->b_data
331 end
332 document bpd
333 Show the contents (char*) of bp->data in the current frame.
334 end
335 document bp
336 Show information about the buffer header pointed to by the
337 variable bp in the current frame.
338 end
339 document bpp
340 Show summary information about the buffer header (struct bp) pointed
341 at by the parameter.
342 end
343 document bpl
344 Show detailled information about the buffer header (struct bp) pointed
345 at by the parameter.
346 end
347 document bpl
348 Show detailled information about the buffer header (struct bp) pointed
349 at by the local variable bp.
350 end
351 define bx
352 printf "\n b_vnbufs " 
353 output/x bp->b_vnbufs
354 printf "\n b_freelist " 
355 output/x bp->b_freelist
356 printf "\n b_act " 
357 output/x bp->b_act
358 printf "\n b_flags " 
359 output/x bp->b_flags
360 printf "\n b_qindex " 
361 output/x bp->b_qindex
362 printf "\n b_usecount " 
363 output/x bp->b_usecount
364 printf "\n b_error " 
365 output/x bp->b_error
366 printf "\n b_bufsize " 
367 output/x bp->b_bufsize
368 printf "\n b_bcount " 
369 output/x bp->b_bcount
370 printf "\n b_resid " 
371 output/x bp->b_resid
372 printf "\n b_dev " 
373 output/x bp->b_dev
374 printf "\n b_data " 
375 output/x bp->b_data
376 printf "\n b_kvasize " 
377 output/x bp->b_kvasize
378 printf "\n b_blkno " 
379 output/x bp->b_bio->bio_blkno
380 printf "\n b_vp " 
381 output/x bp->b_vp
382 printf "\n b_dirtyoff " 
383 output/x bp->b_dirtyoff
384 printf "\n b_validoff " 
385 output/x bp->b_validoff
386 echo \n
387 end
388 define ddb
389 set boothowto=0x80000000
390 s
391 end
392 document ddb
393 Switch back to ddb.
394 end
395 define ps
396     set $nproc = nprocs
397     set $aproc = allproc.lh_first
398     set $proc = allproc.lh_first
399     printf "  pid    proc    addr   uid  ppid  pgrp   flag stat comm         wchan\n"
400     while (--$nproc >= 0)
401         set $pptr = $proc.p_pptr
402         if ($pptr == 0)
403            set $pptr = $proc
404         end
405         if ($proc.p_stat)
406             printf "%5d %08x %08x %4d %5d %5d  %06x  %d  %-10s   ", \
407                    $proc.p_pid, $aproc, \
408                    $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
409                    $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
410                    &$proc.p_comm[0]
411             if ($proc.p_wchan)
412                 if ($proc.p_wmesg)
413                     printf "%s ", $proc.p_wmesg
414                 end
415                 printf "%x", $proc.p_wchan
416             end
417             printf "\n"
418         end
419         set $aproc = $proc.p_list.le_next
420         if ($aproc == 0 && $nproc > 0)
421             set $aproc = zombproc
422         end
423         set $proc = $aproc
424     end
425 end
426 document ps
427 "ps" -- when kernel debugging, type out a ps-like listing of active processes.
428 end
429 define pcb
430     set $nproc = nprocs
431     set $aproc = allproc.lh_first
432     set $proc = allproc.lh_first
433     while (--$nproc >= 0)
434         set $pptr = $proc.p_pptr
435         if ($proc->p_pid == $arg0)
436            set $pcba = $pptr->p_addr->u_pcb
437            printf "ip: %08x sp: %08x bp: %08x bx: %08x\n", $pcba->pcb_eip, $pcba->pcb_esp, $pcba->pcb_ebp, $pcba->pcb_ebx
438            x/1i $pcba->pcb_eip
439            set $nproc = 0
440         end
441         set $aproc = $proc.p_list.le_next
442         if ($aproc == 0 && $nproc > 0)
443             set $aproc = zombproc
444         end
445         set $proc = $aproc
446     end
447 end
448 document pcb
449 Show some pcb contents of process whose pid is specified.
450 end
451 define btr
452 set $frame = $arg0
453 set $fno = 0
454 while (*(int *) $frame > 0xc0000000)
455   set $myebp = *(int *) $frame
456   set $myeip = *(int *) ($frame + 4)
457   printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
458   x/1i $myeip
459   set $frame = $myebp
460   set $fno = $fno + 1
461 end
462 end
463 document btr
464 Show a backtrace from the ebp address specified.  This can be used to
465 get a backtrace from any stack resident in memory.
466 end
467 define btp
468     set $nproc = nprocs
469     set $aproc = allproc.lh_first
470     set $proc = allproc.lh_first
471     while (--$nproc >= 0)
472         if ($proc->p_pid == $arg0)
473            btr $proc->p_addr->u_pcb->pcb_ebp
474            set $nproc = 0
475         else
476            set $aproc = $proc.p_list.le_next
477            if ($aproc == 0 && $nproc > 0)
478               set $aproc = zombproc
479            end
480            set $proc = $aproc
481         end
482    end
483 end
484 document btp
485 Show a backtrace for the process whose pid is specified as a parameter.
486 end
487 define btpa
488     set $nproc = nprocs
489     set $aproc = allproc.lh_first
490     set $proc = allproc.lh_first
491     printf "  pid    proc    addr   uid  ppid  pgrp   flag stat comm         wchan\n"
492     while (--$nproc >= 0)
493         set $pptr = $proc.p_pptr
494         if ($pptr == 0)
495            set $pptr = $proc
496         end
497         if ($proc.p_stat)
498             printf "%5d %08x %08x %4d %5d %5d  %06x %d  %-10s   ", \
499                    $proc.p_pid, $aproc, \
500                    $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
501                    $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
502                    &$proc.p_comm[0]
503             if ($proc.p_wchan)
504                 if ($proc.p_wmesg)
505                     printf "%s ", $proc.p_wmesg
506                 end
507                 printf "%x", $proc.p_wchan
508             end
509             printf "\n"
510            if ($proc->p_flag & 4)
511               btr $proc->p_addr->u_pcb->pcb_ebp
512            else
513               echo (not loaded)\n
514            end
515         end
516         set $aproc = $proc.p_list.le_next
517         if ($aproc == 0 && $nproc > 0)
518             set $aproc = zombproc
519         end
520         set $proc = $aproc
521     end
522 end
523 document btpa
524 Show backtraces for all processes in the system.
525 end
526 define btpp
527   if ($myvectorproc->p_flag & 4)
528     btr $myvectorproc->p_addr->u_pcb->pcb_ebp
529   else
530     echo (not loaded)\n
531   end
532 end
533 document btpp
534 Show a backtrace for the process previously selected with 'defproc'.
535 end
536 define defproc
537     set $nproc = nprocs
538     set $aproc = allproc.lh_first
539     set $proc = allproc.lh_first
540     while (--$nproc >= 0)
541         if ($proc->p_pid == $arg0)
542            set $pptr = $proc.p_pptr
543            if ($pptr == 0)
544               set $pptr = $proc
545            end
546            set $myvectorproc = $proc
547            if ($proc.p_stat)
548                printf "%5d %08x %08x %4d %5d %5d  %06x %d  %-10s   ", \
549                       $proc.p_pid, $aproc, \
550                       $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
551                      $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
552                      &$proc.p_comm[0]
553                if ($proc.p_wchan)
554                    if ($proc.p_wmesg)
555                        printf "%s ", $proc.p_wmesg
556                   end
557                   printf "%x", $proc.p_wchan
558                end
559                printf "\n"
560               end
561            btpp
562            set $nproc = 0
563         else
564            set $proc = $proc.p_list.le_next
565         end
566    end
567 end
568 document defproc
569 Specify a process for btpp and fr commands.
570 end
571 define fr
572 set $fno = 0
573 set $searching = 1
574 if ($myvectorproc->p_flag & 4)
575   set $frame = $myvectorproc->p_addr->u_pcb->pcb_ebp
576   while (($searching == 1) && (*(int *) $frame > 0xc0000000))
577     set $myebp = *(int *) $frame
578     set $myeip = *(int *) ($frame + 4)
579     if ($fno == $arg0)
580       printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
581       x/1i $myeip
582       printf "Called from %8x, stack frame at %8x\n", *(int *) ($myebp+4), *(int *) $myebp
583       printf "last 20 local variables:\n"
584       x/20x ($myebp-80)
585       printf "call parameters:\n"
586       x/8x ($myebp+8)
587       set $searching = 0
588     else
589       set $frame = $myebp
590       set $fno = $fno + 1
591     end
592   end
593   if ($searching == 1)
594     echo frame not found\n
595   end
596 else
597   printf "process %d is not loaded in memory\n", $myvectorproc->p_pid
598 end
599 end
600 document fr
601 Show the frame of the stack of the process previously selected with 'defproc'.
602 end
603 set height 70
604 set width 120
605 define vdev
606 if (vp->v_type == VBLK)
607   p *vp->v_un.vu_spec.vu_specinfo
608   printf "numoutput: %d\n", vp->v_numoutput
609 else
610   echo "Not a block device"
611 end
612 end
613 document vdev
614 Show some information of the vnode pointed to by the local variable vp.
615 end
616 define y
617 echo Check your .gdbinit, it contains a y command\n
618 end
619 define kldstat
620    set $file = files.tqh_first
621    printf "Id Refs Address    Size     Name\n"
622    while ($file != 0)
623      printf "%2d %4d 0x%8x %8x %s\n",   \
624         $file->id,                      \
625         $file->refs,                    \
626         $file->address,                 \
627         $file->size,                    \
628         $file->filename
629      set $file = $file->link.tqe_next
630    end
631 end
632 document kldstat
633 Equivalent of the kldstat(9) command, without options.
634 end
635 define msgbuf
636 printf "%s", msgbufp->msg_ptr
637 end
638 document msgbuf
639 Print the system message buffer (dmesg).  This can take a long time due to the time it takes to transmit the data across a serial line.
640 end