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 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);
|
var nextRequest = new NextRequest(threadId);
|
||||||
_debugProtocolHost.SendRequestSync(nextRequest);
|
_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);
|
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)
|
private string GetRunArguments(SharpIdeProjectModel project)
|
||||||
|
|||||||
@@ -1,17 +1,25 @@
|
|||||||
using GDExtensionBindgen;
|
using GDExtensionBindgen;
|
||||||
using Godot;
|
using Godot;
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
|
using SharpIDE.Godot.Features.Debug_.Tab.SubTabs;
|
||||||
|
|
||||||
namespace SharpIDE.Godot.Features.Debug_.Tab;
|
namespace SharpIDE.Godot.Features.Debug_.Tab;
|
||||||
|
|
||||||
public partial class DebugPanelTab : Control
|
public partial class DebugPanelTab : Control
|
||||||
{
|
{
|
||||||
private Terminal _terminal = null!;
|
private Terminal _terminal = null!;
|
||||||
|
private ThreadsVariablesSubTab _threadsVariablesSubTab = null!;
|
||||||
private Task _writeTask = Task.CompletedTask;
|
private Task _writeTask = Task.CompletedTask;
|
||||||
|
|
||||||
public SharpIdeProjectModel Project { get; set; } = null!;
|
public SharpIdeProjectModel Project { get; set; } = null!;
|
||||||
public int TabBarTab { get; set; }
|
public int TabBarTab { get; set; }
|
||||||
|
|
||||||
|
public override void _EnterTree()
|
||||||
|
{
|
||||||
|
_threadsVariablesSubTab = GetNode<ThreadsVariablesSubTab>("%ThreadsVariablesSubTab");
|
||||||
|
_threadsVariablesSubTab.Project = Project;
|
||||||
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
var terminalControl = GetNode<Control>("%Terminal");
|
var terminalControl = GetNode<Control>("%Terminal");
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ layout_mode = 2
|
|||||||
metadata/_tab_index = 0
|
metadata/_tab_index = 0
|
||||||
|
|
||||||
[node name="ThreadsVariablesSubTab" parent="TabContainer/Threads & Variables" instance=ExtResource("2_e6ax5")]
|
[node name="ThreadsVariablesSubTab" parent="TabContainer/Threads & Variables" instance=ExtResource("2_e6ax5")]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
||||||
[node name="Console" type="Control" parent="TabContainer"]
|
[node name="Console" type="Control" parent="TabContainer"]
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
[gd_scene format=3 uid="uid://1bbofax8nht1"]
|
[gd_scene format=3 uid="uid://1bbofax8nht1"]
|
||||||
|
|
||||||
[node name="ThreadListItem" type="Control"]
|
[node name="ThreadListItem" type="MarginContainer"]
|
||||||
layout_mode = 3
|
offset_right = 40.0
|
||||||
anchors_preset = 15
|
offset_bottom = 40.0
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
layout_mode = 0
|
layout_mode = 2
|
||||||
offset_right = 40.0
|
|
||||||
offset_bottom = 23.0
|
|
||||||
text = "Thread Name"
|
text = "Thread Name"
|
||||||
|
|||||||
@@ -1,13 +1,38 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using SharpIDE.Application.Features.Debugging;
|
||||||
|
using SharpIDE.Application.Features.Events;
|
||||||
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
|
|
||||||
namespace SharpIDE.Godot.Features.Debug_.Tab.SubTabs;
|
namespace SharpIDE.Godot.Features.Debug_.Tab.SubTabs;
|
||||||
|
|
||||||
public partial class ThreadsVariablesSubTab : Control
|
public partial class ThreadsVariablesSubTab : Control
|
||||||
{
|
{
|
||||||
private VBoxContainer _threadsVboxContainer = null!;
|
private PackedScene _threadListItemScene = GD.Load<PackedScene>("res://Features/Debug_/Tab/SubTabs/ThreadListItem.tscn");
|
||||||
|
private VBoxContainer _threadsVboxContainer = null!;
|
||||||
|
public SharpIdeProjectModel Project { get; set; } = null!;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_threadsVboxContainer = GetNode<VBoxContainer>("%ThreadsPanel/VBoxContainer");
|
_threadsVboxContainer = GetNode<VBoxContainer>("%ThreadsPanel/VBoxContainer");
|
||||||
}
|
GlobalEvents.DebuggerExecutionStopped += OnDebuggerExecutionStopped;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnDebuggerExecutionStopped(ExecutionStopInfo arg)
|
||||||
|
{
|
||||||
|
var result = await Singletons.RunService.GetInfoAtStopPoint();
|
||||||
|
var scenes = result.Threads.Select(s =>
|
||||||
|
{
|
||||||
|
var threadListItem = _threadListItemScene.Instantiate<Control>();
|
||||||
|
threadListItem.GetNode<Label>("Label").Text = $"{s.Id}: {s.Name}";
|
||||||
|
return threadListItem;
|
||||||
|
}).ToList();
|
||||||
|
await this.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
foreach (var scene in scenes)
|
||||||
|
{
|
||||||
|
_threadsVboxContainer.AddChild(scene);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://bdu08nd7si641"]
|
[gd_scene load_steps=2 format=3 uid="uid://bdu08nd7si641"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dpc4fvj40e5il" path="res://Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs" id="1_e3p3b"]
|
[ext_resource type="Script" uid="uid://dpc4fvj40e5il" path="res://Features/Debug_/Tab/SubTabs/ThreadsVariablesSubTab.cs" id="1_e3p3b"]
|
||||||
[ext_resource type="PackedScene" uid="uid://1bbofax8nht1" path="res://Features/Debug_/Tab/SubTabs/ThreadListItem.tscn" id="1_hwpe6"]
|
|
||||||
|
|
||||||
[node name="ThreadsVariablesSubTab" type="Control"]
|
[node name="ThreadsVariablesSubTab" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@@ -30,12 +29,12 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/HSplitContainer/ThreadsPanel"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/HSplitContainer/ThreadsPanel"]
|
||||||
layout_mode = 0
|
layout_mode = 1
|
||||||
offset_right = 40.0
|
anchors_preset = 15
|
||||||
offset_bottom = 40.0
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
[node name="ThreadListItem" parent="HSplitContainer/HSplitContainer/ThreadsPanel/VBoxContainer" instance=ExtResource("1_hwpe6")]
|
grow_horizontal = 2
|
||||||
layout_mode = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="StackFramesPanel" type="Panel" parent="HSplitContainer/HSplitContainer"]
|
[node name="StackFramesPanel" type="Panel" parent="HSplitContainer/HSplitContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
Reference in New Issue
Block a user