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