从 gprof 结果中排除函数
我想从 gprof 生成的输出中排除一些函数。换句话说,我不希望在计算每个函数在执行期间花费的时间百分比时将它们包括在内。我在一处读到可以使用 -E 选项。
但是,我正在使用 gprof -E function_to_be_exluded my_program_name,但没有任何反应。手册说它已折旧,您应该使用 symspecs 代替。然而,我浪费了半个小时试图弄清楚如何使用 symspecs 来实现它,但没有运气。任何人都可以在这方面帮助我。
I want to exclude some functions from the output generated by gprof. In other words, I do not want them to be included when calculating percentage time spent by each function during execution. I read at one place -E option can be used.
However I'm using gprof -E function_to_be_exluded my_program_name, but nothing happens. The manual says it is depreciated and you should use symspecs instead. However, I have wasted half an hour trying to figure out how to achieve it with symspecs, but no luck. Anyone can kindly help me in this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确切地说, gprof -e -E 已被弃用并被具有参数 - symspecs 的较新的相关选项所取代。因此,请尝试使用:
将其与其他 gprof 选项一起使用(-E -e 绝对排除)
Exactly, gprof -e -E are deprecated and superseded by usage of newer relevant options that have argument - symspecs. So try using:
Use this along with your other gprof options (-E -e definitely ruled out)
根据该人的说法:
要显示平面配置文件并从中排除功能,您需要使用
-P
选项:要显示调用图并从中排除函数,您需要使用
- Q
选项:此选项可以重复并同时使用:
如果您需要从其中排除函数报告但不排除您需要使用
-p
或-q
选项的其他功能。示例:
创建程序:
编译它:
gcc main.c -pg -o main
并启动:
生成配置文件报告:
如果您只需要打印平面配置文件,则需要调用:
如果您需要打印平面配置文件,不包括函数
func_a
和func_c
以及完整调用您需要调用的图表:如果您需要打印平面配置文件排除函数
func_a
和func_c
以及调用图,排除func_b
您需要调用:According to the man:
for display flat profile and exclude function from it you need use
-P
option:for display call graph and exclude function from it you need use
-Q
option:This options can be repeated and used in the same time:
If you need exclude function from one report but not exclude any function from other you need use
-p
or-q
options.Example:
Create program:
Compile it:
gcc main.c -pg -o main
And launch:
Generate profile reports:
If you need print only flat profile you need call:
If you need print flat profile excluding functions
func_a
andfunc_c
and full call graph you need call:If you need print flat profile excluding functions
func_a
andfunc_c
and call graph excludingfunc_b
you need call:除非我误解了你的要求...
gprof a.out --no-time=function_name
对我有用。
Unless I've misunderstood what you're asking...
gprof a.out --no-time=function_name
works for me.