Notify debugger on BRK instruction

# Conflicts:
#	src/Ryujinx.HLE/Debugger/Debugger.cs
#	src/Ryujinx.HLE/Debugger/Message/ThreadBreakMessage.cs
#	src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs
This commit is contained in:
merry 2022-02-13 16:43:55 +00:00 committed by svc64
parent 9b9137bf0a
commit 09a63ba2b5
4 changed files with 44 additions and 4 deletions

View file

@ -1,4 +1,4 @@
using Ryujinx.Common;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Memory;
using System;
@ -8,6 +8,7 @@ using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using IExecutionContext = Ryujinx.Cpu.IExecutionContext;
namespace Ryujinx.HLE.Debugger
{
@ -134,6 +135,11 @@ namespace Ryujinx.HLE.Debugger
WriteStream.WriteByte((byte)'+');
ProcessCommand(cmd);
break;
case ThreadBreakMessage msg:
HaltApplication();
Reply($"T05thread:{msg.Context.ThreadUid:x};");
break;
}
}
}
@ -641,5 +647,14 @@ namespace Ryujinx.HLE.Debugger
HandlerThread.Join();
}
}
public void ThreadBreak(IExecutionContext ctx, ulong address, int imm)
{
ctx.DebugStop();
Logger.Notice.Print(LogClass.GdbStub, $"Break hit on thread {ctx.ThreadUid} at pc {address:x016}");
Messages.Add(new ThreadBreakMessage(ctx, address, imm));
}
}
}

View file

@ -0,0 +1,18 @@
using IExecutionContext = Ryujinx.Cpu.IExecutionContext;
namespace Ryujinx.HLE.Debugger
{
public class ThreadBreakMessage : IMessage
{
public IExecutionContext Context { get; }
public ulong Address { get; }
public int Opcode { get; }
public ThreadBreakMessage(IExecutionContext context, ulong address, int opcode)
{
Context = context;
Address = address;
Opcode = opcode;
}
}
}

View file

@ -730,9 +730,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public IExecutionContext CreateExecutionContext()
{
ExceptionCallback breakCallback = null;
if (KernelContext.Device.Configuration.EnableGdbStub)
{
breakCallback = KernelContext.Device.Debugger.ThreadBreak;
}
return Context?.CreateExecutionContext(new ExceptionCallbacks(
InterruptHandler,
null,
breakCallback,
KernelContext.SyscallHandler.SvcCall,
UndefinedInstructionHandler));
}