【发布时间】:2013-06-04 05:48:06
【问题描述】:
我想使用 valgrind 获取 C++ 程序调用的函数的时间顺序日志,最好是在文本文件中。
对于下面的示例 C++ 程序 (simple.cpp):
void baz(){
}
void bar(){
for(int i = 0; i < 3; i++)
baz();
}
void foo(){
bar();
}
int main(){
foo();
return 0;
}
我想获得
main() -> foo()-> bar->baz()*3
我尝试过的:
编译为g++ -g simple.cpp -o simple.out
并运行valgrind --tool=callgrind ./simple.out获取callgrind.out.3519
运行 callgrind_annotate --tree=both callgrind.out.3519 | grep baz 不会返回任何内容。
说出kcachegrind callgrind.out.3519,然后在函数main() 的源代码视图中导航,我可以按时间顺序查看调用。
有没有办法将这些信息写入日志?
【问题讨论】:
标签: c++ logging valgrind trace callgrind