mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Debug bridge improvements
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
#if !ZUNE5
|
||||||
|
|
||||||
|
using Microsoft.Iris.Debug.Data;
|
||||||
|
|
||||||
|
namespace Microsoft.Iris.Debug
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A dummy implementation of <see cref="IBridge"/>, used to avoid conditional
|
||||||
|
/// code in consuming libraries.
|
||||||
|
/// </summary>
|
||||||
|
public class Bridge : IBridge
|
||||||
|
{
|
||||||
|
public void LogDispatcher(string message)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogInterpreterOpCode(object context, InterpreterEntry entry)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+1
-4
@@ -2,16 +2,13 @@
|
|||||||
|
|
||||||
using OwlCore.Remoting;
|
using OwlCore.Remoting;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.Iris.Debug
|
namespace Microsoft.Iris.Debug
|
||||||
{
|
{
|
||||||
[RemoteProperty]
|
[RemoteProperty]
|
||||||
[RemoteMethod]
|
[RemoteMethod]
|
||||||
[RemoteOptions(RemotingDirection.Bidirectional)]
|
[RemoteOptions(RemotingDirection.Bidirectional)]
|
||||||
public class Bridge : IDisposable
|
public class Bridge : IBridge, IDisposable
|
||||||
{
|
{
|
||||||
private readonly MemberRemote _memberRemote;
|
private readonly MemberRemote _memberRemote;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.Iris.Debug.Data
|
namespace Microsoft.Iris.Debug.Data
|
||||||
@@ -8,17 +9,22 @@ namespace Microsoft.Iris.Debug.Data
|
|||||||
public InterpreterEntry(object opCode, params OpCodeArgument[] args)
|
public InterpreterEntry(object opCode, params OpCodeArgument[] args)
|
||||||
{
|
{
|
||||||
OpCode = opCode;
|
OpCode = opCode;
|
||||||
Arguments = args;
|
|
||||||
|
if (args != null)
|
||||||
|
Arguments = args;
|
||||||
|
else
|
||||||
|
Arguments = new List<OpCodeArgument>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public object OpCode { get; private set; }
|
public object OpCode { get; }
|
||||||
public OpCodeArgument[] Arguments { get; private set; }
|
public IList<OpCodeArgument> Arguments { get; }
|
||||||
|
public IList<object> ReturnValues { get; } = new List<object>();
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var args =
|
var args =
|
||||||
#if ZUNE5
|
#if ZUNE5
|
||||||
(System.Collections.Generic.IEnumerable<OpCodeArgument>)Arguments;
|
Arguments;
|
||||||
#else
|
#else
|
||||||
Arguments.Select(a => a.ToString()).ToArray();
|
Arguments.Select(a => a.ToString()).ToArray();
|
||||||
#endif
|
#endif
|
||||||
@@ -28,8 +34,16 @@ namespace Microsoft.Iris.Debug.Data
|
|||||||
|
|
||||||
public class OpCodeArgument
|
public class OpCodeArgument
|
||||||
{
|
{
|
||||||
public Type Type { get; private set; }
|
public string Name { get; set; }
|
||||||
public object Value { get; private set; }
|
public Type Type { get; set; }
|
||||||
|
public object Value { get; set; }
|
||||||
|
|
||||||
|
public OpCodeArgument(string name, Type type, object value)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Type = type;
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{Type} {Value}";
|
public override string ToString() => $"{Type} {Value}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
namespace Microsoft.Iris.Debug
|
||||||
|
{
|
||||||
|
internal interface IBridge
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Logs the context, opcode, and arguments of an instruction
|
||||||
|
/// executed by <c>Microsoft.Iris.Markup.Interpreter</c>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="entry"></param>
|
||||||
|
public void LogInterpreterOpCode(object context, Data.InterpreterEntry entry);
|
||||||
|
|
||||||
|
public void LogDispatcher(string message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
<ItemGroup Condition=" '$(UseZune5)' == 'true' ">
|
<ItemGroup Condition=" '$(UseZune5)' == 'true' ">
|
||||||
<PackageReference Include="OwlCore" Version="0.0.67" />
|
<PackageReference Include="OwlCore" Version="0.0.67" />
|
||||||
|
<PackageReference Include="Cauldron.BasicInterceptors" Version="3.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(UseZune5)' == 'true' ">
|
<PropertyGroup Condition=" '$(UseZune5)' == 'true' ">
|
||||||
|
|||||||
@@ -8,5 +8,12 @@ namespace Microsoft.Iris.Debug
|
|||||||
public bool OpenDebugPipe { get; set; } = false;
|
public bool OpenDebugPipe { get; set; } = false;
|
||||||
public List<System.Xml.XmlDocument> DecompileResults { get; } = new List<System.Xml.XmlDocument>();
|
public List<System.Xml.XmlDocument> DecompileResults { get; } = new List<System.Xml.XmlDocument>();
|
||||||
public TraceSettings TraceSettings { get; } = TraceSettings.Current;
|
public TraceSettings TraceSettings { get; } = TraceSettings.Current;
|
||||||
|
|
||||||
|
public Bridge Bridge { get; } =
|
||||||
|
#if ZUNE
|
||||||
|
new(OwlCore.Remoting.RemotingMode.Host);
|
||||||
|
#else
|
||||||
|
new();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -840,9 +840,6 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static System.Collections.Generic.List<OpCode> ExecutedOpCodes { get; set; }
|
|
||||||
= new System.Collections.Generic.List<OpCode>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to generate source UIX from a compiled result
|
/// Attempts to generate source UIX from a compiled result
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -883,7 +880,8 @@ namespace Microsoft.Iris.Markup
|
|||||||
while (!flag)
|
while (!flag)
|
||||||
{
|
{
|
||||||
OpCode opCode = (OpCode)reader.ReadByte();
|
OpCode opCode = (OpCode)reader.ReadByte();
|
||||||
ExecutedOpCodes.Add(opCode);
|
var entry = new Debug.Data.InterpreterEntry(opCode);
|
||||||
|
|
||||||
switch (opCode)
|
switch (opCode)
|
||||||
{
|
{
|
||||||
case OpCode.ConstructObject:
|
case OpCode.ConstructObject:
|
||||||
@@ -898,6 +896,9 @@ namespace Microsoft.Iris.Markup
|
|||||||
typeName = typeName.Substring(0, idxTilde);
|
typeName = typeName.Substring(0, idxTilde);
|
||||||
var objXml = XmlDoc.CreateElement(typeName);
|
var objXml = XmlDoc.CreateElement(typeName);
|
||||||
|
|
||||||
|
entry.Arguments.Add(new Debug.Data.OpCodeArgument(
|
||||||
|
"type", typeof(TypeSchema), typeSchema));
|
||||||
|
|
||||||
ReportErrorOnNull(obj, "Construction", typeSchema.Name);
|
ReportErrorOnNull(obj, "Construction", typeSchema.Name);
|
||||||
if (!ErrorsDetected(watermark, ref result, ref flag))
|
if (!ErrorsDetected(watermark, ref result, ref flag))
|
||||||
{
|
{
|
||||||
@@ -1034,10 +1035,16 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
int num8 = reader.ReadUInt16();
|
int num8 = reader.ReadUInt16();
|
||||||
SymbolReference symbolRef = symbolReferenceTable[num8];
|
SymbolReference symbolRef = symbolReferenceTable[num8];
|
||||||
|
entry.Arguments.Add(new Debug.Data.OpCodeArgument(
|
||||||
|
"symbolRef", typeof(SymbolReference), symbolRef));
|
||||||
|
|
||||||
object obj8 = context.ReadSymbol(symbolRef);
|
object obj8 = context.ReadSymbol(symbolRef);
|
||||||
var objXml8 = XmlDoc.CreateElement(obj8.GetType().Name);
|
var objXml8 = XmlDoc.CreateElement(obj8.GetType().Name);
|
||||||
|
|
||||||
stack.Push(obj8);
|
stack.Push(obj8);
|
||||||
xmlStack.Push(objXml8);
|
xmlStack.Push(objXml8);
|
||||||
|
entry.ReturnValues.Add(obj8);
|
||||||
|
|
||||||
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1049,7 +1056,14 @@ namespace Microsoft.Iris.Markup
|
|||||||
object value = (opCode == OpCode.WriteSymbolPeek) ? stack.Peek() : stack.Pop();
|
object value = (opCode == OpCode.WriteSymbolPeek) ? stack.Peek() : stack.Pop();
|
||||||
int num9 = reader.ReadUInt16();
|
int num9 = reader.ReadUInt16();
|
||||||
SymbolReference symbolRef2 = symbolReferenceTable[num9];
|
SymbolReference symbolRef2 = symbolReferenceTable[num9];
|
||||||
|
|
||||||
|
entry.Arguments.Add(new Debug.Data.OpCodeArgument(
|
||||||
|
"symbolRef", typeof(SymbolReference), symbolRef2));
|
||||||
|
entry.Arguments.Add(new Debug.Data.OpCodeArgument(
|
||||||
|
"value", typeof(object), value));
|
||||||
|
|
||||||
context.WriteSymbol(symbolRef2, value);
|
context.WriteSymbol(symbolRef2, value);
|
||||||
|
|
||||||
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
if (Trace.IsCategoryEnabled(TraceCategory.Markup))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1549,10 +1563,12 @@ namespace Microsoft.Iris.Markup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Application.DebugSettings.Bridge.LogInterpreterOpCode(opCode, entry);
|
||||||
|
|
||||||
if (stack.Count != xmlStack.Count)
|
if (stack.Count != xmlStack.Count)
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"Invalid stacks, stack:{stack.Count} != xmlStack{xmlStack.Count}! " +
|
$"Invalid stacks, stack:{stack.Count} != xmlStack{xmlStack.Count}! " +
|
||||||
$"Check implementations for {opCode} and {ExecutedOpCodes[ExecutedOpCodes.Count - 2]}");
|
$"Check implementations for {opCode}");
|
||||||
}
|
}
|
||||||
while (stack.Count > count)
|
while (stack.Count > count)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -175,10 +175,6 @@ namespace Microsoft.Iris.Queues
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ZUNE5
|
|
||||||
private static Bridge Bridge { get; } = new(OwlCore.Remoting.RemotingMode.Host);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a message via <see cref="debugPipe"/>
|
/// Sends a message via <see cref="debugPipe"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -186,7 +182,7 @@ namespace Microsoft.Iris.Queues
|
|||||||
public static void SendDebugMessage(string message)
|
public static void SendDebugMessage(string message)
|
||||||
{
|
{
|
||||||
#if ZUNE5
|
#if ZUNE5
|
||||||
Bridge.LogDispatcher(message);
|
Application.DebugSettings.Bridge.LogDispatcher(message);
|
||||||
#else
|
#else
|
||||||
if (Application.DebugSettings.OpenDebugPipe && DebugPipe.IsConnected && DebugPipe.CanWrite)
|
if (Application.DebugSettings.OpenDebugPipe && DebugPipe.IsConnected && DebugPipe.CanWrite)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user