Some overhauls of the modified replay code.

This commit is contained in:
2023-02-20 16:02:18 -05:00
parent 9eeaa04159
commit f9aafee165
4 changed files with 47 additions and 9 deletions

View File

@@ -744,6 +744,9 @@ static void replay_sent_outgoing(EngineWrapper *w) {
if ((nbytes > ndata) || (hash != SpookyHash::QkHash64(data, nbytes))) {
return reset_wrapper(w, "nondeterministic in replay_sent_outgoing");
}
if (w->replay_cb_sent_outgoing != nullptr) {
w->replay_cb_sent_outgoing(w->replay_cb_vp, chid, ndata, data);
}
w->engine->drv_sent_outgoing(chid, nbytes);
}
@@ -885,7 +888,6 @@ void replay_set_lua_source(EngineWrapper *w) {
static void replaycore_initialize(EngineWrapper *w, const char *logfn) {
std::cerr << "Memhash before replaycore_initialize: " << eng::memhash() << std::endl;
if (w->engine != nullptr) {
return reset_wrapper(w, "Cannot initialize wrapper, it's already initialized.");
return;
@@ -904,7 +906,7 @@ static void replaycore_initialize(EngineWrapper *w, const char *logfn) {
uint8_t code = rlog_uint8(w);
int hash = rlog_uint32(w);
if (!w->rlog->good()) {
return reset_wrapper(w, "logfile corrupt");
return reset_wrapper(w, "logfile corrupt in initial step");
}
if (hash != eng::memhash()) {
return reset_wrapper(w, "nondeterminism detected in initial step");
@@ -926,9 +928,12 @@ static void replaycore_step(EngineWrapper *w) {
}
uint8_t code = rlog_uint8(w);
if (w->rlog->eof()) {
return reset_wrapper(w, "logfile terminated abruptly");
}
int hash = rlog_uint32(w);
if (!w->rlog->good()) {
return reset_wrapper(w, "logfile corrupt");
return reset_wrapper(w, "logfile corrupt in replay step");
}
if (hash != eng::memhash()) {
return reset_wrapper(w, "nondeterminism detected");

View File

@@ -193,6 +193,32 @@ struct EngineWrapper {
//
void (*replay_step)(EngineWrapper *w);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// CALLBACKS USED ONLY IN REPLAY MODE
//
// The driver can store function pointers here. If it does so, these
// functions will get called during replay_step operations.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void (*replay_cb_sent_outgoing)(void *vp, int chid, int nbytes, const char *data);
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// VOID POINTER USED IN REPLAY CALLBACKS
//
// The driver can store a void pointer here. This void pointer will get passed
// to all the replay callbacks.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void *replay_cb_vp;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//