[Soot-list] When using spark to build a CG, can I specify any class contains main method as mainClass?

Liu Yuan liuyuan at fastmail.com
Mon Jun 1 14:21:38 EDT 2020


Hi everyone,

I want to build a CG for a program. I refer to this post 
<https://o2lab.github.io/710/p/TestSootCallGraph.java> and modified some 
code. It works for me. The main code is as follows.
public static void main(String[] args) {
//ses -- APISeqtest success
String classesDir = "D:\\wkspace\\seed8\\dir\\APISeqtest";
String mainClass = "com.ouc.Demo";

//set classpath
String jreDir = System.getProperty("java.home") + "\\lib\\jce.jar";
String jceDir = System.getProperty("java.home") + "\\lib\\rt.jar";
String path = jreDir + File.pathSeparator + jceDir + File.pathSeparator + 
classesDir;
Scene.v().setSootClassPath(path);

//add an intra-procedural analysis phase to Soot
TestCallGraphSootJaronlyoneclass analysis = new 
TestCallGraphSootJaronlyoneclass();
PackManager.v().getPack("wjtp").add(new Transform("wjtp.TestSootCallGraph", 
analysis));

excludeJDKLibrary();

Options.v().set_process_dir(Arrays.asList(classesDir));
Options.v().set_whole_program(true);
//Options.v().set_app(true);

Scene.v().loadNecessaryClasses();
SootClass sc = Scene.v().getSootClass(mainClass);
Scene.v().setMainClass(sc);

//enableCHACallGraph();
enableSparkCallGraph();

PackManager.v().runPacks();
}

But if a program contains one more main methods, for example, C1, C2 and C3 
all contain a main method, should I choose which one (Scene.v().setMainClass(C1 
or C2 or C3))?

This case does exist. Assume that  C1 is the true mainClass, then main 
method in C1 could call main methods of C2 and C3. Or main method in C3 is 
just used to test C3.

As described above, it's a little difficult to specify the true main method 
and the true mainClass. 

Although I find that if I don't specify a mainClass when building CG, the 
program also works. But this post tell me that it's not precise 
<https://groups.google.com/forum/#!topic/soot-list/jcHrdhzJyl0>.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20200601/3915898b/attachment.html>


More information about the Soot-list mailing list