Chinaunix首页 | 论坛 | 博客
  • 博客访问: 562856
  • 博文数量: 107
  • 博客积分: 3079
  • 博客等级: 少校
  • 技术积分: 1306
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-08 00:03
个人简介

emmoblin.github.com

文章分类

全部博文(107)

文章存档

2012年(8)

2011年(15)

2010年(49)

2009年(9)

2008年(26)

分类: LINUX

2010-05-06 22:13:13

为了理解ipv6代码方便,使用codeviz,显示函数调用关系。
安装的过程比较简答:
1)apt-get install graphviz
2)  下载codeviz,不同版本对应不同的gcc。configure --help 的时候可以得知。
3)下载对应版本的gcc,cp到compiler目录下,执行make,这回对gcc打patch。

这就算安装完成了。
如果要分析哪个代码,需要设置CC为对应的gcc。会为每一个c文件生成cdepn文件。

    CodeViz 使用两个脚本来生成调用图,一个是 genfull,该脚本可以生成项目的完整调
用图,因此调用图可能很大很复杂,缺省使用 cdepn 文件来创建调用图;另一个是
gengraph,该脚本可以对给定一组函数生成一个小的调用图,

 genfull 的-s 选项,-s 指定了检测哪些子目录。


gengraph
-d 指定最大调用层数
-s 仅仅显示指定函数,而不对其调用进行展开
-i 忽略指定函数


gengraph - Generate a call graph for a given set of functions

Usage:
    gengraph [options]

      Main Options:
      -f, --function    Top level functions to graph, quote if more than one
      -t, --trim        Ignore a set of Linux kernel functions (Kernel specific)
      -i, --ignore      Functions to ignore
      -s, --show        Show a function but not the sub-functions
      -d, --maxdepth    Maximum depth of graph
      -r, --reverse     Place the function at the bottom and graph callers
      -g, --graph       Source graph from by genfull (Default: ./full.graph)
      -l, --location    Show the location of the function declarations
      -a, --all-locs    Show the location of declarations and calls
      -k, --keep        Keep the sub.graph file
      -o, --output      Output postscript filename
      -v, --verbose     Verbose output
      -h, --help        Print this message
      --no-extern       Ignore functions not defined in the current source
      --output-type     Set the output type: ps, html png or gif (default: ps)
      --output-font     What font to use for output graph (default: Helvetica)
      --output-fontsize Size of output font (default: 12)
      --output-layout   Layout direction: LR|RL|BT|TB (default TB)
      --version         Print the version number

      HTML Options (specify --output-type=html above):
      -e, --source      Root of the source code being graphed
      --html-fragment   Generate HTML suitable for including in another page
      --base-url        Template URL to use for hyperlinks in the web page
      --shighlight      Use source-highlight for HTML links
      --scss            Cascading style-sheet to use for source-highlight

      Regular Expression Options:
      -z, --func-re     Regular expressions of top-level functions to graph
      -j, --ignore-re   Regular expressions of functions to ignore
      -y, --show-re     Regular expressions of functions to show but not traverse

      Post-Processing Options:
      --pp-stack        Show stack usage and highlight excessive usage
      --pp-cstack       Show cumulative usage in a given set of code paths

      Daemon Options:
      -p, --daemon      Run gengraph as a daemon
      -q, --client      Run gengraph as a client to a gengraph daemon
      --plain           Output the dot graph file but do not use dot
      --stdout          Use this file as standard out instead of normal
      --stderr          Print errors to this file instead of STDERR




    genfull [options]

     Main Options:
      -d, --toplevel Top level source directory (Default: current)
      -f, --file     Files to scan for data     (Default: find all files)
      -s, --subdirs  Subdirectories to graph    (Default: all)
      -g, --method   Method for collecting data (Default: cdepn)
      -o, --output   Output graph               (Default: ./full.graph)
      -h, --help     Print this message
      --version      Print the version number

     Post-Processing Options:
      --skip         Skip collection and only post-process
      --pp-stack     Calculate stack usage

     For Linux kernel call graphs, the following calling is recommended
     genfull -s "arch/i386 net lib ipc mm fs net kernel init drivers"


使用cs模式
gengraph -p -g /usr/src/linux-2.4.20-clean/full.graph
When this returns, the daemon is running. To generate a graph using the daemon, run
gengraph -q -t -d 2 -f alloc_pages
Note the use of the -q switch which says that gengraph should run as a client to the daemon instance. If you are bored, compare the difference in running times between normal gengraph and when it is used as a client :-) . To stop the daemon, do the following
echo QUIT > /tmp/codeviz.pipe

阅读(1467) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~