aac.gdb gdb debug script

define aacqinfo
    set $sc=(struct aac_softc*)$arg0
    set $qstat=$sc->aac_qstat

    printf "Queue stats\n"
    printf "#\tName\t\tLength\tMax\n"
    printf "%d\tFREE\t\t%d\t%d\n",  0, $qstat[0].q_length, $qstat[0].q_max
    printf "%d\tBIO\t\t%d\t%d\n",   1, $qstat[1].q_length, $qstat[1].q_max
    printf "%d\tREADY\t\t%d\t%d\n", 2, $qstat[2].q_length, $qstat[2].q_max
    printf "%d\tBUSY\t\t%d\t%d\n",  3, $qstat[3].q_length, $qstat[3].q_max
end

define aacq_busy
    set $sc=(struct aac_softc*)$arg0
    set $qentry=$sc->aac_busy.tqh_first
    printf "Addr\t\tType\tDelay\n"
    while ($qentry != 0)
        printf "%p\t%d\t%d\n", $qentry, $qentry->cm_fib->Header.Command, time_uptime - $qentry->cm_timestamp
        set $qentry=$qentry->cm_link.tqe_next
    end
end
  1. Source the aac.gdb file
    (kgdb) source ~/gdb/aac.gdb
  2. Locate the aac0aif thread from info threads.
    (kgdb) info threads
    ...
      25 Thread 100020 (PID=24: aac0aif)  sched_switch (td=0xa47f44b0, 
        newtd=0xa75e7640, flags=1) at atomic.h:265
    ...
    (kgdb) thread 25
    [Switching to thread 25 (Thread 100020)]#0  sched_switch (td=0xa47f44b0, 
        newtd=0xa75e7640, flags=1) at atomic.h:265
    265     atomic.h: No such file or directory.
            in atomic.h
  3. Find the aac_softc pointer from aac_command_thread.
    (kgdb) bt
    #0  sched_switch (td=0xa47f44b0, newtd=0xa75e7640, flags=1) at atomic.h:265
    #1  0xa05d2a46 in mi_switch (flags=1, newtd=0x0)
        at /usr/src/sys/kern/kern_synch.c:338
    #2  0xa05ee0e7 in sleepq_switch (wchan=0x0)
        at /usr/src/sys/kern/subr_sleepqueue.c:445
    #3  0xa05ee2b8 in sleepq_timedwait (wchan=0x0)
        at /usr/src/sys/kern/subr_sleepqueue.c:562
    #4  0xa05d2702 in msleep (ident=0xa4816c48, mtx=0xa48e0134, priority=76, 
        wmesg=0x0, timo=50000) at /usr/src/sys/kern/kern_synch.c:207
    #5  0xa0497482 in aac_command_thread (sc=0xa48e0000)
        at /usr/src/sys/dev/aac/aac.c:928
    #6  0xa05aeb08 in fork_exit (callout=0xa04973de <aac_command_thread>, 
        arg=0x0, frame=0x0) at /usr/src/sys/kern/kern_fork.c:812
    #7  0xa07a7d9c in fork_trampoline () at /usr/src/sys/i386/i386/exception.s:208
    (kgdb) frame 5
    #5  0xa0497482 in aac_command_thread (sc=0xa48e0000)
        at /usr/src/sys/dev/aac/aac.c:928
    928     /usr/src/sys/dev/aac/aac.c: No such file or directory.
            in /usr/src/sys/dev/aac/aac.c
    (kgdb) p sc 
    $8 = (struct aac_softc *) 0xa48e0000
  4. Run the aac.gdb commands
    (kgdb) aacqinfo $sc
    Queue stats
    #       Name            Length  Max
    0       FREE            227     246
    1       BIO             0       1
    2       READY           0       1
    3       BUSY            19      137
    (kgdb) aacq_busy $sc
    Addr            Type    Delay
    0xa48ec040      502     25
    0xa48eb900      502     25
    0xa48e9a80      502     25
    0xa48eb140      502     25
    0xa48ec6c0      502     25
    0xa48eb2c0      502     25
    0xa48e9a00      502     25
    0xa48e9100      502     25
    0xa48e9f80      502     25
    0xa48eab40      502     25
    0xa48eab00      502     25
    0xa48ebc00      502     25
    0xa48ebfc0      502     25
    0xa48eb400      502     25
    0xa48e9b40      502     25
    0xa48ec240      502     25
    0xa48eb340      502     25
    0xa48eb540      502     25
    0xa48ea380      600     25

EdMaste/aac (last edited 2010-10-26 19:27:07 by EdMaste)