Pinzger, Martin
unread,Sep 27, 2017, 4:11:23 AM9/27/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to wala...@lists.sourceforge.net
Dear All,
I am using WALA 1.4.3, Java 1.8 to compute forward slices and found that static methods are excluded from the slices. I am using the following simplified source code:
AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope("out/test/classes/dummy", null);
DefaultExclusion.addDefaultExclusions(scope);
ClassHierarchy cha = ClassHierarchyFactory.make(scope);
Iterable<Entrypoint> entrypoints = getEntrypoint(cha); // add all methods of the dummy package
AnalysisOptions options = new AnalysisOptions(scope, entrypoints);
com.ibm.wala.ipa.callgraph.CallGraphBuilder cgb = Util.makeZeroOneContainerCFABuilder(options, new AnalysisCacheImpl(), cha, scope, null, null);
CallGraph cg = cgb.makeCallGraph(options, null);
PointerAnalysis pa = cgb.getPointerAnalysis();
Iterable<CGNode> entryPoint = findMethod(cg, "v", "()J");
Iterable<Statement> callsTo = findCallTo(entryPoint, "m");
Collection sliceForward;
for(Statement call : callsTo){
sliceForward = Slicer.computeForwardSlice(call, cg, pa, Slicer.DataDependenceOptions.FULL, Slicer.ControlDependenceOptions.FULL);
dumpSlice(sliceForward);
}
## The slices are computed on the following input
package dummy;
public class Testing {
public long v() throws InterruptedException {
long y = System.currentTimeMillis();
long tmp = y + 10;
long myI = m(y); // starting point for the forward slice
if (tmp > 10) {
myI += 5;
} else {
myI += 10;
}
return myI;
}
public static long m(long y) {
long lt = 10;
if (y >10) {
return lt + y;
}
return y;
}
}
## Observations and questions:
# If m() is declared static only the following output is generated:
NORMAL v:18 = invokestatic < Application, Ldummy/Testing, m(J)J > 11 @41 exception:17 Node: < Application, Ldummy/Testing, v()J > Context: Everywhere
# If I switch m() to a member method I obtain the full slice:
NORMAL v:18 = invokevirtual < Application, Ldummy/Testing, m(J)J > 1,11 @42 exception:17 Node: < Application, Ldummy/Testing, v()J > Context: Everywhere
NORMAL v:23 = binaryop(add) 18 , 22 Node: < Application, Ldummy/Testing, v()J > Context: Everywhere
NORMAL v:21 = binaryop(add) 18 , 12 Node: < Application, Ldummy/Testing, v()J > Context: Everywhere
NORMAL v:return 24 Node: < Application, Ldummy/Testing, v()J > Context: Everywhere
NORMAL m:5 = compare 2,4 opcode=cmp Node: < Application, Ldummy/Testing, m(J)J > Context: Everywhere
NORMAL m:conditional branch(le, to iindex=11) 5,6 Node: < Application, Ldummy/Testing, m(J)J > Context: Everywhere
NORMAL m:7 = binaryop(add) 4 , 2 Node: < Application, Ldummy/Testing, m(J)J > Context: Everywhere
NORMAL m:return 7 Node: < Application, Ldummy/Testing, m(J)J > Context: Everywhere
…
Why is the slice of the static m() not included? Did I miss something?
Thank you in advance for your support.
Best,
Martin
Martin Pinzger
Software Engineering Research Group
University of Klagenfurt