[Soot-list] NullPointerException in soot.SootMethod.getBodyFromMethodSource

Marc-Andre Laverdiere-Papineau marc-andre.laverdiere-papineau at polymtl.ca
Tue Jul 3 10:20:01 EDT 2012


Hello Eric,

So what would be the proper way of picking my entry points then?

By the way, I added a G.reset() between the two invocations.

Code looks like this:

ArrayList<String> sootOptions = new ArrayList<String>();
sootOptions.add("-w");
for (String ex: EXCLUSIONS){
	sootOptions.add("-x");
	sootOptions.add(ex);
}

sootOptions.add("-src-prec");
sootOptions.add("java");
sootOptions.add("-keep-line-number");
sootOptions.add("-output-format");
sootOptions.add("jimple");
sootOptions.add("-allow-phantom-refs");
sootOptions.add("-no-bodies-for-excluded");
sootOptions.add("-time");
for (String p : processDirs){
	sootOptions.add("-process-path");
	sootOptions.add(p);
}
sootOptions.add("-prepend-classpath");
sootOptions.add("-soot-classpath");
sootOptions.add(classPath);

ArrayList<String> firstRoundSootOptions = new 
ArrayList<String>(sootOptions);
firstRoundSootOptions.add("-phase-option");
firstRoundSootOptions.add("cg");
firstRoundSootOptions.add("enabled:false");

//Load the classes
Scene.v().addBasicClass("javax.servlet.http.HttpServlet",SootClass.SIGNATURES);
Scene.v().addBasicClass("org.apache.jasper.runtime.HttpJspBase", 
SootClass.SIGNATURES);
soot.Main.main(firstRoundSootOptions.toArray(new 
String[firstRoundSootOptions.size()]));

//Reset for the next operation
//TODO make it work on the jimple
G.reset();
Scene.v().addBasicClass("javax.servlet.http.HttpServlet",SootClass.SIGNATURES);
Scene.v().addBasicClass("org.apache.jasper.runtime.HttpJspBase", 
SootClass.SIGNATURES);
Scene.v().addBasicClass("javax.servlet.ServletContext",SootClass.SIGNATURES);

//Set entry points
List<SootMethod> entryPoints = new ArrayList<SootMethod>();

final String servletClassName = "javax.servlet.http.HttpServlet";
final SootClass servletClass = 
Scene.v().loadClassAndSupport(servletClassName);

FastHierarchy fh = Scene.v().getOrMakeFastHierarchy();
//...

logger.info("Found {} entry points: {}", entryPoints.size(), entryPoints);
Scene.v().setEntryPoints(entryPoints);


//Call graph phase options
final String[] phaseOptions = new String[]{
	"cg,enabled:true",
	"cg,implicit-entry:false",
	"cg,verbose:true",
	"cg.cha,enabled:false",
	"cg.spark,enabled:true",
	"cg.paddle,enabled:false",
	"cg.spark,geom-pta:true"
	};
ArrayList<String> phase2Options = new ArrayList<String>(sootOptions);
for(String po: phaseOptions){
	phase2Options.add("-phase-option");
	for (String opt : po.split(","))
		phase2Options.add(opt);
}

logger.debug("Running soot with options: {}", phase2Options);

soot.Main.main(phase2Options.toArray(new String[phase2Options.size()]));

On 07/03/2012 09:19 AM, Eric Bodden wrote:
> Hi Marc-Andre.
>
> You cannot just run the main method twice, as Soon cleans up stuff
> after some of the packs have finished.
>
> Eric
>
> On 3 July 2012 13:08, Marc-Andre Laverdiere-Papineau
> <marc-andre.laverdiere-papineau at polymtl.ca> wrote:
>> Hello,
>>
>> I followed Eric's advice from another thread and converted my driver
>> code to use soot's Main class. Looks like I am still doing something
>> wrong though, because it crashes :(
>>
>> Actually, I am running the main twice. The first time without the the
>> call graph, then I pick the entry points, then I run soot the second
>> time with the call graph options.
>>
>> The code snippet is here
>> http://pastebin.com/tktgdjzN
>>
>> One of the things is that it crashed if I repeated all the options
>> between the two runs, so now I am relying on the previous run's options
>> to be kept by soot... not sure that works 100% as I am expecting.
>>
>> --
>> Marc-André Laverdière-Papineau
>> Étudiant au doctorat - PhD Student
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>
>


-- 
Marc-André Laverdière-Papineau
Étudiant au doctorat - PhD Student




More information about the Soot-list mailing list