-
Notifications
You must be signed in to change notification settings - Fork 24
SVFIR
- SVFIR is the demo program sample to understand SVFIR and their graph representations, i.e., ICFG and PAG
SVFIR/
|-- CMakeLists.txt
|-- SVFIR.cpp
|-- compile.sh
`-- src
|-- swap.c
|-- control-flow.c
|-- example.c
`-- demo.c
* Before coding, please type cd $HOME/Software-Security-Analysis
and git pull
in your terminal to make sure you always have the latest version of the code template.
Option 1: Generate LLVM IR of example.c
via the following command line
cd /home/SVF-tools/Software-Security-Analysis/SVFIR
clang -S -c -O0 -fno-discard-value-names -emit-llvm src/example.c -o example.ll
opt -S -p=mem2reg example.ll -o example.ll # optional command line to simplify the IR to promote memory operations to registers
Option 2: Generate LLVM IR via compile.sh
cd /home/SVF-tools/Software-Security-Analysis/SVFIR
sh compile.sh src/example.c
The .ll file (i.e., example.ll) will be generated under the /home/SVF-tools/Software-Security-Analysis/SVFIR
folder
3.1 launch.json
You need to set the "program"
to be the executable file of SVFIR, i.e., "${workspaceFolder}/bin/svfir"
in
launch.json in order to run and debug
You need to set the "args"
to be the .ll file you have just generated, i.e., "${workspaceFolder}/SVFIR/example.ll"
in
launch.json in order to run and debug
3.2 Debug and run SVFIR.cpp
-
The code in
SVFIR.cpp
shows examples of printing and dumping three types of code graphs, including ICFG, PAG and Constraint Graph. -
Tips for debugging: Always good to use "toString()" method to understand the value of each node and each edge on a code graph
-
The two dot files (i.e,
example.ll.icfg.dot
andexample.ll.pag.dot
) will be generated under the/home/SVF-tools/Teaching-Software-Verification/SVFIR
folder
- Open the dot file under, for example,
/home/SVF-tools/Teaching-Software-Verification/SVFIR/example.ll.icfg.dot
which is the ICFG of the program and call out the command palette
- Enter
> Graphviz
and select `Interactive Preview (beside)
- You will see the ICFG on the right hand side