resess / Slicer4J

Slicer4J is an accurate, low-overhead dynamic slicer for Java programs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

trace.log_icdg.log does not contain required jimple-statement

ArtemUntila opened this issue · comments

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 = sc.split(", ")[0]

The reason is that trace.log_icdg.log does not contain jimple-statement println() and statement with LINENO:11:FILE:Issue at all.
If we remove some of the statements if (args.length != 1), if (javaFiles != null) or method call with parameter args[0]getLength(args[0]), it will work fine.

Thank you for bringing this to my attention. Fixed in latest commit in the dynamic slicing core. Added this issue as a test case.