gdb: Fix the crash that occurs when GDB is connected early (ryubing/ryujinx!159)

See merge request ryubing/ryujinx!159
This commit is contained in:
Coxxs
2025-10-11 19:06:14 -05:00
committed by LotP
parent 1865be47cf
commit ceec9617ef

View File

@@ -859,7 +859,13 @@ namespace Ryujinx.HLE.Debugger
{
if (threadId == 0 || threadId == null)
{
threadId = GetThreads().First().ThreadUid;
var threads = GetThreads();
if (threads.Length == 0)
{
ReplyError();
return;
}
threadId = threads.First().ThreadUid;
}
if (DebugProcess.GetThread(threadId.Value) == null)
@@ -1037,7 +1043,7 @@ namespace Ryujinx.HLE.Debugger
string response = command.Trim().ToLowerInvariant() switch
{
"help" => "backtrace\nbt\nregisters\nreg\nget info\nminidump",
"help" => "backtrace\nbt\nregisters\nreg\nget info\nminidump\n",
"get info" => GetProcessInfo(),
"backtrace" => GetStackTrace(),
"bt" => GetStackTrace(),
@@ -1192,11 +1198,11 @@ namespace Ryujinx.HLE.Debugger
// If the user connects before the application is running, wait for the application to start.
int retries = 10;
while (DebugProcess == null && retries-- > 0)
while ((DebugProcess == null || GetThreads().Length == 0) && retries-- > 0)
{
Thread.Sleep(200);
}
if (DebugProcess == null)
if (DebugProcess == null || GetThreads().Length == 0)
{
Logger.Warning?.Print(LogClass.GdbStub, "Application is not running, cannot accept GDB client connection");
ClientSocket.Close();