views:

615

answers:

5

Does anybody know where I can find a utility/application running on Windows that analyses C source and outputs a functional dependency tree?

What I'm looking for is something along these lines:

PrintString->PrintCharacter->PrintByte->Printf

+5  A: 

It's almost certainly overkill, but you can do this for C, C++, PHP, Java, C#, and more with Doxygen (if you have Graphviz dot installed). Here's a page with a sample call tree generated by Doxygen/dot.

Doxygen runs on Windows fine, and can output HTML and a few other formats.

Mark Rushakoff
jdehaan
+1. Another advantage of using Doxygen for this is the opportunity to actually document your code...
RBerteig
If Doxygen does not actually understand the code, how does it handle calls that are the result of overloaded operators?
Richard Corden
... or indirect function calls? We looked at a system of 250,000 functions. Without a deep understanding the language and the specific code, a call to *foo() could go to literally hundreds of thousand targets, making the call graph useless. (We built a points-to analyzer to help control this problem).
Ira Baxter
A: 

Many tools produce this kind of call-graph. Doxygen may well have the most presentation options for the results, being a "literate programming" tool at its core. The open source tool at http://frama-c.cea.fr/ produces call-graphs (also in the dot format) and tries to group the functions by "services" automatically: http://img23.yfrog.com/img23/8180/9il.png

Pascal Cuoq
A: 

CodeInsight is a commercial editor that has the functionality of CTAGS/CSCOPE rolled in. It can display call tree graphs (and almost any other relationship) as well.

Pev
A: 

Source Navigator seems to be in development again (latest release of SourceNav NG was in February of this year). Source Navigator can give you call trees, class dependencies, etc, etc. I have not tried the recent versions. Works on windows or X11.

http://sourcenav.berlios.de/

Michael Kohne
A: 

Tools that read source but don't understand the programming language in a deep semantic sense can only give you an approximation of the call graph. (What if a call occurs in a macro? What if that call occurs inside a disabled preprocessor conditional? What if the call is indirect?) If this is good enough, and you really don't care to know about what indirect calls do, then tools like Doxygen and CScope will probably be helpful.

If you want an accurate call graph, you need a tool constructs one using full knowledge of the langauge. Frama-C (see other answer) AFAIK is one, although I don't know how it handles macros and indirect calls.

Not free, but the DMS Software Reengineering Toolkit and its C front end have full C macro/preprocessor processing capability, and constructs call graphs for a system of files. It specifically includes a points-to analysis in its call graph construction to give you a conservative approximation of where indirect function calls go. See example call graph with black arcs (direct calls) and blue arcs (conservatively analyzed) indirect calls.

Ira Baxter