C++: Dependency tracking tool (reverse engineering

2019-06-04 03:11发布

问题:

My question is different from though similar to the ones such as:

Tools to reverse engineer C++ ( i.e. to view C++ classes )

Instead of looking for class diagrams, I'm more interested in finding call chains and dependencies and generating nice-looking graphs.

Is there such a tool? I know cscope and ctags can do a little bit of what I'd like to do but in very much low-level interactive manners (one query at a time). I'd like something more automated, e.g., given an API, find all its sub-routine call paths till it reaches the leaf and show them to me.

Is there a tool for this already? Is it possible to do it at the binary level? like reverse-engineering function dependencies in a library (.a, .so, .dll as input)?

EDIT:

I prefer static analysis tool over profilers since I would like it to work for library and module code as well.

Also I prefer cross-platform solutions. I'm mainly on a Mac but tools for Linux or Windows will be interesting as well.

UPDATE

After researching into the recommendations I decided that Doxygen is what I want. It gives caller and callee graphs, and uses static analysis, cross-platform, and free.

Thanks to all the other recommendations. They opened my eyes quite a bit.

回答1:

Doxygen can display caller and callee trees:
doxygen

Edit 1:



回答2:

CppDepend looks totally awesome for the task.

http://www.cppdepend.com/



回答3:

you can use DEPENDS application which detects most of C C++ and C# libraries in windows.
but still wont give you call chains...
here's the link DEPENDS



回答4:

On Windows you can use CodeTune, it will give you call graph showing function dependencies

http://www.thewallsoft.com/codetune-documentation/

On GNU/Linux you can use gprof and then this visualizer to create your call graph

http://code.google.com/p/jrfonseca/wiki/XDot#Screenshots



回答5:

Promoted from comment.

Have you tried using valgrind with the callgrind tool?

Valgrind is useful for debugging but the callgrind tool inside valgrind is very useful for profiling and knowing which functions calls which other functions. It comes with a visual tool called kcachegrind that allows you to see as blocks inside other blocks the function calls.

And it's absolutely free.