Merge pull request #2240 from FearlessTobi/port-4651

Port citra-emu/citra#4651: "gdbstub: Fix some bugs in IsMemoryBreak() and ServeBreak. Add workaround to let watchpoints break into GDB."
This commit is contained in:
bunnei 2019-04-05 23:46:37 -04:00 committed by GitHub
commit 54c7e8e40e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -192,12 +192,13 @@ void ARM_Unicorn::ExecuteInstructions(int num_instructions) {
CHECKED(uc_emu_start(uc, GetPC(), 1ULL << 63, 0, num_instructions)); CHECKED(uc_emu_start(uc, GetPC(), 1ULL << 63, 0, num_instructions));
core_timing.AddTicks(num_instructions); core_timing.AddTicks(num_instructions);
if (GDBStub::IsServerEnabled()) { if (GDBStub::IsServerEnabled()) {
if (last_bkpt_hit) { if (last_bkpt_hit && last_bkpt.type == GDBStub::BreakpointType::Execute) {
uc_reg_write(uc, UC_ARM64_REG_PC, &last_bkpt.address); uc_reg_write(uc, UC_ARM64_REG_PC, &last_bkpt.address);
} }
Kernel::Thread* thread = Kernel::GetCurrentThread(); Kernel::Thread* thread = Kernel::GetCurrentThread();
SaveContext(thread->GetContext()); SaveContext(thread->GetContext());
if (last_bkpt_hit || GDBStub::GetCpuStepFlag()) { if (last_bkpt_hit || GDBStub::IsMemoryBreak() || GDBStub::GetCpuStepFlag()) {
last_bkpt_hit = false; last_bkpt_hit = false;
GDBStub::Break(); GDBStub::Break();
GDBStub::SendTrap(thread, 5); GDBStub::SendTrap(thread, 5);

View File

@ -50,7 +50,7 @@ private:
uc_engine* uc{}; uc_engine* uc{};
Timing::CoreTiming& core_timing; Timing::CoreTiming& core_timing;
GDBStub::BreakpointAddress last_bkpt{}; GDBStub::BreakpointAddress last_bkpt{};
bool last_bkpt_hit; bool last_bkpt_hit = false;
}; };
} // namespace Core } // namespace Core

View File

@ -1030,7 +1030,7 @@ static void Step() {
/// Tell the CPU if we hit a memory breakpoint. /// Tell the CPU if we hit a memory breakpoint.
bool IsMemoryBreak() { bool IsMemoryBreak() {
if (IsConnected()) { if (!IsConnected()) {
return false; return false;
} }