Fix incorrect backend breakpoints implementation
This commit is contained in:
parent
28468f8a18
commit
d09e3b7953
|
@ -135,8 +135,10 @@ bool X64Backend::InstallBreakpoint(Breakpoint* bp) {
|
|||
auto code = guest_function->MapGuestAddressToMachineCode(bp->address());
|
||||
assert_not_zero(code);
|
||||
|
||||
bp->set_backend_data(
|
||||
xe::load_and_swap<uint16_t>(reinterpret_cast<void*>(code + 0x0)));
|
||||
auto orig_bytes =
|
||||
xe::load_and_swap<uint16_t>(reinterpret_cast<void*>(code + 0x0));
|
||||
bp->backend_data().push_back({code, orig_bytes });
|
||||
|
||||
xe::store_and_swap<uint16_t>(reinterpret_cast<void*>(code + 0x0), 0x0F0C);
|
||||
}
|
||||
|
||||
|
@ -144,24 +146,12 @@ bool X64Backend::InstallBreakpoint(Breakpoint* bp) {
|
|||
}
|
||||
|
||||
bool X64Backend::UninstallBreakpoint(Breakpoint* bp) {
|
||||
auto functions = processor()->FindFunctionsWithAddress(bp->address());
|
||||
if (functions.empty()) {
|
||||
// This should not happen.
|
||||
assert_always();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto function : functions) {
|
||||
assert_true(function->is_guest());
|
||||
auto guest_function = reinterpret_cast<cpu::GuestFunction*>(function);
|
||||
auto code = guest_function->MapGuestAddressToMachineCode(bp->address());
|
||||
assert_not_zero(code);
|
||||
|
||||
xe::store_and_swap<uint16_t>(reinterpret_cast<void*>(code + 0x0),
|
||||
uint16_t(bp->backend_data()));
|
||||
bp->set_backend_data(0);
|
||||
for (auto pair : bp->backend_data()) {
|
||||
xe::store_and_swap<uint16_t>(reinterpret_cast<void*>(pair.first),
|
||||
uint16_t(pair.second));
|
||||
}
|
||||
|
||||
bp->backend_data().clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,12 @@ class Breakpoint {
|
|||
void Hit(uint64_t host_pc) { hit_callback_(address_, host_pc); }
|
||||
|
||||
// CPU backend data. Implementation specific - DO NOT TOUCH THIS!
|
||||
uint64_t backend_data() const { return backend_data_; }
|
||||
void set_backend_data(uint64_t backend_data) { backend_data_ = backend_data; }
|
||||
std::vector<std::pair<uint64_t, uint64_t>> backend_data() const {
|
||||
return backend_data_;
|
||||
}
|
||||
std::vector<std::pair<uint64_t, uint64_t>>& backend_data() {
|
||||
return backend_data_;
|
||||
}
|
||||
|
||||
private:
|
||||
Processor* processor_ = nullptr;
|
||||
|
@ -46,7 +50,7 @@ class Breakpoint {
|
|||
std::function<void(uint32_t, uint64_t)> hit_callback_;
|
||||
|
||||
// Opaque backend data. Don't touch this.
|
||||
uint64_t backend_data_ = 0;
|
||||
std::vector<std::pair<uint64_t, uint64_t>> backend_data_;
|
||||
};
|
||||
|
||||
} // namespace cpu
|
||||
|
|
Loading…
Reference in New Issue