Skip to content

[Windows] Breakpoint information not provided once hit #5

@Namey5

Description

@Namey5

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:

// Receive
{
  "seq": 958,
  "type": "event",
  "event": "stopped",
  "body": {
    "threadId": 1,
    "reason": "breakpoint",
    "text": null,
    "allThreadsStopped": true
  }
}

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:

// Send
{
  "type": "request",
  "seq": 8,
  "command": "stackTrace",
  "arguments": {
    "threadId": 1
  }
}

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions