Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# e-Knife: Java edition
e-Knife is a program slicer for Java programs based on the Expression Dependence Graph (EDG).
You can also try this project through [the online demo](https://mist.dsic.upv.es/e-knife-java/).
This project consists of three modules:
* e-Knife: the frontend for the EDG, which implements the necessary tools to slice Java programs.
* EDG: the generic library that implements the graph and slicing techniques.
* Miscellaneous: various shared utilities.
## Compilation
Requirements: Java JDK ≥ 11 and Maven.
Download this project, then open a terminal inside the extracted folder and compile it with the following command:
```bash
mvn package
```
You'll find a file named `e-Knife-...-jar-with-dependencies.jar` inside the `e-Knife/target/` folder.
## Usage
Requirements: Java JRE ≥ 11.
Download the `.jar` file from the releases page or compile the project.
You'll probably want to generate slices, so you should run e-Knife. Run it without args
to obtain a list and explanation of arguments.
```
java -jar path/to/eknife.jar
```
There are 5 mandatory parameters. If one of them is missing the program will do nothing and print a help prompt.
- `-ip <file>`: the file to be sliced.
- `-li <number>`: the line where the slicing criterion is located.
- `-na <name>`: the variable of the slicing criterion.
- `-oc <number>`: the occurrence of the variable in the line (use 1 unless it appears more than one).
- `-op <file>`: the file where the slice should be saved.
For example, to slice `Example.java` with the slicing criterion `11, sum` and save the slice
to `ExampleSliced.java`, you can use the following command:
```
java -jar path/to/eknife.jar -ip Example.java -li 11 -na sum -oc 1 -op ExampleSliced.java
```
### View the sliced graph
To produce a graph, you must specify the optional argument `-pdf <file>`.
In non-trivial programs, the graph can be too complicated to be useful.
You can either:
1. Use the corresponding options to show/hide certain types of arcs (e.g., `-summary`, `-allarcs`, `-control`...).
2. Output the graph to a dot file using `-dot <file>`, and then manually delete unwanted arcs and/or
use an interactive graphviz viewer, such as [XDot][xdot].
[xdot]: https://github.com/jrfonseca/xdot.py
## Import into an IDE
In most Java IDEs you'll find an option to import an existing Maven project, and
thus load the project structure and settings from the `pom.xml` files.
Otherwise, you can treat each folder (EDG, e-Knife and Miscellanea) as a
separate module, with the following dependencies:
* e-Knife requires EDG and Miscellanea.
* EDG requires Miscellanea.
* Miscellanea has no dependencies.
## License
This project is licensed under GNU Affero Public License (Version 3.0).
You should have received a copy of the GNU Affero Public License along with this program.
If not, see https://www.gnu.org/licenses.