mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Add source and stack trace handlers
This commit is contained in:
@@ -31,6 +31,7 @@ internal class BreakpointHandler(DebugSymbolResolver symbolResolver)
|
|||||||
{
|
{
|
||||||
Id = irisBreakpoint.GetHashCode(),
|
Id = irisBreakpoint.GetHashCode(),
|
||||||
InstructionReference = requestedBreakpoint.InstructionReference,
|
InstructionReference = requestedBreakpoint.InstructionReference,
|
||||||
|
Verified = true,
|
||||||
};
|
};
|
||||||
dapBreakpoints.Add(dapBreakpoint);
|
dapBreakpoints.Add(dapBreakpoint);
|
||||||
}
|
}
|
||||||
@@ -45,7 +46,7 @@ internal class BreakpointHandler(DebugSymbolResolver symbolResolver)
|
|||||||
public Task<SetBreakpointsResponse> Handle(SetBreakpointsArguments request, CancellationToken cancellationToken)
|
public Task<SetBreakpointsResponse> Handle(SetBreakpointsArguments request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// Debug symbols are required for setting source (line:column) breakpoints
|
// Debug symbols are required for setting source (line:column) breakpoints
|
||||||
var fsym = symbolResolver?.GetForFile(request.Source.Path);
|
var fsym = symbolResolver?.GetForFile(request.Source.Name);
|
||||||
if (fsym is null)
|
if (fsym is null)
|
||||||
return Task.FromResult(new SetBreakpointsResponse());
|
return Task.FromResult(new SetBreakpointsResponse());
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ internal class BreakpointHandler(DebugSymbolResolver symbolResolver)
|
|||||||
Column = location.Span.Start.Column,
|
Column = location.Span.Start.Column,
|
||||||
EndLine = location.Span.End.Line,
|
EndLine = location.Span.End.Line,
|
||||||
EndColumn = location.Span.End.Column,
|
EndColumn = location.Span.End.Column,
|
||||||
|
Verified = true,
|
||||||
};
|
};
|
||||||
dapBreakpoints.Add(dapBreakpoint);
|
dapBreakpoints.Add(dapBreakpoint);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Microsoft.Iris.DebugAdapter.Server.Handlers;
|
||||||
|
|
||||||
|
internal class SourceHandler(DebugSymbolResolver symbolResolver) : ISourceHandler, ILoadedSourcesHandler
|
||||||
|
{
|
||||||
|
private const string MIME_IRIS_UIX_XML = "application/vnd.microsoft.iris.uix+xml";
|
||||||
|
|
||||||
|
public async Task<SourceResponse> Handle(SourceArguments request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
Debugger.Launch();
|
||||||
|
Debugger.Break();
|
||||||
|
|
||||||
|
var fsym = symbolResolver.GetForFile(request.Source?.Name);
|
||||||
|
if (fsym is null)
|
||||||
|
return new SourceResponse();
|
||||||
|
|
||||||
|
if (fsym.SourceFileName is not null && File.Exists(fsym.SourceFileName))
|
||||||
|
{
|
||||||
|
string text =
|
||||||
|
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
|
||||||
|
await File.ReadAllTextAsync(fsym.SourceFileName, cancellationToken);
|
||||||
|
#else
|
||||||
|
File.ReadAllText(fsym.SourceFileName);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Content = text,
|
||||||
|
MimeType = MIME_IRIS_UIX_XML
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Content = "<UIX>TEST SOURCE</UIX>",
|
||||||
|
MimeType = MIME_IRIS_UIX_XML
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<LoadedSourcesResponse> Handle(LoadedSourcesArguments request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
Debugger.Launch();
|
||||||
|
Debugger.Break();
|
||||||
|
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Sources = []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DapStackFrame = OmniSharp.Extensions.DebugAdapter.Protocol.Models.StackFrame;
|
||||||
|
|
||||||
|
namespace Microsoft.Iris.DebugAdapter.Server.Handlers;
|
||||||
|
|
||||||
|
internal class StackTraceHandler : StackTraceHandlerBase
|
||||||
|
{
|
||||||
|
public override async Task<StackTraceResponse> Handle(StackTraceArguments request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
Debugger.Launch();
|
||||||
|
Debugger.Break();
|
||||||
|
|
||||||
|
List<DapStackFrame> stackFrames = [
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Source = new()
|
||||||
|
{
|
||||||
|
Path = "NowPlayingMusicBackground.uix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
return new StackTraceResponse
|
||||||
|
{
|
||||||
|
StackFrames = stackFrames
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Iris.Debug;
|
using Microsoft.Iris.Debug;
|
||||||
using Microsoft.Iris.Debug.Data;
|
using Microsoft.Iris.Debug.Data;
|
||||||
using Microsoft.Iris.DebugAdapter.Server.Handlers;
|
using Microsoft.Iris.DebugAdapter.Server.Handlers;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
|
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
|
||||||
using OmniSharp.Extensions.DebugAdapter.Server;
|
using OmniSharp.Extensions.DebugAdapter.Server;
|
||||||
using System;
|
using System;
|
||||||
@@ -38,22 +39,6 @@ public class IrisDebugAdapterServer : IDebuggerServer, IRemoteDebuggerState, IDi
|
|||||||
|
|
||||||
if (Server is null)
|
if (Server is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (value is InterpreterCommand.Continue)
|
|
||||||
{
|
|
||||||
Server.SendContinued(new()
|
|
||||||
{
|
|
||||||
ThreadId = 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (value is InterpreterCommand.Break)
|
|
||||||
{
|
|
||||||
Server.SendStopped(new()
|
|
||||||
{
|
|
||||||
Reason = new("unknown"),
|
|
||||||
ThreadId = 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +71,7 @@ public class IrisDebugAdapterServer : IDebuggerServer, IRemoteDebuggerState, IDi
|
|||||||
.WithHandler<BreakpointHandler>()
|
.WithHandler<BreakpointHandler>()
|
||||||
//.WithHandler<ConfigurationDoneHandler>()
|
//.WithHandler<ConfigurationDoneHandler>()
|
||||||
.WithHandler<ThreadsHandler>()
|
.WithHandler<ThreadsHandler>()
|
||||||
//.WithHandler<StackTraceHandler>()
|
.WithHandler<StackTraceHandler>()
|
||||||
//.WithHandler<ScopesHandler>()
|
//.WithHandler<ScopesHandler>()
|
||||||
//.WithHandler<VariablesHandler>()
|
//.WithHandler<VariablesHandler>()
|
||||||
.WithHandler<ContinueHandler>()
|
.WithHandler<ContinueHandler>()
|
||||||
@@ -94,7 +79,7 @@ public class IrisDebugAdapterServer : IDebuggerServer, IRemoteDebuggerState, IDi
|
|||||||
.WithHandler<PauseHandler>()
|
.WithHandler<PauseHandler>()
|
||||||
.WithHandler<StepInHandler>()
|
.WithHandler<StepInHandler>()
|
||||||
//.WithHandler<StepOutHandler>()
|
//.WithHandler<StepOutHandler>()
|
||||||
//.WithHandler<SourceHandler>()
|
.WithHandler<SourceHandler>()
|
||||||
//.WithHandler<SetVariableHandler>()
|
//.WithHandler<SetVariableHandler>()
|
||||||
//.WithHandler<DebugEvaluateHandler>()
|
//.WithHandler<DebugEvaluateHandler>()
|
||||||
// The OnInitialize delegate gets run when we first receive the _Initialize_ request:
|
// The OnInitialize delegate gets run when we first receive the _Initialize_ request:
|
||||||
@@ -158,7 +143,22 @@ public class IrisDebugAdapterServer : IDebuggerServer, IRemoteDebuggerState, IDi
|
|||||||
|
|
||||||
public void WaitForContinue()
|
public void WaitForContinue()
|
||||||
{
|
{
|
||||||
|
System.Diagnostics.Debugger.Launch();
|
||||||
|
if (DebuggerCommand is InterpreterCommand.Break)
|
||||||
|
{
|
||||||
|
Server?.SendStopped(new()
|
||||||
|
{
|
||||||
|
Reason = new("unknown"),
|
||||||
|
ThreadId = 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
while (DebuggerCommand is InterpreterCommand.Break) ;
|
while (DebuggerCommand is InterpreterCommand.Break) ;
|
||||||
|
|
||||||
|
Server?.SendContinued(new()
|
||||||
|
{
|
||||||
|
ThreadId = 0,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
|
|||||||
Reference in New Issue
Block a user