Giter Club home page Giter Club logo

cil-mutate's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.