简体   繁体   English

Kcachegrind。 仅显示我代码中的函数

[英]Kcachegrind. Show only functions from my code

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: 现在我有这样的kcachegrind窗口:

在此处输入图片说明

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)? 有很多核心和库函数,但是如何设置valgrindkcachegrind来仅跟踪代码中的函数(当然,这些函数称为库函数)?

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[])

Go to View -> Grouping and select ELF Object. 转到查看->分组,然后选择ELF对象。 In the corresponding toolview pick your application/library ELF object and it will show only functions within them. 在相应的工具视图中,选择您的应用程序/库ELF对象,它将仅显示其中的功能。

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. 您不能使用Valgrind来测量时间,它只能计数指令,并且可以估计周期数和缓存​​未命中。 And callgrind also does not show you the full function signature, it will always drop the arguments and only displays the function name. 并且callgrind也不显示完整的函数签名,它将始终删除参数并仅显示函数名称。

Valgrind provide facility to suppress particular error or error from particular object file or from some library. Valgrind提供了抑制特定错误或特定目标文件或某些库中的错误的工具。 Check this link . 检查此链接

As per this instruction you can prepare you suppresion file (like a.supp) and pass it to valgrind 按照此说明,您可以准备您的暂停文件(如a.supp)并将其传递给valgrind

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

I haven't use kcachegrind, but I am sure it must provide some facility to change command-line option of valgrind. 我没有使用kcachegrind,但是我确定它必须提供一些工具来更改valgrind的命令行选项。

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. 然后,您可以选择每个源文件或每个ELF对象。 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. 前者将为您提供源文件列表,您可以在其中选择编写的文件,后者将为您提供对象列表,主要是库和带有可执行文件名称的对象:选择它,并且您仅应查看您的源代码中进行的调用的列表。

when you are on os x you can try profilingviewer , it can hide system functions based on customizable presets. 当您使用os x时,可以尝试使用profilingviewer ,它可以基于可自定义的预设隐藏系统功能。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM