Kcachegrind. Show only functions from my code

c++, callgrind, kcachegrind, valgrind

Solution

Go to View -> Grouping and select ELF Object. In the corresponding toolview pick your application/library ELF object and it will show only functions within them.

You won't be able to get the desired output though. You cannot measure time with Valgrind, it only counts instructions and can estimate cycle counts and cache misses. And callgrind also does not show you the full function signature, it will always drop the arguments and only displays the function name.

Problem

I want to profile my code. So I do: ``` valgrind --tool=callgrind my_program [programm arguments] kcachegrind callgrind.out.x ``` Now I have `kcachegrind` window like this: There is a lot of core and library functions, but how can I set up `valgrind` or `kcachegrind` to trace only functions are in my code (which, of course, call library functions)? The expected output is something like that: ``` time number of calls function_name() 4,52% 569854 CSim2Sim my_function1(int argc, char* argv[]) 3,52% 452158 CSim2Sim my_function2(int argc, char* argv[]) 3,52% 36569 CSim2Sim my_function3(int argc, char* argv[]) 1,52% 1258 CSim2Sim my_function4(int argc, char* argv[]) ```

Original source