Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[debug] Theia does not stop on breakpoints with the debugger provided by the vscode.mock-debug extension #11885

Closed
kittaakos opened this issue Nov 18, 2022 · 2 comments · Fixed by #11984
Assignees
Labels
debug issues that related to debug functionality vscode issues related to VSCode compatibility

Comments

@kittaakos
Copy link
Contributor

Bug Description:

Steps to Reproduce:

  1. Build the vscode.mock-debug extension from their repo. Alternatively, you can follow the steps from vscode: add support for debug/toolbar, debug/variables/context menus contribution and debugState when clause context  #11871 and get the mock-debug VS Code extension from my fork.
  2. Open the sampleWorkspace folder from the repo as a workspace in Theia.
  3. Set a breakpoint to line 11,
  4. Start the Debug readme.md file,
  5. Debugger stops on entry,
  6. Continue,
  7. Debugger does not stop on line 11, instead it falls to the end of the readme.

VS Code:

stop_breakpoint_vscode.mp4

Theia:

stop_breakpoint_theia.mp4

When the debugger session starts in Theia, I see the following error in the logs. I do not know if it's related to this bug:

logger-protocol.ts:113 2022-11-18T15:27:58.287Z root ERROR Error setting breakpoints: Cannot read properties of undefined (reading 'breakpoints')
log @ logger-protocol.ts:113
(anonymous) @ logger-frontend-module.ts:42
(anonymous) @ logger.ts:312
(anonymous) @ logger.ts:304
Promise.then (async)
log @ logger.ts:299
log @ logger.ts:45
sendFunctionBreakpoints @ debug-session.tsx:683
async function (async)
sendFunctionBreakpoints @ debug-session.tsx:671
updateBreakpoints @ debug-session.tsx:645
async function (async)
updateBreakpoints @ debug-session.tsx:649
configure @ debug-session.tsx:325
(anonymous) @ debug-session.tsx:121
(anonymous) @ event.ts:128
invoke @ event.ts:136
fire @ event.ts:279
doFire @ debug-session-connection.ts:331
handleEvent @ debug-session-connection.ts:312
handleMessage @ debug-session-connection.ts:265
(anonymous) @ debug-session-connection.ts:171
(anonymous) @ event.ts:128
invoke @ event.ts:136
fire @ event.ts:279
fireMessageReceived @ connection.ts:37
$sendMessage @ connection.ts:82
doInvokeHandler @ rpc-protocol.ts:287
invokeHandler @ rpc-protocol.ts:272
receiveRequest @ rpc-protocol.ts:231
receiveOneMessage @ rpc-protocol.ts:192
(anonymous) @ rpc-protocol.ts:101
(anonymous) @ event.ts:128
invoke @ event.ts:136
fire @ event.ts:279
(anonymous) @ rpc-protocol.ts:343
(anonymous) @ event.ts:128
invoke @ event.ts:136
fire @ event.ts:279
(anonymous) @ hosted-plugin.ts:540
(anonymous) @ event.ts:128
invoke @ event.ts:136
fire @ event.ts:279
postMessage @ hosted-plugin-watcher.ts:35
onRequest @ proxy-factory.ts:167
(anonymous) @ proxy-factory.ts:146
handleRequest @ rpc-protocol.ts:188
handleMessage @ rpc-protocol.ts:86
(anonymous) @ rpc-protocol.ts:75
(anonymous) @ event.ts:128
invoke @ event.ts:136
fire @ event.ts:279
handleData @ channel.ts:239
handleMessage @ channel.ts:197
(anonymous) @ channel.ts:155
(anonymous) @ event.ts:128
invoke @ event.ts:136
fire @ event.ts:279
(anonymous) @ web-socket-channel.ts:38
(anonymous) @ ws-connection-provider.ts:84
Emitter.emit @ index.mjs:136
emitEvent @ socket.js:385
onevent @ socket.js:372
onpacket @ socket.js:340
Emitter.emit @ index.mjs:136
(anonymous) @ manager.js:240
Promise.then (async)
(anonymous) @ websocket-constructor.browser.js:8
ondecoded @ manager.js:239
Emitter.emit @ index.mjs:136
add @ index.js:148
ondata @ manager.js:226
Emitter.emit @ index.mjs:136
onPacket @ socket.js:348
Emitter.emit @ index.mjs:136
onPacket @ transport.js:114
onData @ transport.js:106
ws.onmessage @ websocket.js:87
Show 33 more frames

Additional Information

  • Operating System: macOS, 12.5.1
  • Theia Version: fe8e4c1
@kittaakos
Copy link
Contributor Author

According to the debug adapter protocol, the SetFunctionBreakpoints response always has a body and breakpoints, but in reality, it does not. VS Code has a guard against it, and adding a guard here plus providing the lines solves the issue:

11885_stop_breakpoint.mp4

@vince-fugnitto vince-fugnitto added vscode issues related to VSCode compatibility debug issues that related to debug functionality labels Nov 21, 2022
@kittaakos
Copy link
Contributor Author

Please assign the issue to me.

kittaakos pushed a commit to kittaakos/theia that referenced this issue Dec 13, 2022
 - feat: aded support for `debug/toolbar` and `debug/variables/context`,
 - feat: added support for `debugState` when context (eclipse-theia#11871),
 - feat: can customize debug session timeout, and error handling (eclipse-theia#11879),
 - fix: the `debugType` context that is not updated,
 - fix: `configure` must happen after receiving capabilities (eclipse-theia#11886),
 - fix: added missing conext menu in the _Variables_ view,
 - fix: handle `setFunctionBreakboints` response with no `body` (eclipse-theia#11885),
 - fix: `DebugExt` fires `didStart` event on `didCreate` (eclipse-theia#11916)

Closes eclipse-theia#11871
Closes eclipse-theia#11879
Closes eclipse-theia#11885
Closes eclipse-theia#11886
Closes eclipse-theia#11916

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit to kittaakos/theia that referenced this issue Dec 13, 2022
 - feat: aded support for `debug/toolbar` and `debug/variables/context`,
 - feat: added support for `debugState` when context (eclipse-theia#11871),
 - feat: can customize debug session timeout, and error handling (eclipse-theia#11879),
 - fix: the `debugType` context that is not updated,
 - fix: `configure` must happen after receiving capabilities (eclipse-theia#11886),
 - fix: added missing conext menu in the _Variables_ view,
 - fix: handle `setFunctionBreakboints` response with no `body` (eclipse-theia#11885),
 - fix: `DebugExt` fires `didStart` event on `didCreate` (eclipse-theia#11916)

Closes eclipse-theia#11871
Closes eclipse-theia#11879
Closes eclipse-theia#11885
Closes eclipse-theia#11886
Closes eclipse-theia#11916

Signed-off-by: Akos Kitta <[email protected]>

s

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit to kittaakos/theia that referenced this issue Dec 13, 2022
 - feat: aded support for `debug/toolbar` and `debug/variables/context`,
 - feat: added support for `debugState` when context (eclipse-theia#11871),
 - feat: can customize debug session timeout, and error handling (eclipse-theia#11879),
 - fix: the `debugType` context that is not updated,
 - fix: `configure` must happen after receiving capabilities (eclipse-theia#11886),
 - fix: added missing conext menu in the _Variables_ view,
 - fix: handle `setFunctionBreakboints` response with no `body` (eclipse-theia#11885),
 - fix: `DebugExt` fires `didStart` event on `didCreate` (eclipse-theia#11916),
 - fix: validate editor selection based on the text model (eclipse-theia#11880)

Closes eclipse-theia#11871
Closes eclipse-theia#11879
Closes eclipse-theia#11885
Closes eclipse-theia#11886
Closes eclipse-theia#11916
Closes eclipse-theia#11880

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit to kittaakos/theia that referenced this issue Dec 13, 2022
 - feat: added support for `debug/toolbar` and `debug/variables/context`,
 - feat: added support for `debugState` when context (eclipse-theia#11871),
 - feat: can customize debug session timeout, and error handling (eclipse-theia#11879),
 - fix: the `debugType` context that is not updated,
 - fix: `configure` must happen after receiving capabilities (eclipse-theia#11886),
 - fix: added missing conext menu in the _Variables_ view,
 - fix: handle `setFunctionBreakboints` response with no `body` (eclipse-theia#11885),
 - fix: `DebugExt` fires `didStart` event on `didCreate` (eclipse-theia#11916),
 - fix: validate editor selection based on the text model (eclipse-theia#11880)

Closes eclipse-theia#11871
Closes eclipse-theia#11879
Closes eclipse-theia#11885
Closes eclipse-theia#11886
Closes eclipse-theia#11916
Closes eclipse-theia#11880

Signed-off-by: Akos Kitta <[email protected]>
kittaakos pushed a commit to kittaakos/theia that referenced this issue Jan 17, 2023
 - feat: added support for `debug/toolbar` and `debug/variables/context`,
 - feat: added support for `debugState` when context (eclipse-theia#11871),
 - feat: can customize debug session timeout, and error handling (eclipse-theia#11879),
 - fix: the `debugType` context that is not updated,
 - fix: `configure` must happen after receiving capabilities (eclipse-theia#11886),
 - fix: added missing conext menu in the _Variables_ view,
 - fix: handle `setFunctionBreakboints` response with no `body` (eclipse-theia#11885),
 - fix: `DebugExt` fires `didStart` event on `didCreate` (eclipse-theia#11916),
 - fix: validate editor selection based on the text model (eclipse-theia#11880)

Closes eclipse-theia#11871
Closes eclipse-theia#11879
Closes eclipse-theia#11885
Closes eclipse-theia#11886
Closes eclipse-theia#11916
Closes eclipse-theia#11880

Signed-off-by: Akos Kitta <[email protected]>
paul-marechal added a commit that referenced this issue Jan 24, 2023
* fix: various debug fixes and VS Code compatibility enhancements

 - feat: added support for `debug/toolbar` and `debug/variables/context`,
 - feat: added support for `debugState` when context (#11871),
 - feat: can customize debug session timeout, and error handling (#11879),
 - fix: the `debugType` context that is not updated,
 - fix: `configure` must happen after receiving capabilities (#11886),
 - fix: added missing conext menu in the _Variables_ view,
 - fix: handle `setFunctionBreakboints` response with no `body` (#11885),
 - fix: `DebugExt` fires `didStart` event on `didCreate` (#11916),
 - fix: validate editor selection based on the text model (#11880)

Signed-off-by: Akos Kitta <[email protected]>

* fix: use when context for command node filtering

Signed-off-by: Akos Kitta <[email protected]>

* chore: removed test debug VSIX

Signed-off-by: Akos Kitta <[email protected]>

* fix: revert `timeout` check

Signed-off-by: Akos Kitta <[email protected]>

* fix: clarification on the possible `'debugState'`

Signed-off-by: Akos Kitta <[email protected]>

* fix: use hard-coded debugger `clientID` and `clientName`

Signed-off-by: Akos Kitta <[email protected]>

* fix: use review-requested method name

Signed-off-by: Akos Kitta <[email protected]>

* fix: changed method name + added doc

Signed-off-by: Akos Kitta <[email protected]>

* fix: `stopTimeout` is a default `ctor` argument

Signed-off-by: Akos Kitta <[email protected]>

* fix: incorrect method name

Signed-off-by: Akos Kitta <[email protected]>

* fix: both `didCreate` and `didStart` must be API

Signed-off-by: Akos Kitta <[email protected]>

* fix: call both on create and start

Signed-off-by: Akos Kitta <[email protected]>

* fix: workaround for microsoft/vscode-mock-debug#85

Signed-off-by: Akos Kitta <[email protected]>

* simplify writing

The collection of contributed commands was written in a convoluted way,
this commit makes it more straightforward with just 2 loops.

* use `Math.max` to clamp values into positives

The ternary implementation is stricly equivalent to the `Math.max`
function, so use that instead.

* fix default option value handling

Assigning a default option object to set default values is problematic
as said default values will be discarded if any option object is passed.

Instead default values must be handled in conjuction of whatever options
are passed to functions.

Signed-off-by: Akos Kitta <[email protected]>
Co-authored-by: Paul Maréchal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug issues that related to debug functionality vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants