Skip to content

Commit

Permalink
added debug info to aspecj template
Browse files Browse the repository at this point in the history
  • Loading branch information
kheradmand committed Feb 6, 2015
1 parent 9cbd912 commit 22f6227
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/replaymop/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void main(String[] args){
parseArguments(args);
File inputFile = new File(parameters.inputFile.get(0));
ReplaySpecification spec = RSParser.parse(inputFile);
Aspect aspect = AspectJGenerator.generate(spec);
Aspect aspect = AspectJGenerator.generate(spec, parameters);
File outputFile = new File(inputFile.getParent() + File.separator + aspect.name + ".aj");
PrintWriter writer = new PrintWriter(outputFile);
writer.println(aspect.toString());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/replaymop/Parameters.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package replaymop;

import java.io.File;
import java.util.List;

import com.beust.jcommander.*;
Expand All @@ -9,6 +8,8 @@ public class Parameters {
@Parameter(description = "Input file")
public List<String> inputFile;

@Parameter(names = "-debug-runtime", description = "Causes the replayed program to print debug info")
public boolean debug_runtime = true;


}
15 changes: 12 additions & 3 deletions src/main/java/replaymop/output/AspectJGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
import java.util.List;
import java.util.StringJoiner;

import replaymop.Parameters;
import replaymop.output.aspectj.Aspect;
import replaymop.parser.rs.ReplaySpecification;

public class AspectJGenerator {
ReplaySpecification spec;
Aspect aspect;
Parameters params;

private AspectJGenerator(ReplaySpecification spec) {
private AspectJGenerator(ReplaySpecification spec, Parameters params) {
this.spec = spec;
this.params = params;
aspect = new Aspect(spec.fileName + "Aspect");
}

Expand Down Expand Up @@ -67,6 +70,11 @@ void generateThreadSchedule() {
printList(counts));

}

void handleDebugInfo(){
aspect.setParameter("DEBUG_BEGIN", params.debug_runtime ? "" : "\\*");
aspect.setParameter("DEBUG_END", params.debug_runtime ? "" : "/*");
}

void startGeneration() {
generateThreadCreationOrder();
Expand All @@ -75,11 +83,12 @@ void startGeneration() {
generateBeforeSyncPointCut();
generateAfterSyncPointCut();
generateThreadSchedule();
handleDebugInfo();

}

public static Aspect generate(ReplaySpecification spec) {
AspectJGenerator generator = new AspectJGenerator(spec);
public static Aspect generate(ReplaySpecification spec, Parameters params) {
AspectJGenerator generator = new AspectJGenerator(spec, params);
generator.startGeneration();
return generator.aspect;
}
Expand Down
21 changes: 19 additions & 2 deletions src/main/resources/AspectJTemplate.aj
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,31 @@ public aspect %NAME% {
schedule_count[threadScheduleIndex]--;
if (schedule_count[threadScheduleIndex] == 0){
threadScheduleIndex++;
this.notifyAll();
threadScheduleLock.notifyAll();
}
}
}
}

//===========================sched enforce end===========================


//============================debug info begin===========================

%DEBUG_BEGIN%
before(): beforeSync() && !cflow(adviceexecution()) {
printThread();
}

after(): afterSync() && !cflow(adviceexecution()){
printThread();
}

void printThread(){
System.out.printf("%d sync event\n", Thread.currentThread().getId());
}
%DEBUG_END%


//============================debug info begin===========================

}

0 comments on commit 22f6227

Please sign in to comment.