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