Tool to visualise code flow (C/C++)

C++CCode Analysis

C++ Problem Overview


Do you have any sugestions of tools to ease the task of understanding C/C++ code? We just inherited a large piece of software written by others and we need to quickly get up to speed on it. Any advice on tools that might simplify this task?

C++ Solutions


Solution 1 - C++

SourceInsight and Understand for C++ are the best tools you can get for c/c++ code analysis including flow charts.

Solution 2 - C++

Profiling software gives you an idea of which functions have been called.

If you can use Linux, try KCachegrind

Solution 3 - C++

Doxygen is very good at generating diagrams from code without applying markup, if you turn on the EXTRACT_ALL option. You need GraphViz installed to get diagrams generated with the HAVE_DOT setting. I find having it installed and leaving the DOT_PATH blank works fine on Windows but on OS/X keep having to point directly to the dot tool location.

There's an excellent Code Spelunking article in ACM Queue which talks more about using doxygen and DTrace.

Solution 4 - C++

Personally, I use the debugger. Run through the code and see what its doing, and where its going is the only way.

However, you can run it through some documentation-generators which (sometimes) help. A good example is doxygen.

Solution 5 - C++

KScope, built upon the cscope utility, if you're on linux (KDE). The best thing I ever used (and use all the time) to deleve into some huge piece of unfamiliar code which I have to modify somehow or which API I'm to employ for my needs. Among its features are the cross-reference database, which can be searched in a plenty of ways: you can find all references of a symbol, its global definition, find callers/callees of a function and much more. It even has a built-in IDE and an ability to show a call-graph.

Solution 6 - C++

Doxygen will give you class relationship diagrams if you use graphviz, even if you haven't specifically prepared for it.

Solution 7 - C++

There are some tools like Egypt http://www.gson.org/egypt/egypt.html that work, but only if you match the expected GCC version used to compile the code and the exact version of the callgraph generator. The same can be said about codeviz http://www.csn.ul.ie/~mel/projects/codeviz/

Other option is valgrind used in cachegrind mode (it generates a type of callgraph that you can follow from kcachegrind program.

Solution 8 - C++

I personnaly use Visual Studio debugger tools.

It comes with the "Caller Graph" feature which will allow you to visualize stuff in little boxes. Also the Call Stack and the usual watch features are usually all I need

Solution 9 - C++

There's also AspectBrowser which doesn't work very good with Eclipse 3.4.0

Solution 10 - C++

try AQtime, It's a profiling tool that displays all the functions that got called (and the time it took), you can set the start and end points for the analysis. They have a 30 day trial.

Solution 11 - C++

I used Borland Together a while back and it did a decent job of generating models from code. I believe it will even generate sequence diagrams from code. Keep in mind if your code is a mess your model will be too. And as I recall it isn't cheap but sometimes you can catch a special.

Solution 12 - C++

Rational Quantify also presents a nice call graph.

Solution 13 - C++

i tried a tool named Visustin which is not very great graphically but does what it says: Flowchart from Code. http://www.aivosto.com/visustin.html

Solution 14 - C++

doxygen is a free doc-generating tool (similar to Javadoc) that will also produce relationship graphs as well.

Solution 15 - C++

Doxygen, the good thing about it is it will let you know hoe ugly/good is your code in terms of cyclic dependency of classes. So you will be forced to re-factor your code, though you may not like it :-)

Solution 16 - C++

Slickedit is great for navigating large blocks of code you don't know. The tags feature allows you to deal with the code on a functional basis, without having to deal with which file is it in. (EMACS actually has tags and is every bit as good as Slickedit, but with a slightly steeper learning curve)

When you get to a method or class or variable you don't understand, you just push-tag to go to that code, look it over, then pop-tag back. (those are bound to keystrokes, so it is very quick)

You can also use find-references to see where that function/variable is used.

Saves tons of time over having to go and figure out which file something is in.

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
QuestionDpradoView Question on Stackoverflow
Solution 1 - C++akuView Answer on Stackoverflow
Solution 2 - C++Thorsten79View Answer on Stackoverflow
Solution 3 - C++Andy DentView Answer on Stackoverflow
Solution 4 - C++gbjbaanbView Answer on Stackoverflow
Solution 5 - C++dekkardView Answer on Stackoverflow
Solution 6 - C++Douglas MayleView Answer on Stackoverflow
Solution 7 - C++OldManView Answer on Stackoverflow
Solution 8 - C++EricView Answer on Stackoverflow
Solution 9 - C++user23787View Answer on Stackoverflow
Solution 10 - C++recView Answer on Stackoverflow
Solution 11 - C++Craig TylerView Answer on Stackoverflow
Solution 12 - C++QBziZView Answer on Stackoverflow
Solution 13 - C++rjdthegreatView Answer on Stackoverflow
Solution 14 - C++lukeView Answer on Stackoverflow
Solution 15 - C++rptonyView Answer on Stackoverflow
Solution 16 - C++boatcoderView Answer on Stackoverflow