[Soot-list] [PATCH] added classaddpack
Eric Bodden
bodden at st.informatik.tu-darmstadt.de
Tue Jun 14 11:01:55 EDT 2011
Thanks for the patch, Phil, however I am a bit reluctant to adding
this patch to Soot.
Here is why:
While your patch does allow programmers to add classes to Soot,
avoiding an ConcurrentModificationException, this is really all it
does, right? In particular, if I am not mistaken, added classes will
not be analyzed. Whether or not added classes *should* be analyzed is
hard to decide upfront and probably should be left for the programmer
to decide. Hence, I somewhat prefer the current solution as is, as in
this case the programmer would need to write this code by his/herself
but then at least would be fully aware of the semantic implications
this change would have.
What do other people think?
Eric
On 11 June 2011 20:15, Phil Pratt-Szeliga <pcpratts at syr.edu> wrote:
> This patch allows someone to add classes during transformation. It does
> all classes in a phase before going on to the next phase. This is useful
> if you are doing whole program analysis but you don't want the expense
> that the full whole program analyzer incurs in compile time.
>
> -Phil Pratt-Szeliga
>
> diff -r 557b6b1f9f60 -r eaca941f4caf src/soot/PackManager.java
> --- a/src/soot/PackManager.java Sat Jun 11 13:42:33 2011 -0400
> +++ b/src/soot/PackManager.java Sat Jun 11 14:12:02 2011 -0400
> @@ -180,6 +180,8 @@
> p.add(new Transform("sop.cpf",
> SConstantPropagatorAndFolder.v()));
> }
>
> + addPack(p = new BodyPack("classaddpack"));
> +
> // Jimple transformation pack
> addPack(p = new BodyPack("jtp"));
>
> @@ -377,9 +379,52 @@
> }
>
> public void runBodyPacks() {
> + runClassAddPack();
> runBodyPacks( reachableClasses() );
> }
>
> + private List iteratorToList(Iterator iter){
> + List output = new ArrayList();
> + while(iter.hasNext()){
> + output.add(iter.next());
> + }
> + return output;
> + }
> +
> + private void runClassAddPack(){
> + Iterator phases = getPack("classaddpack").iterator();
> + while(phases.hasNext()){
> + Transform transform = (Transform) phases.next();
> +
> + //convert the iterator to a list so that we can add application
> classes at will
> + List classes = iteratorToList(reachableClasses());
> + for(int i = 0; i < classes.size(); ++i){
> + SootClass c = (SootClass) classes.get(i);
> + System.out.println("Applying transform
> "+transform.getPhaseName()+" to class "+c.getName());
> +
> + List methods = iteratorToList(c.methodIterator());
> + for(int j = 0; j < methods.size(); ++j){
> + SootMethod m = (SootMethod) methods.get(j);
> +
> + if (!m.isConcrete()) continue;
> +
> + ShimpleBody sBody = null;
> + Body body = m.retrieveActiveBody();
> + if(body instanceof ShimpleBody){
> + sBody = (ShimpleBody) body;
> + if(!sBody.isSSA())
> + sBody.rebuild();
> + } else {
> + sBody = Shimple.v().newBody(body);
> + }
> + m.setActiveBody(sBody); //set it here so transforms
> that get the active body deep in the process can get the shimple one
> + transform.apply(sBody);
> + m.setActiveBody(sBody); //set it here so the changes
> in the transform are saved
> + }
> + }
> + }
> + }
> +
> private ZipOutputStream jarFile = null;
> public void writeOutput() {
> if( Options.v().output_jar() ) {
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>
--
Dr. Eric Bodden, http://bodden.de/
Principal Investigator in Secure Services at CASED
Coordinator of the CASED Advisory Board of Study Affairs
PostDoc at Software Technology Group, Technische Universität Darmstadt
Tel: +49 6151 16-5478 Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
More information about the Soot-list
mailing list