Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit fafa5fc

Browse files
committed
Adding support for multithreaded stack traces.
Added C# extension as a dependency, making sure that it is installed' along side the debugger extension. Path added in launch config to remove the warnings within VS Code.
1 parent 80bf3dd commit fafa5fc

12 files changed

+41
-840
lines changed

Changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Git: https://github.com/Unity-Technologies/vscode-unity-debug
66
Changes
77
-------
88

9+
2.6.0
10+
=====
11+
- Multithreaded stack trace unwrapping is now enabled. Making it possible to switch context.
12+
913
2.5.0
1014
=====
1115
- New support for halt on exception. In debug view a list of exceptions control which to break on.

External/Mono.Addins.dll

270 KB
Binary file not shown.

Images/unity-logo128x128.png

-12.1 KB
Binary file not shown.

UnityDebug/Program.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Reflection;
55
using Mono.Debugging.Client;
66
using MonoDevelop.Debugger.Soft.Unity;
7-
using MonoDevelop.Debugger.VsCodeDebugProtocol;
87
using VSCodeDebug;
98

109
namespace UnityDebug
@@ -82,12 +81,6 @@ static void RunSession(Stream inputStream, Stream outputStream)
8281
debugSession.Start(inputStream, outputStream).Wait();
8382
}
8483

85-
static void RunVSSession(Stream inputStream, Stream outputStream)
86-
{
87-
VSCodeDebuggerSession debugSession = new VSCodeDebuggerSession();
88-
debugSession.Start(inputStream, outputStream);
89-
}
90-
9184
static string GetUnityProcesses()
9285
{
9386
var processes = UnityProcessDiscovery.GetAttachableProcesses();

UnityDebug/UnityDebug.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
<HintPath>..\packages\Microsoft.VisualStudio.Shared.VsCodeDebugProtocol.15.6.20118.1\lib\net45\Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.dll</HintPath>
6565
<Private>True</Private>
6666
</Reference>
67+
<Reference Include="Mono.Addins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
68+
<HintPath>..\External\Mono.Addins.dll</HintPath>
69+
</Reference>
6770
<Reference Include="Mono.Cairo, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756">
6871
<HintPath>..\External\Mono.Cairo.dll</HintPath>
6972
</Reference>
@@ -195,10 +198,6 @@
195198
</Compile>
196199
<Compile Include="Platform.cs" />
197200
<Compile Include="Util.cs" />
198-
<Compile Include="VSCodeDebugger\VsCodeBacktrace.cs" />
199-
<Compile Include="VSCodeDebugger\VSCodeDebuggerSession.cs" />
200-
<Compile Include="VSCodeDebugger\VsCodeObjectSource.cs" />
201-
<Compile Include="VSCodeDebugger\VsCodeStackFrame.cs" />
202201
</ItemGroup>
203202
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
204203
<ItemGroup>

UnityDebug/UnityDebugSession.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@
77
using System;
88
using System.Collections.Generic;
99
using System.IO;
10-
using System.Threading;
1110
using System.Linq;
1211
using System.Net;
12+
using System.Threading;
1313
using Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages;
1414
using Mono.Debugging.Client;
15-
using VSCodeDebug;
15+
using Mono.Debugging.Soft;
1616
using MonoDevelop.Debugger.Soft.Unity;
1717
using MonoDevelop.Unity.Debugger;
1818
using Newtonsoft.Json.Linq;
19+
using VSCodeDebug;
1920
using Breakpoint = Mono.Debugging.Client.Breakpoint;
20-
using ResponseBreakpoint = Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages.Breakpoint;
2121
using ExceptionBreakpointsFilter = VSCodeDebug.ExceptionBreakpointsFilter;
2222
using InitializedEvent = VSCodeDebug.InitializedEvent;
2323
using OutputEvent = VSCodeDebug.OutputEvent;
24+
using ResponseBreakpoint = Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages.Breakpoint;
2425
using Scope = VSCodeDebug.Scope;
2526
using Source = VSCodeDebug.Source;
2627
using SourceBreakpoint = VSCodeDebug.SourceBreakpoint;
2728
using StackFrame = Mono.Debugging.Client.StackFrame;
2829
using StoppedEvent = VSCodeDebug.StoppedEvent;
2930
using TerminatedEvent = VSCodeDebug.TerminatedEvent;
31+
using Thread = VSCodeDebug.Thread;
3032
using ThreadEvent = VSCodeDebug.ThreadEvent;
3133
using UnityProcessInfo = MonoDevelop.Debugger.Soft.Unity.UnityProcessInfo;
3234
using Variable = VSCodeDebug.Variable;
@@ -46,24 +48,26 @@ internal class UnityDebugSession : DebugSession
4648
private const int MAX_CONNECTION_ATTEMPTS = 10;
4749
private const int CONNECTION_ATTEMPT_INTERVAL = 500;
4850

49-
private AutoResetEvent m_ResumeEvent = new AutoResetEvent(false);
51+
private AutoResetEvent m_ResumeEvent;
5052
private bool m_DebuggeeExecuting;
5153
private readonly object m_Lock = new object();
52-
private Mono.Debugging.Soft.SoftDebuggerSession m_Session;
54+
private SoftDebuggerSession m_Session;
5355
private ProcessInfo m_ActiveProcess;
54-
SourceBreakpoint[] m_Breakpoints = new SourceBreakpoint[0];
56+
SourceBreakpoint[] m_Breakpoints;
5557
private List<Catchpoint> m_Catchpoints;
5658
private DebuggerSessionOptions m_DebuggerSessionOptions;
5759

5860
private Handles<ObjectValue[]> m_VariableHandles;
5961
private Handles<StackFrame> m_FrameHandles;
6062
private ObjectValue m_Exception;
61-
private Dictionary<int, VSCodeDebug.Thread> m_SeenThreads;
63+
private Dictionary<int, Thread> m_SeenThreads;
6264
private bool m_Terminated;
6365
IUnityDbgConnector unityDebugConnector;
6466

6567
public UnityDebugSession() : base()
6668
{
69+
m_ResumeEvent = new AutoResetEvent(false);
70+
m_Breakpoints = new SourceBreakpoint[0];
6771
m_VariableHandles = new Handles<ObjectValue[]>();
6872
m_FrameHandles = new Handles<Mono.Debugging.Client.StackFrame>();
6973
m_SeenThreads = new Dictionary<int, VSCodeDebug.Thread>();
@@ -157,7 +161,7 @@ public UnityDebugSession() : base()
157161
m_Session.TargetThreadStarted += (sender, e) => {
158162
int tid = (int)e.Thread.Id;
159163
lock (m_SeenThreads) {
160-
m_SeenThreads[tid] = new VSCodeDebug.Thread(tid, e.Thread.Name);
164+
m_SeenThreads[tid] = new Thread(tid, e.Thread.Name);
161165
}
162166
SendEvent(new ThreadEvent("started", tid));
163167
};
@@ -275,12 +279,12 @@ private void Connect(IPAddress address, int port)
275279
{
276280
lock (m_Lock) {
277281

278-
var args0 = new Mono.Debugging.Soft.SoftDebuggerConnectArgs(string.Empty, address, port) {
282+
var args0 = new SoftDebuggerConnectArgs(string.Empty, address, port) {
279283
MaxConnectionAttempts = MAX_CONNECTION_ATTEMPTS,
280284
TimeBetweenConnectionAttempts = CONNECTION_ATTEMPT_INTERVAL
281285
};
282286

283-
m_Session.Run(new Mono.Debugging.Soft.SoftDebuggerStartInfo(args0), m_DebuggerSessionOptions);
287+
m_Session.Run(new SoftDebuggerStartInfo(args0), m_DebuggerSessionOptions);
284288

285289
m_DebuggeeExecuting = true;
286290
}
@@ -361,7 +365,7 @@ public override void SetFunctionBreakpoints(Response response, dynamic arguments
361365
public override void Continue(Response response, dynamic args)
362366
{
363367
WaitForSuspend();
364-
SendResponse(response);
368+
SendResponse(response, new ContinueResponseBody());
365369
lock (m_Lock) {
366370
if (m_Session == null || m_Session.IsRunning || m_Session.HasExited) return;
367371

@@ -656,16 +660,16 @@ public override void Variables(Response response, dynamic args)
656660

657661
public override void Threads(Response response, dynamic args)
658662
{
659-
var threads = new List<VSCodeDebug.Thread>();
663+
var threads = new List<Thread>();
660664
var process = m_ActiveProcess;
661665
if (process != null) {
662-
Dictionary<int, VSCodeDebug.Thread> d;
666+
Dictionary<int, Thread> d;
663667
lock (m_SeenThreads) {
664-
d = new Dictionary<int, VSCodeDebug.Thread>(m_SeenThreads);
668+
d = new Dictionary<int, Thread>(m_SeenThreads);
665669
}
666670
foreach (var t in process.GetThreads()) {
667671
int tid = (int)t.Id;
668-
d[tid] = new VSCodeDebug.Thread(tid, t.Name);
672+
d[tid] = new Thread(tid, t.Name);
669673
}
670674
threads = d.Values.ToList();
671675
}

0 commit comments

Comments
 (0)