Reputation: 822
I want to know which all functions are executed in a particular scenario .
To be specific I want to understand MMC/SD card stack in Linux kernel.
My idea was to put prints like this :
pr_info("Entering %s\n", __func__);
pr_info("Leaving %s\n", __func__);
to all the functions present in drivers/mmc/
.
But this is a tedious task.
Is there a better method to do this ?
Note : I explored the possibility of using instrumentation functions provided by gcc __cyg_profile_func_enter
and __cyg_profile_func_exit
.
Those instrumentation functions work perfectly for small modules.
But can these functions be used in Linux Kernel also ? Or do we have some different method for this?
My environment : The code will be cross compiled for Cortex A7/A9.
Upvotes: 3
Views: 888
Reputation: 16441
You can compile the source files you want with -finstrument-functions
. Then you can implement these two functions yourself, in some file of the kernel.
Note that:
__cyg_profile_func_enter/exit
with -finstrument-functions
(or, you should use __attribute__((no_instrument_function))
).__cyg_profile_func_enter/exit
must not call code compiled with -finstrument-functions
- this will lead to infinite recursion. If all they do is printk
, and printk
and the low-level drivers it calls are not compiled this way, you're OK.Upvotes: 4