Hiten Pandya and Matt Dillon have put together a debug script area for the kernel. Pasted here is Hiten’s commit message.
“Add a debug directory under src/test, where we will house all of our debug scripts that will aid the debugging of the kernel and other code.
I have added a GDB macro set in file ‘gdb.kernel’ which contains some helpful macros, such as listing processes, iterating CPU’s globaldata, a kldstat(1) style macro etc.
The ‘gdb.kernel’ file was written by: Hiten Pandya and Matthew Dillon
The kldstat(1) macro should be helpful with the asf(1) utility which is used for setting the right offset to load the KLD’s symbols.”