[Soot-list] Emitting line numbers from Jasmin?
Hal Hildebrand
hal.hildebrand at gmail.com
Sat Aug 7 00:21:38 EDT 2010
Thanks, that did the trick. To be clear, I'm not running soot through the
main invocation. I find it terribly difficult to do unit testing when run
under that mechanism. What I was doing was the rather simple thing of unit
testing my transformations, then converting the SootClasses which I then
load to test my assertions. Thus, your pointer to the PackManager line was
precisely what I needed to make my testing regime work.
For posterity's sake, here's the summary:
First, to instruct Soot to capture and annotate method bodies with source
line annotations, do the following:
Options.v().set_keep_line_number(true);
PhaseOptions.v().setPhaseOption("tag.ln", "on");
Next, to emit class files that have the source line annotations in the
generated class files, add the following two lines to the
soot.baf.JasminClass.emitInst(Inst) method:
LineNumberTag lnTag = (LineNumberTag) inst.getTag("LineNumberTag");
if(lnTag != null) emit(".line " + lnTag.getLineNumber());
Finally, if you have a SootClass with methods with Jimple active bodies, you
can transform them with the following code snippet:
SootClass clazz = ....
for (SootMethod method: clazz.getMethods()) {
method.setActiveBody(Baf.v().newBody((JimpleBody)
method.getActiveBody()));
}
Agan, thanks for the help. Much appreciated!
On Fri, Aug 6, 2010 at 4:09 PM, Saswat Anand <saswat78 at gmail.com> wrote:
> Unless you are using -via-grimp command line option, soot should
> convert Jimple body to Baf body just before producing bytecodes (and
> after all transformations are done).
>
> See the code around line 791 in PackManager.java which does the conversion.
>
> Saswat
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100806/ce77f8d3/attachment.html
More information about the Soot-list
mailing list