I am doing first steps into Linux kernel development.
I have some code producing a .ko
kernel module that I install with insmod
. I would like a way to debug what happens when I install the module but I am facing some difficulties.
I need to debug the call to
init_module
. Is this function called when I runinsmode
?I try to use
insmod "/my/url/fil.ko" -m
to debug what happens but each time I got error-1 Unknown symbol in module
while in/cat/log/message
I can see the errorunknown parameter -m
Do you know if there is a way to debug with GDB?
Advertisement
Answer
Yes, the init_module function gets called as soon as you load it to the kernel using insmod. You can just add a line of printk and verify it being printed as soon as you insert the module.
You cannot pass a parameter such as -m to debug the kernel module.
You can only pass parameters that are intended to be handled within the kernel module that you have written, using MODULE_PARAMS.