send step over

This commit is contained in:
Matt Parker
2025-08-25 22:28:49 +10:00
parent 4fef025786
commit 11bfe4d958
8 changed files with 55 additions and 8 deletions

View File

@@ -13,4 +13,6 @@ public class Debugger
{
await _debuggingService.Attach(ProcessId, breakpointsByFile, cancellationToken);
}
public async Task StepOver(int threadId, CancellationToken cancellationToken = default) => await _debuggingService.StepOver(threadId, cancellationToken);
}

View File

@@ -72,7 +72,8 @@ public class DebuggingService
var dict = prop?.GetValue(@event) as Dictionary<string, JToken>;
var filePath = dict?["source"]?["path"]!.Value<string>()!;
var line = (dict?["line"]?.Value<int>()!).Value;
GlobalEvents.InvokeDebuggerExecutionStopped(filePath, line);
var executionStopInfo = new ExecutionStopInfo { FilePath = filePath, Line = line, ThreadId = @event.ThreadId!.Value };
GlobalEvents.InvokeDebuggerExecutionStopped(executionStopInfo);
if (@event.Reason is StoppedEvent.ReasonValue.Exception)
{
Console.WriteLine("Stopped due to exception, continuing");
@@ -125,4 +126,11 @@ public class DebuggingService
debugProtocolHost.SendRequestSync(configurationDoneRequest);
}
// Typically you would do attachRequest, configurationDoneRequest, setBreakpointsRequest, then ResumeRuntime. But netcoredbg blows up on configurationDoneRequuest if ResumeRuntime hasn't been called yet.
public async Task StepOver(int threadId, CancellationToken cancellationToken)
{
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
var nextRequest = new NextRequest(threadId);
_debugProtocolHost.SendRequestSync(nextRequest);
}
}

View File

@@ -0,0 +1,8 @@
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; }
}

View File

@@ -18,6 +18,6 @@ public static class GlobalEvents
public static event Func<SharpIdeProjectModel, Task> ProjectStoppedRunning = _ => Task.CompletedTask;
public static void InvokeProjectStoppedRunning(SharpIdeProjectModel project) => ProjectStoppedRunning?.Invoke(project);
public static event Func<string, int, Task> DebuggerExecutionStopped = (_, _) => Task.CompletedTask;
public static void InvokeDebuggerExecutionStopped(string filePath, int line) => DebuggerExecutionStopped?.Invoke(filePath, line);
public static event Func<ExecutionStopInfo, Task> DebuggerExecutionStopped = _ => Task.CompletedTask;
public static void InvokeDebuggerExecutionStopped(ExecutionStopInfo executionStopInfo) => DebuggerExecutionStopped?.Invoke(executionStopInfo);
}

View File

@@ -14,6 +14,7 @@ public class RunService
{
private readonly ConcurrentDictionary<SharpIdeProjectModel, SemaphoreSlim> _projectLocks = [];
public ConcurrentDictionary<SharpIdeFile, List<Breakpoint>> Breakpoints { get; } = [];
private Debugger? _debugger; // TODO: Support multiple debuggers for multiple running projects
public async Task RunProject(SharpIdeProjectModel project)
{
var isDebug = true;
@@ -84,8 +85,9 @@ public class RunService
if (isDebug)
{
// Attach debugger (which internally uses a DiagnosticClient to resume startup)
var debuggingService = new Debugger { Project = project, ProcessId = process.ProcessId };
await debuggingService.Attach(project.RunningCancellationTokenSource.Token, Breakpoints.ToDictionary()).ConfigureAwait(false);
var debugger = new Debugger { Project = project, ProcessId = process.ProcessId };
_debugger = debugger;
await debugger.Attach(project.RunningCancellationTokenSource.Token, Breakpoints.ToDictionary()).ConfigureAwait(false);
}
project.Running = true;
@@ -126,6 +128,11 @@ public class RunService
await project.RunningCancellationTokenSource.CancelAsync().ConfigureAwait(false);
}
public async Task SendDebuggerStepOver(int threadId)
{
await _debugger!.StepOver(threadId);
}
private string GetRunArguments(SharpIdeProjectModel project)
{
var dllFullPath = ProjectEvaluation.GetOutputDllFullPath(project);