Skip to content

Commit

Permalink
Fix checkpointing so checkpoints are only taken after primitive calls
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenS11 committed Nov 20, 2024
1 parent bcdac1e commit c6b91d4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Debug/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ void Debugger::setSnapshotPolicy(Module *m, uint8_t *interruptData) {
}
}

std::optional<uint32_t> getPrimitiveBeingCalled(uint8_t *pc_ptr) {
std::optional<uint32_t> getPrimitiveBeingCalled(Module *m, uint8_t *pc_ptr) {
if (!pc_ptr) {
return {};
}
Expand All @@ -962,7 +962,9 @@ std::optional<uint32_t> getPrimitiveBeingCalled(uint8_t *pc_ptr) {
if (opcode == 0x10) { // call opcode
uint8_t *pc_copy = pc_ptr + 1;
uint32_t fidx = read_LEB_32(&pc_copy);
return fidx;
if (fidx < m->import_count) {
return fidx;
}
}
return {};
}
Expand All @@ -979,7 +981,7 @@ void Debugger::handleSnapshotPolicy(Module *m) {
instructions_executed++;

// Store arguments of last primitive call.
if ((fidx_called = getPrimitiveBeingCalled(m->pc_ptr))) {
if ((fidx_called = getPrimitiveBeingCalled(m, m->pc_ptr))) {
const Type *type = m->functions[*fidx_called].type;
for (uint32_t i = 0; i < type->param_count; i++) {
prim_args[type->param_count - i - 1] =
Expand Down

0 comments on commit c6b91d4

Please sign in to comment.