Generating dynamic call graph of c/c++ programs on the run
If one were to visualize the running of a program, I suppose one would start by getting the call graphs of the program.
But how would you get the call graph of c/c++ programs while on the run?
edit: clarifications, I'm currently running things on linux, using g++, but I suppose I am also c开发者_JS百科urious about solutions if I'm using a different platform.
I've used etrace to trace executions of programs.
Egypt does the same thing, but only has a limited support for C++.
Both requires the program to be instrumented with gcc.
You can use KCachegrind to generate and analyze call graphs based on data generated by Valgrind's callgrind tool.
The Bug Validator from SofwareVerify (free public beta available) does this.
Excerpt from homepage:
C++ Bug Validator provides automatic execution history logging of applications as they run. There is no need to recompile or relink your application. C++ Bug Validator works with debug information and/or MAP files. C++ Bug Validator allows you to perform execution history logging on your entire application, or on just the DLLs you require.
(Markup from me).
I don't know how they do it, but obviously, it's possible.
精彩评论