debugging kernel module __init function?
I can’t for the life of me figure out how to set a breakpoint on a kernel module’s __init function. Everything I’ve read talks about using add-symbol-file with the values for .text, .bss, and .data after the module is loaded, a la: https://www.linux.com/learn/linux-training/33991-the-kernel-newbie-corner-ke... How do I debug the __init function (that is called on module load)? Thanks, Nick
In this case, no. But I’m curious if there’s a way to pull this off, or if it’s fundamentally impossible? Thanks, Nick
On Aug 4, 2015, at 1:07 PM, Valdis.Kletnieks@vt.edu wrote:
On Tue, 04 Aug 2015 12:23:18 -0700, Nicholas Murphy said:
How do I debug the __init function (that is called on module load)?
Is your .init function actually doing so much odd stuff that a few carefully placed printk() calls aren't sufficient?
In this case, no. But I’m curious if there’s a way to pull this off, or if it’s fundamentally impossible?
What happens 'after' __init gets called ? After boot, the kernel frees up a special section. All functions marked with __init and data structures marked with __initdata are dropped after boot is complete. Similarly 'modules' DISCARD this memory after initialization. So what is the workaround ? Write the module_init function without the __init attribute. ( They never read the documentation : /Documentation/DocBook/kernel-hacking.tmpl , I never used to read the documentation either :)
participants (3)
-
Aruna Hewapathirane -
Nicholas Murphy -
Valdis.Kletnieks@vt.edu