views:

480

answers:

3

Are there softwares that can generate graphs that show which functions call which functions?

I need to analyze JavaScript source code, a language which Doxygen/Graphviz does not support, though it does support C++ and others.

If there are no tools that support JavaScript out-of-the-box, is there a way to convert JS to C++ so I can use Doxygen itself?

+2  A: 

Most real langauges have pointers in some form (C, obviously; in Java they're called "objects").

Good call graphs (black arcs, direct calls; blue arcs, indirect calls) usually require resolving pointers using sophisticated flow analysis to a realistic set of targets. Otherwise an indirect call might be marked as going nowhere or everywhere (or least a very big set of places) which really doesn't help much.

The DMS Software Reengineering Toolkit provides general and specific points-to analysis infrastructure already instantiated for C, Java and IBM Enterprise COBOL.

This infrastructure can be reused for other languages. DMS has parsers for many languages, including JavaScript (and a draft parser for AS3). Obviously this isn't an off-the-shelf solution for your favorite set, but it does mean they can be obtained.

Ira Baxter
+1  A: 

Google's Closure Compiler can generate dot files with the --print_ast flag. The only reference I could find was this article in Russian (auto-translated into English). As the article says, you can use a tool like Graphviz to view the call graphs.

Annie
+3  A: 

Have a look at this tool, I think it can do most of what you want, it links up with Graphviz to generate the graphs visually. Follow Annie's steps to get it working.

It even goes a level deeper and shows code blocks and conditional statements. I don't think it visualizes class level dependencies although that's not what you asked for.

alt text

Kevin Boyd