From 6f3012cf9eaf9ba32b5dd8ed0ae86f0a0ad66018 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Mon, 2 Jan 2023 15:59:03 +0100 Subject: [PATCH] dislproj: done ex3 --- DiSLProject2022/src-profiler/ex3/Instrumentation.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/DiSLProject2022/src-profiler/ex3/Instrumentation.java b/DiSLProject2022/src-profiler/ex3/Instrumentation.java index f193fd5..8eabf9e 100644 --- a/DiSLProject2022/src-profiler/ex3/Instrumentation.java +++ b/DiSLProject2022/src-profiler/ex3/Instrumentation.java @@ -1,4 +1,15 @@ package ex3; +import ch.usi.dag.disl.annotation.Before; +import ch.usi.dag.disl.dynamiccontext.DynamicContext; +import ch.usi.dag.disl.marker.BytecodeMarker; +import ch.usi.dag.disl.staticcontext.InstructionStaticContext; + public class Instrumentation { + @Before(marker = BytecodeMarker.class, args = "astore", scope = "ex3.MainThread.checkAccess") + static void printVariable(final InstructionStaticContext isc, final DynamicContext dc) { + if ("granted".equals(dc.getStackValue(0, Object.class))) { + System.out.printf("Thread: %s\n", Thread.currentThread().getName()); + } + } }