I'm trying to generate calling graph with which to find out all the possible execution paths that are hitting a particular function (so that I don't have to figure out all the paths manually, as there are many paths that lead to this function). For instance:
path 1: A -> B -> C -> D
path 2: A -> B -> X -> Y -> D
path 3: A -> G -> M -> N -> O -> P -> S -> D
...
path n: ...
I have tried Codeviz and Doxygen, somehow both results show nothing but callees of target function, D. In my case, D is a member function of a class whose object will be wrapped within a smart pointer. Clients will always obtain the smart pointer object through a factory in order to invoke D.
Does anyone know how to achieve this?
You can use CppDepend, it can generates many kinds of graphs
Then
Yields some shiny picture (there is an "external node", because
main
has external linkage and might be called from outside that translation unit too):You may want to postprocess this with
c++filt
, so that you can get the unmangled names of the functions and classes involved. Like in the followingYields this beauty (oh my, the size without optimizations turned on was too big!)
That mystical unnamed function,
Node0x884c4e0
, is a placeholder assumed to be called by any function whose definition is not known.