Creating Soot Plugins - VictoryWangCN/soot GitHub Wiki
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!