[kdb] [PATCH 0/13] RFC ONLY - kdb for kgdb
Jason Wessel
jason.wessel at windriver.com
Fri May 8 16:23:07 CDT 2009
This patch series is a request for comments on several levels.
1) Do people find kdb useful? (See * and **)
2) Would kdb folks be willing to use it if it was a front end to kgdb?
3) Does kdb have a future in the mainline kernel?
4) Is this a reasonable approach to have some level of
unification to end up with a more robust kernel debugger?
* This is not meant to be a religious war
** This will never replace printk :-)
What follows is a series of patches to the development kernel which
enable kdb as a front end to kgdb for arm, mips, powerpc, and x86.
This is a very raw prototype, but enough of it it works such that
folks can try it out.
To get the most basic functionality, you only need the first 2 patches
in the series. The remainder of the patches go on to incrementally
add back some of the functionality that was removed from kdb. I made
an attempt to try to make the first part just the generic set of
changes required to get kdb working on 1 or more archs.
The kdb front end works a little differently than if you were to take
the original kdb patch set from:
ftp://oss.sgi.com/projects/kdb/download/v4.4/
In the kernel .config you should enable the following options:
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_KGDB_LOW_LEVEL_TRAP=y
CONFIG_KGDB_KDB=y
CONFIG_KGDB_KDB_PRIMARY=y
CONFIG_KDB_KEYBOARD=y
CONFIG_KDB_USB=y
If you were using the serial port with kdb before, now you just use
the kgdboc mechanism with no differences at all. IE use you kernel
command line with:
console=ttyS0,115200 kgdboc=ttyS0 kgdbwait
That will get you access to kdb just after the console has been
registered. If you want to use the keyboard, you could use:
console=tty0 kgdboc=kdb kgdbwait
You can also use the keyboard and or serial console:
console=ttyS0,115200 console=tty0 kgdboc=kdb,ttyS0
In terms of breaking into the debugger after the system is up, you
must use the sysrq-g sequence. That means you could run:
echo g > /proc/sysrq-trigger
Or you can use the SysRq key on your key board. On a typical laptop
you might have to do the following:
press and hold ALT -- You will be holding this the whole time
press and hold FN
press and release the key with the SysRq label
release FN
press and release g
release ALT
I have also found on some PS/2 keyboards you have press alt again
after resuming the system because the key up event got lost somewhere.
Once you are in kdb you can run help to see a limited list of
commands.
You can also still connect gdb or re-enter kdb without leaving the
exception state. To get out of kgdb mode you can type "$3#33", or to
get into kgdb mode from kdb, you can type "kgdb". Also from gdb you
can issue commands to the kdb front end, via gdb's montior command.
For instance you could issue "monitor lsmod". Allowing the gdb
monitor extension was certainly another motivation behind the
prototype.
More information about the kdb
mailing list