[DiSL-user] DiSL

Lukas Marek lukas.marek at d3s.mff.cuni.cz
Mon Dec 5 22:32:49 CET 2016


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





More information about the Disl-user mailing list