Kcachegrind. Show only functions from my code
Asked Answered
G

4

13

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:

enter image description here

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[])
Goblin answered 28/10, 2016 at 12:25 Comment(2)
Cannot you click the "Location" tab to have all of your functions grouped? Additional note: You can do this using Qt Creator's call profiler.Clostridium
@Asu Yes, I did that, but source-code grouping also includes files from library and include files (which I don't want see)Goblin
A
5

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.

Aerodonetics answered 7/11, 2016 at 9:26 Comment(0)
C
3

Valgrind provide facility to suppress particular error or error from particular object file or from some library. Check this link.

As per this instruction you can prepare you suppresion file (like a.supp) and pass it to valgrind

valgrind --tool=callgrind --suppressions=/path/to/a.supp my_program [programm arguments]

I haven't use kcachegrind, but I am sure it must provide some facility to change command-line option of valgrind.

Corkwood answered 3/11, 2016 at 4:57 Comment(0)
C
1

The closest thing to what you are looking for is probably grouping. In the Toolbar : View -> Grouping. You can then choose either per Source file or per ELF object. The former will give you the list of source files, where you can select the files you wrote, the latter will give you a list of objects, mostly libraries and an object with the name of your executable : select it and you should only view the list of calls made in your source code.

Cru answered 7/11, 2016 at 8:54 Comment(0)
M
0

when you are on os x you can try profilingviewer, it can hide system functions based on customizable presets.

enter image description here

Merlon answered 28/10, 2016 at 15:16 Comment(2)
I am ubuntu user =(Goblin
This app no longer exists.Patiencepatient

© 2022 - 2024 — McMap. All rights reserved.