-
-
Notifications
You must be signed in to change notification settings - Fork 712
Creating Soot Plugins
Bernhard J. Berger edited this page Oct 17, 2013
·
1 revision
An easy way to contribute new analyses to Soot is to use the plugin mechanism. This way analyses are interchangeable. All you have to do is to write an additional plugin class implementing SootPhasePlugin. You have to implement four simple methods:
public class MyFirstPlugin implements SootPhasePlugin {
@Override
public Transformer getTransformer() {
// return your SceneTransformer or BodyTransformer
return new MyTransformer();
}
@Override
public void setDescription(final PhasePluginDescription pluginDescription) {
// perhaps you want to initialize something depending on the plugin description
}
@Override
public String[] getDeclaredOptions() {
// declare all command-line options
return new String [] {"opt"};
}
@Override
public String[] getDefaultOptions() {
// declare default values
return new String [] {ENABLED_BY_DEFAULT, "opt:false"};
}
}
If you want to use the plugin you have to create a configuration file and pass it to Soot. The configuration file is specified using xml:
<?xml version="1.0" encoding="UTF-8"?>
<soot-plugins xmlns="http://github.com/Sable/soot/plugins">
<!-- register MyFirstPlugin (the class implementing SootPhasePlugin) twice. -->
<phase-plugin phase="jap.foo" class="MyFirstPlugin"/>
<phase-plugin phase="jap.bar" class="MyFirstPlugin"/>
</soot-plugins>
Now you can call Soot:
java -cp soot.jar:plugin.jar soot.Main --plugin plugin.xml -p jap.foo opt:true java.lang.Object
Please note, that you have to specify --plugin
before you pass the plugin configurations.
Hope you have fun!
Also check out Soot's webpage.
NOTE: If you find any bugs in those tutorials (or other parts of Soot) please help us out by reporting them in our issue tracker.
- Home
- Getting Help
- Tutorials
- Reference Material
- General Notions
- Getting Started
- A Few Uses of Soot
- Using Soot as a Command-Line Tool
- Using the Soot Eclipse Plugin
- Using Soot as a Compiler Framework
- Building Soot
- Coding Conventions
- Contributing to Soot
- Updating the Soot Web Page
- Reporting Bugs
- Preparing a New Soot Release