[Soot-list] Source line number info
Guillaume Salagnac
Guillaume.Salagnac at imag.fr
Thu Jul 21 07:18:09 EDT 2005
From: Ashok Sreenivas <ashoks at pune.tcs.co.in>
Subject: [Soot-list] Source line number info
Date: Thu, 21 Jul 2005 15:05:07 +0530 (IST)
> Hi
>
> Is there any I can map back from SSA/shimple representation to
> line numbers etc. in the original Java source code? Of course,
> this is assuming that the class file was created through "javac
> -g" and that no transformations have been performed on the
> shimple representation.
Provided that soot.Main is called with the -keep-line-number switch, I
use something like this :
int getLineNumberForStatement(Stmt s)
{
List tags = s.getTags();
int ln=-1;
Iterator it = tags.iterator();
while(it.hasNext() && ln == -1 )
{
Tag tag = (Tag) it.next();
if (tag instanceof LineNumberTag )
{
byte[] value = tag.getValue();
ln = ((value[0] & 0xff) << 8) | (value[1] & 0xff);
}
else if (tag instanceof SourceLnPosTag)
{
ln = ((SourceLnPosTag) tag).startLn();
}
else if (tag instanceof SourceLineNumberTag)
{
ln = ((SourceLineNumberTag) tag).getLineNumber();
}
}
return ln;
}
-Guillaume
--
Guillaume Salagnac
PhD Student, Laboratoire Vérimag, Grenoble, France.
More information about the Soot-list
mailing list