display threads at stop point

This commit is contained in:
Matt Parker
2025-08-29 21:39:17 +10:00
parent a7e05f6ebb
commit bb6d2796ca
9 changed files with 124 additions and 25 deletions

View File

@@ -15,4 +15,5 @@ public class Debugger
}
public async Task StepOver(int threadId, CancellationToken cancellationToken = default) => await _debuggingService.StepOver(threadId, cancellationToken);
public async Task<ThreadsStackTraceModel> GetInfoAtStopPoint() => await _debuggingService.GetInfoAtStopPoint();
}

View File

@@ -137,4 +137,44 @@ public class DebuggingService
var nextRequest = new NextRequest(threadId);
_debugProtocolHost.SendRequestSync(nextRequest);
}
public async Task<ThreadsStackTraceModel> GetInfoAtStopPoint()
{
var model = new ThreadsStackTraceModel();
try
{
var threads = _debugProtocolHost.SendRequestSync(new ThreadsRequest());
foreach (var thread in threads.Threads)
{
var threadModel = new ThreadModel { Id = thread.Id, Name = thread.Name };
model.Threads.Add(threadModel);
var stackTrace = _debugProtocolHost.SendRequestSync(new StackTraceRequest { ThreadId = thread.Id });
var frame = stackTrace.StackFrames!.FirstOrDefault();
if (frame == null) continue;
var frameModel = new StackFrameModel
{
Id = frame.Id,
Name = frame.Name,
Line = frame.Line,
Column = frame.Column,
Source = frame.Source?.Path
};
threadModel.StackFrames.Add(frameModel);
var scopes = _debugProtocolHost.SendRequestSync(new ScopesRequest { FrameId = frame.Id });
foreach (var scope in scopes.Scopes)
{
var scopeModel = new ScopeModel { Name = scope.Name };
frameModel.Scopes.Add(scopeModel);
var variablesResponse = _debugProtocolHost.SendRequestSync(new VariablesRequest { VariablesReference = scope.VariablesReference });
scopeModel.Variables = variablesResponse.Variables;
}
}
}
catch (Exception ex)
{
throw;
}
return model;
}
}

View File

@@ -0,0 +1,31 @@
using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages;
namespace SharpIDE.Application.Features.Debugging;
public class ThreadsStackTraceModel
{
public List<ThreadModel> Threads { get; set; } = [];
}
public class ThreadModel
{
public required int Id { get; set; }
public required string Name { get; set; }
public List<StackFrameModel> StackFrames { get; set; } = [];
}
public class StackFrameModel
{
public required int Id { get; set; }
public required string Name { get; set; }
public required int? Line { get; set; }
public required int? Column { get; set; }
public required string? Source { get; set; }
public List<ScopeModel> Scopes { get; set; } = [];
}
public class ScopeModel
{
public required string Name { get; set; }
public List<Variable> Variables { get; set; } = [];
}

View File

@@ -147,9 +147,9 @@ public class RunService
await _debugger!.StepOver(threadId);
}
public async Task GetInfoAtStopPoint()
public async Task<ThreadsStackTraceModel> GetInfoAtStopPoint()
{
await _debugger!.GetInfoAtStopPoint();
return await _debugger!.GetInfoAtStopPoint();
}
private string GetRunArguments(SharpIdeProjectModel project)