Installation and use of CODEVIZ+GRAPHVIZ+GCC

Source: Internet
Author: User
Tags gmp pack stdin perl script
Codeviz is the author of "Understanding the Linux Virtual Memory Manager" (at Amazon, download the address at the end of the page), wrote by Mel Gorman, an op that analyzes the relationship of function calls in C + + source code The En source tool (similar to the open source software has Egypt, NCC). The rationale is to patch up GCC and let it dump the call graph of the function in each source file at compile time, and then collect and organize the invocation relationship with the Perl script and hand it over to Graphviz to draw the graph.

Installation premise: After many tests, I found that 64-bit Linux installation failed, under 32-bit RHEL 6.5 installed successfully
First, download the installation package 1, codeviz-1.0.12 http://www.csn.ul.ie/~mel/projects/codeviz/2, graphviz-2.38.0 http://ww w.graphviz.org/download_source.php 3, gcc-4.6.2 http://ftp.gnu.org/gnu/gcc/gcc-4.6.2/gcc-4.6.2.tar.gz 4, installation of GCC required          Dependency Pack 4.1 mpc-1.0.3 http://www.multiprecision.org/index.php?prog=mpc&page=download 4.2 mpfr-3.1.4 http://www.mpfr.org/4.3 gmp-5.0.1 https://gmplib.org/
Second, install 1, will download the installation package on the/home/shlian/downloads/directory, decompression: Codeviz, Graphviz, MPC, MPFR, GMP to the current directory
2. Install GCC Dependency Pack CD gmp-5.0.1./configure--prefix=/usr && make && sudo make install && Cd.. /mpfr-3.1.4 &&/configure--prefix=/usr && make && sudo make install && CD. /mpc-1.0.3 &&/configure--prefix=/usr && make && sudo make install execute the following command to install GMP, MPFR, and MPC, because the MPC relies on GMP, MPFR 3, installs Graphviz CD graphviz-2.38.0./configure--prefix=/usr && make &&am P sudo make install 4, install Codeviz CD codeviz-1.0.12 CP. /gcc-4.6.2.tar.gz compilers./configure--prefix=/usr && make && sudo make install installing GCC takes approximately To one hours or so, slowly let him install it ..... After waiting patiently, the installation is finished, then you can use the
After the installation is complete, you will have the following information: patched GCC is installed to/usr/local/gccgraph. To compile a project for UseWith Codeviz, genearlly the following'll work make CC=/USR/LOCAL/GCCGRAPH/BIN/GCC org++ to generate a full.graph file forC UseGenfull forC + +, make sure UseThe Cppdepn method with Genfull-g CPPDEPN orThe results won't be what to you expect.
This GCC will be installed by default to the/usr/gccgraph/bin/directory,
Third, the use of the process

1. Use the gcc-4.6.2 you just installed to compile all the. C files in the current directory, gcc/g++ generate. cdepn files for each of the compiled/C + + files. Just compile (parameter-c) on the line, no link required.

That is:/USR/GCCGRAPH/BIN/GCC test.c-c


2. The call genful generates a full.graph file in the current directory that generates a complete call graph information file for the project, recording the location of all functions in the source code and the invocation relationship between them. Therefore, the call graph information file can be very complex, and the CDEPN file is used by default to create the call graph information file.

That is: Genfull-f TEST.C.CDEPN


3. Using Gengraph, you can generate a small call graph main.ps for a given set of functions, showing the function invocation relationship.

That is: $ gengraph-f main-g full.graph

In the visual environment, open main.ps, of course, can also generate other formats of the picture, see the following text
Iv. Example Demo 1, write a simple program: 2, using just installed GCC compiled:

Generates a TEST.C.CDEPN file containing information about the generated. Graph 谇:

3, generate Full.graph file to view the contents of the Full.graph file: 4, Generate graphics files: This main.ps can be used in the visual environment to open the Graphviz, see Effect map: This picture is very clear Response to the call relationship between functions to generate different types of graphics files: gengraph--output-type "PNG"-F main #详见gengraph--man Five, command parameters detailed 1, genfull genfull --man #可查看详细的参数 2, gengraph gengraph--man #可查看详细的参数

-F: Specifies the top-level function, that is, the entry function, such as main (which, of course, is not defined as main);

-O: Specifies the output of the Postfile file name, not specified is the function name, such as the above main;

--output-type: Specifies the output type, such as PNG, GIF, HTML, and PS, and defaults to PS, as above main.ps;

-D: Specifies the maximum number of call layers;

-S: Displays only the specified function, not the call to expand;

-I: ignoring the specified function

-T: ignores Linux-specific kernel function sets;

-K: Preserves the intermediate file formed by the internal details that are ignored by-s, for Sub.graph Six, PostScript: 1, after the installation completes, calls Gengraph (gengraph-f main-g full.graph) generates the PS format file, will report the following error: :<stdin> error:syntax Error in line 4 near '; ', do not know why, not yet resolved, but can generate main.ps, and main.ps information is correct, see the above effect chart. If you use gengraph-f main-g full.graph--output-type "PNG" will not be an error ... 2, if it is C + + files, using genfull-g cppdepn TEST.C.CDEPN generated full.graph, but in the call Gengraph, error: error:<stdin> error:syntax error In line 4 near '; Error: <stdin>: syntax error in line near ' _tp ' and generate not main.ps,
after many tests found that the error and--output-type output format is related, some format will not be an error, some will Error, really doubt gengraph exist problem-solving method is still looking for ...

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.