[Soot-list] Instrumenting OSGi bundles

Nuno Machado nmachado at gsd.inesc-id.pt
Mon Feb 6 10:40:54 EST 2012


Hi Eric,
Hi Eric,

Thanks for your reply! I've read that tutorial (it is very useful, by the way!), but when I instrument the class without a main method, I get the following error:

Exception in thread "main" java.lang.RuntimeException: Main-class has no main method!
	at soot.Scene.setMainClass(Scene.java:127)
	at soottest.CalculatorTransformer.main(CalculatorTransformer.java:101)


My settings in the transformer class are as follows:

public static void main(String[] args) {
		PackManager.v().getPack("jtp").add(
				new Transform("jtp.intrumenter", MyInstrumenter.v()));


		PhaseOptions.v().setPhaseOption("jb", "enabled:true");
		Options.v().set_keep_line_number(true);
		Options.v().setPhaseOption("jb", "use-original-names:true");
		List settings = new ArrayList();
		settings.add("soottest.");
		settings.add("org.eclipse.");
		settings.add("javax.");
		settings.add("java.");
		settings.add("runtime_registry_compatibility.");
		settings.add("com.");
		settings.add("net.");
		Options.v().set_exclude(settings);
		Options.v().set_whole_program(true);
		Options.v().set_app(true);

		Scene.v().setSootClassPath(System.getProperty("sun.boot.class.path")
				+ File.pathSeparator + System.getProperty("java.class.path"));

		SootClass appclass = Scene.v().loadClassAndSupport(args[0]);
		Scene.v().setMainClass(appclass);
		Scene.v().loadClassAndSupport(dynamicContClass);

		String[] args1 = {"-pp",args[0]}; 

		soot.Main.main(args1);
	}

I suppose that the problem should be related to the option "setMainClass(appclass)", right?

Just another question: in order to instrument the osgi classes that I need, I have to add a lot of .jar files to the class path, which I don't want to instrument. For that reason, I defined a list of packages to be excluded (as shown in the code above). However, it seems not to be working, as soot still analyzes them and put some instrumented classes in the sootoutput folder. Am I missing something or doing anything wrong?

Thank you,
Nuno


On Feb 2, 2012, at 6:35 PM, Eric Bodden wrote:

> Hi Nuno.
> 
>> I would like to use Soot to instrument an application that consists of OSGi bundles. Since there is no main class or single entry point, is this possible to do?
> 
> Instrumentation requires no main class, in fact no entry point at all.
> You can just instrument any method body independently if you want.
> 
> Did you have a look at the goto instrumenter tutorial?
> 
> Eric

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120206/b263516e/attachment.html 


More information about the Soot-list mailing list