[DiSL-user] DiSL
Lubomír Bulej
lubomir.bulej at d3s.mff.cuni.cz
Tue Dec 6 17:26:27 CET 2016
Hi Mario,
if you check-out the trunk version of DiSL from OW2, you will find a
FieldAccessStaticContext that you can use with a bytecode marker configured to
mark putfield/getfield or putstatic/getstatic bytecodes.
Your snippet would then look like this:
@Before (
marker = BytecodeMarker.class, args = "putfield"
)
public static void beforeInstanceReferenceFieldStore (
final FieldAccessStaticContext fsc
) {
...
}
If you wanted to determine the kind of field access using the static context,
I can make an extended version, but usually the snippets are different for
putfield/getfield or putstatic/getstatic so it was not really needed so far.
Best regards,
Lubomir
On 05/12/16 22:32, Lukas Marek wrote:
> Hi Mario,
>
> huh, it is long time (at least from IT and my memory perspective) since I
> worked with DiSL. I will try my best to point you in the right direction.
>
> I believe you have this tutorial in mind for the custom bytecode marker:
>
> http://d3s.mff.cuni.cz/publications/download/Marek-scpest14.pdf
>
> The tutorial also mentions custom static context in the section 3.3. This
> should be exactly what you need. If you are marking only a single instruction,
> it should be enough to access the first marked instruction and get the name of
> the field out of it.
>
> The following code is an example what I meant (but written directly here so it
> will most probably not even compile - not mentioning correctness):
>
> public class FieldInsnStaticContext extends AbstractStaticContext {
> public String getAccessedFieldName() {
>
> AbstractInsnNode startInsn = staticContextData.getRegionStart();
>
> if(! (startInsn instanceof FieldInsnNode)) {
> // TODO error - wrong context
> }
>
> return ((FieldInsnNode)startInsn).name;
> }
> }
>
> If you need a reference of an object on which the instruction operates on, it
> should be possible to access it also via DynamicContext.
>
> Best regards,
> Lukas
>
> On 12/05/2016 02:44 PM, Mario César wrote:
>> Hi Lukas.
>> How is it going?
>> I'm a student of Computer Science at University of Chile and currently
>> I'm involved in a course about Software Quality.
>> I've been playing with DiSL this days, It's a great tool.
>>
>> I'm trying to use DiSL to obtain data about reads/writes on instance
>> variables
>>
>> I did a Custom Bytecode Marker just as is explained in the Introduction
>> pdf (but using instead "instruction instanceof FieldInsnNode" for
>> selecting the instructions)
>>
>> http://asm.ow2.org/asm50/javadoc/user/org/objectweb/asm/tree/FieldInsnNode.html
>>
>> I'm getting the current instance using DynamicContext and comparing the
>> values of all fields using java reflections, also I'm getting the
>> BytecodeNumber using BytecodeStaticContext, with this number I can tell
>> if the instruction is a read or a write.
>>
>> But I don't know yet how to get what field is been read or write (in
>> case that the same value is writed)
>>
>> Any ideas?
>>
>> I will be grateful for any help you can provide
>>
>> Mario Cornejo
>
>
> _______________________________________________
> Disl-user mailing list
> Disl-user at d3s.mff.cuni.cz
> https://d3s.mff.cuni.cz/mailman/listinfo/disl-user
--
Dept. Dist. and Dependable Systems
Faculty of Mathematics and Physics
Charles University, Czech Republic
Web: http://d3s.mff.cuni.cz
Tel: +420-221914267
More information about the Disl-user
mailing list