[Soot-list] Jimple to class file

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Fri Dec 3 07:36:58 EST 2010


Hi Divya.

I don't think you can do what you want to do. Jimple can have tags in
its abstract syntax tree but the printed Jimple code holds tags only
as comments, which are ignored when the Jimple is parsed back into
Soot. Thus, at this point you lose the tagged information, I believe.

Eric

--
Dr. Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt



On 2 December 2010 21:55, DIVYA IYER <sirius.strider at gmail.com> wrote:
> Hi,
>
> I want to generate a class file from a jimple file by using soot, such that
> the class file also has all the line number information as present in the
> jimple file (as LineNumberTag)
>
> The code that I have written to do so is :
> import soot.*;
> import java.util.*;
> import soot.util.*;
> import soot.jimple.Stmt;
> import soot.tagkit.LineNumberTag;
> import java.io.*;
>
> public class create_class extends BodyTransformer
> {
>     private static create_class instance = new create_class();
>     private create_class() {};
>     public static create_class v()
>     {
>     return instance;
>     }
>     public static void main(String args[])
>     {
>     soot.options.Options.v().set_keep_line_number(true);
>     soot.options.Options.v().whole_program();
>     soot.options.Options.v().set_src_prec(3);
>     soot.options.Options.v().print_tags_in_output();
>     PackManager.v().getPack("jtp").add(new Transform
> ("jtp.annotexample",trans.v()));
>     soot.Main.main(args);
>     }
>     protected void internalTransform(Body b, String phaseName, Map options)
>     {
>     int linenum = 0;
>     int count = 0;
>     int array[] = new int[20];
>     PatchingChain units = b.getUnits();
>     Iterator unitsIt = units.iterator();
>     while(unitsIt.hasNext())
>         {
>         Unit unit = (Unit)unitsIt.next();
>         LineNumberTag tag = (LineNumberTag) unit.getTag("LineNumberTag");
>         System.out.println(unit);
>         if (tag != null)
>         {
>            System.out.println("line number:"+tag.getLineNumber());
>          }
>        }
>      }
> }
>
> When I run the above program, it does not print any tags.Also the generated
> class file does not contain any line number info. Any comments regarding
> this problem would be greatly appreciated.
>
> Thanks!
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>


More information about the Soot-list mailing list