gdbstub: only let Execute breakpoints write/restore BKPT opcodes into target memory
This commit is contained in:
parent
bad2e084e3
commit
d388fe58f7
@ -409,10 +409,13 @@ static void RemoveBreakpoint(BreakpointType type, VAddr addr) {
|
|||||||
|
|
||||||
LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: {:08x} bytes at {:08x} of type {}",
|
LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: {:08x} bytes at {:08x} of type {}",
|
||||||
bp->second.len, bp->second.addr, static_cast<int>(type));
|
bp->second.len, bp->second.addr, static_cast<int>(type));
|
||||||
Core::System::GetInstance().Memory().WriteBlock(
|
|
||||||
*Core::System::GetInstance().Kernel().GetCurrentProcess(), bp->second.addr,
|
if (type == BreakpointType::Execute) {
|
||||||
bp->second.inst.data(), bp->second.inst.size());
|
Core::System::GetInstance().Memory().WriteBlock(
|
||||||
Core::CPU().ClearInstructionCache();
|
*Core::System::GetInstance().Kernel().GetCurrentProcess(), bp->second.addr,
|
||||||
|
bp->second.inst.data(), bp->second.inst.size());
|
||||||
|
Core::CPU().ClearInstructionCache();
|
||||||
|
}
|
||||||
p.erase(addr);
|
p.erase(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,11 +924,14 @@ static bool CommitBreakpoint(BreakpointType type, VAddr addr, u32 len) {
|
|||||||
Core::System::GetInstance().Memory().ReadBlock(
|
Core::System::GetInstance().Memory().ReadBlock(
|
||||||
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, breakpoint.inst.data(),
|
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, breakpoint.inst.data(),
|
||||||
breakpoint.inst.size());
|
breakpoint.inst.size());
|
||||||
|
|
||||||
static constexpr std::array<u8, 4> btrap{0x70, 0x00, 0x20, 0xe1};
|
static constexpr std::array<u8, 4> btrap{0x70, 0x00, 0x20, 0xe1};
|
||||||
Core::System::GetInstance().Memory().WriteBlock(
|
if (type == BreakpointType::Execute) {
|
||||||
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, btrap.data(),
|
Core::System::GetInstance().Memory().WriteBlock(
|
||||||
btrap.size());
|
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, btrap.data(),
|
||||||
Core::CPU().ClearInstructionCache();
|
btrap.size());
|
||||||
|
Core::CPU().ClearInstructionCache();
|
||||||
|
}
|
||||||
p.insert({addr, breakpoint});
|
p.insert({addr, breakpoint});
|
||||||
|
|
||||||
LOG_DEBUG(Debug_GDBStub, "gdb: added {} breakpoint: {:08x} bytes at {:08x}\n",
|
LOG_DEBUG(Debug_GDBStub, "gdb: added {} breakpoint: {:08x} bytes at {:08x}\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user