【问题标题】:using the gprof -f option in Linux for c++在 Linux for c++ 中使用 gprof -f 选项
【发布时间】:2012-09-26 11:41:23
【问题描述】:

您好,我已经开始使用 gprof 进行分析工作,它工作正常,除了 -f 选项允许我指定要在调用图中查看的特定函数。

例如

                 Call graph (explanation follows)


granularity: each sample hit covers 4 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00       1/1           __do_global_ctors_aux [13]
[5]      0.0    0.00    0.00       1         global constructors keyed to main [5]
                0.00    0.00       1/1           __static_initialization_and_destruction_0(int, int) [6]
-----------------------------------------------
                0.00    0.00       1/1           global constructors keyed to main [5]
[6]      0.0    0.00    0.00       1         __static_initialization_and_destruction_0(int, int) [6]
-----------------------------------------------
                0.00    0.00       1/1           main [4]
[7]      0.0    0.00    0.00       1         car::DisplayPrice() [7]
-----------------------------------------------
                0.00    0.00       1/1           main [4]
[8]      0.0    0.00    0.00       1         car::showc() [8]
-----------------------------------------------
                0.00    0.00       1/1           main [4]
[9]      0.0    0.00    0.00       1         car::car(std::string, int) [9]
                0.00    0.00       1/1           vehical::vehical(int, int) [12]
-----------------------------------------------
                0.00    0.00       1/1           main [4]
[10]     0.0    0.00    0.00       1         car::~car() [10]
-----------------------------------------------
                0.00    0.00       1/1           main [4]
[11]     0.0    0.00    0.00       1         vehical::show() [11]
-----------------------------------------------
                0.00    0.00       1/1           car::car(std::string, int) [9]
[12]     0.0    0.00    0.00       1         vehical::vehical(int, int) [12]
-----------------------------------------------

现在如果我指定

gprof -f car::car(std::string, int) a.out gmon.out

我得到错误

意外标记'('附近的语法错误

如果我这样做了

gprof -f car::car(std::string, int) a.out gmon.out

我得到一个错误

没有这样的文件或目录

如果我尝试将函数放在双引号中,我会得到如上所示的输出,没有任何变化..

有人可以帮我吗? 提前致谢

【问题讨论】:

  • 您可能只需要一对 "' 围绕 car::car(std::string, int)。 ,int) 之间的空格被识别为两个不同的参数

标签: c++ linux gprof


【解决方案1】:

() 被您的外壳占用。试试这样:

gprof -f 'car::car(std::string, int)' a.out gmon.out

【讨论】:

  • 我已经用 ' 和 " 尝试过这个,但我得到了相同的结果,即我得到了与代码相关的所有函数,而我只想要与函数 car::car(std ::字符串,整数)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-01-24
  • 2012-01-15
  • 1970-01-01
  • 2011-11-22
  • 1970-01-01
  • 2023-04-01
  • 2019-04-20
相关资源
最近更新 更多