perf report
的输出如下:
8.04% hello_world hello_world [.] _ZN9__gnu_cxx13new_allocatorIdE9constructEPdRKd
|
---_ZN9__gnu_cxx13new_allocatorIdE9constructEPdRKd
_ZN9__gnu_cxx14__alloc_traitsISaIdEE9constructIdEEvRS1_PdRKT_
_ZNSt6vectorIdSaIdEE9push_backERKd
_Z14playWithVectorRSt6vectorIdSaIdEE
main
__libc_start_main
0x12e6258d4c544155
我的世界代码中有一个名为playWithVector的函数,该函数是:
// 'Hello World!' program to examine profiling tools likes perf.
/*
Compile it with
g++ -g hello_world.cpp -o hello_world
*/
#include <iostream>
#include <unistd.h>
#include <vector>
int wait(unsigned int musec)
{
usleep(musec);
}
std::vector<double> playWithVector(std::vector<double>& vec)
{
std::vector<double> dummy;
for (int i=0; i<vec.size(); i++)
{
dummy.push_back(i);
}
return dummy;
}
int main()
{
std::cout << "Hello World!" << std::endl;
std::vector<double> vec;
vec.resize(10000);
int i=0;
while(true)
{
i+=1;
if ((i%2)==0)
{
wait(0.5e6);
} else {
vec=playWithVector(vec);
}
//if (i>10)
// return 0;
}
return 0;
}
简而言之,我希望看到playWithVector
而不是_Z14playWithVectorRSt6vectorIdSaIdEE
。
当我查看gdb中的符号时,名称就可以了。
二进制文件通过
g++ -g hello_world.cpp -o hello_world
Perf执行为
perf record -g ./hello_world
并通过perf report -g graph --no-children --stdio
有没有办法让perf在二进制文件中使用调试信息?
谢谢!