How can I debug kernel module running on a virtual machine?

Chan Kim ckim at
Tue Apr 5 05:53:43 EDT 2022

Hello all,

I think I have once read about this but can't find it now.
I'm running linux-5.4.188 on a qemu arm64 virtual machine. Because I built
the kernel from the source, I can debug(analyze) the kernel by attaching to
the linux kernel program running on a remote machine(qemu virtual machine).
To test an application which uses our device(the device model is in qemu
too), I compiled a device driver against kernel 5.4.188 and the linux
application and can do insmod the driver and run the application.  
Now something is wrong and I have panic while running the application. I can
debug linux kernel itself, but I don't know where the kernel module was
loaded, so the debugger cannot debug the driver module. How can I debug the
device driver? (or even the application? in case I need to someday). I
remember by first getting the loaded address of the kernel module, and doing
add-symbol-file for the driver image relative to that loaded address, it is
possible to do kernel module debug. I think this is what driver developers
will be doing always.  Please tell me how I can do it. If this is possible,
it will save many days for me. 

Thank you!
Chan Kim

More information about the Kernelnewbies mailing list