I'm working on integration with Zed and I've managed to get the debugger connecting to a running Unity session just fine - however, whilst the Unity session correctly hits a given breakpoint and stops playback, Zed recognizes that the debugger has stopped but never receives enough info to know what breakpoint has actually been hit.
Looking through the DAP communications, it would appear that the stopped event does come through:
It does not provide the hitBreakpointIds field in the body, although I am not familiar enough with the history of DAP to know if debugging clients strictly require this to function (or if Zed even uses this).
Afterwards, Zed sends a stackTrace request which would in theory provide the missing information:
However this request never receives a response from the DAP - in fact it looks like the DAP stops sending any response messages altogether (event messages do continue to arrive as normal though).
This causes Unity to hang indefinitely and the Mono process executing unity-debug-adapter.exe to slowly leak memory (consuming ~60GB on my machine) until it is manually killed.
I'm guessing there might be a deadlock when trying to fetch the stack trace after the debugger has already been stopped, but the only place I can see where such a deadlock would occur is in WaitForSuspend() while handling StackTrace():
|
public override void StackTrace(Response response, dynamic arguments) |
|
{ |
|
int maxLevels = GetInt(arguments, "levels", 10); |
|
int startFrame = GetInt(arguments, "startFrame", 0); |
|
int threadReference = GetInt(arguments, "threadId", 0); |
|
|
|
WaitForSuspend(); |
m_ResumeEvent should have been signalled immediately after sending the stopped event however, so I'm not sure what exactly is happening here (maybe an unhandled exception in SendEvent()?):
|
m_Session.TargetHitBreakpoint += (sender, e) => |
|
{ |
|
Frame = e.Backtrace.GetFrame(0); |
|
Stopped(); |
|
SendEvent(CreateStoppedEvent("breakpoint", e.Thread)); |
|
m_ResumeEvent.Set(); |
|
}; |
Additional Info:
Operating System: Windows 11 24H2 (26100.7462)
Unity: 6.2.6f2
Mono: 6.12.0
unity-dap: v0.0.1
I'm working on integration with Zed and I've managed to get the debugger connecting to a running Unity session just fine - however, whilst the Unity session correctly hits a given breakpoint and stops playback, Zed recognizes that the debugger has stopped but never receives enough info to know what breakpoint has actually been hit.
Looking through the DAP communications, it would appear that the
stoppedevent does come through:It does not provide the
hitBreakpointIdsfield in the body, although I am not familiar enough with the history of DAP to know if debugging clients strictly require this to function (or if Zed even uses this).Afterwards, Zed sends a
stackTracerequest which would in theory provide the missing information:However this request never receives a response from the DAP - in fact it looks like the DAP stops sending any
responsemessages altogether (eventmessages do continue to arrive as normal though).This causes Unity to hang indefinitely and the
Monoprocess executingunity-debug-adapter.exeto slowly leak memory (consuming ~60GB on my machine) until it is manually killed.I'm guessing there might be a deadlock when trying to fetch the stack trace after the debugger has already been stopped, but the only place I can see where such a deadlock would occur is in
WaitForSuspend()while handlingStackTrace():unity-dap/unity-debug-adapter/UnityDebugSession.cs
Lines 560 to 566 in bbe5993
m_ResumeEventshould have been signalled immediately after sending thestoppedevent however, so I'm not sure what exactly is happening here (maybe an unhandled exception inSendEvent()?):unity-dap/unity-debug-adapter/UnityDebugSession.cs
Lines 98 to 104 in bbe5993
Additional Info: