display threads at stop point
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; } = [];
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user