Skip to content

Commit

Permalink
SPU/Debugger: Improve debugging reservations
Browse files Browse the repository at this point in the history
Simplify and make the debugging results more consistent.
  • Loading branch information
elad335 authored and Nekotekina committed Aug 22, 2022
1 parent 9d8f4d5 commit a71bdc7
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions rpcs3/Emu/Cell/SPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4248,6 +4248,8 @@ s64 spu_thread::get_ch_value(u32 ch)
resrv_mem = vm::get_super_ptr<decltype(rdata)>(raddr);
std::shared_ptr<utils::shm> rdata_shm;

const u32 old_raddr = raddr;

// Does not need to safe-access reservation if LR is the only event masked
// Because it's either an access violation or a livelock if an invalid memory is passed
if (raddr && mask1 > SPU_EVENT_LR)
Expand Down Expand Up @@ -4293,14 +4295,6 @@ s64 spu_thread::get_ch_value(u32 ch)
return -1;
}

if (is_paused(old))
{
// Ensure spu_thread::rdata's stagnancy while the thread is paused for debugging purposes
check_state();
state += cpu_flag::wait;
continue;
}

// Optimized check
if (raddr && (!vm::check_addr(raddr) || rtime != vm::reservation_acquire(raddr) || !cmp_rdata(rdata, *resrv_mem)))
{
Expand All @@ -4326,11 +4320,6 @@ s64 spu_thread::get_ch_value(u32 ch)
return false;
}

if (is_paused(old))
{
return true;
}

if (!vm::check_addr(_this->raddr) || !cmp_rdata(_this->rdata, *_this->resrv_mem))
{
_this->set_events(SPU_EVENT_LR);
Expand All @@ -4355,6 +4344,18 @@ s64 spu_thread::get_ch_value(u32 ch)
}

wakeup_delay();

if (is_paused(state - cpu_flag::suspend))
{
if (!raddr && old_raddr)
{
// Restore reservation address temporarily for debugging use
raddr = old_raddr;
check_state();
raddr = 0;
}
}

check_state();
return events.events & mask1;
}
Expand Down

0 comments on commit a71bdc7

Please sign in to comment.