Tools to get a pictorial function call graph of code
Egypt (free software)
ncc
KcacheGrind (GPL)
Graphviz (CPL)
CodeViz (GPL)
Static analysis for call-graph generation in C programs
For malloc
related bugs, the valgrind tool is very useful (at runtime, when testing).
Your quest cannot be satisfied by purely textual inspection of source code (e.g. because malloc
might be called from many inlined functions or macros, and because it even could be #define
-d to something else, or called thru function pointers, or in functions from external libraries: even fopen
or fprintf
may call malloc
). Actually it can be proven equivalent to the halting problem.
Also, the call stack is only known at runtime, and it is dynamically changing. It has no sense at compile time. The compiler only organize call frames.
You need a tool which works inside the compiler, on internal representations of the compiler, so you need some more sophisticated static program analyzer, and even that will give you approximate results.
You could use MELT (a plugin and domain specific language to customize the GCC compiler, that I am developing as free software) since it works on GCC internal representations. The example of findgimple
mode in the tutorial about using MELT is quite close to your question, but you could customize GCC with your own MELT extension (or ask someone to do that).
PS. valgrind
& MELT are mostly available on Linux and POSIX systems. You might try hard to find costly equivalents in the Microsoft ecosystem.
Generating dynamic call graph of c/c++ programs on the run
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.
Generating Function Call-Graph Doxygen+Graphviz
By rebooting and removing the DOT_PATH specification, it solved the problem.
Related Topics
How to Get Error Message When Ifstream Open Fails
Nice Way to Append a Vector to Itself
Default Value of Function Parameter
How to Print the Wchar_T Values to Console
Boost_1_60_0 .Zip Installation in Windows
How to Redirect Qdebug, Qwarning, Qcritical etc Output
Gdb Complaining About Missing Raise.C
What Belongs in an Educational Tool to Demonstrate the Unwarranted Assumptions People Make in C/C++
How to Read a Value from the Windows Registry
Compiling Multithread Code With G++
Is the Size of Std::Array Defined by Standard
C++11 Allows In-Class Initialization of Non-Static and Non-Const Members. What Changed
Public Data Members VS Getters, Setters
Why Is Out-Of-Bounds Pointer Arithmetic Undefined Behaviour
Why Is the Size of an Empty Class in C++ Not Zero