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

liuyuan at fastmail.com liuyuan at fastmail.com
Mon Jun 1 19:38:29 EDT 2020


Dear all,

I want to build a CG for a program. I refer to this post 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.

Besides, I want to extract the identifiers from method body, is there already APIs support that in soot?

Any help would be greatly appreciated!

Best regards,
Yuan Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20200601/d7beb710/attachment-0001.html>


More information about the Soot-list mailing list