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

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Thu Jul 22 05:14:18 EDT 2010


Hi again.

I think that the only problem is that you are using the wrong tag.
SourceLnPosTag is what you are looking for.

I agree, though, that LineNumberTag has a misleading name. I also
often confuse them myself...

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 22 July 2010 10:21, Jochen Huck <jochen.huck at student.kit.edu> wrote:
> 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
>
> _______________________________________________
> 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