[Soot-list] Correct type of locals, and correct line numbers
Jochen Huck
jochen.huck at student.kit.edu
Fri Jul 23 04:58:08 EDT 2010
Hi,
thank you very much. I didn't even think about the possibility that I am
using the wrong tag. So thanks for the solution. There is still jimple
code that has no SourceLnPosTag but these units have a LineNumberTag. So
I'll combine the two tags.
But I have another problem now. The jimple representation after
analyzing source code is different to the jimple file when analyzing
byte code. When analyzing source code there is a temp$x variable for
every local variable. And a single assignment to a local is split into
two assignments. First: assign the result to temp$x and then assign
temp$x to the local variable. Is there a (simple) possibility to archive
the byte-code-like jimple file when analyzing source code?
The source:*
*
*int theUltimateAnswer = getTheAnswer();*
The jimple file after analyzing byte code:
*theUltimateAnswer = staticinvoke <object.Example: int
getTheAnswer()>();*
The jimple file after analyzing source code:
*temp$0 = staticinvoke <object.Example: int getTheAnswer()>();
theUltimateAnswer = temp$0;*
Thanks again for your help.
Jochen
Am 22.07.2010 11:14, schrieb Eric Bodden:
> Hi again.
>
> I think that the only problem is that you are using the wrong tag.
> SourceLnPosTag is what you are looking for.
>
> I agree, though, that LineNumberTag has a misleading name. I also
> often confuse them myself...
>
> Eric
>
> --
> Dr. Eric Bodden
> Software Technology Group, Technische Universität Darmstadt, Germany
> Tel: +49 6151 16-5478 Fax: +49 6151 16-5410
> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>
>
>
> On 22 July 2010 10:21, Jochen Huck<jochen.huck at student.kit.edu> wrote:
>
>> Hi,
>>
>> thanks for your reply. I'm sorry I didn't attach my example code.
>>
>> What do you mean by "the line numbers are incorrect"? Please be more
>> specific. Soot has certainly produced (mostly) correct line numbers
>> from source code in the past.
>>
>>
>>
>> I just want to know the source code line number for each unit. This is a
>> shortened example of how I do that:
>> I start the program with: java PrintLineNumbers --f n --cp ...
>> --keep-line-numbers --src-prec java HelloWorld
>>
>> public class PrintLineNumbers {
>>
>> static class MyBodyTransformer extends BodyTransformer {
>> protected void internalTransform(Body body, String phaseName, Map
>> options) {
>> for (Unit unit: body.getUnits()) {
>> G.v().out.println(getLineNumber(unit) + " - " +
>> unit.toString());
>> }
>> }
>> }
>>
>> public static int getLineNumber(Unit unit) {
>> LineNumberTag tag=(LineNumberTag) unit.getTag("LineNumberTag");
>> if(tag != null) {
>> return tag.getLineNumber();
>> }
>> else {
>> return -1;
>> }
>> }
>>
>> public static void main(String[] args) {
>> MyBodyTransformer b = new MyBodyTransformer();
>> MyTransform t = new MyTransform("jtp.myTransform", b);
>> PackManager.v().getPack("jtp").add(t);
>> soot.Main.main(args);
>> }
>>
>> static class MyTransform extends Transform {
>> public MyTransform(String phaseName, Transformer t) {
>> super(phaseName, t);
>> }
>> }
>> }
>>
>> The result is that most of the line numbers are -1. The line numbers are
>> correct if I do the same thing with the byte code.
>>
>> What am I doing wrong?
>>
>>
>> Cheers,
>> Jochen
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100723/2dd94e73/attachment.html
More information about the Soot-list
mailing list