mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Implement source breakpoints
This commit is contained in:
@@ -79,8 +79,8 @@ public class IrisDebugAdapterClient : IDebuggerClient, IRemoteDebuggerState, IDi
|
||||
;
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
await tcs.Task;
|
||||
// TODO: How to keep the thread alive while the debug adapter is running?
|
||||
await Task.Delay(-1).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Iris.Debug.Symbols;
|
||||
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -18,7 +19,19 @@ internal class BreakpointHandler(DebugSymbolResolver symbolResolver)
|
||||
|
||||
foreach (var requestedBreakpoint in request.Breakpoints)
|
||||
{
|
||||
|
||||
var parts = requestedBreakpoint.InstructionReference.Split(['@'], 2);
|
||||
var loadUri = parts[0];
|
||||
var offset = Convert.ToUInt32(parts[1], 16);
|
||||
|
||||
IrisBreakpoint irisBreakpoint = new(loadUri, offset);
|
||||
Application.DebugSettings.Breakpoints.Add(irisBreakpoint);
|
||||
|
||||
DapBreakpoint dapBreakpoint = new()
|
||||
{
|
||||
Id = irisBreakpoint.GetHashCode(),
|
||||
InstructionReference = requestedBreakpoint.InstructionReference,
|
||||
};
|
||||
dapBreakpoints.Add(dapBreakpoint);
|
||||
}
|
||||
|
||||
SetInstructionBreakpointsResponse response = new()
|
||||
|
||||
@@ -86,43 +86,42 @@ public class DebugCommand : AsyncCommand<DebugCommand.Settings>
|
||||
|
||||
if (inputParts.Length >= 3 && inputParts[2].StartsWith("0x"))
|
||||
{
|
||||
breakOffset = uint.Parse(inputParts[2][2..], NumberStyles.HexNumber);
|
||||
breakOffset = Convert.ToUInt32(inputParts[2], 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (symbolResolver is null)
|
||||
{
|
||||
AnsiConsole.MarkupLine("[red]Setting breakpoints via source code requires debug symbols. Use the --symbols argument to specify a directory.[/]");
|
||||
break;
|
||||
}
|
||||
|
||||
var fsym = symbolResolver.GetForFile(fileName);
|
||||
if (fsym is null)
|
||||
{
|
||||
AnsiConsole.MarkupLineInterpolated($"[red]No symbols loaded for '{fileName}'.[/]");
|
||||
break;
|
||||
}
|
||||
|
||||
if (fsym.OriginalFileName is not null)
|
||||
path = fsym.OriginalFileName;
|
||||
|
||||
var line = int.Parse(inputParts[2]);
|
||||
var column = int.Parse(inputParts[3]);
|
||||
var position = new SourcePosition(line, column);
|
||||
|
||||
var location = fsym!.SourceMap.GetLocationFromPosition(position);
|
||||
if (location is null)
|
||||
var fsym = symbolResolver?.GetForFile(fileName);
|
||||
if (fsym is null)
|
||||
{
|
||||
AnsiConsole.MarkupLineInterpolated($"[red]Line {line}, column {column} has known offset in '{fileName}'.[/]");
|
||||
AnsiConsole.MarkupLineInterpolated($"[yellow]No symbols loaded for '{fileName}'.[/]");
|
||||
|
||||
client.UpdateBreakpoint(new(path, line, column));
|
||||
AnsiConsole.MarkupLineInterpolated($"[green]Breakpoint set in '{path}' at line {line}, column {column}.[/]");
|
||||
break;
|
||||
}
|
||||
|
||||
breakOffset = location.Offset;
|
||||
|
||||
if (fsym.HasSourceCode())
|
||||
else
|
||||
{
|
||||
var sourceCode = fsym.GetSourceSubstring(location.Span);
|
||||
AnsiConsole.Write(new Panel(sourceCode.EscapeMarkup()));
|
||||
if (fsym.OriginalFileName is not null)
|
||||
path = fsym.OriginalFileName;
|
||||
|
||||
var position = new SourcePosition(line, column);
|
||||
var location = fsym!.SourceMap.GetLocationFromPosition(position);
|
||||
if (location is null)
|
||||
{
|
||||
AnsiConsole.MarkupLineInterpolated($"[red]Line {line}, column {column} has known offset in '{fileName}'.[/]");
|
||||
break;
|
||||
}
|
||||
|
||||
breakOffset = location.Offset;
|
||||
|
||||
if (fsym.HasSourceCode())
|
||||
{
|
||||
var sourceCode = fsym.GetSourceSubstring(location.Span);
|
||||
AnsiConsole.Write(new Panel(sourceCode.EscapeMarkup()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user