[Soot-list] Unable to access line numbers

Joe Qian owqian at gmail.com
Wed Jun 29 10:15:54 EDT 2005


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.


More information about the Soot-list mailing list