debugging - remove executing line on stop

This commit is contained in:
Matt Parker
2025-12-12 22:31:41 +10:00
parent 1ab3d62bec
commit b512bd16bd
5 changed files with 45 additions and 19 deletions

View File

@@ -10,9 +10,9 @@ public class Debugger
public required SharpIdeProjectModel Project { get; init; }
public required int ProcessId { get; init; }
private DebuggingService _debuggingService = new DebuggingService();
public async Task Attach(string? debuggerExecutablePath, Dictionary<SharpIdeFile, List<Breakpoint>> breakpointsByFile, CancellationToken cancellationToken)
public async Task Attach(string? debuggerExecutablePath, Dictionary<SharpIdeFile, List<Breakpoint>> breakpointsByFile, SharpIdeProjectModel project, CancellationToken cancellationToken)
{
await _debuggingService.Attach(ProcessId, debuggerExecutablePath, breakpointsByFile, cancellationToken);
await _debuggingService.Attach(ProcessId, debuggerExecutablePath, breakpointsByFile, project, cancellationToken);
}
public async Task StepOver(int threadId, CancellationToken cancellationToken = default) => await _debuggingService.StepOver(threadId, cancellationToken);

View File

@@ -8,6 +8,7 @@ using Newtonsoft.Json.Linq;
using SharpIDE.Application.Features.Debugging.Signing;
using SharpIDE.Application.Features.Events;
using SharpIDE.Application.Features.SolutionDiscovery;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.Debugging;
@@ -15,7 +16,7 @@ namespace SharpIDE.Application.Features.Debugging;
public class DebuggingService
{
private DebugProtocolHost _debugProtocolHost = null!;
public async Task Attach(int debuggeeProcessId, string? debuggerExecutablePath, Dictionary<SharpIdeFile, List<Breakpoint>> breakpointsByFile, CancellationToken cancellationToken = default)
public async Task Attach(int debuggeeProcessId, string? debuggerExecutablePath, Dictionary<SharpIdeFile, List<Breakpoint>> breakpointsByFile, SharpIdeProjectModel project, CancellationToken cancellationToken = default)
{
Guard.Against.NegativeOrZero(debuggeeProcessId, nameof(debuggeeProcessId), "Process ID must be a positive integer.");
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
@@ -86,7 +87,7 @@ public class DebuggingService
{
var filePath = additionalProperties?["source"]?["path"]!.Value<string>()!;
var line = (additionalProperties?["line"]?.Value<int>()!).Value;
var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value };
var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value, Project = project };
GlobalEvents.Instance.DebuggerExecutionStopped.InvokeParallelFireAndForget(executionStopInfo);
}
else
@@ -97,7 +98,7 @@ public class DebuggingService
var topFrame = stackTraceResponse.StackFrames.Single();
var filePath = topFrame.Source.Path;
var line = topFrame.Line;
var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value };
var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value, Project = project };
GlobalEvents.Instance.DebuggerExecutionStopped.InvokeParallelFireAndForget(executionStopInfo);
}

View File

@@ -1,8 +1,12 @@
namespace SharpIDE.Application.Features.Debugging;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Application.Features.Debugging;
public class ExecutionStopInfo
{
public required string FilePath { get; init; }
public required int Line { get; init; }
public required int ThreadId { get; init; }
// Currently assuming only one instance of a project can be debugged at a time
public required SharpIdeProjectModel Project { get; init; }
}

View File

@@ -94,7 +94,7 @@ public class RunService(ILogger<RunService> logger, RoslynAnalysis roslynAnalysi
// Attach debugger (which internally uses a DiagnosticClient to resume startup)
var debugger = new Debugger { Project = project, ProcessId = process.ProcessId };
_debugger = debugger;
await debugger.Attach(debuggerExecutablePath, Breakpoints.ToDictionary(), project.RunningCancellationTokenSource.Token).ConfigureAwait(false);
await debugger.Attach(debuggerExecutablePath, Breakpoints.ToDictionary(), project, project.RunningCancellationTokenSource.Token).ConfigureAwait(false);
}
project.Running = true;