[Soot-list] Correct type of locals, and correct line numbers

Jochen Huck jochen.huck at student.kit.edu
Thu Jul 22 04:21:33 EDT 2010


Hi,

thanks for your reply. I'm sorry I didn't attach my example code.

> What do you mean by "the line numbers are incorrect"? Please be more
> specific. Soot has certainly produced (mostly) correct line numbers
> from source code in the past.
>
>    

I just want to know the source code line number for each unit. This is a 
shortened example of how I do that:
I start the program with: java PrintLineNumbers --f n --cp ... 
--keep-line-numbers --src-prec java HelloWorld

    public class PrintLineNumbers {

         static class MyBodyTransformer extends BodyTransformer {
             protected void internalTransform(Body body, String
    phaseName, Map options) {
                 for (Unit unit: body.getUnits()) {
                     G.v().out.println(getLineNumber(unit) + " - " +
    unit.toString());
                 }
             }
         }

         public static int getLineNumber(Unit unit) {
             LineNumberTag tag=(LineNumberTag) unit.getTag("LineNumberTag");
             if(tag != null) {
                 return tag.getLineNumber();
             }
             else {
                 return -1;
             }
         }

         public static void main(String[] args) {
             MyBodyTransformer b = new MyBodyTransformer();
             MyTransform t = new MyTransform("jtp.myTransform", b);
             PackManager.v().getPack("jtp").add(t);
             soot.Main.main(args);
         }

         static class MyTransform extends Transform {
             public MyTransform(String phaseName, Transformer t) {
                 super(phaseName, t);
             }
         }
    }

The result is that most of the line numbers are -1. The line numbers are 
correct if I do the same thing with the byte code.

What am I doing wrong?


Cheers,
Jochen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100722/9c2500f6/attachment.html 


More information about the Soot-list mailing list