Question

Any code-analysis or "reverse-engineering" tool that can do either of these?:

  • Calculate which classes are sub-classes of which classes
  • Calculate which classes instantiate which classes -- (like VS Class Designer)
  • Calculate which functions call which functions -- (much like a Call Stack)
Was it helpful?

Solution

Calculate which functions call which functions

NDepend can produce some useful methods or class call graph like for example the screenshot below (image full size here) Disclaimer: I am one of the developers of the tool

NDepend Methods Call Graph

Find more explanations about how to generate call graph with NDepend here.

Calculate which classes are sub-classes of which classes

The same way NDepend can generate class inheritance graph (explanation to generate class inheritance graph here).

Calculate which classes instantiate which classes

NDepend lets write Code Query over LINQ Query (what we call CQLinq). With CQLinq, you can ask for methods or classes that creates a particular class, for example:

from m in Methods 
where m.CreateA("NUnit.Core.NUnitConfiguration")
select m

Such CQLinq query result can be exported to the graph view, to get a visual representation of dependencies.

As a side note, with CQLinq one can also write code rules. More than 200 code rules are proposed by default, these include rules concerning design, architecture, code quality, code evolution, naming conventions, dead code, .NET Fx usage...

CQLinq rules can be verified live in Visual Studio, or that can be verified during build process and reported in an HTML/javascript report.

OTHER TIPS

Doxygen + GraphViz (for pictures, doxygen requires GraphViz)

That has the largest languages support (since you did not specify a language) and the viewer is a browser, so once generated, anyone should be able to view it.

Configure doxygen to generate even non documented members, and to include the source code. This way the source code will include links to function declarations for easy navigation.

There are also tools that specialize in a language, such as Understand for C++.

Understand 2.0

...shows the dependence between parts of the code written in different languages. CLA make it easy to follow the calls. ~ Combined Language Analysis

Specifically this Function Call tree image.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top