C/C++ source code visualization?

C++CVisualization

C++ Problem Overview


Basically I want tools which generate source code visualization like:

  • function call graph
  • dependency graph
  • ...

C++ Solutions


Solution 1 - C++

http://www.doxygen.nl/">Doxygen</a> is really excellent for this, although you will need to install http://www.graphviz.org/">GraphViz</a> to get the the graphs to draw.

Once you've got everything installed, it's really rather simple to draw the graphs. Make sure you set http://www.doxygen.nl/manual/config.html#cfg_extract_all">EXTRACT_ALL</a> and http://www.doxygen.nl/manual/config.html#cfg_call_graph">CALL_GRAPH</a> to true and you should be good to go.

The full documentation on this function for doxygen is http://www.doxygen.nl/manual/diagrams.html">here</a>;.

Solution 2 - C++

I strongly recommend http://www.bouml.fr/">BOUML</a>;. It's a free UML modelling application, which:

  • is extremely fast (fastest UML tool ever created, check out http://bouml.free.fr/benchmark.html">benchmarks</a>;),
  • has rock solid C++ import support,
  • has great SVG export support, which is important, because viewing large graphs in vector format, which scales fast in e.g. Firefox, is very convenient (you can quickly switch between "birds eye" view and class detail view),
  • is full featured, impressively intensively developed (look at http://bouml.free.fr/historic.html">development history, it's hard to believe that so fast progress is possible).

So: import your code into BOUML and view it there, or export to SVG and view it in Firefox.

For the free version:

Solution 3 - C++

You can look at different tools for software design and modelling (Rational Rose, Sparx Enterprise Architect, Umbrello, etc). Majority of them have some functionality to reverse modeling by source code, and getting UML class diagrams, and sometimes even sequence diagrams (and this is very close to functions call graph).

But after you get some pictures on really big project code base you could realise that such graphs are rather hard to read and understand. Unfortunally visualization capabilities of complexity are very limited.

As for me, using a "divide and rule" idiom is more convinient approach. You can extract different functionality blocks or layers from your some code base (just sorting cpp-files by different folders sometimes enough). Another way is to use some scripts (bash, python) to create simple csv tables with interested parameters of files, classes or functions like "number of dependencies" etc).

Solution 4 - C++

Try doxygen

Example output from Xerces

Solution 5 - C++

If you use Visual Studio, the 2010 Ultimate release lets you generate sequence diagrams and dependency graphs. However, the release currently supports only .NET application projects.

The team has gotten lots of interest in supporting C++ in a future release, so you might want stay tuned. In the meantime, you can post in the VS 2010 Architectural Discovery & Modeling Tools forum at http://social.msdn.microsoft.com/Forums/en-US/vsarch/threads to request an update. I know the product team loves hearing customer feedback about the tools.

In the meantime, you can learn more about creating sequence diagrams and dependency diagrams from .NET code in the following topics:

How to: Find Code Using Architecture Explorer: http://msdn.microsoft.com/en-us/library/dd409431%28VS.100%29.aspx

How to: Generate Graph Documents from Code: http://msdn.microsoft.com/en-us/library/dd409453%28VS.100%29.aspx#SeeSpecificSource

How to: Explore Code with Sequence Diagrams: http://msdn.microsoft.com/en-us/library/ee317485%28VS.100%29.aspx

To try the RC release and provide feedback, download it at http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a

Solution 6 - C++

In addition to written tools above, you may try understand. But, it is not free.

Solution 7 - C++

Might be a duplication, but check out ollydbg, IDA Pro and http://www.openrce.org/">this website has a whole bunch of resources with some very sexy images.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAvinashView Question on Stackoverflow
Solution 1 - C++Andrew WilkinsonView Answer on Stackoverflow
Solution 2 - C++anonView Answer on Stackoverflow
Solution 3 - C++AndreyBarkView Answer on Stackoverflow
Solution 4 - C++epatelView Answer on Stackoverflow
Solution 5 - C++Esther Fan - MSFTView Answer on Stackoverflow
Solution 6 - C++baris.aydinozView Answer on Stackoverflow
Solution 7 - C++Steve MView Answer on Stackoverflow