Check out the new USENIX Web site. next up previous
Next: Isolation Up: Applications Previous: Applications

Kernel debugging

This port was originally conceived as a kernel debugging tool. A user-mode kernel port makes it possible to do kernel development without needing a separate test machine. It also enables the use of the standard suite of process development and debugging tools, like gdb, gcov, and gprof, on the kernel.

A difficulty with using gdb is that the kernel's threads are already being ptraces by the tracing thread. This makes it impossible for gdb to attach to them to debug them. Early on, this problem was dealt with by having the tracing thread detach from the thread of interest. Then, gdb could attach to it, and it could be debugged as a normal process. Rarely, when this was over, the thread was re-attached by the tracing thread, and the kernel continued. More often, the whole kernel was killed at the end of that debugging session.

Now, there is a mechanism that allows gdb to debug a kernel thread without needing to attach to it, and without needing to detach the tracing thread from it. This works by having the tracing thread start gdb under system call tracing. The tracing thread intercepts ptrace system calls and a few others made by gdb, executes them itself, nullifies the gdb system call, and writes the return value into the appropriate register in gdb. In this way, gdb is faked into believing that it is attached to the thread and is debugging it.


next up previous
Next: Isolation Up: Applications Previous: Applications
Jeff Dike 2000-08-23