linuxgdbqemu

GDB hangs after continuing from "start_kernel" breakpoint?


I am trying to familiarize myself with the Linux kernel source code. So, I figured I would setup a Qemu machine that boots the kernel (using debug settings) so that I can interact with the kernel using GDB and explore different areas of the kernel. This way I have a machine running the kernel and can reference the source code at the same time.

I have installed Qemu and compiled the Linux kernel on an Ubuntu machine. I can successfully connect to the Qemu machine remotely on my Ubuntu machine with GDB.

But now I am stumped. I set a breakpoint at "start_kernel" and the Qemu machine does break as expected. However, once I press "c" in GDB, I lose control of GDB as it just hangs (waiting for the Qemu machine, I think). My Qemu machine drops into a shell at this point.

So, I am looking for some advice has to how I can continue setting breakpoints, dumping information, and more within GDB?


Solution

  • At the GDB prompt you can use Ctrl+c to interrupt (pause) the inferior (your kernel), so you can inspect the state and set new breakpoints.