Skip to content

Commit fa54dd9

Browse files
committed
Make it possible to debug forked VMs
1 parent bd0fa02 commit fa54dd9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/tinykvm/rsp_client.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ void RSPClient::handle_writemem()
468468
if (data == '{' && i+1 < rlen) {
469469
data = bin[++i] ^ 0x20;
470470
}
471-
auto* mem = machine().rw_memory_at(addr+i, 1);
472-
mem[0] = data;
471+
machine().copy_to_guest(addr+i, &data, 1);
473472
}
474473
reply_ok();
475474
} catch (...) {
@@ -659,12 +658,14 @@ void RSPClient::report_gprs()
659658
const auto offset = cpu().exception_extra_offset(cpu().current_exception);
660659
if (i == 16)
661660
{
662-
char* rip = machine().unsafe_memory_at(regs.rsp+offset, 8);
663-
putreg(d, end, *(uint64_t *)rip);
661+
uint64_t rip;
662+
machine().unsafe_copy_from_guest(&rip, regs.rsp+offset, 8);
663+
putreg(d, end, rip);
664664
continue;
665665
} else if (i == 7) {
666-
char* rip = machine().unsafe_memory_at(regs.rsp+offset+24, 8);
667-
putreg(d, end, *(uint64_t *)rip);
666+
uint64_t rip;
667+
machine().unsafe_copy_from_guest(&rip, regs.rsp+offset+24, 8);
668+
putreg(d, end, rip);
668669
continue;
669670
}
670671
}

0 commit comments

Comments
 (0)