diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index 1947c0c8..2b78264c 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -1024,7 +1024,16 @@ void Debugger::handleSnapshotPolicy(Module *m) { this->channel->write("\n"); } else if (snapshotPolicy == SnapshotPolicy::checkpointing) { if (instructions_executed >= checkpointInterval || fidx_called) { - checkpoint(m); + if (min_return_values == 0) { + checkpoint(m); + } else { + if (fidx_called) { + const Type *type = m->functions[*fidx_called].type; + if (type->result_count >= min_return_values) { + checkpoint(m); + } + } + } } instructions_executed++; @@ -1046,19 +1055,6 @@ void Debugger::checkpoint(Module *m, const bool force) { return; } - if (min_return_values != 0) { - if (!fidx_called) { - // Tracing mode is on, but no primitive was called. - return; - } - - const Type *type = m->functions[*fidx_called].type; - if (type->result_count < min_return_values) { - // Primitive was called but did not have the required return values. - return; - } - } - this->channel->write(R"(CHECKPOINT {"instructions_executed": %d, )", instructions_executed); if (fidx_called) { @@ -1614,10 +1610,11 @@ bool Debugger::handleUpdateStackValue(const Module *m, uint8_t *bytes) const { return true; } -bool Debugger::reset(Module *m) const { +bool Debugger::reset(Module *m) { auto *wasm = static_cast(malloc(sizeof(uint8_t) * m->byte_count)); memcpy(wasm, m->bytes, m->byte_count); + instructions_executed = 0; m->warduino->update_module(m, wasm, m->byte_count); this->channel->write("Reset WARDuino.\n"); return true; diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index cec77b23..1cfda22a 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -201,7 +201,7 @@ class Debugger { bool handleUpdateStackValue(const Module *m, uint8_t *bytes) const; - bool reset(Module *m) const; + bool reset(Module *m); //// Handle out-of-place debugging