http://allmybrain.com/Debugging Linux Kernel Modules with VirtualBox and KGDBPosted in April 29th, 2010
by Dennis
in Programming
I found a few different pages with information on debugging a Linux kernel with kgdb. There wasn't a single source with all the information I needed to get set up and working though. So here is how I set things up on my Linux host machine to debug a target Linux kernel running in a VirtualBox VM.
You need to convert the pipe that VirtualBox created to a serial port like object. socat does that job: Notice that your dev is pts/3. Now we make a .gdbinit file so you can start gdb without typing the commands every time. file vmlinux set remotebaud 115200 target remote /dev/pts/3 You'll change your pts setting to whatever is relevant. start gdb. On the target, when you send the g to sysrq-trigger, you should drop to a breakpoint in gdb. Next job is to load the module symbols. > add-symbol-file <path to module> <.text address> > b some_file.c:NNN > c Now you can set breakpoints or press c to continue. The target should continue until it comes to a breakpoint or encounters an error. A last tidbit, when I wanted to close gdb on the host, use detach instead of quit. Happy debugging! |