Perhaps you should consider writing a Linux kernel module (LKM).
There is a tutorial here: http://www.tldp.org/LDP/lkmpg/2.6/html/
If you need an accurate profiling system, you can attach your kernel module to some interrupt or any other valid entry point * and save (with a few instructions!) What you need for your account. Then, after the interruption, periodically collect and analyze this data.
You can export information in the same way as other modules do, through a special file in the file system (created in user space via mknode or inside initialization using MKDEV / register_chrdev).
There is some information in the link provided.
* For example, you can attach your module to syscall reading (wrap the actual reading from yours) or export the file and catch attempts to open / close.
An example of using a later version will look something like this:
void f() { int fd_prof; fd_prof = open("/dev/profiler", O_RDONLY); close(fd_prof);
Please remember that when compiling LKM, you do not have access to the standard C library, since libc does not exist in kernel space.
Donβt worry, you will still have functions like sprintf implemented in kernel space, and of course you have direct access (without context switches) to any syscall (read, write ...)
ssice source share