[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
Tue Jun 2 14:17:16 EDT 2020


HI Eric,

Thank you for your explain.

Best,
Yuan
 
From: Eric Bodden
Date: 2020-06-02 10:26
To: liuyuan at fastmail.com
CC: soot-list
Subject: Re: [Soot-list] When using spark to build a CG, can I specify any class contains the main method as the sootMainClass?
Hi.
 
Yes that’s exactly why the method setMainClass exists. If you do not set a main class manually then Soot will just pick the first one it finds.
 
Cheers
Eric
 
> On 2. Jun 2020, at 01:38, liuyuan at fastmail.com wrote:
> 
> 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
> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20200602/61454baf/attachment.html>


More information about the Soot-list mailing list