From a926ef677665a71669e0896bc70d105be041e586 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 9 Mar 2013 00:40:33 -0800 Subject: [PATCH] Respect read/write only mem breakpoints in x86 jit. --- Core/Debugger/Breakpoints.cpp | 8 ++------ Core/Debugger/Breakpoints.h | 2 +- Core/MIPS/x86/Jit.cpp | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index 9a46fa9494..c072b62384 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -34,18 +34,14 @@ MemCheck::MemCheck(void) numHits=0; } -void MemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc) +void MemCheck::Action(u32 addr, bool write, int size, u32 pc) { if ((write && bOnWrite) || (!write && bOnRead)) { ++numHits; if (bLog) - { - char temp[256]; - sprintf(temp,"CHK %08x %s%i at %08x (%s), PC=%08x (%s)",iValue,write?"Write":"Read",size*8,addr,symbolMap.GetDescription(addr),pc,symbolMap.GetDescription(pc)); - ERROR_LOG(MEMMAP,"%s",temp); - } + NOTICE_LOG(MEMMAP, "CHK %s%i at %08x (%s), PC=%08x (%s)", write ? "Write" : "Read", size * 8, addr, symbolMap.GetDescription(addr), pc, symbolMap.GetDescription(pc)); if (bBreak) Core_Pause(); } diff --git a/Core/Debugger/Breakpoints.h b/Core/Debugger/Breakpoints.h index 675f42763e..223dab3895 100644 --- a/Core/Debugger/Breakpoints.h +++ b/Core/Debugger/Breakpoints.h @@ -47,7 +47,7 @@ struct MemCheck u32 numHits; - void Action(u32 _iValue, u32 addr, bool write, int size, u32 pc); + void Action(u32 addr, bool write, int size, u32 pc); }; class CBreakPoints diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index 71b7d18dde..3afc1d9eae 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -659,12 +659,11 @@ void Jit::JitSafeMem::Finish() jit_->SetJumpTarget(skipCheck_); } -void JitMemCheck(u32 addr, int size) +void JitMemCheck(u32 addr, int size, int isWrite) { MemCheck *check = CBreakPoints::GetMemCheck(addr, size); - // TODO: Value, hmm... also need to do read/write... if (check) - check->Action(0, addr, false, size, currentMIPS->pc); + check->Action(addr, isWrite == 1, size, currentMIPS->pc); } void Jit::JitSafeMem::MemCheckImm(ReadType type) @@ -672,8 +671,13 @@ void Jit::JitSafeMem::MemCheckImm(ReadType type) MemCheck *check = CBreakPoints::GetMemCheck(iaddr_, size_); if (check) { + if (!check->bOnRead && type == MEM_READ) + return; + if (!check->bOnWrite && type == MEM_WRITE) + return; + jit_->MOV(32, M(&jit_->mips_->pc), Imm32(jit_->js.compilerPC)); - jit_->ABI_CallFunctionCC(jit_->thunks.ProtectFunction((void *)&JitMemCheck, 2), iaddr_, size_); + jit_->ABI_CallFunctionCCC(jit_->thunks.ProtectFunction((void *)&JitMemCheck, 3), iaddr_, size_, type == MEM_WRITE ? 1 : 0); jit_->CMP(32, M((void*)&coreState), Imm32(0)); if (!jit_->js.inDelaySlot) @@ -696,6 +700,11 @@ void Jit::JitSafeMem::MemCheckAsm(ReadType type) { for (auto it = CBreakPoints::MemChecks.begin(), end = CBreakPoints::MemChecks.end(); it != end; ++it) { + if (!it->bOnRead && type == MEM_READ) + continue; + if (!it->bOnWrite && type == MEM_WRITE) + continue; + FixupBranch skipNext, skipNextRange; if (it->bRange) { @@ -712,7 +721,7 @@ void Jit::JitSafeMem::MemCheckAsm(ReadType type) jit_->PUSH(xaddr_); jit_->MOV(32, M(&jit_->mips_->pc), Imm32(jit_->js.compilerPC)); - jit_->ABI_CallFunctionAC(jit_->thunks.ProtectFunction((void *)&JitMemCheck, 2), R(xaddr_), size_); + jit_->ABI_CallFunctionACC(jit_->thunks.ProtectFunction((void *)&JitMemCheck, 3), R(xaddr_), size_, type == MEM_WRITE ? 1 : 0); jit_->POP(xaddr_); jit_->CMP(32, M((void*)&coreState), Imm32(0));