How to use a Systemtap probe on a kernel module function while that module is loaded. I am trying to print the functions being called for a particular module while it is being loaded. Suppose I have a kernel module hello.ko which is not loaded. Now I want to trace a function hello_init() of that module. I tried with the following Systemtap script but it did not work.
Command:
stap test10.stp -c "modprobe hello" --> this printed nothing
Systemtap script:
#!/usr/bin/env stap
global traces
probe module("hello").function("hello_init") {
printf("hello")
print_stack(backtrace())
}
Kernel module:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_INFO "Done\n");
}
module_init(hello_init);
module_exit(hello_exit);