JSlice also supports performing
dynamic slicing w.r.t. statement occurrence in the middle the
execution, i.e. not the last occurrence of this statement. The
trick is: add last occurrence of the interesting statement into
the dynamic slicing criterion. In the Java program, add an if
statement, so that the if statement is evaluated to true
iff the interesting statement occurrence appears. In the true
branch of this if statement, call
java.lang.System.exit(1) to terminate the execution. Then JSlice
will return the desired result.
For example, we have a program
fragment
1.
for (i=0; i<10; i++){
2. j=j+f(i);
3. }
|
and we are interested in how the
value of variable j in the 6th loop iteration is computed. So,
we add last occurrence of statement 2 into the dynamic
slicing criterion, and revise the program by adding the two blue
lines.
for (i=0;
i<10; i++){
j=j+f(i);
if (i>=5)
java.lang.System.exit(1);
}
|