Tools for viewing, understanding, and reading source code

I am primarily a C and C ++ programmer, and I often need to quickly make sense of the structure of very large code bases (gcc, linux kernel). I wonder if there are any tools in this regard. I am particularly interested in call graphs, links to the data structure in the project, include dependency graphs, quick character layout, etc. I knew about ctags and cscope, but I'm looking for something with more visualization, for example, a call schedule that allows you to quickly find the definition of a function, the root of the graph for a particular call, invert it (i.e. identify all calls to a given function), and so on. .d.

+7
source share
3 answers

If you want to build call diagrams, you can collapse your code using GCC -finstrument-functions .

Basically, when you compile a program with the option turned on, GCC calls the following functions when 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 create a call schedule.

This extremely detailed tutorial explains how you can create a call schedule using -finstrument-functions and GraphViz . All tools involved are FOSS and free.

Of course:

  • GraphViz charts are autonomous and not part of the IDE.
  • I'm not sure that creating a Linux call diagram (kernel) is possible this way.
+5
source

Try using SourceInsight . This is very useful when viewing code and understanding it. It provides most of the features requested by you.

0
source

You can try cflow. This gives you a graph of function calls inside. It is not very flexible though.

0
source

All Articles