Skip to content

4016-debug-extension: support debugging of extensions using Debug panel #8706

Merged
colin-grant-work merged 3 commits intoeclipse-theia:masterfrom
danarad05:4016-debug-extension
Jul 20, 2021
Merged

4016-debug-extension: support debugging of extensions using Debug panel #8706
colin-grant-work merged 3 commits intoeclipse-theia:masterfrom
danarad05:4016-debug-extension

Conversation

@danarad05
Copy link
Contributor

@danarad05 danarad05 commented Nov 3, 2020

Signed-off-by: Dan Arad dan.arad@sap.com

What it does

fixed #4016 with this functionality:

  1. Supports start, restart, stop of pwa-extensionHost launch type on debug toolbar.
  2. Utilizes Hosted Plugin functionality.

How to test

Note: can only be tested on browser as electron doesn't support Hosted Plugin functionality currently (see #2868)

  1. Add pwa-extensionHost configuration to launch configurations like so:
    image
  2. start debugging from debug toolbar
  3. two threads will eventually appear after the hosted plugin windows will be opened - like so:
    image
  4. you can choose restart or stop in debug toolbar.

Approved CQ for copied code: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=22801

Review checklist

Reminder for reviewers

@danarad05
Copy link
Contributor Author

FYI: @amiramw @DoroNahari

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danarad05 I do not believe the @theia/debug extension should know about plugins.

cc @colin-grant-work @kenneth-marut-work you may be interested in the following changes which impact debugging.

@vince-fugnitto vince-fugnitto added debug issues that related to debug functionality vscode issues related to VSCode compatibility labels Nov 3, 2020
@kittaakos kittaakos added the CQ Required (deprecated) issues requiring a CQ (contributor questionnaire) label Nov 3, 2020
@kittaakos
Copy link
Contributor

I won't have the bandwidth to review the changes this week, but as I see, it requires a CQ. Please start the CQ process as documented here, by the time we have the legal approval for the merge, hopefully, we will have the review too ;)

@danarad05
Copy link
Contributor Author

@danarad05 I do not believe the @theia/debug extension should know about plugins.

cc @colin-grant-work @kenneth-marut-work you may be interested in the following changes which impact debugging.

@vince-fugnitto I have created a debug ContributionProvider for hosted plugin to registering to. Issue #4016 talks about invoking hosted plugin from debug toolbar (maybe thinking eventually to removing invoking hosted plugin from command box).
@amiramw

@danarad05
Copy link
Contributor Author

e time we have the legal approval for the merge, hopefully, we will have the review too ;)

Hi @kittaakos

  1. Thanks for your input.
  2. I'm not able to find the intellectual property section - tried also searching for it and the CQ but to no avail. Please advise.
  3. Furthermore, I copied a couple of very small structures - nothing major IMO - if that is an issue I can change it a bit to simplify things... it would be a shame if this process takes time for this small of a change.

Thanks
Fyi: @amiramw

@kittaakos
Copy link
Contributor

2. I'm not able to find the intellectual property section - tried also searching for it and the CQ but to no avail. Please advise.

I do not understand this 😊 You do not know how to submit a CQ, is this the question?

3. copied a couple of very small structures - nothing major IMO

I am not a lawyer nor a decision-maker, so I do one thing during the review; if there is copied code, we need a CQ:

// copied from https://github.com/microsoft/vscode-node-debug2/blob/bcd333ef87642b817ac96d28fde7ab96fee3f6a9/src/nodeDebugInterfaces.d.ts

@amiramw
Copy link
Member

amiramw commented Nov 3, 2020

@danarad05 i'll try to help with the CQ

@danarad05
Copy link
Contributor Author

danarad05 commented Nov 4, 2020

  1. I'm not able to find the intellectual property section - tried also searching for it and the CQ but to no avail. Please advise.

I do not understand this 😊 You do not know how to submit a CQ, is this the question?

I meant that explanation in the link you provided didn't get me to the "Intellectual Property" section etc... I don't know if it works for you - I logged in and didn't see and "Intellectual Property" section and tried searching for it. Maybe you should check if explanation there is still valid..

image

I will try to resolve it with the help of @amiramw, Thanks.

@amiramw
Copy link
Member

amiramw commented Nov 15, 2020

CQ for copied code: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=22801

@danarad05 danarad05 force-pushed the 4016-debug-extension branch from 156fe9b to c70850e Compare November 15, 2020 10:53
@amiramw
Copy link
Member

amiramw commented Nov 16, 2020

CQ for copied code: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=22801

If I understand correctly the CQ is approved.

@danarad05 danarad05 force-pushed the 4016-debug-extension branch from e30a678 to 01b6c74 Compare December 2, 2020 10:05
@danarad05
Copy link
Contributor Author

danarad05 commented Dec 8, 2020

@vince-fugnitto @akosyakov
cc: @amiramw
Hi,
A question I hope you can help me with (or if you can direct me to someone who might help that would be also great):
I'm starting debugging a pwa-extensionHost config type whicheventually creates 4 threads created under Threads pane like so:
image

When I try to stop debugging - one thread is disposed of but not the others. If I'm clicking stop again - then it disposes all the others.

From what I can see last thread received 'terminated' event (because clicking on stop debug button selects by default last thread to stop) and so it was disposed successfully - BUT previous thread (thread #3 in list) has not received 'terminated' event by DebugSession and therefore it isn't disposed of.
If on the other hand I select first thread and then click 'stop' - all threads are disposed of.

So my questions are:

  1. You have any idea/input concerning why 'terminated' event is not received by DebugSession for 3rd thread in list?
  2. Is it a viable solution in your eyes that when clicking 'stop' debug - first thread will be selected by default instead of last one?

Any suggestions are welcomed. I tried different approaches but to no avail.

Thanks,
-Dan

Issue also reproduced for "Launch VSCode Tests" config:
captured (1)

@amiramw
Copy link
Member

amiramw commented Dec 9, 2020

@danarad05 i don't think you need to address this behavior in this PR as it is not unique for hosted plugin debug.

@danarad05
Copy link
Contributor Author

@vince-fugnitto @amiramw ready for your review.
p.s. I didn't solve issues with debug stop not closing all threads.

@danarad05
Copy link
Contributor Author

@vince-fugnitto @amiramw
#8706 (comment)
reminder

@danarad05
Copy link
Contributor Author

@vince-fugnitto @amiramw
#8706 (comment)
reminder

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the feature using pwa-extensionHost and it worked correctly but I'm wondering why the standard extensionHost type is not supported yet (which is the default when generating an extension):

{
    "name": "Run Extension",
    "type": "extensionHost",
    "request": "launch",
    "args": [
        "--extensionDevelopmentPath=${workspaceFolder}"
    ],
    "outFiles": [
        "${workspaceFolder}/out/**/*.js"
    ],
    "preLaunchTask": "${defaultBuildTask}"
},

@danarad05
Copy link
Contributor Author

I tested the feature using `pwa-extensionHost` and it worked correctly but I'm wondering why the standard `extensionHost` **type** is not supported yet (which is the default when generating an extension):

```json
{
    "name": "Run Extension",
    "type": "extensionHost",
    "request": "launch",
    "args": [
        "--extensionDevelopmentPath=${workspaceFolder}"
    ],
    "outFiles": [
        "${workspaceFolder}/out/**/*.js"
    ],
    "preLaunchTask": "${defaultBuildTask}"
},

I don't know if and when extensionHost type worked. Currently pwa-extensionHost in vscode-js-debug builtin plugin replaced it. See:

@vince-fugnitto
Copy link
Member

vince-fugnitto commented Jan 20, 2021

I don't know if and when extensionHost type worked. Currently pwa-extensionHost in vscode-js-debug builtin plugin replaced it. See:

@danarad05 I believe that extensionHost should be supported, not only pwa-extensionHost which only limits debugging a small subset of extensions:

https://github.com/microsoft/vscode/blob/e2bce32da4b7345e776e1b54caf40e30e7da4ad7/src/vs/workbench/contrib/debug/common/debugUtils.ts#L61-L63

Moreover, the extensionHost is the default when generating extensions (using yo code for example), and is the extension type of all the vscode-builtins from which the framework consumes:

The following was just a subset of extension for example purposes. Since the framework supports the debug configurations defined in .vscode/launch.json, I would not expect end-users to prefix pwa- before their type when debugging with the framework.

Please let me know whether you believe this is outside the scope of the pull-request, but we are limiting what the framework can successfully debug, and it looks like extensionHost is the more common type. For my own understanding I wanted to know why pwa- was required but not the standard type.

@danarad05 danarad05 force-pushed the 4016-debug-extension branch 3 times, most recently from 884def3 to fcb4cd7 Compare March 31, 2021 10:22
@danarad05
Copy link
Contributor Author

@amiramw fixed and rebased. some convs - please check response. Thanks

@danarad05
Copy link
Contributor Author

@kittaakos are you planning to review this PR? Thanks

@danarad05
Copy link
Contributor Author

@vince-fugnitto @kittaakos
cc: @offer8
anyone planning on reviewing this?

@danarad05 danarad05 force-pushed the 4016-debug-extension branch from fcb4cd7 to e2b0f97 Compare May 20, 2021 10:28
@danarad05
Copy link
Contributor Author

@vince-fugnitto @kittaakos @marechal-p

  1. Rebased.
  2. In continuation of my remark here - I would like to complete this PR review ASAP.

Thanks

@danarad05
Copy link
Contributor Author

@vince-fugnitto Are we needing another reviewer approval or is this PR going to be added to this release?

Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this somewhat superficially in base Theia and against our internal debugging setup. Debugging a VSCode plugin in the browser seemed to work fairly well, though I got a notice on session start that a task 'npm' couldn't befound. Testing against our internal setup, I found that the changes to the session restart logic seem to have broken scenarios that previously worked - the session is killed but doesn't restart - but I haven't been able to track down exactly where the problem occurs. On that basis, I'd prefer that we wait till after the release to merge this, but then, with a little more time to explore its consequences, I'd be happy to work to get it merged next week.

if (res instanceof Error) {
this.fireExited(res);
}
}).catch(this.fireExited);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this needs to be this.fireExited.bind(this) or () => this.fireExited(). Otherwise this won't have the right referent and this.connection will be undefined when this.connection['fire']('exited', { reason }); is run.

In fact, it came up in my testing:
image

CHANGELOG.md Outdated
- [core] updated `nsfw` dependency to `^2.1.2` [#9267](https://github.com/eclipse-theia/theia/pull/9267)
- [debug] fixed hover issues for the `currentFrame` editor [#9256](https://github.com/eclipse-theia/theia/pull/9256)
- [debug] improved error messages [#9386](https://github.com/eclipse-theia/theia/pull/9386)
- [debug] added support for managing debug sessions for extensions from debug panel (previously only possible using `Hosted Plugin` commands) [#8706](https://github.com/eclipse-theia/theia/pull/8706)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to update the position of this entry in the changelog.

@EstherPerelman
Copy link
Contributor

@colin-grant-work updated PR accordingly, Can you merge please?

@colin-grant-work
Copy link
Contributor

@EstherPerelman, it looks like more conflicts have cropped up in the CHANGELOG. Sorry it's such a pain. Once those are fixed, I have no objection to merging, if others see no problem.

@kittaakos kittaakos removed their request for review July 18, 2021 12:22
danarad05 and others added 3 commits July 19, 2021 13:55
1. Supports start, restart, stop of pwa-extensionHost launch type on debug toolbar.
2. Utilizes Hosted Plugin functionality.

Signed-off-by: Dan Arad <dan.arad@sap.com>
Signed-off-by: Esther Perelman <esther.perelman@sap.com>
Signed-off-by: Esther Perelman <esther.perelman@sap.com>
@EstherPerelman
Copy link
Contributor

@EstherPerelman, it looks like more conflicts have cropped up in the CHANGELOG. Sorry it's such a pain. Once those are fixed, I have no objection to merging, if others see no problem.

@colin-grant-work resolved conflicts, I wish you'll merge soon!

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that the debugging behavior works fine, and there are no regressions from what I can tell.

protected readonly messages: MessageClient,
protected readonly fileService: FileService) {
protected readonly fileService: FileService,
protected readonly debugContributionProvider: ContributionProvider<DebugContribution>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change? Should it be reflected in the changelog?
The same would be true for packages/plugin-ext/src/main/browser/debug/plugin-debug-session-factory.ts even if it is not likely that someone would extend it.

@vince-fugnitto
Copy link
Member

@msujew is the pull-request something you're interested in taking a look at, I'm not sure if it impacts the work you've done as part of #9613.

@msujew
Copy link
Member

msujew commented Jul 19, 2021

@vince-fugnitto I took a quick look at it. I'm expecting some small merge conflicts, but nothing major. Feature-wise this is quite independent of my changes. Thanks for watching out though 👍

@colin-grant-work colin-grant-work merged commit 61f229e into eclipse-theia:master Jul 20, 2021
@vince-fugnitto vince-fugnitto added this to the 1.16.0 milestone Jul 29, 2021
dna2github pushed a commit to dna2fork/theia that referenced this pull request Aug 25, 2021
…el (eclipse-theia#8706)

* 4016-debug-extension: support debugging of extensions using Debug panel

1. Supports start, restart, stop of pwa-extensionHost launch type on debug toolbar.
2. Utilizes Hosted Plugin functionality.

Signed-off-by: Dan Arad <dan.arad@sap.com>
Signed-off-by: Esther Perelman <esther.perelman@sap.com>
Co-authored-by: Dan Arad <dan.arad@sap.com>
Co-authored-by: Esther Perelman <esther.perelman@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CQ Required (deprecated) issues requiring a CQ (contributor questionnaire) debug issues that related to debug functionality vscode issues related to VSCode compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support debugging VS Code extensions via the debug view

9 participants