Skip to content

Commit 9055164

Browse files
committed
[PEx] Store temporary changes
1 parent 82b298c commit 9055164

File tree

15 files changed

+263
-269
lines changed

15 files changed

+263
-269
lines changed

Src/PRuntimes/PExplicitRuntime/src/main/java/pexplicit/RuntimeExecutor.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import pexplicit.runtime.STATUS;
55
import pexplicit.runtime.logger.PExplicitLogger;
66
import pexplicit.runtime.logger.StatWriter;
7+
import pexplicit.runtime.scheduler.Schedule;
78
import pexplicit.runtime.scheduler.explicit.ExplicitSearchScheduler;
8-
import pexplicit.runtime.scheduler.replay.ReplayScheduler;
9+
import pexplicit.runtime.scheduler.replay.ReceiverQueueReplayer;
10+
import pexplicit.runtime.scheduler.replay.SenderQueueReplayer;
911
import pexplicit.utils.exceptions.BugFoundException;
1012
import pexplicit.utils.exceptions.MemoutException;
1113
import pexplicit.utils.monitor.MemoryMonitor;
@@ -99,21 +101,31 @@ private static void process(boolean resume) throws Exception {
99101
PExplicitGlobal.setResult(String.format("found cex of length %d", scheduler.getStepNumber()));
100102
PExplicitLogger.logStackTrace(e);
101103

102-
ReplayScheduler replayer = new ReplayScheduler(scheduler.schedule);
103-
PExplicitGlobal.setScheduler(replayer);
104+
SenderQueueReplayer senderQueueReplayer = new SenderQueueReplayer(scheduler.schedule);
105+
PExplicitGlobal.setScheduler(senderQueueReplayer);
104106
try {
105-
replayer.run();
106-
} catch (NullPointerException | StackOverflowError | ClassCastException replayException) {
107-
PExplicitLogger.logStackTrace((Exception) replayException);
108-
throw new BugFoundException(replayException.getMessage(), replayException);
109-
} catch (BugFoundException replayException) {
110-
PExplicitLogger.logStackTrace(replayException);
111-
throw replayException;
112-
} catch (Exception replayException) {
113-
PExplicitLogger.logStackTrace(replayException);
114-
throw new Exception("Error when replaying the bug", replayException);
107+
senderQueueReplayer.run();
108+
} catch (NullPointerException | StackOverflowError | ClassCastException | BugFoundException senderQueueException) {
109+
ReceiverQueueReplayer receiverQueueReplayer = new ReceiverQueueReplayer(senderQueueReplayer.getReceiverSemanticsSchedule());
110+
PExplicitGlobal.setScheduler(receiverQueueReplayer);
111+
try {
112+
receiverQueueReplayer.run();
113+
} catch (NullPointerException | StackOverflowError | ClassCastException receiverQueueException) {
114+
PExplicitLogger.logStackTrace((Exception) receiverQueueException);
115+
throw new BugFoundException(receiverQueueException.getMessage(), receiverQueueException);
116+
} catch (BugFoundException receiverQueueException) {
117+
PExplicitLogger.logStackTrace(receiverQueueException);
118+
throw receiverQueueException;
119+
} catch (Exception receiverQueueException) {
120+
PExplicitLogger.logStackTrace(receiverQueueException);
121+
throw new Exception("Error when replaying the bug in receiver queue semantics", receiverQueueException);
122+
}
123+
throw new Exception("Failed to replay bug in receiver queue semantics", e);
124+
} catch (Exception senderQueueException) {
125+
PExplicitLogger.logStackTrace(senderQueueException);
126+
throw new Exception("Error when replaying the bug in sender queue semantics", senderQueueException);
115127
}
116-
throw new Exception("Failed to replay bug", e);
128+
throw new Exception("Failed to replay bug in sender queue semantics", e);
117129
} catch (InterruptedException e) {
118130
PExplicitGlobal.setStatus(STATUS.INTERRUPTED);
119131
throw new Exception("INTERRUPTED", e);

Src/PRuntimes/PExplicitRuntime/src/main/java/pexplicit/runtime/logger/PExplicitLogger.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
import pexplicit.runtime.scheduler.explicit.SearchStatistics;
2222
import pexplicit.runtime.scheduler.explicit.StateCachingMode;
2323
import pexplicit.runtime.scheduler.explicit.strategy.SearchTask;
24-
import pexplicit.runtime.scheduler.replay.ReplayScheduler;
24+
import pexplicit.runtime.scheduler.replay.ReceiverQueueReplayer;
25+
import pexplicit.runtime.scheduler.replay.SenderQueueReplayer;
2526
import pexplicit.utils.monitor.MemoryMonitor;
2627
import pexplicit.values.ComputeHash;
2728
import pexplicit.values.PEvent;
@@ -184,11 +185,11 @@ public static void logStartIteration(SearchTask task, int iter, int step) {
184185
}
185186
}
186187

187-
public static void logStartStep(int step, PMachine sender, PMessage msg) {
188+
public static void logStartStep(int step, PMessage msg) {
188189
if (verbosity > 0) {
189190
log.info(String.format(
190191
" Step %d: %s sent %s to %s",
191-
step, sender, msg.getEvent(), msg.getTarget()));
192+
step, msg.getSender(), msg.getEvent(), msg.getTarget()));
192193
if (verbosity > 5) {
193194
log.info(String.format(" payload: %s", msg.getPayload()));
194195
}
@@ -267,7 +268,8 @@ public static void logNewState(int step, int idx, Object stateKey, SortedSet<PMa
267268
}
268269

269270
private static boolean isReplaying() {
270-
return (PExplicitGlobal.getScheduler() instanceof ReplayScheduler);
271+
return (PExplicitGlobal.getScheduler() instanceof SenderQueueReplayer ||
272+
PExplicitGlobal.getScheduler() instanceof ReceiverQueueReplayer);
271273
}
272274

273275
private static boolean typedLogEnabled() {
@@ -320,15 +322,15 @@ public static void logCreateMachine(PMachine machine, PMachine creator) {
320322
}
321323
}
322324

323-
public static void logSendEvent(PMachine sender, PMessage message) {
325+
public static void logSendEvent(PMessage message) {
324326
PExplicitGlobal.getScheduler().updateLogNumber();
325327
if (typedLogEnabled()) {
326328
String payloadMsg = "";
327329
if (message.getPayload() != null) {
328330
payloadMsg = String.format(" with payload %s", message.getPayload());
329331
}
330332
typedLog(LogType.SendLog, String.format("%s in state %s sent event %s%s to %s.",
331-
sender, sender.getCurrentState(), message.getEvent(), payloadMsg, message.getTarget()));
333+
message.getSender(), message.getSender().getCurrentState(), message.getEvent(), payloadMsg, message.getTarget()));
332334
}
333335
}
334336

@@ -401,7 +403,11 @@ public static void logDequeueEvent(PMachine machine, PMessage message) {
401403
public static void logStartReplay() {
402404
if (verbosity > 0) {
403405
log.info("--------------------");
404-
log.info("Replaying schedule");
406+
switch(PExplicitGlobal.getConfig().getBufferSemantics()) {
407+
case SenderQueue -> log.info("Replaying schedule: sender queue semantics");
408+
case ReceiverQueue -> log.info("Replaying schedule: receiver queue semantics");
409+
}
410+
405411
}
406412
}
407413
}

Src/PRuntimes/PExplicitRuntime/src/main/java/pexplicit/runtime/logger/ScheduleWriter.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pexplicit.utils.misc.Assert;
77
import pexplicit.values.PBool;
88
import pexplicit.values.PInt;
9+
import pexplicit.values.PMessage;
910
import pexplicit.values.PValue;
1011

1112
import java.io.File;
@@ -56,8 +57,8 @@ public static void logDataChoice(PValue<?> choice) {
5657
}
5758

5859
public static void logScheduleChoice(PMachine choice) {
59-
logComment("schedule choice");
60-
log(String.format("(%d)", choice.getInstanceId()));
60+
logComment(String.format("schedule choice: %s", choice));
61+
// log(String.format("(%d)", choice.getInstanceId()));
6162
}
6263

6364
public static void logHeader() {
@@ -74,4 +75,14 @@ public static void logHeader() {
7475
logComment("create Main(2)");
7576
log("(1)");
7677
}
78+
79+
public static void logSend(PMessage msg) {
80+
log(String.format("// send %s from %s to %s", msg.getEvent(), msg.getSender(), msg.getTarget()));
81+
log(String.format("(%d)", msg.getSender().getInstanceId()));
82+
}
83+
84+
public static void logReceive(PMessage msg) {
85+
log(String.format("// receive %s at %s", msg.getEvent(), msg.getTarget()));
86+
log(String.format("(%d)", msg.getTarget().getInstanceId()));
87+
}
7788
}

Src/PRuntimes/PExplicitRuntime/src/main/java/pexplicit/runtime/logger/TraceLogger.java

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)