Conceptually understanding how KGDB works
KGDB is a source-level debugger, allowing you to debug kernel (and module) code at the level of the C source file(s)!
Hang on a moment though. In order for an application process such as GDB to debug the kernel, it will need to halt the kernel's execution upon it hitting a breakpoint and while single-stepping code paths within the kernel. How is that possible? What will run the GDB process (and the rest of the system) then?
The reality is that GDB, supporting a client-server architecture, is used with two machines: one, a host system where the client GDB program runs (the one we're used to working with); the other, the target system, where the GDB server component is embedded into the kernel itself! (Unlike typical client/server apps, the GDB server component is the smaller of the two, and the GDB client is the relatively large one – the regular GDB program you're used to using.)