[Soot-list] custom entry points on a CallGraph

Marc-André Laverdière marc-andre.laverdiere-papineau at polymtl.ca
Wed Feb 5 09:38:11 EST 2014


Hello Moritz,

I have not looked at your code in depth, but here are a few gotchas for
entry points:

a) They need to be static, otherwise you'll have missing edges (that's
the unconfirmed urban legend in the mailing list)
b) If you have many main() methods, then Soot will just pick the first
one, unless you tell otherwise.
c) The standard method everybody has been using is to generate a dummy
main that will call the real entry points

>From what I am seeing, you want all the methods to be entry points. Why
is that? Are you trying to analyze a library? What are you trying to
analyze?

Marc-André Laverdière-Papineau
Doctorant - PhD Candidate

On 02/05/2014 05:37 AM, Moritz Tiedje wrote:
> Hello,
> I need a complete callGraph of all the method calls in a library. The
> problem is, that upon calling soot.Main.main(), a main Method in the
> library to analyse is searched, found and used to derive a very
> incomplete call path. Using the following piece of code, I can overwrite
> this incomplete CallGraph with the complete CallGraph that I need:
> 
>      ArrayList<SootMethod> entryPoints = new ArrayList<SootMethod>();
>      for (SootClass currentClass : Scene.v().getClasses())
>           for (SootMethod method : currentClass.getMethods())
>                if(method.hasActiveBody())
>                     entryPoints.add(method);
>      Scene.v().setEntryPoints(entryPoints);
>      CHATransformer.v().transform();
> 
> Here, I set every single method that has an active Body as an entry
> Point for the call graph and proceed to calculating it.
> 
> Could you help me find a way calculate the CallGraph only once? So far I
> have looked for ways to either suppress the calculation of the callGraph
> in soot.Main.main() or to set custom entry points for it but have been
> unsuccessful. You can find an abbreviated Version of my code below:
> 
> public static void main(String[] args)
> {
>      PackManager
>           .v()
>           .getPack("wjtp")
>           .add(new Transform("wjtp.permissionAnalysis",
>                  new SceneTransformer() {
> 
>                       @Override
>                       protected void internalTransform(String arg0, Map
> arg1)
>                       {
>                            ArrayList<SootMethod> entryPoints = new
> ArrayList<SootMethod>();
>                            for (SootClass currentClass :
> Scene.v().getClasses())
>                                 for (SootMethod method :
> currentClass.getMethods())
>                                      if(method.hasActiveBody())
>                                           entryPoints.add(method);
>                            Scene.v().setEntryPoints(entryPoints);
>                            CHATransformer.v().transform();
>                                
>                           //customAnalysis is an instance of a class
> that implements CallGraphAnalysis
>                           
> customAnalysis.performAnalysis(Scene.v().getCallGraph())
>                        }
>                   }));
> 
>      //createDefaultArgs is defined below
>      ArrayList<String> argList = createDefaultArgs(args);
>     
>      soot.Main.main(argList.toArray(new String[0]))
> }
> 
> 
> private static ArrayList<String> createDefaultArgs(String[] args) {
>      ArrayList<String> argList = new ArrayList<String>(Arrays.asList(args));
>     
>      argList.add("-no-bodies-for-excluded");
>      argList.add("-allow-phantom-refs");
>      argList.add("-w");
>        
>      argList.add("-f");
>      argList.add("none");
> 
>      argList.add("-pp");
> 
>      argList.add("-p");
>      argList.add("jb");
>      argList.add("use-original-names:true");
>   
>      argList.add("-p");
>      argList.add("cg.spark");
>      argList.add("enabled:true");
> 
>      argList.add("-p");
>      argList.add("cg.spark");
>      argList.add("pre-jimplify");     argList.add("-cp");
> 
>     //LIBRARY_JAR is a String that contains the path to the library we
> wish to analyze
>      argList.add(fileToItsPath(LIBRARY_JAR));
>        
>      argList.add("-process-path");
>        
>      argList.add(LIBRARY_JAR);
> 
>      return argList;
> }
> 
> Thank you for your time, Moritz Tiedje
> 
> 
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 


More information about the Soot-list mailing list