在Linux for c ++中使用gprof -f选项

时间:2012-09-26 11:41:23

标签: c++ linux gprof

大家好,我已经开始使用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

我收到错误

  

没有这样的文件或目录

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

CAN有人请帮帮我吗? 提前致谢

1 个答案:

答案 0 :(得分:3)

()取自你的shell。试试这样:

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