[Soot-list] Jimple to class file

DIVYA IYER sirius.strider at gmail.com
Thu Dec 2 15:55:45 EST 2010


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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20101202/9baad556/attachment.html 


More information about the Soot-list mailing list