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

@@ -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;
}
}