[Soot-list] Unable to access line numbers

Jennifer Lhotak jlhotak at cs.mcgill.ca
Wed Jun 29 10:23:50 EDT 2005


Hi,

You need to use the -keep-line-number option as an argument when invoking
Soot.

Jennifer

On Wed, 29 Jun 2005, Joe Qian wrote:

> Hi,
> I tried to use the following program to access the line number of each
> unit, but no line number
> is successfully read. Can anybody help me?
> Thanks,
> Joe Qian
> ------------------------------------------------------------------------
> import soot.*;
> import soot.util.*;
> import soot.tagkit.LineNumberTag;
> import java.util.*;
>
> public class LineNumberReader extends BodyTransformer {
> private static LineNumberReader instance = new LineNumberReader();
> private LineNumberReader() {}
> public static LineNumberReader v() { return instance; }
>
> protected void internalTransform(Body body, String phaseName, Map options) {
> Chain ch = body.getUnits();
> for (Iterator it = ch.iterator(); it.hasNext();) {
> Unit n = (Unit) it.next();
> LineNumberTag tag = (LineNumberTag) n.getTag("LineNumberTag");
> if (tag != null) {
> System.out.println("[" + tag.getLineNumber() + "] " + n.toString());
> }
> }
> }
>
> public static void main(String[] args) {
> String newArgs[] = { "-p","tag.ln","on","SootTest" };
> //PhaseOptions.v().setPhaseOption("tag.ln", "on");
>
> PackManager.v().getPack("jtp").add(new Transform("jtp.instrumenter",
> LineNumberReader.v()));
> soot.Main.main(newArgs);
> }
> }
> ------------------------------------------------------------------------
> The result is:
>
> Soot started on Wed Jun 29 22:04:52 CST 2005
> Transforming SootTest...
> Writing to sootOutput\SootTest.class
> Soot finished on Wed Jun 29 22:04:56 CST 2005
> Soot has run for 0 min. 3 sec.
> _______________________________________________
> 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