Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source code browsing, comprehension and reading tools [closed]

Tags:

c

call-graph

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.

like image 410
Inso Reiges Avatar asked Aug 14 '12 09:08

Inso Reiges


1 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:

  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.
like image 148
ArjunShankar Avatar answered Sep 23 '22 23:09

ArjunShankar