[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes from 1.2.4
I'm finally getting around to upgrading to 2.0.1, but I've run into some
difficulties...
It used to be that a transformer declared the valid options, which was
convenient for the rest of the world, if not for you guys, since it made a
transformer self contained... Can this come back? (Looks like its a
fairly simply matter of checking for the HasPhaseOptions interface).
It is much more useful for the Transformer to implement this interface than
the transform.
I built a workaroud, but it is not very good:
/** Add a new transform to the given pack, dealing properly with
* options specified in the transformer.
*/
public static void addTransform(Pack pack, String name, Transformer
transformer, String defaultOptions) {
Transform t = new Transform(name, transformer);
if(transformer instanceof HasPhaseOptions) {
HasPhaseOptions options = (HasPhaseOptions) transformer;
t.setDefaultOptions(t.getDefaultOptions() + " " +
options.getDefaultOptions() + " " + defaultOptions);
t.setDeclaredOptions(t.getDeclaredOptions() + " " +
options.getDeclaredOptions());
}
pack.add(t);
}
Also useful would be a set of required options that would be checked.
This is a stupid warning message... I put the phase in the right pack, and
the options match up and everything... just let me do it.:
Or, is there an option to turn this off?
Warning: Phase wjtp.hack is not a standard Soot phase listed in XML files.
Have you guys considered using a hierarchy pattern for Packs? Namely the
code below is obnoxious because it means that new toplevel packs cannot be
added... This used to not be a problem, because I could put everything
into wjtp, but now that is tied to spark...
public void runPacks() {
if (Options.v().whole_program()) {
runWholeProgramPacks();
}
preProcessDAVA();
runBodyPacks( reachableClasses() );
}
Since I'm nitpicking, the difference between scene transformers and body
transformers is really stupid... I don't see any reason why
BodyTransformers are needed other than convenience, so I wrote an adapter
that turns BodyTransformers into SceneTransformers:
public class TransformerAdapter extends SceneTransformer {
/** Construct a new transformer
*/
public TransformerAdapter(BodyTransformer transformer) {
_transformer = transformer;
}
protected void internalTransform(String phaseName, Map options) {
System.out.println("TransformerAdapter.internalTransform("
+ phaseName + ", " + options + ")");
Iterator classes = Scene.v().getApplicationClasses().iterator();
while (classes.hasNext()) {
SootClass theClass = (SootClass)classes.next();
Iterator methods = theClass.getMethods().iterator();
while (methods.hasNext()) {
SootMethod method = (SootMethod) methods.next();
if (!method.isConcrete())
continue;
try {
JimpleBody body = (JimpleBody)
method.retrieveActiveBody();
// FIXME: pass in the options.
// Currently this is not possible because the
// internalTransform method is protected.
_transformer.transform(body, phaseName);
} catch (RuntimeException ex) {
System.err.println("Exception occured while processing "
+ method);
throw ex;
}
}
}
}
private BodyTransformer _transformer;
}
I also have some flow analyses over a call graph... this used to work fine
since InvokeGraph was a HashMutableDirectedGraph, but CallGraph is
not.. Any thoughts on providing an adapter? I don't really feel like
rewriting it...
Steve