1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

Thread.cpp: Prevent repeatedly halting the debugger

This commit is contained in:
Eladash 2024-04-19 15:59:27 +03:00 committed by Elad Ashkenazi
parent bef832f4e0
commit 4905cd425f

View File

@ -2663,9 +2663,32 @@ void thread_base::exec()
logs::listener::sync_all();
if (IsDebuggerPresent())
{
// Prevent repeatedly halting the debugger in case multiple threads crashed at once
static atomic_t<u64> s_last_break = 0;
const u64 current_break = get_system_time() & -2;
if (s_last_break.fetch_op([current_break](u64& v)
{
if (current_break >= (v & -2) && current_break - (v & -2) >= 20'000'000)
{
v = current_break;
return true;
}
// Let's allow a single more thread to halt the debugger so the programmer sees the pattern
if (!(v & 1))
{
v |= 1;
return true;
}
return false;
}).second)
{
utils::trap();
}
}
if (const auto _this = g_tls_this_thread)
{