8

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.

Inso Reiges
  • 1,889
  • 3
  • 17
  • 30

3 Answers3

5

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:

  1. The graphs GraphViz produces are stand-alone, and not part of an IDE.
  2. I'm not really sure if producing a call-graph of Linux (the kernel) is possible in this way.
ArjunShankar
  • 23,020
  • 5
  • 61
  • 83
0

Please try and use SourceInsight. It is quite helpful with browsing code and understanding it. It provides most of the features requested by you.

Jay
  • 24,173
  • 25
  • 93
  • 141
0

You could try cflow. It gives you a graf of the calls of functions inside. It is not very flexible though.

Dimitar Slavchev
  • 1,597
  • 3
  • 16
  • 20