2015年12月4日 星期五

C call graph with cscope

sudo apt-get install xdot
sudo apt-get install cscope

CallGraphviz—依據 cscope、Graphviz 以及 xdot 實作的 call graph visualizer - OpenFoundry
http://www.openfoundry.org/tw/tech-column/8352-callgraphviz-cscopegraphviz-xdot-call-graph-visualizer

git clone https://github.com/chihchun/callgraphviz.git
python visualizer.py
問題
  • 要一個一個symbol自己key進去
  • 無法刪除已key入的symbol
  • 無法Save成.dot檔案

toolchainguru: Bash: C Call Trees and Graphs
http://www.toolchainguru.com/2008/07/bash-c-call-trees-and-graphs.html
The bash script works for me with some modification.
https://github.com/mkl0301/callgraphviz/blob/master/calltree.sh

Functions supported:
  1. downstream X: functions called by X (callee)
  2. upstream X: functions that call X(caller)
  3. subgraph X Y: all code paths that lead from function X to function Y.
  4. related A, B, ... Z: all code paths between an arbitrary set of functions A, B, C, [...] Z
First you need to have your cscope.out generated. Second source the script calltree.sh:
. calltree.sh;
Then:
downstream FUNC1 LEVEL
upstream FUNC1 LEVEL
subgraph FUNC1 FUNC2
related FUNC1...FUNCn

FUNCx: Function name
LEVEL: levels to look into. 0: infinite
The latest script could take the Function name as the first parameter:
Call the built-in function by providing the function name as the first
    parameter:
        ./calltree.sh FUNC PARM1 PARM2...PARM8

Thus I could do the following directly:
./calltree.sh downstream FUNC1 LEVEL


CCTree - C Call-Tree Explorer -- Cscope based source-code browser; code flow analyzer : vim online
http://www.vim.org/scripts/script.php?script_id=2368
Vim CCTree -- Call-tree Explorer plugin
https://sites.google.com/site/vimcctree/
cctree help file
http://sites.google.com/site/vimcctree/cctree.txt
Copy cctree.vim to ~/.vim/plugins/

Load database
    :CCTreeLoadDB
(Please note that it might take a while depending on the  database size)

Save native Xref Db
   :CCTreeSaveXRefDB  cctree.out

Load native XRef Db~
    :CCTreeLoadXRefDB  cctree.out

Get reverse call tree for symbol  <C-\> <
    :CCTreeTraceReverse       
Get forward call tree for symbol
<C-\> >
    :CCTreeTraceForward
Increase depth of tree and update
<C-\> =
    :CCTreeRecurseDepthPlus     
Decrease depth of tree and update
<C-\>  -
    :CCTreeRecurseDepthMinus    



沒有留言: