Dehydra GCC: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎Talk: Fix words repetition and a typo)
Line 45: Line 45:
==Talk==
==Talk==


At Mozilla we extended GCC to assist with our refactoring efforts. Refactoring tools at Mozilla fall into two categories: analyzing code and rewriting code. We added a plugin mechanism that allows plugins to hook into various front and middle-end passes. The Dehydra plugin implements a JavaScript query API for the AST to meet our analysis needs. Dehydra enables the user to write scripts that look for deprecated APIs, find unsafe code and other static analysis type checks. This meets our analysis needs analysis needs well.  
At Mozilla we extended GCC to assist with our refactoring efforts. Refactoring tools at Mozilla fall into two categories: analyzing code and rewriting code. We added a plugin mechanism that allows plugins to hook into various front and middle-end passes. The Dehydra plugin implements a JavaScript query API for the AST to meet our analysis needs. Dehydra enables the user to write scripts that look for deprecated APIs, find unsafe code and other static analysis type checks. This meets our analysis needs well.  




In this talk background will be given on the refactoring challenges due to the size of the Mozilla codebase. The shall discuss our experience with reusing the gcc frontend. In addition to analysis, we shall also discuss our needs for C/C++/etc source rewriting.
In this talk background will be given on the refactoring challenges due to the size of the Mozilla codebase. We shall discuss our experience with reusing the gcc frontend. In addition to analysis, we shall also discuss our needs for C/C++/etc source rewriting.


http://www.gccsummit.org/2008/cfp.php
http://www.gccsummit.org/2008/cfp.php

Revision as of 22:30, 29 January 2008

Dehydra GCC is a C version of DeHydra implemented as a GCC plugin.

Installation

hg clone http://gcc.gnu.org/hg/gcc/trunk gcc

Add mq repository from http://hg.mozilla.org/users/tglek_mozilla.com/gcc-moz-plugin-mq/. This requires mq to be enabled.

cd gcc
hg clone http://hg.mozilla.org/users/tglek_mozilla.com/gcc-moz-plugin-mq .hg/patches
hg qpush -a
cd ..

Compile gcc with

mkdir gcc-build
cd gcc-build
# following export is only needed if debugging
export CFLAGS=-O0 -g3
# add  --enable-checking --disable-bootstrap for debugging/development of gcc plugins
../gcc/configure --enable-languages=c++ --without-libstdcxx
make
cd ..

Compile the dehydra plugin:

hg clone http://hg.mozilla.org/users/tglek_mozilla.com/dehydra-gcc/
cd dehydra-gcc
make

Run dehydra-gcc tests

cd test
make

Hacking GCC

Very useful GCC guide

debug trees by doing print debug_tree(t)

"make stage1-gcc" with --enable-stage1-langues=c,c++ (etc.) or "make all-gcc;cd gcc;make clean;make -j3 cc1 cc1plus xgcc"


To dump a cfg: -fdump-tree-cfg

suppose you want to dump the results of CCP, you use -fdump-tree-ccp, if you say -fdump-tree-ccp-blocks will show block boundaries.

this shell script will generate a .dot file for you out of that dump: http://www.airs.com/dnovillo/pub/dump2dot

Talk

At Mozilla we extended GCC to assist with our refactoring efforts. Refactoring tools at Mozilla fall into two categories: analyzing code and rewriting code. We added a plugin mechanism that allows plugins to hook into various front and middle-end passes. The Dehydra plugin implements a JavaScript query API for the AST to meet our analysis needs. Dehydra enables the user to write scripts that look for deprecated APIs, find unsafe code and other static analysis type checks. This meets our analysis needs well.


In this talk background will be given on the refactoring challenges due to the size of the Mozilla codebase. We shall discuss our experience with reusing the gcc frontend. In addition to analysis, we shall also discuss our needs for C/C++/etc source rewriting.

http://www.gccsummit.org/2008/cfp.php