Skip to contentSkip to conversation

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

DISCUSSION Chan Kim 1 participant 1 message Apr 5, 2022

lore
Share & tools
lore

Chan Kim

author
#0 lore raw

Hello all,

I found how to do it, I had asked it on stackoverflow.com and posted it as an answer there.
Please see if you are interested.
https://stackoverflow.com/questions/71749640/how-can-i-debug-kernel-module-r
unning-on-a-virtual-machine/71753139#71753139
Thank you!

Chan Kim

Quoted 26 lines

-----Original Message-----
From: Chan Kim <[email protected]>
Sent: Tuesday, April 5, 2022 6:54 PM
To: 'qemu-discuss' <[email protected]>; [email protected]
Subject: How can I debug kernel module running on a virtual machine?

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.

Quoted 2 lines

Thank you!
Chan Kim

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies