2022-06-07 01:00:15 -05:00
|
|
|
using Microsoft.Iris.Debug;
|
2023-05-23 20:12:35 -05:00
|
|
|
using Microsoft.Iris.Debug.Data;
|
2023-06-01 20:18:53 -05:00
|
|
|
using Microsoft.Iris.Debug.SystemNet;
|
2023-05-23 20:12:35 -05:00
|
|
|
using System;
|
2023-06-02 00:09:51 -05:00
|
|
|
using System.Threading;
|
2022-06-07 01:00:15 -05:00
|
|
|
|
2023-05-23 20:12:35 -05:00
|
|
|
namespace SimpleDebugClient;
|
|
|
|
|
|
|
|
|
|
internal class Program
|
2022-06-07 01:00:15 -05:00
|
|
|
{
|
2023-05-23 20:12:35 -05:00
|
|
|
static IDebuggerClient? Debugger { get; set; }
|
|
|
|
|
|
2023-05-24 10:14:07 -05:00
|
|
|
static int Main(string[] args)
|
2022-06-07 01:00:15 -05:00
|
|
|
{
|
2023-06-01 20:18:53 -05:00
|
|
|
var connectionString = args.Length >= 2
|
|
|
|
|
? new Uri(args[1]) : DebugRemoting.DEFAULT_TCP_URI;
|
2022-10-07 09:34:08 -05:00
|
|
|
|
2023-06-01 20:18:53 -05:00
|
|
|
Debugger = new NetDebuggerClient(connectionString);
|
2023-06-02 00:09:51 -05:00
|
|
|
//Debugger.DispatcherStep += Debugger_DispatcherStep;
|
2023-05-24 10:14:07 -05:00
|
|
|
Debugger.InterpreterStep += Debugger_InterpreterStep;
|
2023-06-02 00:09:51 -05:00
|
|
|
Debugger.InterpreterStateChanged += Debugger_InterpreterStateChanged;
|
2022-06-12 21:21:29 -05:00
|
|
|
|
2023-06-02 00:09:51 -05:00
|
|
|
Console.WriteLine($"Listening for debug messages at '{Debugger.ConnectionUri}'. Press Ctrl-C or 'x' to exit.");
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
var cmd = Console.ReadLine();
|
|
|
|
|
if (cmd[0] == 'x')
|
|
|
|
|
{
|
|
|
|
|
if (Debugger is IDisposable debugger)
|
|
|
|
|
debugger.Dispose();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (cmd[0])
|
|
|
|
|
{
|
|
|
|
|
case 's':
|
|
|
|
|
Debugger.DebuggerCommand = InterpreterCommand.Step;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
|
Debugger.DebuggerCommand = InterpreterCommand.Continue;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-24 10:14:07 -05:00
|
|
|
|
|
|
|
|
return 0;
|
2023-05-23 20:12:35 -05:00
|
|
|
}
|
|
|
|
|
|
2023-06-02 00:09:51 -05:00
|
|
|
private static void Debugger_InterpreterStateChanged(InterpreterCommand state)
|
2023-05-23 20:12:35 -05:00
|
|
|
{
|
2023-06-02 00:09:51 -05:00
|
|
|
Console.WriteLine($"Interpreter is in {state} mode");
|
2023-05-23 20:12:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void Debugger_DispatcherStep(string obj)
|
|
|
|
|
{
|
2023-05-24 16:04:09 -05:00
|
|
|
Console.WriteLine($"[Dispatcher] {obj}");
|
2023-05-23 20:12:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void Debugger_InterpreterStep(object? sender, InterpreterEntry e)
|
|
|
|
|
{
|
2023-06-02 00:09:51 -05:00
|
|
|
if (e.LoadUri.EndsWith("TopToolbarSignIn.uix"))
|
|
|
|
|
return;
|
2023-05-25 21:01:48 -05:00
|
|
|
Console.WriteLine($"[Interpreter] {e}");
|
2022-06-07 01:00:15 -05:00
|
|
|
}
|
|
|
|
|
}
|