Use Graphviz + Codeviz to generate a C + + function call graph (called graph)

Source: Internet
Author: User
Tags ftp perl script linux


First, Graphviz + Codeviz Simple Introduction



Codeviz is an open source tool for analysis of function invocation relationships in C + + source code (similar to open, understanding the author of the Linux Virtual Memory Manager), Mel Gorman Source software has Egypt, NCC). The rationale is to patch up GCC (if your version of GCC does not meet its requirements, download the correct version of GCC), let it dump the call graph of the function in each source file, and then collect and organize the calling relationship with the Perl script. Transfer to Graphviz draw graphics (Graphviz belong to back end, Codeviz belong to front end).



Codeviz was originally the author used to analyze the Linux virtual memory of the source code written by a small tool, now has a basic support for C + + language, the latest version 1.0.9 can be successfully compiled with Windows + Cygwin.



The basic introduction is here, if you are more interested in the principle, you can refer to this article: Analysis function call graph (called graph) several methods



Second, Graphviz + Codeviz compile installation



1. Installation GraphViz Call graph generation relies on GraphViz, so first install GraphViz. Can download source package compile, install (Download homepage: http://www.graphviz.org/Download.php).



If the Ubuntu system can be directly apt to install: sudo apt-get install Graphviz



2. Install Codeviz download codevize Source pack: http://www.csn.ul.ie/~mel/projects/codeviz/



Decompression: Tar xvf codeviz-1.0.12.tar.gz (currently the latest version is 1.0.12)



Into the unpacked directory: CD codeviz-1.0.12/



Codeviz uses a patch version of the GCC compiler, and different versions of the GCC version of the Codeviz version are different, you can download the Codeviz source package to see the Makefile file to determine the GCC version to use



Ben, codeviz-1.0.12 uses GCC-4.6.2. In fact, setup script make checks the current version of GCC if it is not compliant and automatically downloads the corresponding gcc and plays patch, but due to the large GCC if the network is not good and easy to download failure or system error in the virtual machine, so here we are better to install the step-by-step, the First install GCC and then come back to install Codeviz.



(1) Install GCC



Download gcc-4.6.2.tar.gz to the compilers in the CD codeviz-1.0.12 directory.



Download Address: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.6.2/gcc-4.6.2.tar.gz



The Codeviz installation script compilers/install_gcc-4.6.2.sh automatically detects if there is a GCC source package in the compilers directory, and if not, automatically downloads and plays patch. Here has been downloaded, directly moved to the directory, then the rest is the decompression installation. Install_gcc-3.4.6.sh will uncompress gcc and install it to the specified directory, and if no directory is specified, $home/gcc-graph is used by default, usually with the specified installation in/usr/



Local/gcc-graph (now requires root permission).



Installation:./install_gcc-4.6.2.sh



Note: There may be some errors installed here, specific errors and solutions to see later.



(2) Installation Codeviz



./configure && Make Install-codeviz



Note 1: Do not need make, because makes is to detect whether there is GCC if there is no download the source package, so as long as the installation of Codeviz can be. View the Makefile file specifically.



Note: Why this is not the usual make install, because the purpose of make install is to install GCC and install Codeviz, and then GCC is installed, so just install Codeviz, that is, make Install-codeviz script, which is to copy Genfull and gengraph to the/usr/local/bin directory.



So far, the Codeviz installation has been completed.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.