It is advised to go through Docs
to get an understanding of the project. If you are in a hurry, this will get you set
up.
- Before building the project, make sure the dependencies are met. You can also make use of the docker image, where the environment is already set up for you.
- Clone
Hydrogen
from GitHub. If you are using the Docker, you can clone it into/home/Hydrogen/MVICFG
folder. - Compile
Hydrogen
with the help ofCMakeLists.txt
. You can also useGNU Make
, if that is the preferred method. - Assuming you are using the Docker and Ninja, the steps would be like below. But first install Docker using the recommended method for your system.
# Download and run the Docker from your system.
$ docker run -it --name Hydrogen_Env ashwinkj/hydrogen_env
# The above command will put you inside the Docker Container.
$$ git clone https://github.com/iowastateuniversity-programanalysis/hydrogen /home/Hydrogen/MVICFG
$$ cd /home/Hydrogen/MVICFG
$$ mkdir BuildNinja
$$ cmake -B BuildNinja -G Ninja .
$$ cd BuildNinja
$$ ninja
- Hydrogen needs both the source code and LLVM IR code to generate MVICFG and output it as
MVICFG.dot
for visualization. - To compile a single file program into LLVM IR code necessary for Hydrogen invoke
clang
with-O0 -Xclang -disable-O0-optnone -g -emit-llvm -S
flag. - To generate MVICFG, call Hydrogen with both the LLVM IR and paths to their source files. Hydrogen will generate the diff from the source files to generate the MVICFG.
- Assuming that you have two versions of
Prog.c
in two folderBuggy
andCorrect
, the tentative steps to generate MVICFG is shown below.
# In folder Buggy, compile Prog.c into LLVM IR (ProgV1.bc)
$ cd TestPrograms/Buggy
$ clang -c -O0 -Xclang -disable-O0-optnone -g -emit-llvm -S Prog.c -o ProgV1.bc
# Similary in folder Correct, compile Prog.c into LLVM IR (ProgV2.bc)
$ cd ../Correct
$ clang -c -O0 -Xclang -disable-O0-optnone -g -emit-llvm -S Prog.c -o ProgV2.bc
- Once the LLVM IR are generated, then use Hydrogen to generate the MVICFG.
# Generic Command
$ Hydrogen.out <Path-to-LLVMIR_1> <Path-to-LLVMIR_2> .. <Path-to-LLVMIR_N> :: <Path-to-file1-for-Prog_V1> ..\
<Path-to-fileN-for-Prog_V1> :: <Path-to-file1-for-Prog_V2> .. <Path-to-fileN-for-Prog_V2> ..
# Command for the above example from BuildNinja folder
$ ./Hydrogen.out ../TestPrograms/Buggy/ProgV1.bc ../TestPrograms/Correct/ProgV2.bc :: ../TestPrograms/Buggy/Prog.c ::\
../TestPrograms/Correct/Prog.c
- A python script
BuildSystem.py
is provided to ease the process of invoking the Hydrogen executable. It will also rebuild Hydrogen (if necessary) and transfer the resultingMVICFG.dot
file into the parent directory. This python script is an example to base your own scripts. You might need to adpat this into bash script if running in Docker.
Hydrogen depends on the LLVM Framework
and Boost Libraries
. Roughly, the following are required for Hydrogen to
build properly
Program | Version |
---|---|
Clang |
8.0 |
LLVM |
8.0 |
Boost |
1.69 |
Cmake |
3.14 |
Ninja |
1.9 |
While slightly older versions for Cmake
and Ninja
can be used without any problem, using older versions of
LLVM Framework
and Boost
can have unwanted consequences and may even result in build failure.
Comments and more details for the program including the class structure with their supporting functions and their purpose can be
found in Doc
folder. Follow the README.txt
inside the folder for more information.
In case of questions about the usage/functionality of the framework or if you want to report a bug, please email hydrogen-mvicfg@iastate.edu
. The repository will be updated with more features and bug fixes in time, but there will be a delay in responding to the emails.
This work is developed under the support of the National Science Foundation (NSF) under Award 1542117