Skip to content

Commit

Permalink
Merge pull request #17423 from unknownbrackets/debugger
Browse files Browse the repository at this point in the history
Debugger: Correct PC if replacement breaks
  • Loading branch information
hrydgard committed May 6, 2023
2 parents c4422e5 + 8721705 commit 13815e6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Core/Debugger/MemBlockInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ static inline bool MergeRecentMemInfo(const PendingNotifyMem &info, size_t copyL

for (size_t i = 1; i <= 4; ++i) {
auto &prev = pendingNotifies[pendingNotifies.size() - i];
if (prev.flags != info.flags)
continue;

if (prev.start >= info.start + info.size || prev.start + prev.size <= info.start)
continue;

Expand Down
8 changes: 8 additions & 0 deletions Core/MIPS/ARM/ArmJit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,14 @@ bool ArmJit::ReplaceJalTo(u32 dest) {
js.compilerPC += 4;
// No writing exits, keep going!

if (CBreakPoints::HasMemChecks()) {
// We could modify coreState, so we need to write PC and check.
// Otherwise, PC may end up on the jal. We add 4 to skip the delay slot.
FlushAll();
WriteExit(GetCompilerPC() + 4, js.nextExit++);
js.compiling = false;
}

// Add a trigger so that if the inlined code changes, we invalidate this block.
blocks.ProxyBlock(js.blockStart, dest, funcSize / sizeof(u32), GetCodePtr());
#endif
Expand Down
8 changes: 8 additions & 0 deletions Core/MIPS/ARM64/Arm64Jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@ bool Arm64Jit::ReplaceJalTo(u32 dest) {
js.compilerPC += 4;
// No writing exits, keep going!

if (CBreakPoints::HasMemChecks()) {
// We could modify coreState, so we need to write PC and check.
// Otherwise, PC may end up on the jal. We add 4 to skip the delay slot.
FlushAll();
WriteExit(GetCompilerPC() + 4, js.nextExit++);
js.compiling = false;
}

// Add a trigger so that if the inlined code changes, we invalidate this block.
blocks.ProxyBlock(js.blockStart, dest, funcSize / sizeof(u32), GetCodePtr());
#endif
Expand Down
7 changes: 7 additions & 0 deletions Core/MIPS/x86/Jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ bool Jit::ReplaceJalTo(u32 dest) {
js.compilerPC += 4;
// No writing exits, keep going!

if (CBreakPoints::HasMemChecks()) {
// We could modify coreState, so we need to write PC and check.
// Otherwise, PC may end up on the jal. We add 4 to skip the delay slot.
MOV(32, MIPSSTATE_VAR(pc), Imm32(GetCompilerPC() + 4));
js.afterOp |= JitState::AFTER_CORE_STATE;
}

// Add a trigger so that if the inlined code changes, we invalidate this block.
blocks.ProxyBlock(js.blockStart, dest, funcSize / sizeof(u32), GetCodePtr());
return true;
Expand Down

0 comments on commit 13815e6

Please sign in to comment.