display stack frames

This commit is contained in:
Matt Parker
2025-08-30 00:20:32 +10:00
parent 4502fd94fa
commit 6580276041
4 changed files with 59 additions and 16 deletions

View File

@@ -1,3 +1,4 @@
using Ardalis.GuardClauses;
using Godot;
using SharpIDE.Application.Features.Debugging;
using SharpIDE.Application.Features.Events;
@@ -9,19 +10,24 @@ public partial class ThreadsVariablesSubTab : Control
{
private PackedScene _threadListItemScene = GD.Load<PackedScene>("res://Features/Debug_/Tab/SubTabs/ThreadListItem.tscn");
private VBoxContainer _threadsVboxContainer = null!;
private VBoxContainer _stackFramesVboxContainer = null!;
private VBoxContainer _variablesVboxContainer = null!;
public SharpIdeProjectModel Project { get; set; } = null!;
private ThreadModel? _selectedThread = null!; // null when not at a stop point
public override void _Ready()
{
_threadsVboxContainer = GetNode<VBoxContainer>("%ThreadsPanel/VBoxContainer");
_stackFramesVboxContainer = GetNode<VBoxContainer>("%StackFramesPanel/VBoxContainer");
_variablesVboxContainer = GetNode<VBoxContainer>("%VariablesPanel/VBoxContainer");
GlobalEvents.DebuggerExecutionStopped += OnDebuggerExecutionStopped;
}
private async Task OnDebuggerExecutionStopped(ExecutionStopInfo arg)
private async Task OnDebuggerExecutionStopped(ExecutionStopInfo stopInfo)
{
var result = await Singletons.RunService.GetInfoAtStopPoint();
var scenes = result.Threads.Select(s =>
var threadScenes = result.Threads.Select(s =>
{
var threadListItem = _threadListItemScene.Instantiate<Control>();
threadListItem.GetNode<Label>("Label").Text = $"{s.Id}: {s.Name}";
@@ -29,10 +35,28 @@ public partial class ThreadsVariablesSubTab : Control
}).ToList();
await this.InvokeAsync(() =>
{
foreach (var scene in scenes)
foreach (var scene in threadScenes)
{
_threadsVboxContainer.AddChild(scene);
}
});
var stoppedThreadId = stopInfo.ThreadId;
var stoppedThread = result.Threads.SingleOrDefault(t => t.Id == stoppedThreadId);
Guard.Against.Null(stoppedThread, nameof(stoppedThread));
var stackFrameScenes = stoppedThread!.StackFrames.Select(s =>
{
var stackFrameItem = _threadListItemScene.Instantiate<Control>();
stackFrameItem.GetNode<Label>("Label").Text = $"{s.ClassName}.{s.MethodName}() in {s.Namespace}, {s.AssemblyName}";
return stackFrameItem;
}).ToList();
await this.InvokeAsync(() =>
{
foreach (var scene in stackFrameScenes)
{
_stackFramesVboxContainer.AddChild(scene);
}
});
}
}