mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 12:12:50 +01:00
Thread.cpp: Prevent repeatedly halting the debugger
This commit is contained in:
parent
bef832f4e0
commit
4905cd425f
@ -2664,7 +2664,30 @@ void thread_base::exec()
|
|||||||
|
|
||||||
if (IsDebuggerPresent())
|
if (IsDebuggerPresent())
|
||||||
{
|
{
|
||||||
utils::trap();
|
// 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)
|
if (const auto _this = g_tls_this_thread)
|
||||||
|
Loading…
Reference in New Issue
Block a user