From 658027604177a2f156b12d82de9100a32b8bf73a Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Sat, 30 Aug 2025 00:20:32 +1000 Subject: [PATCH] display stack frames --- .../Features/Debugging/DebuggingService.cs | 14 ++++++++- .../Debugging/ThreadsStackTraceModel.cs | 5 ++++ .../Tab/SubTabs/ThreadsVariablesSubTab.cs | 30 +++++++++++++++++-- .../Tab/SubTabs/ThreadsVariablesSubTab.tscn | 26 ++++++++-------- 4 files changed, 59 insertions(+), 16 deletions(-) diff --git a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs index 3e74d5d..28c6632 100644 --- a/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs +++ b/src/SharpIDE.Application/Features/Debugging/DebuggingService.cs @@ -151,13 +151,25 @@ public class DebuggingService var stackTrace = _debugProtocolHost.SendRequestSync(new StackTraceRequest { ThreadId = thread.Id }); var frame = stackTrace.StackFrames!.FirstOrDefault(); if (frame == null) continue; + // Infrastructure.dll!Infrastructure.DependencyInjection.AddInfrastructure(Microsoft.Extensions.DependencyInjection.IServiceCollection services, Microsoft.Extensions.Configuration.IConfiguration configuration) Line 23 + var name = frame.Name; + if (name == "[External Code]") continue; // TODO: handle this case + // need to parse out the class name, method name, namespace, assembly name + var methodName = name.Split('!')[1].Split('(')[0]; + var className = methodName.Split('.').Reverse().Skip(1).First(); + var namespaceName = string.Join('.', methodName.Split('.').Reverse().Skip(2).Reverse()); + var assemblyName = name.Split('!')[0]; var frameModel = new StackFrameModel { Id = frame.Id, Name = frame.Name, Line = frame.Line, Column = frame.Column, - Source = frame.Source?.Path + Source = frame.Source?.Path, + ClassName = className, + MethodName = methodName, + Namespace = namespaceName, + AssemblyName = assemblyName }; threadModel.StackFrames.Add(frameModel); var scopes = _debugProtocolHost.SendRequestSync(new ScopesRequest { FrameId = frame.Id }); diff --git a/src/SharpIDE.Application/Features/Debugging/ThreadsStackTraceModel.cs b/src/SharpIDE.Application/Features/Debugging/ThreadsStackTraceModel.cs index 5528510..78a27dd 100644 --- a/src/SharpIDE.Application/Features/Debugging/ThreadsStackTraceModel.cs +++ b/src/SharpIDE.Application/Features/Debugging/ThreadsStackTraceModel.cs @@ -16,6 +16,11 @@ public class ThreadModel public class StackFrameModel { + public required string ClassName { get; set; } + public required string MethodName { get; set; } + public required string Namespace { get; set; } + public required string AssemblyName { get; set; } + public required int Id { get; set; } public required string Name { get; set; } public required int? Line { get; set; } diff --git a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs index 1f4011b..a9bdfcb 100644 --- a/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs +++ b/src/SharpIDE.Godot/Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs @@ -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("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("%ThreadsPanel/VBoxContainer"); + _stackFramesVboxContainer = GetNode("%StackFramesPanel/VBoxContainer"); + _variablesVboxContainer = GetNode("%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(); threadListItem.GetNode