Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem on soot path. #986

Open
damorosodaragona opened this issue Jul 10, 2018 · 1 comment
Open

Problem on soot path. #986

damorosodaragona opened this issue Jul 10, 2018 · 1 comment

Comments

@damorosodaragona
Copy link

damorosodaragona commented Jul 10, 2018

package main;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import soot.MethodOrMethodContext;
import soot.PackManager;
import soot.Scene;
import soot.SceneTransformer;
import soot.SootClass;
import soot.SootMethod;
import soot.Transform;
import soot.jimple.toolkits.callgraph.CHATransformer;
import soot.jimple.toolkits.callgraph.CallGraph;
import soot.jimple.toolkits.callgraph.Targets;

public class CallGraphExample
{	
	public static void main(String[] args) {
	   List<String> argsList = new ArrayList<String>(Arrays.asList(args));
	   argsList.addAll(Arrays.asList(new String[]{
			   "-w",
			   "-main-class",
			   "testers.CallGraphs",//main-class
			   "testers.CallGraphs",//argument classes
			   "testers.A"			//
	   }));
	

	   PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new SceneTransformer() {

		@Override
		protected void internalTransform(String phaseName, Map options) {
		       CHATransformer.v().transform();
                       SootClass a = Scene.v().getSootClass("testers.A");

		       SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");
		       CallGraph cg = Scene.v().getCallGraph();

		       Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(src));
		       while (targets.hasNext()) {
		           SootMethod tgt = (SootMethod)targets.next();
		           System.out.println(src + " may call " + tgt);
		       }
		}
		   
	   }));

           args = argsList.toArray(new String[0]);
           
           soot.Main.main(args);
	}
}

This is the code that i find on soot tutorials for Call Graphs, now when i try to run it in eclipse i have this error:
Soot started on Tue Jul 10 18:50:06 CEST 2018
soot.SootResolver$SootClassNotFoundException: couldn't find class: testers.CallGraphs (is your soot-class-path set properly?)
at soot.SootResolver.bringToHierarchyUnchecked(SootResolver.java:228)
at soot.SootResolver.bringToHierarchy(SootResolver.java:208)
at soot.SootResolver.bringToSignatures(SootResolver.java:266)
at soot.SootResolver.bringToBodies(SootResolver.java:311)
at soot.SootResolver.processResolveWorklist(SootResolver.java:163)
at soot.SootResolver.resolveClass(SootResolver.java:133)
at soot.Scene.loadClass(Scene.java:853)
at soot.Scene.loadClassAndSupport(Scene.java:839)
at soot.Scene.loadNecessaryClass(Scene.java:1569)
at soot.Scene.loadNecessaryClasses(Scene.java:1582)
at soot.Main.run(Main.java:250)
at soot.Main.main(Main.java:147)
at main.CallGraphExample.main(CallGraphExample.java:54)

Ouuups... something went wrong! Sorry about that.
Follow these steps to fix the problem:
1.) Are you sure you used the right command line?
Click here to double-check:
https://soot-build.cs.uni-paderborn.de/doc/sootoptions/

2.) Not sure whether it's a bug? Feel free to discuss
the issue on the Soot mailing list:
https://github.com/Sable/soot/wiki/Getting-help

3.) Sure it's a bug? Click this link to report it.
Please be as precise as possible when giving us
information on how to reproduce the problem. Thanks!
[...]

I can't understand how i must setting soot path to run it.. Can somebody explain to me?
In my eclipse project i have 2 packages, first named "Main" where there is "CallGraphExample.java" class (is the class shown above), and second named "testers" where there is "CallGraph.java" class.
The code of "CallGraphs.java" is:

package testers;

public class CallGraphs
{
	public static void main(String[] args) {
		doStuff();
	}
	
	public static void doStuff() {
		new A().foo();
	}
}

class A
{
	public void foo() {
		bar();
	}
	
	public void bar() {
	}
}
@Symbolk
Copy link

Symbolk commented Oct 26, 2018

Yeah this is the offical example, but really outdated (2008).
The same problem also bothers me, did you solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants