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] debug-ext prematurely fires didStart event on didCreate #11916

Closed
kittaakos opened this issue Nov 24, 2022 · 1 comment · Fixed by #11984
Closed

[debug] debug-ext prematurely fires didStart event on didCreate #11916

kittaakos opened this issue Nov 24, 2022 · 1 comment · Fixed by #11984
Assignees
Labels
debug issues that related to debug functionality

Comments

@kittaakos
Copy link
Contributor

kittaakos commented Nov 24, 2022

Bug Description:

As the title says, the debug-ext will incorrectly fire the didStart event, on didCreate and will call the debug adapter. It's too early.

async $sessionDidCreate(sessionId: string): Promise<void> {
const session = this.sessions.get(sessionId);
if (session) {
this.onDidStartDebugSessionEmitter.fire(session);
}
}

Some debug adapters will run custom DAP requests on session start, such as the cortex-debug extension here, and will break, as the session has not been initialized yet.

2022-11-24T13:19:18.818Z root ERROR [hosted-plugin: 30330] /Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:16423
            if (this.serverController.customRequest(command, response, args)) {
                                      ^

TypeError: Cannot read properties of undefined (reading 'customRequest')
    at GDBDebugSession.<anonymous> (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:16423:39)
    at Generator.next (<anonymous>)
    at /Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:15519:71
    at new Promise (<anonymous>)
    at __webpack_modules__../src/gdb.ts.__awaiter (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:15515:12)
    at GDBDebugSession.customRequest (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:16418:16)
    at GDBDebugSession.dispatchRequest (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:515:22)
    at GDBDebugSession.dispatchRequest (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:1183:15)
    at GDBDebugSession.handleMessage (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:1364:18)
    at GDBDebugSession._handleData (/Users/a.kitta/dev/git/theia/plugins/cortex-debug/extension/dist/debugadapter.js:1458:34)

Steps to Reproduce:

  1. Get the 1.5.1 cortex-debug VSIX from my fork: https://github.com/kittaakos/cortex-debug/raw/1.5.1/marus25.cortex-debug-1.5.1-development.vsix
  2. Configure the debug session based on the official documentation: https://github.com/Marus/cortex-debug#installation
  3. Start the debug session

Additional Information

  • Operating System: macOS 12.5.1
  • Theia Version: 1.31.1
@vince-fugnitto vince-fugnitto added the debug issues that related to debug functionality label Nov 24, 2022
@kittaakos
Copy link
Contributor Author

Please assign this to me. Thanks!

kittaakos pushed a commit to kittaakos/arduino-ide that referenced this issue Nov 24, 2022
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Nov 28, 2022
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Nov 29, 2022
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Nov 29, 2022
kittaakos pushed a commit to arduino/arduino-ide that referenced this issue Dec 1, 2022
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 <a.kitta@arduino.cc>
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 <a.kitta@arduino.cc>

s

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
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 <a.kitta@arduino.cc>
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 <a.kitta@arduino.cc>
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 <a.kitta@arduino.cc>
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 <a.kitta@arduino.cc>

* fix: use when context for command node filtering

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

* chore: removed test debug VSIX

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

* fix: revert `timeout` check

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

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

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

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

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

* fix: use review-requested method name

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

* fix: changed method name + added doc

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

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

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

* fix: incorrect method name

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

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

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

* fix: call both on create and start

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

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

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>

* 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 <a.kitta@arduino.cc>
Co-authored-by: Paul Maréchal <paul.marechal@ericsson.com>
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants