[Soot-list] want to maintain bytecode offsets for classfiles

Eric Bodden eric.bodden at mail.mcgill.ca
Mon Oct 6 16:34:48 EDT 2008


If I am not mistaken then LineNumber is an attribute used to encode
source code line numbers.

Just checking: you are aware of the -keep-offset flag, I assume?
http://www.sable.mcgill.ca/soot/tutorial/usage/index.html

This should generate tags of type BytecodeOffsetTag
(http://www.sable.mcgill.ca/soot/doc/soot/tagkit/BytecodeOffsetTag.html).
Is this not what you are looking for?

Eric

2008/10/6 Manjiri Namjoshi <manjiri.namjoshi at googlemail.com>:
> Hello,
>
> I was taking a look at the array bounds check annotation example.
> The attributes that are added are something like this:
>
> void footest()
> Code(max_stack = 3, max_locals = 2, code_length = 9)
>
> 0:    iconst_2
> 1:    newarray                <int>
> 3:    astore_1
> 4:    aload_1
> 5:    iconst_0
> 6:    iconst_1
> 7:    iastore
> 8:    return
>
> Attribute(s) = LineNumber(0, 5), LineNumber(4, 7), LineNumber(8, 3)
>
> The line numbers seem to be the bytecode offsets ... am i right?
> If yes then the offsets should get maintained after the annotation of
> classfiles.
>
> Please correct me if i am going wrong.
>
> Thanks !
>
> Sincerely,
> Manjiri
>
> 2008/10/6 Manjiri Namjoshi <manjiri.namjoshi at googlemail.com>
>>
>> Hi,
>>
>> Thank You !
>> Sorry to bother again but does SOOT provide any flag to turn off the
>> optimizations on the classfiles and only allow annotations?
>>
>> Sincerely,
>> Manjiri
>>
>> 2008/10/6 Eric Bodden <eric.bodden at mail.mcgill.ca>
>>>
>>> Looking at the source code it seems that it returns the offset from
>>> the original classfile.
>>>
>>> Eric
>>>
>>> 2008/10/5 Manjiri Namjoshi <manjiri.namjoshi at googlemail.com>:
>>> > Hi,
>>> >
>>> > Thanks for your reply !
>>> > Actually i would like to know which bytecode offset does the
>>> > getBytecodeOffset() return ?
>>> > The offset from the original classfile or the transformed classfile?
>>> >
>>> > I am caring about the offset because i want to add method annotations
>>> > with a
>>> > value as offsets corresponding to only if_cmp instructions !
>>> >
>>> > Thank You.
>>> >
>>> >
>>> > Sincerely,
>>> > Manjiri
>>> >
>>> > 2008/10/4 Eric Bodden <eric.bodden at mail.mcgill.ca>
>>> >>
>>> >> Hi Manjiri.
>>> >>
>>> >> I don't think that what you are looking for is possible. Soot converts
>>> >> bytecode to an intermediate representation called Jimple and then back
>>> >> to bytecode. This is not a 1:1 transformation. You can try to disable
>>> >> some of the phases in the "jb" pack (see here
>>> >> http://www.sable.mcgill.ca/soot/tutorial/phase/index.html) but I don't
>>> >> think that this is going to preserve all the offsets either.
>>> >>
>>> >> Just out of curiosity: Why would you care about the offsets?
>>> >>
>>> >> Eric
>>> >>
>>> >> 2008/10/4 Manjiri Namjoshi <manjiri.namjoshi at googlemail.com>:
>>> >> > Hello,
>>> >> >
>>> >> > I am trying to run a soot transformation and annotate the
>>> >> > classfiles.
>>> >> > I observed that the classfiles which the soot produces have
>>> >> > different
>>> >> > bytecode offsets than the original bytecode offsets.
>>> >> >
>>> >> > I think soot optimizations is causing this to happen.
>>> >> >
>>> >> > This is the transformation:
>>> >> >        /* adds the transformer. */
>>> >> >         PackManager.v().getPack("jtp").add(new
>>> >> >                         Transform("jtp.annotexample",
>>> >> >                   CreateAnnotationFile.v()));
>>> >> >
>>> >> >         /* invokes Soot */
>>> >> >         soot.Main.main(args);
>>> >> >
>>> >> > I want to somehow suppress these optimizations and maintain the
>>> >> > bytecode
>>> >> > offsets.
>>> >> >
>>> >> > Thanks in advance!
>>> >> >
>>> >> > Sincerely,
>>> >> > Manjiri
>>> >> >
>>> >> > _______________________________________________
>>> >> > Soot-list mailing list
>>> >> > Soot-list at sable.mcgill.ca
>>> >> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>> >> >
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Eric Bodden
>>> >> Sable Research Group
>>> >> McGill University, Montréal, Canada
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Eric Bodden
>>> Sable Research Group
>>> McGill University, Montréal, Canada
>>
>
>



-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


More information about the Soot-list mailing list