resess / slicer4j Goto Github PK
View Code? Open in Web Editor NEWSlicer4J is an accurate, low-overhead dynamic slicer for Java programs.
License: MIT License
Slicer4J is an accurate, low-overhead dynamic slicer for Java programs.
License: MIT License
i'm trying to execute the SliceMe example but i'm facing some issues. i made sure that the files structure is as instructed, but when i run the python command i get these errors:
when i ran mvn -Dmaven.test.skip=true clean install to the Slicer4J i got this error:
even though it has built successfully, it might be the cause but i couldn't figure how to fix it.
java version 1.8, python 3.
any help?
Issue.java
:
1. import java.util.ArrayList;
2. import java.util.List;
3.
4. public class Issue {
5.
6. static List<String> list = new ArrayList<>();
7.
8. public static void main(String[] args) {
9. list.add("A");
10. System.out.println(list.get(0));
11. }
12. }
Running Slicer4J w.r.t. Issue:10
line:
python3 slicer4j.py -j .../issue.jar -o .../issue -b Issue:10 -m "Issue"
slice.log
:
Issue:10
Issue:6
As you can see, the statement list.add("A")
on the 9th line wasn't included in the slice.
Note: if the variable list
was declared inside the method body, the statement list.add("A")
would be included in the slice.
In the run_benchmarks.py file you generated slice for the following paramters:
"JacksonCore_4b": ("target/jackson-core-2.5.0-SNAPSHOT.jar", "org.junit.runner.JUnitCore com.fasterxml.jackson.core.util.TestTextBuffer", "com.fasterxml.jackson.core.util.TextBuffer", "587", "expandCurrentSegment", "JacksonCore_4b/target/test-classes/:JacksonCore_4b/target/dependency/*"),
when debugging I am not finding 587 line in the com.fasterxml.jackson.core.util.TextBuffer test class, neither did I find the expandCurrentSegment method. In the paper you mentioned that you used failing test assertion statement as the slicing criterion , but none of the criteria are taken from a test file. I am investigating this as I am having troubling generating slice from the test assertion as I mentioned in another issue. Any clarification will be highly appreciated.
I am trying to generate the dynamic slice for the junit assertions in a test class of the joda-time subject. However, the script throws error such as:
looking for LINENO:324:FILE:org.joda.time.tz.TestBuilder
None
Traceback (most recent call last):
File "run_benchmarks.py", line 207, in
run_slicer4j(project, jar_name, project_arg, extra_libs, sc_file, slice_line)
File "run_benchmarks.py", line 148, in run_slicer4j
line = sc.split(", ")[0]
AttributeError: 'NoneType' object has no attribute 'split'
Is it because the tool does not instrument test classes? Not sure if I am making any mistake, any help would be highly appreciated!
While I was working with slicer4J I discovered the below two false positives in the slice (statements that are irrelevant to the criteria but exist in the slice).
Issue 1: performing backward slice from produce (line 11) should not include the statements related to sum (line 10).
In the slice-dependencies.log there is the below dependency which caused the statement depending on sum to be included in the slice:
(testDebug:10) virtualinvoke $stack12.<java.io.PrintStream: void println(double)>(sum) <--data:java.lang.System.out-- testDebug:11
Issue 2: performing backward slice from line 22 should not include lines 1 and 2. In the slice-dependencies.log, these two lines are included in the slice because the control dependency of Func() (line 10) on them. Since C is depending on Func(), the lines 1 and 2 are eventually in the slice. This was the essence of the issue but I attached one of the defects4J cases (Math 37) which slicing from line 1054 in org.apache.commons.math.complex.ComplexTest includes lines 39 and 40 in this file.
bug.zip
1: A = Func(1)
2: B = Func(2)
3: C = Func(3)
....
10: Func(){…}
...
20: Test(A, 10)
21: Test(B, 20)
22: Test(C, 30) ==> slicing critters
Hi,
In the readme, it was just changed to specify that 8 is the required java environment version.
I just wanted to see if this is correct -- I just installed and ran all of the tests with openjdk 15.0.3 and everything seems to work, but I just wanted to see if there was something about newer versions that breaks the Slicer4J in a way that the tests and installation would not detect.
Thanks!
Main.java
:
1. import java.util.Arrays;
2.
3. public class Main {
4.
5. public static void main(String[] args) {
6. int[] a = new int[]{ 0, 1 };
7. a = addAndReturn(a);
8. add(a);
9. System.out.println(Arrays.toString(a));
10. }
11.
12. public static void add(int[] a) {
13. a[0] += 1;
14. }
15.
16. public static int[] addAndReturn(int[] a) {
17. a[0] += 1;
18. return a;
19. }
20. }
If we run the program, it outputs:
[2, 1]
Running Slicer4J w.r.t. Main:9
line, we get the following slice:
cd scripts
python3 slicer4j.py -j ../example.jar -o ../example -b Main:9 -m "Main"
slice.log
:
Main:6
Main:7
Main:17
Main:18
Main:9
Despite method add()
affecting the state of variable a
, it wasn’t included in the slice, and the sliced program prints:
[1, 1]
Hi there, I got another problem with Jar instrumentation.
I tried to slice test cases from javapoet and I got the following error message in instr-debug.log
:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/lukas/workspace/master-jsr/slicer/Slicer4J/Slicer4J/target/slicer4j-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/lukas/workspace/master-jsr/slicer/Slicer4J/Slicer4J/target/lib/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[main] INFO JimpleWriter - initialize (17): Initializing Instrumenter
[main] INFO JimpleWriter - initialize (29): Initialization done
[main] INFO JimpleWriter - start (36): Running packs ...
[main] INFO JimpleWriter - start (38): Writing output ...
[main] INFO JimpleWriter - start (40): Output written ...
[main] INFO JavaInstrumenter - initialize (78): Initializing Instrumenter
[main] INFO JavaInstrumenter - initialize (97): Initialization done
[main] INFO JavaInstrumenter - start (250): Running packs ...
[main] INFO JavaInstrumenter - start (252): Writing output ...
[Thread-57] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: value null
java.lang.IllegalArgumentException: value null
at org.objectweb.asm.SymbolTable.addConstant(SymbolTable.java:501)
at org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:259)
at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:595)
at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:549)
at soot.AbstractASMBackend.generateAnnotations(AbstractASMBackend.java:521)
at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:355)
at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:273)
at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:224)
at soot.PackManager.writeClass(PackManager.java:1141)
at soot.PackManager.lambda$writeOutput$1(PackManager.java:699)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "Thread-57" Exception in thread "main" java.lang.IllegalArgumentException: value null
at org.objectweb.asm.SymbolTable.addConstant(SymbolTable.java:501)
at org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:259)
at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:595)
at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:549)
at soot.AbstractASMBackend.generateAnnotations(AbstractASMBackend.java:521)
at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:355)
at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:273)
at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:224)
at soot.PackManager.writeClass(PackManager.java:1141)
at soot.PackManager.lambda$writeOutput$1(PackManager.java:699)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
java.lang.IllegalArgumentException: value null
at org.objectweb.asm.SymbolTable.addConstant(SymbolTable.java:501)
at org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:259)
at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:595)
at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:549)
at soot.AbstractASMBackend.generateAnnotations(AbstractASMBackend.java:521)
at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:355)
at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:273)
at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:224)
at soot.PackManager.writeClass(PackManager.java:1141)
at soot.PackManager.lambda$writeOutput$1(PackManager.java:699)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Here's the fat jar I created from the project:
javapoet-1.14.0-SNAPSHOT-fat-tests.zip
This is not the first time that I am seeing issues related to SymbolTable
. When I was trying to perform slicing on the commons-lang
library I got similar errors during instrumentation. This is really a problem because I need to benchmark at least 10 projects for my Master's thesis and so far Slicer4J managed to work with 3 of over 20 open source projects I tried.
I would be really happy if you could look into this issue. Thank you.
It seems that the root .gitmodules file wasn't committed to the repo. This problem prevents users of this repo from running the defects4j benchmarks.
Hello,
I am currently trying to create dynamic slices from the test cases of this project. The project depends on the following libraries:
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
I've created a fat jar containing the compiled source and test classes, as well as the classes of all libraries.
After instrumenting the jar with SLice4J (mode i
), the classes from javax.servlet
are all missing in the resulting *_i.jar
file! This is a problem as I get exceptions like this one for obvious reasons when I want to trace the execution:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
Is there something I can do as a user of Slicer4J to fix this or is this a problem/bug in the implementation or one of its libraries (soot?)?
Thanks and have a nice day!
Hello,
first off, thank you very(!) much for your contribution. I am a student at Graz University of Technology and I am currently working on my Master's thesis which deals with test suite reduction. For my approach I need to compute dynamic slices of Java programs and thus I was very happy when I found out that this tool was published just weeks before I started with my project. I'll make sure to cite your publication and give proper credit to you in my thesis!
Unfortunately though, as of now, I cannot seem to get the slicer working. Some words on my environment: I use Archlinux and I tried everything with JDK 11 and 16 but there's no difference in behaviour.
I tried to follow the Readme to produce a dynamic slice of the SliceMe
program. For that I conducted the following steps:
mvn -Dmaven.test.skip=true clean install
for both, the core
and the Slicer4J
repocd
'd to benchmarks/SliceMe
and performed a mvn clean install
there to get the target/sliceme-1.0.0.jar
.Then I first tried to run the provided python script for Slicer4J:
python3 ../../scripts/slicer4j.py -j target/sliceme-1.0.0.jar -o sliceme_slice/ -b SliceMe:9 -m "SliceMe"
which provided the following output:
Instrumenting the JAR
Instrumented jar is at: /home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/sliceme_slice/sliceme-1.0.0_i.jar
Running the instrumented JAR
Running instrumented JAR
------------------------------------
Error: Main Class SliceMe could not be found or loaded
Caused by: java.lang.ClassNotFoundException: SliceMe
------------------------------------
Slicing from line SliceMe:9
Traceback (most recent call last):
File "/home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/../../scripts/slicer4j.py", line 181, in <module>
main()
File "/home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/../../scripts/slicer4j.py", line 67, in main
log_file, slice_graph = dynamic_slice(jar_file=jar_file, out_dir=out_dir, backward_criterion=backward_criterion,
File "/home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/../../scripts/slicer4j.py", line 128, in dynamic_slice
line = sc.split(", ")[0]
UnboundLocalError: local variable 'sc' referenced before assignment
I also tried to run the Slicer4J jar directly as described in the Readme (with the -h
option just to verify if the program actually works):
java -cp "../../Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h
which yielded the following error message:
Error: Main class ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer cannot be initialized
Caused by java.lang.NoClassDefFoundError: soot/Type
Please note that I translated parts of the error message from German to English so they might not be a 100% equal to the actual english output.
It could very well be an error on my end but I can run every other Java program correctly on my system.
Anyway, I'd be glad if you could help me. Thanks a lot again.
Hello again,
after getting SLicer4J to run, I started looking into the source code and the dependencies. I noticed that Slicer4J's pom.xml
declares soot-infoflow
as a dependency with a local jar. I assume that was because by the time of developing the tool version 2.9 of the library was not yet released. According to Maven Central version 2.9.0 is publicly available, removing the necessity of including the snapshot jar in this repository in the libs
directory. I edited the pom.xml
locally and it seems that everything works as before.
If you want I can submit a PR with the updated pom.xml
(although the change is quite subtle).
Have a good day!
Hi,
I'm a PhD student from the University of Buenos Aires, I read your paper, Slicer4J: A Dynamic Slicer For Java, and in my opinion, this is a great contribution. So, thank you so much, I appreciate your research on this topic.
I wanted to try to use it on some programs... but I had a soundness problem in the presence of recursive methods. I don't know if this is a known issue or if I'm doing something wrong.
I'm attaching the complete source code for reproducing this issue (2 files), the log and the slice file produced by this tool.
This is TreeAdd, from Olden's benchmark. If you run this program with "-l 2", and slice on line 53 (TreeAdd:53) the slice is:
TreeAdd:36
TreeAdd:40
TreeAdd:53
TreeNode:49
TreeNode:101
TreeNode:106
int addTree()
{
int total = value; /* line 101 */
if (left != null)
total += left.addTree();
if (right != null)
total += right.addTree();
return total; /* line 106 */
}
The problem is between lines 101 and 106.
As you can see in the log, lines from 101 to 106 are executed and they are used to compute the variable total returned in 106 (of TreeNode), which is used to print the criterion in line 53 of TreeAdd.
In Javaslicer they are part of the slice (I checked this and it's okay).
It's important to run this with "-l 2" (or a greater number) as arguments for replying this behaviour.
Thanks in advance for everything.
Hi, when I try to run the benchmark using the python3 run_benchmarks.py command, it does not find the javaslicer inside the benchmark directory. Even though it does not show any error by the slice size is zero for the javaslicer and investigating further inside the result directory I found that this tool is not found. Any idea why that would happen?
Benchmark: javaslicer-bench1-intra-procedural
Original exec time (s): 0.04744410514831543
Running Slicer4J
Instrumentation time (s): 0.7002263069152832
Execution time (s): 0.04601740837097168
Slice time (s): 0.9844796657562256
Length of trace (Jimple LoC): 10
Slice size (Java LoC): 6
Running JavaSlicer
Instr + exec time (s): 0.005282878875732422
Slice time (s): 0.0013234615325927734
Length of trace (bytecode LoC): 0
Slice size (Java LoC): 0
Hi again,
I think that I'll be your main slicer tester.
This is because I'm working on my own dynamic slicer and I'm performing several tests.
In this case, I'll use the same case as before, TreeAdd.
I developed a comparer for helping me to characterize the difference between different slicers.
I'm slicing from line 53 in TreeAdd.java with the same parameters as before "-l 2".
In this picture, lines from 101 to 106 are in the slice, and this is OK!
But in this picture, lines 54 and 55 are not in the slice.
At the left is my slicer, in the middle Javaslicer, in the right Slcier4j (I used the same for comparing to ORBS).
Probably, I guess, this is because the compiler omits those lines (since null values are the default ones...).
I don't know if this is easy or not to solve,
Anyway, I'll upload more "issues" as soon, I hope the best for this tool,
And if you need some help I can help :)
Regards.
Main.java
:
1. import java.util.Arrays;
2. import java.util.Collection;
3. import java.util.HashSet;
4. import java.util.Set;
5.
6. public class Main {
7.
8. public static void main(String[] args) {
9. PairSet<Integer, String> pairSet = new PairSet<>(Arrays.asList(new Pair<>(1, "A"), new Pair<>(2, "B")));
10. System.out.println(pairSet);
11. }
12. }
13.
14. class PairSet<T, G> {
15.
16. Set<Pair<T, G>> set;
17.
18. public PairSet() {
19. set = new HashSet<>();
20. }
21.
22. public PairSet(Collection<Pair<T, G>> collection) {
23. this();
24. set.addAll(collection);
25. }
26.
27. @Override
28. public String toString() {
29. StringBuilder sb = new StringBuilder();
30. for (Pair<T, G> pair : set) {
31. sb.append(pair).append('\n');
32. }
33. return sb.toString();
34. }
35. }
36.
37. class Pair<T, G> {
38.
39. T first;
40. G second;
41.
42. public Pair(T first, G second) {
43. this.first = first;
44. this.second = second;
45. }
46.
47. @Override
48. public String toString() {
49. return String.format("%s %s %s", first, (char) 8212, second);
50. }
51. }
If we run the program, it outputs:
2 — B
1 — A
Running Slicer4J w.r.t. Main:10 line:
cd scripts
python3 slicer4j.py -j .../issue.jar -o .../issue -b Main:10 -m "Main"
slice.log
:
Main:10
Main:9
PairSet:23
PairSet:18
PairSet:19
Class Pair
and both toString()
methods were not included at all, despite Pair
constructor was definitely executed.
Not included class Pair
is relevant to my previous issue #10, which means that the same thing will happen with any
data classes. Lines 16 and 24 are directly related to the issue #10.
Issue.java
:
1. public class Issue {
2.
3. public static void main(String[] args) {
4. int b = 2;
5. int a = 1 + b;
6. System.out.println(a);
7. }
8. }
Running Slicer4J w.r.t. Issue:6
line:
cd scripts
python3 slicer4j.py -j .../issue.jar -o .../issue -b Issue:6 -m "Issue"
slice.log
:
Issue:5
Issue:6
Despite variable a
is data-dependent on variable b
, the line with declaration of variable b
wasn't included in slice.log
.
In the example from README
the same situation is observed:
For the example,
slice.log
contains:SliceMe:4 SliceMe:7 SliceMe:9
Which indicates that the slice is:
4. if (args.length > 0){ 7. parsed = null; 9. System.out.println(parsed.length);
In this example line with declaration of variable parsed
also wasn't included in slice.log
.
Is such behaviour expected?
Issue.java
:
1. public class Issue {
2.
3. public static void main(String[] args) {
4. if (args.length != 1)
5. throw new IllegalArgumentException();
6. Integer length = getLength(args[0]);
7. String output = "Empty";
8. if (length != null) {
9. output = "Not " + output;
10. }
11. System.out.println(output);
12. }
13.
14. private static Integer getLength(String s) {
15. int length = s.length();
16. if (length == 0) {
17. return null;
18. }
19. return length;
20. }
21.
22. }
Running Slicer4J w.r.t. Issue:11
line:
cd scripts
python3 slicer4j.py -j ../issue.jar -o ../issue -b Issue:11 -m "Issue something"
And it fails with:
Slicing from line Issue:11
Traceback (most recent call last):
...
UnboundLocalError: local variable 'sc' referenced before assignment
Line 117 in 235b466
trace.log_icdg.log
does not contain jimple-statement println()
and statement with LINENO:11:FILE:Issue
at all.if (args.length != 1)
, if (javaFiles != null)
or method call with parameter args[0]
– getLength(args[0])
, it will work fine.Hi @khaled-e-a,
I wonder if you can kindly advise me on how to create a suitable jar for Slicer4J from Defects4J. I have tried to compile a Defects4J project using their "defects4j compile" and then create a jar using jar cf but it seems to be not working. Particularly, when using jar produced by jar cf, I got nothing from the trace log. I guess there may be some mismatch leading to my produced jar are not compatible with Slicer4J. I'd really appreciate it if you could share the way you construct your benchmark projects.
Thank you very much.
Best regards,
Thanh
Here are three defects4J cases from the chart project (as examples) that Slicer4J does not produce the full slice for. The uploaded zip file (Google Drive) contains these three cases. Inside each case, there is a "bug" folder containing the program and a file "failing_tests" which includes the failing test and the line number as the slicing criteria. In addition, there is a "results" folder in each case that includes "REASESlice" and "EARSETrace" outputted by another slicing tool (for your reference) and a "Slicer4JResults" folder which includes the output of the Slicer4J in this case. I also provided the mapping between the EARSETrace and Slicer4J Trace to make the comparison of slices easier. More specifically, the cases are:
Case 4:
python3 /PATH_TO/Slicer4J/scripts/slicer4j.py -j /PATH_TO/4/results/new/program.jar -o /PATH_TO/4/results/new/Slicer4JResults -b org.jfree.chart.axis.junit.LogAxisTests:260 -tc org.jfree.chart.axis.junit.LogAxisTests -tm testXYAutoRange1 -dep /PATH_TO/4/bug/lib
Case 15
python3 /PATH_TO/Slicer4J/scripts/slicer4j.py -j /PATH_TO/15/results/new/program.jar -o /PATH_TO/15/results/new/Slicer4JResults -b org.jfree.chart.plot.junit.PiePlot3DTests:151 -tc org.jfree.chart.plot.junit.PiePlot3DTests -tm testDrawWithNullDataset -dep /PATH_TO/15/bug/lib
Case 19
python3 /PATH_TO/Slicer4J/scripts/slicer4j.py -j /PATH_TO/19/results/new/program.jar -o /PATH_TO/19/results/new/Slicer4JResults -b org.jfree.chart.plot.junit.CategoryPlotTests:761 -tc org.jfree.chart.plot.junit.CategoryPlotTests -tm testGetRangeAxisIndex -dep /PATH_TO/19/bug/lib
when I run this usage command java -cp "Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h, it throws exception
slicer4j/Slicer4J$ java -cp "Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h
usage: java -jar Slicer4j/target/slicer4j-jar-with-dependencies.jar
-ctrl,--Control-only Track control dependence only
-d,--debug Enable debug
-data,--data-only Track data-flow dependence only
-f,--framework Path to folder with extra framework
methods
-fw,--forward-slice-position starting statement for the forward
slice (for chopping)
-h,--help Display this help and exit
-j,--jar jar path
-lc,--logger-classes logger classes jar
-m,--mode Tool mode: i for instrument, g to
produce the dynamic control flow
graph, s to slice
-o,--outDir Output directory
-once,--once Slice one step only
-sd,--stub-droid Location of the StubDroid summaries
-sl,--static-log Static-log file path
-sp,--slice-position starting statement for the slice
-sv,--slice-variables dash-joined list of starting
variables to slice from
-t,--trace Execution trace
-tw,--taint-wrapper Location of the FlowDroid's
taint-wrapper list
usage: java -jar Slicer4j/target/slicer4j-jar-with-dependencies.jar
-ctrl,--Control-only Track control dependence only
-d,--debug Enable debug
-data,--data-only Track data-flow dependence only
-f,--framework Path to folder with extra framework
methods
-fw,--forward-slice-position starting statement for the forward
slice (for chopping)
-h,--help Display this help and exit
-j,--jar jar path
-lc,--logger-classes logger classes jar
-m,--mode Tool mode: i for instrument, g to
produce the dynamic control flow
graph, s to slice
-o,--outDir Output directory
-once,--once Slice one step only
-sd,--stub-droid Location of the StubDroid summaries
-sl,--static-log Static-log file path
-sp,--slice-position starting statement for the slice
-sv,--slice-variables dash-joined list of starting
variables to slice from
-t,--trace Execution trace
-tw,--taint-wrapper Location of the FlowDroid's
taint-wrapper list
Exception in thread "main" ca.ubc.ece.resess.slicer.dynamic.core.exceptions.InvalidCommandsException: Invalid commands
at ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer.throwParseException(Slicer.java:422)
at ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer.main(Slicer.java:230)
i want to use on jdk 1.8 version ,can it support?
Hi,
I am trying to analyze a .jar
file that do not contain the line number information, therefore failing to provide the parameter. (I tried javap -l
and javap -v
and there is no line number table. )
I don't have the source code, and it seems that the debug symbols were not included when it was compiled. Any suggestion on how to deal with this case? Thanks!
Hi,
I'm using the Olden's benchmark (with recursive programs) for playing with the tool.
I chose Voronoi with the arguments "-n 9", and the line with the println invocation as criterion.
The problem is that there are 2 sliced lines in the output, the line with println and the slicingVariable1B declaration.
If I try with -n 2 it works!
If I try with -n 3 it doesn't work (and it's not producing the output I don't know why)
If I try with -n 9 it works returning only 2 lines.
I think the problem is on recursion, but I'm know that is too hard to find these issues... (and if there are issues...)
Vertex.seed = 1023;
Vertex extra = Vertex.createPoints(1, new MyDouble(1.0), points);
Vertex point = Vertex.createPoints(points-1, new MyDouble(extra.X()), points-1);
Edge edge = point.buildDelaunayTriangulation(extra);
Edge slicingVariable1 = edge;
// This is the only line in the slice, and slicingVariable1 is not null
Boolean slicingVariable1B = (slicingVariable1 != null);
Edge[] slicingVariable2 = edge.quadList;
Edge slicingVariable3 = edge.quadList[0];
int slicingVariable4 = edge.listPos;
Vertex slicingVariable5 = edge.vertex;
Edge slicingVariable6 = edge.next;
System.out.println(slicingVariable1B); // I'm slicing this line
I'm attaching the source code and the output (including the trace), except the jars.
Voronoi.zip
Thank you so much in advance,
Alexis.
Hello. After running run_benchmarks.py, I checked the results and found that all the contents in each trace.log are like this:
..E.SLICING: ZLIB: eJztmmtuGzEMhE9UQC+Sku9/sGpF2SIncVMDqVG0/EXowy6l4cphdladqd3yj85EGngGSkM0dA3jCjmlGVovRQNrmFfeaMY2U5QLdARDL6xXkp6bhnn3rVfi1scoF+gAyjWblFYcn+DKM6clxydgBIKgA+gJQUWASftVEa6wqgkqgquebaxAiZsGUcga9ggKNihp1fXWoRdT0VB1fl5FGA2WN4ry4XlNBQFpdRtWlxAwgg6AEgJMuvaWcIFHyaUhIASMQADUtU247YBTtHwVhEr2+qms7U71A4dNQ5UQMALYVtQSgopA1uyU9TdXNFSFOCGJSqsoDauHz47x2T2vxntUj1AdqkN1qA7VoTpUh+pQHapD9X+jWp680b/vJXSu0td8AgbAFcEAIJhDrhqyQPEmYASQSnAykQ9grVvAq5ggK8fruyhvwb+VF+QdAT5bEgDjqYGWc507UxLVu4PmyVMLrY1SSi/pYaFZYC20w72Fdvi20BwQBB3A2pYOVASY1Fpoh28LzYHXLDRbsVc9NLs+66EZrh6aA8ZDc+UlBIygA6CEAJOqh9Yy5G5ZEAwAq8s4UAFcLtgV8E7dJwQJvHnmOGwXbV8OMALYUNq+HKgIvjLP7MXavho+ktZQKxUE7Xer8R7VXzXtUB2qQ3WoDtWhOlSH6lAdqkP1P6OajHlm+DvfPrd5dvg2zyzgimAAEMxhzTPDBXOreWYBTqbmmQPGPLPcmmeOGxMo+PfxgrwjwGdLAuC5eSZSRKQVuXtnDvzi9NmgxmwOnz3GapzJNn43ninTLZ+jZxs/Tp6dscC4+/G2cs+4whjy+TNnGz+OnJ3xa3aZKdLrJ84ea/MHzu74ft7sjJd7JeunLneP+9R1/U0tLfvc26ZsTQNUfS8oboqb4qa/7abyZ2b6/NvJKJkGEefHtxNHnjYAYhJOtad7B7BAW4CeWT18AvPt5PDdBBwQBB3A6gMOVASY1LaCw3cvcODFbyemYq92A7s+2w4M137gAGl5G5aXEDACQTBWqvU1wvJaEWDu69//T59xrCpWFauKVcWqvm9VPwGdkcgI
SLICING: ZLIB: eJzt0jsOwyAQRdEVWTLMj7D/hYXgNH6pUqXIrZCu5OEwcmWP2WZkVJ42zqOyp4bS8JhtHdakm2nQ2Tb2l73rRNeAChUqVKhQoUKFChUqVKhQoUKFChUqVKhQoUKFChUqVKhQoUL1jcrOPdvfh17hS3uM6Hf0CrG7ffSSII9ZITUMCS/LPZiG2rfHxmX067Ar6oVR19N0za7bc92e6/a8/u33QIUKFSpUqFChQoUKFSpUqFChQoUKFSpUqFCh+r3qCW+LSZ8=
SLICING: ZLIB: eJztztEJgDAMQMGJBNvYtHb/wRQ/s4L3FXiQ5GZG7LZHjplnrPOYGaOGtds7ei+9XzXUzZ41zBru73a0+pOKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiorqd6oHDqhR5A==
Not the same content but a similar form. I wonder about the meaning of the log. Is there something missing in my environment?
Thank you.
I read the document and had a glance at the code. I think the analysis have 4 steps:
What I want to know is that whether Slicer4J can record and create tdcg after the whole test suite run. For example, run step 1 to instrument the original code. Then run the test suite (eg. unit test) to record the trace. Finally do slicing base on the trace produced by testsuite. Thus I can re-run step 4 to slice the code on demand.
Now I can see the way to invoke the application is to run the main
function or invoke a single junit test. Would the whole test trace analysis cause heavy burden to CPU and Memory?
Thank you very much!
When trying to run Slicer4J through the python script, the instrumentation fails. I am using JDK 9, on Mac OS. Here is the content of instr-debug.log.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/austin/git/Slicer4J/Slicer4J/target/slicer4j-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/austin/git/Slicer4J/Slicer4J/target/lib/soot-infoflow-2.9.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/austin/git/Slicer4J/Slicer4J/target/lib/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[main] INFO JimpleWriter - initialize (17): Initializing Instrumenter
[main] INFO JimpleWriter - initialize (30): Initialization done
[main] INFO JimpleWriter - start (37): Running packs ...
[main] INFO JimpleWriter - start (39): Writing output ...
[main] INFO JimpleWriter - start (41): Output written ...
[main] INFO JavaInstrumenter - initialize (79): Initializing Instrumenter
[main] INFO JavaInstrumenter - initialize (98): Initialization done
[main] INFO JavaInstrumenter - start (252): Running packs ...
[Thread-31] INFO InstrumenterUtils - addPrint (456): Statement: $stack6 = string.<java.lang.String: char[] value>
[Thread-31] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: Resolved field is null: string.<java.lang.String: char[] value>
Resolved field is null: string.<java.lang.String: char[] value>
in unit: $stack6 = string.<java.lang.String: char[] value>
in body:
public static boolean regionMatches(java.lang.String, int, java.lang.String, int, int)
{
int start, $stack7, length, $stack8, thisStart, $stack10, $stack11, $stack12, $stack14, i, $i0, $i1, hashCode;
java.lang.String string, thisStr, tmpString, tmpString;
char $stack16, $stack17;
char[] $stack6, $stack9, $stack13, $stack15;
java.lang.StringBuilder sb, sb;
java.lang.Object tmpField;
thisStr := @parameter0: java.lang.String;
thisStart := @parameter1: int;
string := @parameter2: java.lang.String;
start := @parameter3: int;
length := @parameter4: int;
sb = new java.lang.StringBuilder;
specialinvoke sb.<java.lang.StringBuilder: void <init>()>();
hashCode = staticinvoke <java.lang.System: int identityHashCode(java.lang.Object)>(string);
virtualinvoke sb.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("814193");
tmpString = virtualinvoke sb.<java.lang.StringBuilder: java.lang.String toString()>();
staticinvoke <DynamicSlicingLogger: void println(java.lang.String,int)>(tmpString, hashCode);
$stack6 = string.<java.lang.String: char[] value>;
$stack7 = lengthof $stack6;
$stack8 = $stack7 - start;
if $stack8 < length goto label1;
if start >= 0 goto label2;
label1:
return 0;
label2:
if thisStart < 0 goto label3;
$stack9 = thisStr.<java.lang.String: char[] value>;
$stack10 = lengthof $stack9;
$stack11 = $stack10 - thisStart;
if $stack11 >= length goto label4;
label3:
return 0;
label4:
if length > 0 goto label5;
return 1;
label5:
i = 0;
label6:
if i >= length goto label8;
$stack13 = thisStr.<java.lang.String: char[] value>;
$stack12 = thisStart + i;
$stack17 = $stack13[$stack12];
$stack15 = string.<java.lang.String: char[] value>;
$stack14 = start + i;
$stack16 = $stack15[$stack14];
$i0 = (int) $stack17;
$i1 = (int) $stack16;
if $i0 == $i1 goto label7;
return 0;
label7:
i = i + 1;
goto label6;
label8:
return 1;
}
at soot.jimple.validation.FieldRefValidator.validate(FieldRefValidator.java:83)
at soot.jimple.JimpleBody.validate(JimpleBody.java:124)
at soot.jimple.JimpleBody.validate(JimpleBody.java:106)
at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.addPrint(InstrumenterUtils.java:454)
at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:70)
at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:183)
at soot.BodyTransformer.transform(BodyTransformer.java:47)
at soot.Transform.apply(Transform.java:126)
at soot.BodyPack.internalApply(BodyPack.java:49)
at soot.Pack.apply(Pack.java:126)
at soot.PackManager.runBodyPacks(PackManager.java:991)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.base/java.lang.Thread.run(Thread.java:844)
Exception in thread "main" Resolved field is null: string.<java.lang.String: char[] value>
in unit: $stack6 = string.<java.lang.String: char[] value>
in body:
public static boolean regionMatches(java.lang.String, int, java.lang.String, int, int)
{
int start, $stack7, length, $stack8, thisStart, $stack10, $stack11, $stack12, $stack14, i, $i0, $i1, hashCode;
java.lang.String string, thisStr, tmpString, tmpString;
char $stack16, $stack17;
char[] $stack6, $stack9, $stack13, $stack15;
java.lang.StringBuilder sb, sb;
java.lang.Object tmpField;
thisStr := @parameter0: java.lang.String;
thisStart := @parameter1: int;
string := @parameter2: java.lang.String;
start := @parameter3: int;
length := @parameter4: int;
sb = new java.lang.StringBuilder;
specialinvoke sb.<java.lang.StringBuilder: void <init>()>();
hashCode = staticinvoke <java.lang.System: int identityHashCode(java.lang.Object)>(string);
virtualinvoke sb.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("814193");
tmpString = virtualinvoke sb.<java.lang.StringBuilder: java.lang.String toString()>();
staticinvoke <DynamicSlicingLogger: void println(java.lang.String,int)>(tmpString, hashCode);
$stack6 = string.<java.lang.String: char[] value>;
$stack7 = lengthof $stack6;
$stack8 = $stack7 - start;
if $stack8 < length goto label1;
if start >= 0 goto label2;
label1:
return 0;
label2:
if thisStart < 0 goto label3;
$stack9 = thisStr.<java.lang.String: char[] value>;
$stack10 = lengthof $stack9;
$stack11 = $stack10 - thisStart;
if $stack11 >= length goto label4;
label3:
return 0;
label4:
if length > 0 goto label5;
return 1;
label5:
i = 0;
label6:
if i >= length goto label8;
$stack13 = thisStr.<java.lang.String: char[] value>;
$stack12 = thisStart + i;
$stack17 = $stack13[$stack12];
$stack15 = string.<java.lang.String: char[] value>;
$stack14 = start + i;
$stack16 = $stack15[$stack14];
$i0 = (int) $stack17;
$i1 = (int) $stack16;
if $i0 == $i1 goto label7;
return 0;
label7:
i = i + 1;
goto label6;
label8:
return 1;
}
at soot.jimple.validation.FieldRefValidator.validate(FieldRefValidator.java:83)
at soot.jimple.JimpleBody.validate(JimpleBody.java:124)
at soot.jimple.JimpleBody.validate(JimpleBody.java:106)
at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.addPrint(InstrumenterUtils.java:454)
at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:70)
at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:183)
at soot.BodyTransformer.transform(BodyTransformer.java:47)
at soot.Transform.apply(Transform.java:126)
at soot.BodyPack.internalApply(BodyPack.java:49)
at soot.Pack.apply(Pack.java:126)
at soot.PackManager.runBodyPacks(PackManager.java:991)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.base/java.lang.Thread.run(Thread.java:844)
Exception in thread "Thread-31" Resolved field is null: string.<java.lang.String: char[] value>
in unit: $stack6 = string.<java.lang.String: char[] value>
in body:
public static boolean regionMatches(java.lang.String, int, java.lang.String, int, int)
{
int start, $stack7, length, $stack8, thisStart, $stack10, $stack11, $stack12, $stack14, i, $i0, $i1, hashCode;
java.lang.String string, thisStr, tmpString, tmpString;
char $stack16, $stack17;
char[] $stack6, $stack9, $stack13, $stack15;
java.lang.StringBuilder sb, sb;
java.lang.Object tmpField;
thisStr := @parameter0: java.lang.String;
thisStart := @parameter1: int;
string := @parameter2: java.lang.String;
start := @parameter3: int;
length := @parameter4: int;
sb = new java.lang.StringBuilder;
specialinvoke sb.<java.lang.StringBuilder: void <init>()>();
hashCode = staticinvoke <java.lang.System: int identityHashCode(java.lang.Object)>(string);
virtualinvoke sb.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("814193");
tmpString = virtualinvoke sb.<java.lang.StringBuilder: java.lang.String toString()>();
staticinvoke <DynamicSlicingLogger: void println(java.lang.String,int)>(tmpString, hashCode);
$stack6 = string.<java.lang.String: char[] value>;
$stack7 = lengthof $stack6;
$stack8 = $stack7 - start;
if $stack8 < length goto label1;
if start >= 0 goto label2;
label1:
return 0;
label2:
if thisStart < 0 goto label3;
$stack9 = thisStr.<java.lang.String: char[] value>;
$stack10 = lengthof $stack9;
$stack11 = $stack10 - thisStart;
if $stack11 >= length goto label4;
label3:
return 0;
label4:
if length > 0 goto label5;
return 1;
label5:
i = 0;
label6:
if i >= length goto label8;
$stack13 = thisStr.<java.lang.String: char[] value>;
$stack12 = thisStart + i;
$stack17 = $stack13[$stack12];
$stack15 = string.<java.lang.String: char[] value>;
$stack14 = start + i;
$stack16 = $stack15[$stack14];
$i0 = (int) $stack17;
$i1 = (int) $stack16;
if $i0 == $i1 goto label7;
return 0;
label7:
i = i + 1;
goto label6;
label8:
return 1;
}
at soot.jimple.validation.FieldRefValidator.validate(FieldRefValidator.java:83)
at soot.jimple.JimpleBody.validate(JimpleBody.java:124)
at soot.jimple.JimpleBody.validate(JimpleBody.java:106)
at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.addPrint(InstrumenterUtils.java:454)
at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:70)
at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:183)
at soot.BodyTransformer.transform(BodyTransformer.java:47)
at soot.Transform.apply(Transform.java:126)
at soot.BodyPack.internalApply(BodyPack.java:49)
at soot.Pack.apply(Pack.java:126)
at soot.PackManager.runBodyPacks(PackManager.java:991)
at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.base/java.lang.Thread.run(Thread.java:844)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.