[Soot-list] source linenumber from jimple

mbatch at cs.mcgill.ca mbatch at cs.mcgill.ca
Wed Oct 18 11:29:53 EDT 2006


You are probably looking for the -keep-line-number command-line option.
This will make sure classfiles generated by soot KEEP their line numbers
(from the original source or classfile). If you are creating new code
within soot (i.e. instrumenting) then you'll need to assign your OWN line
numbers to the new code you insert.

If you are simply inserting new code (not building completely new methods)
and just want a "good enough" answer for those pieces of code that you
insert, you can tag your new code Stmts with a line number tag assigned
with the same value as the previous (non-instrumented) Stmt in the code.

If you are working with pre-generated jimple files, I don't think there is
a way to embed line numbers into them as far as I know. The
-keep-line-numbers does not append a line number table in the .jimple
output. You could always generate your own auxilary line number index
files.

As an aside, when I am instrumenting code I often find it useful to know
which bytecode an error is thrown at as opposed to the source line. You
can change the line numbers to bytecode numbers with this code (run on
Baf):

protected void internalTransform(Body b, String phaseName, Map options) {
  int idx = 0;
  PatchingChain units = b.getUnits();
  Iterator it = units.iterator();
  while (it.hasNext()) {
    Inst i  = (Inst)it.next();
    List tags = i.getTags();
    for (int k = 0; k < tags.size(); k++) {
      Tag t = (Tag)tags.get(k);
      if (t instanceof LineNumberTag) {
          tags.remove(k);
          break;
      }
    }
    i.addTag(new LineNumberTag(idx++));
  }
}

On Wed, October 18, 2006 3:02 am, Toth.Gabriella.2 at stud.u-szeged.hu wrote:
> Hi!
> I would like to know , which source linenumber belongs to a soot.Stmt
> . How can I execute it? I read about LineNumberTag. Do I have to do
> with it?




More information about the Soot-list mailing list