Initial import from FreeBSD RELENG_4:
[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_rcred:      "
306 output $bp->b_rcred
307 printf "\nb_wcred:      "
308 output $bp->b_wcred
309 printf "\nb_validoff:   "
310 output $bp->b_validoff
311 printf "\nb_validend:   "
312 output $bp->b_validend
313 printf "\nb_pblkno:     "
314 output $bp->b_pblkno
315 printf "\nb_saveaddr:   "
316 output $bp->b_saveaddr
317 printf "\nb_savekva:    "
318 output $bp->b_savekva
319 printf "\nb_driver1:    "
320 output $bp->b_driver1
321 printf "\nb_driver2:    "
322 output $bp->b_driver2
323 printf "\nb_spc:        "
324 output $bp->b_spc
325 printf "\nb_npages:     "
326 output $bp->b_npages
327 printf "\n"
328 end
329 define bp
330 bpp bp
331 end
332 define bpd
333     printf "Buffer data:\n%s", (char *) bp->b_data
334 end
335 document bpd
336 Show the contents (char*) of bp->data in the current frame.
337 end
338 document bp
339 Show information about the buffer header pointed to by the
340 variable bp in the current frame.
341 end
342 document bpp
343 Show summary 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 parameter.
349 end
350 document bpl
351 Show detailled information about the buffer header (struct bp) pointed
352 at by the local variable bp.
353 end
354 define bx
355 printf "\n b_vnbufs " 
356 output/x bp->b_vnbufs
357 printf "\n b_freelist " 
358 output/x bp->b_freelist
359 printf "\n b_act " 
360 output/x bp->b_act
361 printf "\n b_flags " 
362 output/x bp->b_flags
363 printf "\n b_qindex " 
364 output/x bp->b_qindex
365 printf "\n b_usecount " 
366 output/x bp->b_usecount
367 printf "\n b_error " 
368 output/x bp->b_error
369 printf "\n b_bufsize " 
370 output/x bp->b_bufsize
371 printf "\n b_bcount " 
372 output/x bp->b_bcount
373 printf "\n b_resid " 
374 output/x bp->b_resid
375 printf "\n b_dev " 
376 output/x bp->b_dev
377 printf "\n b_data " 
378 output/x bp->b_data
379 printf "\n b_kvasize " 
380 output/x bp->b_kvasize
381 printf "\n b_blkno " 
382 output/x bp->b_blkno
383 printf "\n b_iodone_chain " 
384 output/x bp->b_iodone_chain
385 printf "\n b_vp " 
386 output/x bp->b_vp
387 printf "\n b_dirtyoff " 
388 output/x bp->b_dirtyoff
389 printf "\n b_validoff " 
390 output/x bp->b_validoff
391 echo \n
392 end
393 define ddb
394 set boothowto=0x80000000
395 s
396 end
397 document ddb
398 Switch back to ddb.
399 end
400 define ps
401     set $nproc = nprocs
402     set $aproc = allproc.lh_first
403     set $proc = allproc.lh_first
404     printf "  pid    proc    addr   uid  ppid  pgrp   flag stat comm         wchan\n"
405     while (--$nproc >= 0)
406         set $pptr = $proc.p_pptr
407         if ($pptr == 0)
408            set $pptr = $proc
409         end
410         if ($proc.p_stat)
411             printf "%5d %08x %08x %4d %5d %5d  %06x  %d  %-10s   ", \
412                    $proc.p_pid, $aproc, \
413                    $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
414                    $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
415                    &$proc.p_comm[0]
416             if ($proc.p_wchan)
417                 if ($proc.p_wmesg)
418                     printf "%s ", $proc.p_wmesg
419                 end
420                 printf "%x", $proc.p_wchan
421             end
422             printf "\n"
423         end
424         set $aproc = $proc.p_list.le_next
425         if ($aproc == 0 && $nproc > 0)
426             set $aproc = zombproc
427         end
428         set $proc = $aproc
429     end
430 end
431 document ps
432 "ps" -- when kernel debugging, type out a ps-like listing of active processes.
433 end
434 define pcb
435     set $nproc = nprocs
436     set $aproc = allproc.lh_first
437     set $proc = allproc.lh_first
438     while (--$nproc >= 0)
439         set $pptr = $proc.p_pptr
440         if ($proc->p_pid == $arg0)
441            set $pcba = $pptr->p_addr->u_pcb
442            printf "ip: %08x sp: %08x bp: %08x bx: %08x\n", $pcba->pcb_eip, $pcba->pcb_esp, $pcba->pcb_ebp, $pcba->pcb_ebx
443            x/1i $pcba->pcb_eip
444            set $nproc = 0
445         end
446         set $aproc = $proc.p_list.le_next
447         if ($aproc == 0 && $nproc > 0)
448             set $aproc = zombproc
449         end
450         set $proc = $aproc
451     end
452 end
453 document pcb
454 Show some pcb contents of process whose pid is specified.
455 end
456 define btr
457 set $frame = $arg0
458 set $fno = 0
459 while (*(int *) $frame > 0xc0000000)
460   set $myebp = *(int *) $frame
461   set $myeip = *(int *) ($frame + 4)
462   printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
463   x/1i $myeip
464   set $frame = $myebp
465   set $fno = $fno + 1
466 end
467 end
468 document btr
469 Show a backtrace from the ebp address specified.  This can be used to
470 get a backtrace from any stack resident in memory.
471 end
472 define btp
473     set $nproc = nprocs
474     set $aproc = allproc.lh_first
475     set $proc = allproc.lh_first
476     while (--$nproc >= 0)
477         if ($proc->p_pid == $arg0)
478            btr $proc->p_addr->u_pcb->pcb_ebp
479            set $nproc = 0
480         else
481            set $aproc = $proc.p_list.le_next
482            if ($aproc == 0 && $nproc > 0)
483               set $aproc = zombproc
484            end
485            set $proc = $aproc
486         end
487    end
488 end
489 document btp
490 Show a backtrace for the process whose pid is specified as a parameter.
491 end
492 define btpa
493     set $nproc = nprocs
494     set $aproc = allproc.lh_first
495     set $proc = allproc.lh_first
496     printf "  pid    proc    addr   uid  ppid  pgrp   flag stat comm         wchan\n"
497     while (--$nproc >= 0)
498         set $pptr = $proc.p_pptr
499         if ($pptr == 0)
500            set $pptr = $proc
501         end
502         if ($proc.p_stat)
503             printf "%5d %08x %08x %4d %5d %5d  %06x %d  %-10s   ", \
504                    $proc.p_pid, $aproc, \
505                    $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
506                    $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
507                    &$proc.p_comm[0]
508             if ($proc.p_wchan)
509                 if ($proc.p_wmesg)
510                     printf "%s ", $proc.p_wmesg
511                 end
512                 printf "%x", $proc.p_wchan
513             end
514             printf "\n"
515            if ($proc->p_flag & 4)
516               btr $proc->p_addr->u_pcb->pcb_ebp
517            else
518               echo (not loaded)\n
519            end
520         end
521         set $aproc = $proc.p_list.le_next
522         if ($aproc == 0 && $nproc > 0)
523             set $aproc = zombproc
524         end
525         set $proc = $aproc
526     end
527 end
528 document btpa
529 Show backtraces for all processes in the system.
530 end
531 define btpp
532   if ($myvectorproc->p_flag & 4)
533     btr $myvectorproc->p_addr->u_pcb->pcb_ebp
534   else
535     echo (not loaded)\n
536   end
537 end
538 document btpp
539 Show a backtrace for the process previously selected with 'defproc'.
540 end
541 define defproc
542     set $nproc = nprocs
543     set $aproc = allproc.lh_first
544     set $proc = allproc.lh_first
545     while (--$nproc >= 0)
546         if ($proc->p_pid == $arg0)
547            set $pptr = $proc.p_pptr
548            if ($pptr == 0)
549               set $pptr = $proc
550            end
551            set $myvectorproc = $proc
552            if ($proc.p_stat)
553                printf "%5d %08x %08x %4d %5d %5d  %06x %d  %-10s   ", \
554                       $proc.p_pid, $aproc, \
555                       $proc.p_addr, $proc.p_cred->p_ruid, $pptr->p_pid, \
556                      $proc.p_pgrp->pg_id, $proc.p_flag, $proc.p_stat, \
557                      &$proc.p_comm[0]
558                if ($proc.p_wchan)
559                    if ($proc.p_wmesg)
560                        printf "%s ", $proc.p_wmesg
561                   end
562                   printf "%x", $proc.p_wchan
563                end
564                printf "\n"
565               end
566            btpp
567            set $nproc = 0
568         else
569            set $proc = $proc.p_list.le_next
570         end
571    end
572 end
573 document defproc
574 Specify a process for btpp and fr commands.
575 end
576 define fr
577 set $fno = 0
578 set $searching = 1
579 if ($myvectorproc->p_flag & 4)
580   set $frame = $myvectorproc->p_addr->u_pcb->pcb_ebp
581   while (($searching == 1) && (*(int *) $frame > 0xc0000000))
582     set $myebp = *(int *) $frame
583     set $myeip = *(int *) ($frame + 4)
584     if ($fno == $arg0)
585       printf " frame %d at %p: ebp %8x, eip ", $fno, $frame, $myebp
586       x/1i $myeip
587       printf "Called from %8x, stack frame at %8x\n", *(int *) ($myebp+4), *(int *) $myebp
588       printf "last 20 local variables:\n"
589       x/20x ($myebp-80)
590       printf "call parameters:\n"
591       x/8x ($myebp+8)
592       set $searching = 0
593     else
594       set $frame = $myebp
595       set $fno = $fno + 1
596     end
597   end
598   if ($searching == 1)
599     echo frame not found\n
600   end
601 else
602   printf "process %d is not loaded in memory\n", $myvectorproc->p_pid
603 end
604 end
605 document fr
606 Show the frame of the stack of the process previously selected with 'defproc'.
607 end
608 set height 70
609 set width 120
610 define vdev
611 if (vp->v_type == VBLK)
612   p *vp->v_un.vu_spec.vu_specinfo
613   printf "numoutput: %d\n", vp->v_numoutput
614 else
615   echo "Not a block device"
616 end
617 end
618 document vdev
619 Show some information of the vnode pointed to by the local variable vp.
620 end
621 define y
622 echo Check your .gdbinit, it contains a y command\n
623 end
624 define kldstat
625    set $file = files.tqh_first
626    printf "Id Refs Address    Size     Name\n"
627    while ($file != 0)
628      printf "%2d %4d 0x%8x %8x %s\n",   \
629         $file->id,                      \
630         $file->refs,                    \
631         $file->address,                 \
632         $file->size,                    \
633         $file->filename
634      set $file = $file->link.tqe_next
635    end
636 end
637 document kldstat
638 Equivalent of the kldstat(9) command, without options.
639 end
640 define msgbuf
641 printf "%s", msgbufp->msg_ptr
642 end
643 document msgbuf
644 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.
645 end