From 82aae9cc03374b2aa4a028f09795dd644c00323e Mon Sep 17 00:00:00 2001 From: kheradmand Date: Fri, 6 Feb 2015 19:00:50 -0600 Subject: [PATCH] added end of thread execution as default sync event changed rs for Example1 accordingly --- examples/Example1/Example1.rs | 2 +- src/main/java/replaymop/output/AspectJGenerator.java | 4 ++++ src/main/java/replaymop/parser/RSParser.java | 6 +++++- src/main/java/replaymop/parser/rs/ReplaySpecification.java | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/Example1/Example1.rs b/examples/Example1/Example1.rs index 4a5740c..26b273f 100644 --- a/examples/Example1/Example1.rs +++ b/examples/Example1/Example1.rs @@ -15,5 +15,5 @@ after_sync: default ; -schedule: 1 x 7 , 10 x 5 , 1 x 1 , 10 x 1 ; +schedule: 1 x 7 , 10 x 5 , 1 x 2 , 10 x 2 ; diff --git a/src/main/java/replaymop/output/AspectJGenerator.java b/src/main/java/replaymop/output/AspectJGenerator.java index bc7a1bc..cb729a4 100644 --- a/src/main/java/replaymop/output/AspectJGenerator.java +++ b/src/main/java/replaymop/output/AspectJGenerator.java @@ -41,6 +41,8 @@ void generateBeforeSyncPointCut() { StringJoiner pointcuts = new StringJoiner(" ||\n\t\t\t"); if (spec.beforeMonitorEnter) pointcuts.add("lock()"); + if (spec.afterThreadBegin) //trick: before run execution = after thread begin + pointcuts.add("execution(* Thread+.run())"); for (String sync : spec.beforeSync){ pointcuts.add(String.format("call(%s)", sync)); } @@ -51,6 +53,8 @@ void generateAfterSyncPointCut() { StringJoiner pointcuts = new StringJoiner(" ||\n\t\t\t"); if (spec.afterMonitorExit) pointcuts.add("unlock()"); + if (spec.beforeThreadEnd) //trick: after run execution = before thread end + pointcuts.add("execution(* Thread+.run())"); for (String sync : spec.afterSync){ pointcuts.add(String.format("call(%s)", sync)); } diff --git a/src/main/java/replaymop/parser/RSParser.java b/src/main/java/replaymop/parser/RSParser.java index 5227d00..6ecf0e3 100644 --- a/src/main/java/replaymop/parser/RSParser.java +++ b/src/main/java/replaymop/parser/RSParser.java @@ -84,6 +84,8 @@ void handleBeforeSync() throws ReplayMOPException { spec.addBeforeSyncDefault(); else if (func.equals("synchronized")) spec.beforeMonitorEnter = true; + else if (func.equals("begin")) + spec.beforeThreadEnd = true; else if (func.equals(";")) return; else @@ -100,7 +102,9 @@ void handleAfterSync() throws ReplayMOPException { if (func.equals("default")) spec.addAfterSyncDefault(); else if (func.equals("synchronized")) - spec.afterMonitorExit = false; + spec.afterMonitorExit = true; + else if (func.equals("begin")) + spec.afterThreadBegin = true; else if (func.equals(";")) return; else diff --git a/src/main/java/replaymop/parser/rs/ReplaySpecification.java b/src/main/java/replaymop/parser/rs/ReplaySpecification.java index 7a8af26..14f4065 100644 --- a/src/main/java/replaymop/parser/rs/ReplaySpecification.java +++ b/src/main/java/replaymop/parser/rs/ReplaySpecification.java @@ -14,8 +14,10 @@ public class ReplaySpecification { public Set shared; public Set beforeSync; public boolean beforeMonitorEnter = false; + public boolean beforeThreadEnd = false; public Set afterSync; public boolean afterMonitorExit = false; + public boolean afterThreadBegin = false; public List schedule; public String input; @@ -40,11 +42,13 @@ public ReplaySpecification() { public void addBeforeSyncDefault(){ beforeMonitorEnter = true; + beforeThreadEnd = true; beforeSync.addAll(Arrays.asList(beforeSyncDefault)); } public void addAfterSyncDefault(){ afterMonitorExit = true; + //afterThreadBegin = true; afterSync.addAll(Arrays.asList(afterSyncDefault)); }