[Soot-list] Error the CallGraph: Edges not present
Dhriti Khanna
dhritik at iiitd.ac.in
Mon Dec 16 00:23:05 EST 2019
Hello,
My issue is resolved.
Thank you.
On Sun, Dec 15, 2019 at 4:12 PM Dhriti Khanna <dhritik at iiitd.ac.in> wrote:
> Hello,
> For method A, I want to find all the methods that A might invoke in a Java
> class. I am implementing this as follows:
>
> List<String> argsList = new ArrayList<String>(Arrays.asList(_cut));
> argsList.addAll(Arrays.asList(new String[]{
> "-w",
> "-main-class",
> _cut
> }));
>
> Options.v().set_no_bodies_for_excluded(true);
> Options.v().set_output_format(Options.output_format_jimple);
>
> Options.v().set_output_dir("/home/dhriti/Dropbox/new-workspace/EscapeAnalysis/sootOutput");
> Options.v().setPhaseOption("cg.spark", "on");
> Options.v().set_whole_program(true);
> Options.v().set_prepend_classpath(true);
> Options.v().set_allow_phantom_refs(true);
> Scene.v().addBasicClass("sun.misc.ClassFileTransformer",
> SootClass.HIERARCHY);
> Scene.v().addBasicClass("java.io.ObjectStreamClass$MemberSignature",
> SootClass.HIERARCHY);
> SootClass sootClass = Scene.v().forceResolve(_cut, SootClass.BODIES);
> sootClass.setApplicationClass();
> Scene.v().loadNecessaryClasses();
> PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new
> SceneTransformer() {
>
> @Override
> protected void internalTransform(String arg0, Map arg1) {
> Iterator<SootMethod> sootMethodsIt = sootClass.getMethods().iterator();
> while(sootMethodsIt.hasNext()) {
>
> SootMethod caller = sootMethodsIt.next();
> if(caller.isPublic() &&
> caller.getDeclaringClass().getName().equals(_cut)) {
> List<SootMethod> entryPoints = new ArrayList<SootMethod>();
> entryPoints.add(caller);
> Scene.v().setEntryPoints(entryPoints);
>
> CallGraph cg = Scene.v().getCallGraph();
> Iterator<Edge> edges = cg.edgesOutOf(caller);
> ArrayList<SootMethod> targets = new ArrayList<SootMethod>();
> while(edges.hasNext()) {
> Edge edge = edges.next();
> SootMethod target = edge.getTgt().method();
> if(target.getDeclaringClass().getName().equals(_cut)) {
> targets.add(target);
> }
> }
> targetMethods_For_Method.put(caller, targets); // List of
> targets can be empty
> }
> }
> }
> }));
>
> String[] argsArray = (String[]) argsList.toArray(new
> String[argsList.size()]);
> soot.Main.main(argsArray);
>
> However, I am not getting the required output unless I call anyone method
> of the class from the main method. If I do this, then the output is fine.
> Otherwise, if I leave the main method empty, the target list for each
> method is empty. Why is this happening even when I set the entry point to
> be a non-main method (as highlighted in the color yellow above)?
>
> Note: This is an issue with Soot-2.5.0
>
> --
> Regards
> Dhriti Khanna
> PhD Scholar
> IIIT Delhi
>
--
Regards
Dhriti Khanna
PhD Scholar
IIIT Delhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20191216/8e3a6e1d/attachment.html>
More information about the Soot-list
mailing list