I am primarily a C and C++ programmer and i often need to quickly comprehend the structure of very large code bases (gcc, linux kernel). I wonder if there are any tools to help in this regard. I am particularly interested in call graphs, data structure references across the project, include dependency graphs, quick symbol location, etc. I known about ctags and cscope but i am looking for something with more visualization like a call graph that allows to quickly locate definition of a function, root the graph at a particular call, inverting it (i.e. locating all calls to a given function), etc.
-
RTCM - read the compiler manual. Most compilers do some of what you want and I expect that the compiler(s) you use are no exception. – High Performance Mark Aug 14 '12 at 10:17
3 Answers
If you want to build call graphs, you could roll your own with GCC's -finstrument-functions
.
Basically, when you compile a program with that option enabled, GCC calls the following functions whenever the target program enters or exits a function:
void __cyg_profile_func_enter (void *this_fn,
void *call_site);
void __cyg_profile_func_exit (void *this_fn,
void *call_site);
What you need to do is define these functions, and write in your logic to produce the call graph there.
This extremely thorough tutorial explains how you could produce a call graph using -finstrument-functions
and GraphViz. All the tools involved are FOSS and gratis.
Of course:
- The graphs GraphViz produces are stand-alone, and not part of an IDE.
- I'm not really sure if producing a call-graph of Linux (the kernel) is possible in this way.

- 23,020
- 5
- 61
- 83
Please try and use SourceInsight. It is quite helpful with browsing code and understanding it. It provides most of the features requested by you.

- 24,173
- 25
- 93
- 141
You could try cflow. It gives you a graf of the calls of functions inside. It is not very flexible though.

- 1,597
- 3
- 16
- 20