1 # $DragonFly: src/test/debug/gdb.kernel,v 1.3 2005/04/04 14:19:10 joerg 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.
18 set history expansion on
21 printf "%10s\n",$arg0->td_comm
25 set $kld = linker_files.tqh_first
26 printf "Id Refs Address Size Name\n"
28 printf "%2d %4d 0x%08x %-8x %s\n", \
29 $kld->id, $kld->refs, $kld->address, $kld->size, $kld->filename
30 set $kld = $kld->link.tqe_next
36 printf "cpu pid thread flags comm wchan wmesg\n"
38 set $gd = &((struct privatespace *)&CPU_prvspace)[$cpu].mdglobaldata
39 set $td = $gd->mi.gd_tdallq.tqh_first
41 if ( $td->td_proc != 0 )
42 set $pid = $td->td_proc->p_pid
46 if ( $td->td_wmesg != 0 )
47 printf "%3d %5d %08x %08x %-10s %08x %s\n", \
48 $cpu, $pid, $td, $td->td_flags, $td->td_comm, $td->td_wchan, \
51 printf "%3d %5d %08x %08x %-10s %08x\n", \
52 $cpu, $pid, $td, $td->td_flags, $td->td_comm, $td->td_wchan
54 set $td = $td->td_allq.tqe_next
61 define running_threads
63 printf "cpu curthread wchan\n"
65 set $ipvspace = (struct privatespace *)&CPU_prvspace
66 set $gd = $ipvspace[$icpu].mdglobaldata.mi
67 set $td = $gd.gd_curthread
68 printf "%d %10s %08x\n", \
69 $gd.gd_cpuid, $td->td_comm, $td->td_wchan
75 set $proc = allproc->lh_first
77 printf "%p%6d%10s\n",$proc,$proc->p_pid,$proc->p_thread->td_comm
78 set $proc = $proc->p_list.le_next
82 # Documentation, usable within GDB using the 'help' command.
84 Output list of loaded kernel modules in kldstat(1) style.
88 Print command name of the given thread pointer (first argument).
92 Output a list of processes with wait-channel (wchan) informaiton.
95 document running_threads
96 List the threads which are currently running and their CPU number.
100 Output a list of processes.