[Wala-wala] Creating analysis scope for class files.

108 views
Skip to first unread message

Danny q

unread,
Jun 28, 2015, 12:54:41 PM6/28/15
to WALA discussion and Q&A
I am trying to create an analysis scope for a class file. I will use this later to get a control flow graph and hopefully for taint analysis.

My code is fairly simple and is based on the docs
                AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
FileProvider fp = new FileProvider();
try {
                        //geting the class file
File file = fp.getFile(pathToFile);
scope.addClassFileToScope(ClassLoaderReference.Application, file);
} catch (IOException | IllegalArgumentException | InvalidClassFileException e) {
System.out.println("Could not get file " + pathToFile);
e.printStackTrace();
}
return scope;


and I have another method that takes this scope and creates a ClassHierarchy
     ClassHierarchy cha = ClassHierarchy.make(scope);
     Iterable<Entrypoint> e = Util.makeMainEntrypoints(scope, cha);

I am getting the following error failed to load root <Primordial,Ljava/lang/Object> of class hierarchy
I checked the troubleshooting page, and I am positive I do not have an issue with my java runtime path.

I eliminated this problem by using the following example 
//here pathToFile is a path to a jar file
       AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(pathToFile, null);
  ClassHierarchy cha = ClassHierarchy.make(scope); //this is working

Any ideas what I am doing wrong?
Any suggestion on how to move on to CFG and taint analysis once I get the cha?

Thanks!


Manu Sridharan

unread,
Jun 29, 2015, 1:28:21 PM6/29/15
to WALA discussion and Q&A
I'm not sure what is wrong with your initial code example exactly, but if I were doing this, I would use your second approach, passing in the appropriate classpath to makeJavaBinaryAnalysisScope().  (E.g., if your class is foo.bar.Baz, the classpath should be the parent directory of foo.)  Or you can use a scope file, as outlined here:


--Manu

-------------------------
Manu Sridharan
Samsung Research America

Reply all
Reply to author
Forward
0 new messages