So I'm no kernel dev and only did a web search out of curiosity... Based on https://www.kernel.org/doc/html/latest/process/debugging/gdb... and https://sergioprado.blog/debugging-the-linux-kernel-with-gdb... , it reads as if it's fairly easy so long as you're willing to compile the kernel yourself. Actually, at that point I would personally favor UML, since at that point Linux is just a normal userspace program that you can attach to: https://www.kernel.org/doc/html/latest/virt/uml/user_mode_li...

But I'm not a kernel dev and it's been a very long time since I would have needed to debug the kernel; does this not actually work?