mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-27 22:06:24 +02:00
gdb: Prevent BreakHandler being called multiple times from the same breakpoint
This commit is contained in:
parent
669179ca2e
commit
cd2a7c9916
1 changed files with 10 additions and 3 deletions
|
@ -32,6 +32,7 @@ namespace Ryujinx.HLE.Debugger
|
||||||
private Thread DebuggerThread;
|
private Thread DebuggerThread;
|
||||||
private Thread MessageHandlerThread;
|
private Thread MessageHandlerThread;
|
||||||
private bool _shuttingDown = false;
|
private bool _shuttingDown = false;
|
||||||
|
private ManualResetEventSlim _breakHandlerEvent = new ManualResetEventSlim(false);
|
||||||
|
|
||||||
private ulong? cThread;
|
private ulong? cThread;
|
||||||
private ulong? gThread;
|
private ulong? gThread;
|
||||||
|
@ -237,6 +238,7 @@ namespace Ryujinx.HLE.Debugger
|
||||||
case ThreadBreakMessage { Context: var ctx }:
|
case ThreadBreakMessage { Context: var ctx }:
|
||||||
DebugProcess.DebugStop();
|
DebugProcess.DebugStop();
|
||||||
gThread = cThread = ctx.ThreadUid;
|
gThread = cThread = ctx.ThreadUid;
|
||||||
|
_breakHandlerEvent.Set();
|
||||||
Reply($"T05thread:{ctx.ThreadUid:x};");
|
Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1266,15 +1268,20 @@ namespace Ryujinx.HLE.Debugger
|
||||||
Messages.Add(new KillMessage());
|
Messages.Add(new KillMessage());
|
||||||
MessageHandlerThread.Join();
|
MessageHandlerThread.Join();
|
||||||
Messages.Dispose();
|
Messages.Dispose();
|
||||||
|
_breakHandlerEvent.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BreakHandler(IExecutionContext ctx, ulong address, int imm)
|
public void BreakHandler(IExecutionContext ctx, ulong address, int imm)
|
||||||
{
|
{
|
||||||
Logger.Notice.Print(LogClass.GdbStub, $"Break hit on thread {ctx.ThreadUid} at pc {address:x016}");
|
|
||||||
|
|
||||||
Messages.Add(new ThreadBreakMessage(ctx, address, imm));
|
|
||||||
DebugProcess.DebugInterruptHandler(ctx);
|
DebugProcess.DebugInterruptHandler(ctx);
|
||||||
|
|
||||||
|
_breakHandlerEvent.Reset();
|
||||||
|
Messages.Add(new ThreadBreakMessage(ctx, address, imm));
|
||||||
|
// Messages.Add can block, so we log it after adding the message to make sure user can see the log at the same time GDB receives the break message
|
||||||
|
Logger.Notice.Print(LogClass.GdbStub, $"Break hit on thread {ctx.ThreadUid} at pc {address:x016}");
|
||||||
|
// Wait for the process to stop before returning to avoid BreakHander being called multiple times from the same breakpoint
|
||||||
|
_breakHandlerEvent.Wait(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StepHandler(IExecutionContext ctx)
|
public void StepHandler(IExecutionContext ctx)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue