Intra-function slicer for C code. This repository a lightweight implementation of extracting forward and backward slices from a given source code.
This slicer is based on Joern Fuzzy Code parser.
- Gradle (
sudo apt-get install gradle
) - Graphviz (
sudo apt install graphviz-dev
) - Python >= 3.5
- Enter into the source code
cd C-Code-Slicer
- Build Joern
cd joern ./build.sh cd ..
To extract slice use
./slicer.sh <Dir> <FileName> <LineNo> <OutDir> <DataFlowOnly(Optional)>
For Example
./slicer.sh test test1.c 7 test-output
- Dir: The directory path of the .C file.
- FileName: Name of the C file (*.c format)
- LineNo: Line Number where the slice will begin.
- OutDir: The Directory path for the output.
- DataFlowOnly: This is optional, if this is mentioned, slicer will produce slices only on dataflow graph.
This slicer will produce 4 outputs in the OutDir.
- <OutDir>/<FileName>.forward will contain the lines in the forward slice.
- <OutDir>/<FileName>.backward will contain the lines in the backward slice.
- <OutDir>/<FileName>pdf will contain the visual representation of the graph.
- <OutDir>/<FileName> will contain the dot representation of the graph.
- As of now, we assume only one function per c file.