From 63fd7848c15dcef868a8ac0da29a4b67e366dc65 Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Wed, 11 Oct 2023 13:22:33 -0500 Subject: [PATCH] Add Connected event and default to break state --- .../Iris/Debug/Data/InterpreterCommand.cs | 2 +- UIX/Microsoft/Iris/Debug/IDebuggerClient.cs | 9 +-------- UIX/Microsoft/Iris/Debug/IDebuggerServer.cs | 4 +--- UIX/Microsoft/Iris/Debug/IDebuggerState.cs | 19 +++++++++++++++++++ .../Iris/Debug/SystemNet/NetDebuggerClient.cs | 5 ++++- .../Iris/Debug/SystemNet/NetDebuggerServer.cs | 5 ++++- 6 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 UIX/Microsoft/Iris/Debug/IDebuggerState.cs diff --git a/UIX/Microsoft/Iris/Debug/Data/InterpreterCommand.cs b/UIX/Microsoft/Iris/Debug/Data/InterpreterCommand.cs index 2dcbf0b..30eb105 100644 --- a/UIX/Microsoft/Iris/Debug/Data/InterpreterCommand.cs +++ b/UIX/Microsoft/Iris/Debug/Data/InterpreterCommand.cs @@ -2,7 +2,7 @@ public enum InterpreterCommand : byte { - Continue, Break, + Continue, Step, } diff --git a/UIX/Microsoft/Iris/Debug/IDebuggerClient.cs b/UIX/Microsoft/Iris/Debug/IDebuggerClient.cs index 1a08a11..81e4e9f 100644 --- a/UIX/Microsoft/Iris/Debug/IDebuggerClient.cs +++ b/UIX/Microsoft/Iris/Debug/IDebuggerClient.cs @@ -3,15 +3,8 @@ using System; namespace Microsoft.Iris.Debug; -public interface IDebuggerClient +public interface IDebuggerClient : IDebuggerState { - /// - /// The URI the client is connected to. - /// - Uri ConnectionUri { get; } - - InterpreterCommand DebuggerCommand { get; set; } - event Action InterpreterStateChanged; /// diff --git a/UIX/Microsoft/Iris/Debug/IDebuggerServer.cs b/UIX/Microsoft/Iris/Debug/IDebuggerServer.cs index 808eaf7..312d1bb 100644 --- a/UIX/Microsoft/Iris/Debug/IDebuggerServer.cs +++ b/UIX/Microsoft/Iris/Debug/IDebuggerServer.cs @@ -2,10 +2,8 @@ namespace Microsoft.Iris.Debug; -internal interface IDebuggerServer +internal interface IDebuggerServer : IDebuggerState { - InterpreterCommand DebuggerCommand { get; set; } - /// /// Logs the context, opcode, and operands of an instruction /// decoded by Microsoft.Iris.Markup.Interpreter. diff --git a/UIX/Microsoft/Iris/Debug/IDebuggerState.cs b/UIX/Microsoft/Iris/Debug/IDebuggerState.cs new file mode 100644 index 0000000..acf0cfb --- /dev/null +++ b/UIX/Microsoft/Iris/Debug/IDebuggerState.cs @@ -0,0 +1,19 @@ +using Microsoft.Iris.Debug.Data; +using System; + +namespace Microsoft.Iris.Debug; + +public interface IDebuggerState +{ + /// + /// The URI the client is connected to. + /// + public Uri ConnectionUri { get; } + + InterpreterCommand DebuggerCommand { get; set; } + + /// + /// Fired when a connection is established. + /// + public event Action Connected; +} diff --git a/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerClient.cs b/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerClient.cs index 591316b..09c9647 100644 --- a/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerClient.cs +++ b/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerClient.cs @@ -12,7 +12,7 @@ public class NetDebuggerClient : IDebuggerClient, IDisposable private readonly Socket _socket; private readonly ConcurrentQueue _outQueue = new(); private readonly IFormatter _formatter; - private InterpreterCommand _uibCommand = InterpreterCommand.Continue; + private InterpreterCommand _uibCommand; public Uri ConnectionUri { get; } @@ -31,6 +31,7 @@ public class NetDebuggerClient : IDebuggerClient, IDisposable public event EventHandler InterpreterExecute; public event Action DispatcherStep; public event Action InterpreterStateChanged; + public event Action Connected; public NetDebuggerClient(string connectionUri) : this(connectionUri is null ? null : new Uri(connectionUri)) { @@ -127,6 +128,8 @@ public class NetDebuggerClient : IDebuggerClient, IDisposable catch { } } + Connected?.Invoke(this, _socket); + System.Threading.Thread receiveThread = new(MessageReceiveLoop) { IsBackground = true }; System.Threading.Thread sendThread = new(MessageSendLoop) { IsBackground = true }; receiveThread.Start(); diff --git a/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerServer.cs b/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerServer.cs index cf25faa..c1ad4a6 100644 --- a/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerServer.cs +++ b/UIX/Microsoft/Iris/Debug/SystemNet/NetDebuggerServer.cs @@ -15,7 +15,9 @@ internal class NetDebuggerServer : IDebuggerServer, IDisposable private readonly IFormatter _formatter; private Socket _socket; private bool _disposed = false; - private InterpreterCommand _uibCommand = InterpreterCommand.Continue; + private InterpreterCommand _uibCommand; + + public event Action Connected; public Uri ConnectionUri { get; } @@ -130,6 +132,7 @@ internal class NetDebuggerServer : IDebuggerServer, IDisposable if (_disposed) return; _socket = _listener.AcceptSocket(); + Connected?.Invoke(this, _socket); System.Threading.Thread receiveThread = new(MessageReceiveLoop) { IsBackground = true }; System.Threading.Thread sendThread = new(MessageSendLoop) { IsBackground = true };