Manipulate C Intermediate Language ASTs with CIL
OCaml Shell C
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
etc
.gitignore
COPYING
Makefile
PKGBUILD
README
cilMutate.ml

README

Manipulate C Intermediate Language ASTs with CIL

This tool performs a number of operations on CIL ASTs parsed from C
source files.

      ids | prints the total number of statements
     list | list each statement with its ID
 fulllist | show each statements with its ID
     show | show the numbered statement
      cut | cut the numbered statement
    trace | instrument to trace execution
   insert | copies the second numbered statement before the first
     swap | swaps the two numbered statements

Installation

  The cil-mutate tool requires that CIL [1] be installed on your
  machine and able to be found by the ocamlfind utility.

  [1] http://kerneis.github.com/cil/

Examples

    $ cat etc/hello.c
    #include <stdio.h>
    int main(int argc, char *argv[])
    {
      puts("hello");
      return 0;
    }

    $ cil-mutate etc/hello.c
    extern int ( /* missing proto */  puts)() ;
    int main(int argc , char **argv )
    {


      {
      puts("hello");
      return (0);
    }
    }

    $ cil-mutate -ids etc/hello.c
    2

    $ cil-mutate -list etc/hello.c
    1 Instr
    2 Return

    $ cil-mutate -cut -stmt1 1 etc/hello.c
    extern int ( /* missing proto */  puts)() ;
    int main(int argc , char **argv )
    {


      {
      {

      }
      return (0);
    }
    }

    $ cil-mutate -swap -stmt1 1 -stmt2 2 etc/hello.c
    extern int ( /* missing proto */  puts)() ;
    int main(int argc , char **argv )
    {


      {
      return (0);
      puts("hello");
    }
    }

    $ cil-mutate -trace etc/hello.c
    void *_coverage_fout ;
    extern int ( /* missing proto */  puts)() ;
    int main(int argc , char **argv )
    {


      {
      if (_coverage_fout == 0) {
        _coverage_fout = fopen("trace", "wb");
      }
      fprintf(_coverage_fout, "1\n");
      fflush(_coverage_fout);
      puts("hello");
      fprintf(_coverage_fout, "2\n");
      fflush(_coverage_fout);
      return (0);
    }
    }

    $ cil-mutate -show -stmt1 1 etc/hello.c
    #line 4 "hello.c"
    puts("hello");

License

  Licensed under the GPLV3, see the COPYING file in this directory for
  more information.