14

I want to generate Full and Partially Call Trees from cscope database of c and c++ projects in Linux.

The project is rather large, so it can be not easy to work with the full call tree of project, so I want to limit call tree generation with grep-like filter of function names.

And also I want to be able to build "called by" and "called from" sub-trees from any point.

So tool must be interactive and easy to patch.

PS: I want use cscope database, because it is already used in project and generating of it is rather fast. I use vim editor and have X windows system.

There is cbrowser program on sourceforge, but its call-tree (callgraph) functionality is broken.

osgx
  • 90,338
  • 53
  • 357
  • 513
  • And does cscope handle indirect or virtual method calls? If it doesn't, what's the meaning of your "full call tree"? If you are willing to settle for a "partial call tree", how partial can it be (the empty call tree is a valid partial call tree, but isn't very interesting). – Ira Baxter Feb 26 '10 at 05:21
  • I use cscope for C project. I don't need it to be very exact, only to such degree as do cscope with queries "calls to" and "called from". I want to get full call-graph of functions in big c project. It must include explicit function calls. anything else is optional. – osgx Feb 26 '10 at 10:45

5 Answers5

4

if you want to do it using vim here is a way:

http://www.vim.org/scripts/script.php?script_id=2368

user406948
  • 56
  • 3
2

I've made an attempt to "fix" the call tree problem in cbrowser (see http://retprogbug.wordpress.com/2010/09/18/an-attempt-to-resuscitate-cbrowser-0-8/) though being a complete programming noob I make no guarantees.

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
  • 2
    do you have a results? screenshoot of some sources with calltree drawed by cbrowser? – osgx Sep 20 '10 at 00:21
1

I got this cscope-based Bash script to work in Cygwin & Windows: http://toolchainguru.blogspot.com/2011/03/c-calltrees-in-bash-revisited.html

See example call "graph" (I've been calling it a call "tree", whoops). See example from the Linux kernel.

It requires cscope (of course) and graphviz. It is able to do upstream and downstream graphs, as well as combined up & down graphs (see example).

I haven't demonstrated it here but this method works really quite well on large projects where the same function might be defined in multiple directories. There will just be one node drawn for the same function name (so one "main" node even if you have multiple main()'s defined in your directory structure)---and you'll have multiple edges emanating from such a node, with file/line indicators. I found this aspect to be more useful than GNU cflow, which insisted on picking only one directory to look in. (The Jason Nyberg Bash script as is doesn't play well with threading, which GNU cflow handles nicely; something to keep in mind.)

Ahmed Fasih
  • 6,458
  • 7
  • 54
  • 95
1

I'm not aware of any programs, other than cscope, that read cscope databases. Even vim's cstag functionality just starts a background cscope process which it queries.

As for call-graph generation, if you don't mind stepping outside cscope, I rather like what doxygen creates. They can be a little big, but it also generates the graph from almost all points, and it's incredibly easy to browse source directly in it.

Jens
  • 69,818
  • 15
  • 125
  • 179
1

kscope may be another option. I'm not sure if it will do everything specified, but it is fairly versatile for a GUI app.

Ubuntu users having trouble getting it running are advised to follow these instructions.

intuited
  • 23,174
  • 7
  • 66
  • 88
  • screenshoots of call-tree seems to be http://sourceforge.net/dbimage.php?id=200328 – osgx Jan 15 '11 at 13:33
  • @osgx: Thanks. Though I'm not sure if the OP is looking for a tree in that sense, or for a [call *graph*](http://kscope.sourceforge.net/callgraph.png). – intuited Jan 16 '11 at 04:01
  • im looking for both. the tree is good, the callgraph is better, and the best is the callgraph for part of funcions. (filtered or subgraph). And I'm a OP :) – osgx Jan 16 '11 at 10:01