<div dir="ltr">Hello,<br><br>I'm trying to instrument a class to display the columnNumbers and lineNumbers of the statement, during the execution.<br><br>I've made a simple BodyTransformer: <br><font face="monospace, monospace"><br></font><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><font face="monospace, monospace"><span style="color:rgb(187,181,41)">@Override<br></span><span style="color:rgb(204,120,50)">protected void </span><span style="color:rgb(255,198,109)">internalTransform</span>(Body body<span style="color:rgb(204,120,50)">, </span>String s<span style="color:rgb(204,120,50)">, </span>Map<String<span style="color:rgb(204,120,50)">, </span>String> map) {<br>    Chain units = body.getUnits()<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)">    </span>Iterator stmtIt = units.snapshotIterator()<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"><br></span><span style="color:rgb(204,120,50)">    while </span>(stmtIt.hasNext()) {<br>        Stmt stmt = (Stmt) stmtIt.next()<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"><br></span><span style="color:rgb(204,120,50)">        if </span>(!stmt.containsInvokeExpr()) {<br>            <span style="color:rgb(204,120,50)">continue;<br></span><span style="color:rgb(204,120,50)">        </span>}<br>        String value = <span style="color:rgb(106,135,89)">"col: "</span>+stmt.getJavaSourceStartColumnNumber()+<span style="color:rgb(106,135,89)">" line:"</span>+stmt.getJavaSourceStartLineNumber()<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"><br></span><span style="color:rgb(204,120,50)">        </span>InvokeExpr newExp = Jimple.<span style="font-style:italic">v</span>().newStaticInvokeExpr(<span style="color:rgb(152,118,170);font-style:italic">callMethod</span>.makeRef()<span style="color:rgb(204,120,50)">, </span>StringConstant.<span style="font-style:italic">v</span>(value))<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"><br></span><span style="color:rgb(204,120,50)">        </span>Stmt newInvokeStmt = Jimple.<span style="font-style:italic">v</span>().newInvokeStmt(newExp)<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"><br></span><span style="color:rgb(204,120,50)">        </span>units.insertBefore(newInvokeStmt<span style="color:rgb(204,120,50)">, </span>stmt)<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)">    </span>}<br>}</font></blockquote><br clear="all"><div>callMethod refers to a method executing a System.out.println(String value).<br><br>When I run the instrumented classes, the classes only display : <br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace, monospace">col: -1 line:-1</font></blockquote><div><br>What should I do to get the exact values of the columns and line numbers ? <br><br>Thank you, <br><br>Best regards,</div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Thibault Béziers la Fosse<br></div><br></div></div>
</div>