microsoft / vscode-debugadapter-node

Debug adapter protocol and implementation for VS Code.
Other
271 stars 77 forks source link

Remote debugging doesn't fire launch/attach requests #265

Closed Vadimtro closed 2 years ago

Vadimtro commented 2 years ago

I'm writing a debugging server, which communicates with vscode debugger via port 4711. Here is the transcript of the conversation:

header = Content-Length: 412
 token = {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"pwa-node","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true},"type":"request","seq":1}

sent to client>> {"seq":1,"type":"responce","request_seq":1,"command":"initialize","success":true,"body":{"supportsBreakpointLocationsRequest": true ,"supportsCancelRequest": true ,"supportsCompletionsRequest": true ,"completionTriggerCharacters": ["."] , ... ,"supportsWriteMemoryRequest": true }}

sent to client>> {"seq":1,"type":"event","event":"initialized"}

header = Content-Length: 266
 token = {"command":"setBreakpoints","arguments":{"source":{"name":"connections.sql","path":"c:\\Users\\dim\\git\\vscode-mock-debug\\sampleWorkspace\\menu\\connections.sql"},"lines":[3,5],"breakpoints":[{"line":3},{"line":5}],"sourceModified":false},"type":"request","seq":2}

sent to client>> {"seq":2,"type":"event","event":"stopped","body":{"reason":"entry"}}
sent to client>> {"seq":2,"type":"responce","request_seq":2,"command":"setBreakpoints","sucess":true,"body":{ "breakpoints": [{ "verified": true, "line":3, "id":1 },{ "verified": false, "line":5, "id":2 }] } }
sent to client>> {"seq":3,"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"verified":true,"id":1}}}

header = Content-Length: 46
 token = {"command":"threads","type":"request","seq":3}

sent to client>> {"seq":3,"type":"responce","request_seq":3,"command":"threads","body":{ "threads": [{"id": 1, "name": "oNe" }] } }
header = Content-Length: 79
 token = {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":4}

After comparing it with the mock debugging trace, it misses the attach or launch request. Also, the client fails to disable the breakpoints which failed to verify, and doesn't proceed to setDataBreakpoints. I'm sending the stopped event in desperate attempt to advance the protocol workflow, but it is also stuck, as I'm not receiving the stacktrace request.

Please advice.

Vadimtro commented 2 years ago

Not the right venue to ask. Probably an issue with vscode generic debugger.

Vadimtro commented 2 years ago

On the client side registerDebugAdapterTrackerFactory captured the same conversation:

start: 05876ade-1231-40f0-bbfe-75733c858bf1
===> {
  "command": "initialize",
  "arguments": {
    "clientID": "vscode",
    "clientName": "Visual Studio Code",
    "adapterID": "mock",
    "pathFormat": "path",
    "linesStartAt1": true,
    "columnsStartAt1": true,
    "supportsVariableType": true,
    "supportsVariablePaging": true,
    "supportsRunInTerminalRequest": true,
    "locale": "en-us",
    "supportsProgressReporting": true,
    "supportsInvalidatedEvent": true,
    "supportsMemoryReferences": true
  },
  "type": "request",
  "seq": 1
}
<=== {
  "seq": 1,
  "type": "responce",
  "request_seq": 1,
  "command": "initialize",
  "success": true,
  "body": {
    "supportsBreakpointLocationsRequest": true,
    "supportsCancelRequest": true,
    "supportsCompletionsRequest": true,
    "completionTriggerCharacters": [
      "."
    ],
    "supportsConfigurationDoneRequest": true,
    "supportsDataBreakpoints": true,
    "supportsDisassembleRequest": true,
    "supportsFunctionBreakpoints": true,
    "supportsEvaluateForHovers": true,
    "supportsExceptionFilterOptions": false,
    "supportsExceptionInfoRequest": true,
    "supportsInstructionBreakpoints": true,
    "supportsRestartFrame": true,
    "supportsGotoTargetsRequest": true,
    "supportsStepInTargetsRequest": true,
    "supportsModulesRequest": true,
    "supportsRestartRequest": true,
    "supportsExceptionOptions": true,
    "supportsValueFormattingOptions": true,
    "supportsDelayedStackTraceLoading": true,
    "supportsLoadedSourcesRequest": true,
    "supportsLogPoints": true,
    "supportsReadMemoryRequest": true,
    "supportsSetExpression": true,
    "supportsSetVariable": true,
    "supportsSteppingGranularity": true,
    "supportSuspendDebuggee": true,
    "supportTerminateDebuggee": true,
    "supportsWriteMemoryRequest": true
  }
}
<=== {
  "seq": 1,
  "type": "event",
  "event": "initialized"
}
===> {
  "command": "setBreakpoints",
  "arguments": {
    "source": {
      "name": "connections.sql",
      "path": "c:\\Users\\dim\\git\\vscode-mock-debug\\sampleWorkspace\\menu\\connections.sql"
    },
    "lines": [
      3,
      5
    ],
    "breakpoints": [
      {
        "line": 3
      },
      {
        "line": 5
      }
    ],
    "sourceModified": false
  },
  "type": "request",
  "seq": 2
}
<=== {
  "seq": 2,
  "type": "event",
  "event": "stopped",
  "body": {
    "reason": "entry"
  }
}
<=== {
  "seq": 2,
  "type": "responce",
  "request_seq": 2,
  "command": "setBreakpoints",
  "success": true,
  "body": {
    "breakpoints": [
      {
        "verified": true,
        "line": 3,
        "id": 7
      },
      {
        "verified": false,
        "line": 5,
        "id": 8
      }
    ]
  }
}
<=== {
  "seq": 3,
  "type": "event",
  "event": "breakpoint",
  "body": {
    "reason": "changed",
    "breakpoint": {
      "verified": true,
      "id": 1
    }
  }
}
===> {
  "command": "threads",
  "type": "request",
  "seq": 3
}
<=== {
  "seq": 3,
  "type": "responce",
  "request_seq": 3,
  "command": "threads",
  "success": true,
  "body": {
    "threads": [
      {
        "id": 1,
        "name": "oNe"
      }
    ]
  }
}

I assume it is possible to have debug extension with virtually no custom client side debug adapter code.

Curiously, there seems to be no debugger project satisfying this requirement on github which can be used as a template. This is unlike LSP extensions, where the examples with vscode frontend, and java backend are plenty.

puremourning commented 2 years ago

There are many adapters (most actually) that don't require custom client code. That's how there are more clients than just vscode.

Vadimtro commented 2 years ago

Indeed. I have cloned as sample debugging extension https://github.com/Calindro/emulicious-debugger/, which contains only one extension.ts file. It does little more than just call vscode.debug.startDebugging but the result is the same as I had before with mock debugger. It must be that the error is somewhere on my server side, but shouldn't it be spotted from the message exchange log?

roblourens commented 2 years ago

"type":"responce"

Could the problem be with misspelling "response" or is that just in logging code?