Merge pull request #2625 from unknownbrackets/debugger

Fix some memcheck bugs
This commit is contained in:
Henrik Rydgård 2013-07-05 02:26:13 -07:00
commit abc03520b4
2 changed files with 22 additions and 12 deletions

View File

@ -248,12 +248,12 @@ MemCheck *CBreakPoints::GetMemCheck(u32 address, int size)
MemCheck &check = *iter;
if (check.end != 0)
{
if (address >= check.start && address + size < check.end)
if (address + size >= check.start && address < check.end)
return &check;
}
else
{
if (check.start==address)
if (check.start == address)
return &check;
}
}

View File

@ -735,6 +735,10 @@ void JitMemCheck(u32 addr, int size, int isWrite)
if (CBreakPoints::CheckSkipFirst() == currentMIPS->pc)
return;
// Did we already hit one?
if (coreState != CORE_RUNNING)
return;
MemCheck *check = CBreakPoints::GetMemCheck(addr, size);
if (check)
check->Action(addr, isWrite == 1, size, currentMIPS->pc);
@ -755,26 +759,29 @@ void Jit::JitSafeMem::MemCheckImm(ReadType type)
jit_->CMP(32, M((void*)&coreState), Imm32(0));
skipChecks_.push_back(jit_->J_CC(CC_NE, true));
jit_->js.afterOp = JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE;
jit_->js.afterOp |= JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE;
}
}
void Jit::JitSafeMem::MemCheckAsm(ReadType type)
{
auto memchecks = CBreakPoints::GetMemChecks();
const auto memchecks = CBreakPoints::GetMemChecks();
bool possible = false;
for (auto it = memchecks.begin(), end = memchecks.end(); it != end; ++it)
{
if (!(it->cond & MEMCHECK_READ) && type == MEM_READ)
return;
continue;
if (!(it->cond & MEMCHECK_WRITE) && type == MEM_WRITE)
return;
continue;
possible = true;
FixupBranch skipNext, skipNextRange;
if (it->end != 0)
{
jit_->CMP(32, R(xaddr_), Imm32(it->start - offset_));
jit_->CMP(32, R(xaddr_), Imm32(it->start - offset_ - size_));
skipNext = jit_->J_CC(CC_B);
jit_->CMP(32, R(xaddr_), Imm32(it->end - offset_ - size_));
jit_->CMP(32, R(xaddr_), Imm32(it->end - offset_));
skipNextRange = jit_->J_CC(CC_AE);
}
else
@ -789,14 +796,17 @@ void Jit::JitSafeMem::MemCheckAsm(ReadType type)
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));
skipChecks_.push_back(jit_->J_CC(CC_NE, true));
jit_->js.afterOp = JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE;
jit_->SetJumpTarget(skipNext);
if (it->end != 0)
jit_->SetJumpTarget(skipNextRange);
}
if (possible)
{
jit_->CMP(32, M((void*)&coreState), Imm32(0));
skipChecks_.push_back(jit_->J_CC(CC_NE, true));
jit_->js.afterOp |= JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE;
}
}
void Jit::Comp_DoNothing(u32 op) { }