C++: Dependency tracking tool (reverse engineering

2019-06-04 03:09发布

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.

5条回答
别忘想泡老子
2楼-- · 2019-06-04 03:21

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

查看更多
啃猪蹄的小仙女
3楼-- · 2019-06-04 03:30

CppDepend looks totally awesome for the task.

enter image description here

http://www.cppdepend.com/

查看更多
戒情不戒烟
4楼-- · 2019-06-04 03:36

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.

enter image description here

查看更多
男人必须洒脱
5楼-- · 2019-06-04 03:37

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

查看更多
祖国的老花朵
6楼-- · 2019-06-04 03:41

Doxygen can display caller and callee trees:
doxygen

Edit 1:
Example Doxygen call trees

查看更多
登录 后发表回答