Pre-2.0 release, MFC firewire disk changes to properly detach SIMs.
[dragonfly.git] / test / debug / gdb.kernel
blob2643e3173d45fc7898cb41ba3053342cea83e4b8
1 # $DragonFly: src/test/debug/gdb.kernel,v 1.4 2005/07/28 15:48:56 hmp Exp $
3 # Command file for the GNU Debugger, for kernel debugging.
5 # This file can either be put in your home directory as ~/.gdbinit,
6 # or selected at run time as:
8 #       'gdb -k -q -x /usr/src/test/debug/gdb.kernel ...'
10 # Here is a list of macros and short one-line descriptions:
12 #    kldstat    - kldstat(1) command style output of loaded modules 
13 #    pcomm      - print command name of arg0's (thread's) process pointer
14 #    psx        - process listing with wchan information
15 #    running_threads - the current running thread on each CPU.
17 set print union
18 set history expansion on
20 define pcomm
21         printf "%10s\n",$arg0->td_comm
22 end
24 define lsvfs
25         set $vfc = vfsconf->vfc_next
26         printf "Filesystem      Refs    Flags\n"
27         while ($vfc != 0)
28                 printf "%-10s %6d       0x%08x\n", $vfc->vfc_name, \
29                         $vfc->vfc_refcount, $vfc->vfc_flags
30                 set $vfc = $vfc->vfc_next
31         end
32 end
34 define lsmount
35         set $mnt = (mountlist->tqh_first)
36         while ($mnt != 0)
37                 print *$mnt
38                 set $mnt = $mnt->mnt_list->tqe_next
39         end
40 end
42 define lsvfsops
43         set $vfc = vfsconf->vfc_next
44         while ($vfc != 0)
45                 printf "Filesystem: %s, Refs: %d, Flags: 0x%08x\n", \
46                         $vfc->vfc_name, $vfc->vfc_refcount, $vfc->vfc_flags
47                 printf "VFS ops: \n"
48                 set print pretty
49                 print *$vfc->vfc_vfsops
50                 set print pretty off
51                 set $vfc = $vfc->vfc_next
52         end
53 end
56 define kldstat
57         set $kld = linker_files.tqh_first
58         printf "Id Refs Address    Size     Name\n"
59         while ($kld != 0)
60                 printf "%2d %4d 0x%08x %-8x %s\n", \
61                 $kld->id, $kld->refs, $kld->address, $kld->size, $kld->filename
62                 set $kld = $kld->link.tqe_next
63         end
64 end
66 define psx 
67     set $cpu = 0
68     printf "cpu  pid    thread    flags comm       wchan wmesg\n"
69     while ($cpu < ncpus)
70         set $gd = &((struct privatespace *)&CPU_prvspace)[$cpu].mdglobaldata
71         set $td = $gd->mi.gd_tdallq.tqh_first
72         while ( $td != 0 )
73             if ( $td->td_proc != 0 )
74                 set $pid = $td->td_proc->p_pid
75             else
76                 set $pid = -1
77             end
78             if ( $td->td_wmesg != 0 )
79                 printf "%3d %5d %08x %08x %-10s %08x %s\n",     \
80                     $cpu, $pid, $td, $td->td_flags, $td->td_comm, $td->td_wchan, \
81                     $td->td_wmesg
82             else
83                 printf "%3d %5d %08x %08x %-10s %08x\n",        \
84                     $cpu, $pid, $td, $td->td_flags, $td->td_comm, $td->td_wchan
85             end
86             set $td = $td->td_allq.tqe_next
87         end
88         set $cpu = $cpu + 1
89     end
90 end
93 define running_threads
94     set $icpu = 0
95         printf "cpu    curthread    wchan\n"
96         while ($icpu < ncpus)
97             set $ipvspace = (struct privatespace *)&CPU_prvspace
98                 set $gd = $ipvspace[$icpu].mdglobaldata.mi
99                 set $td = $gd.gd_curthread
100             printf "%d    %10s    %08x\n", \
101                         $gd.gd_cpuid, $td->td_comm, $td->td_wchan
102             set $icpu = $icpu + 1
103         end
106 define psax
107     set $proc = allproc->lh_first
108     while $proc != 0
109         printf "%p%6d%10s\n",$proc,$proc->p_pid,$proc->p_thread->td_comm
110         set $proc = $proc->p_list.le_next
111     end
114 # Documentation, usable within GDB using the 'help' command.
115 document lsvfs
116 Output list of loaded file systems, refcount, similar to the
117 lsvfs(1) utility.
120 document lsmount
121 Iterate the current list of mount structures loaded from the
122 memory core, there should be one per loaded VFS.
125 document lsvfsops
126 Display the VFS operations vector for each file system found in
127 the memory core, preceded by a summarised header.
130 document kldstat
131 Output list of loaded kernel modules in kldstat(1) style.
134 document pcomm
135 Print command name of the given thread pointer (first argument).
138 document psx
139 Output a list of processes with wait-channel (wchan) informaiton.
142 document running_threads
143 List the threads which are currently running and their CPU number.
146 document psax
147 Output a list of processes.