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

10011: Add DebugProtocolSource and DebugProtocolBreakpoint #10926

Merged
merged 2 commits into from
Jul 21, 2022

Conversation

CamilleLetavernier
Copy link
Contributor

@CamilleLetavernier CamilleLetavernier commented Mar 25, 2022

Signed-off-by: Camille Letavernier [email protected]

What it does

Introduce new APIs for the Theia plug-in API: DebugProtocolBreakpoint, DebugProtocolSource, and related methods:

  • DebugSession.getDebugProtocolBreakpoint()
  • debug.asDebugSourceUri()

How to test

I've created a small test extension that just prints breakpoints on the console, after using the new APIs. It can be used to test the changes:

https://github.com/CamilleLetavernier/debug-protocol-extension/releases

To use it:

  • Run the Test debug protocol command to start observing breakpoints of the active debug session
  • Start a debug session (Should work with any debug adapter) and toggle some breakpoints
  • The extension will print the "DebugProtocolBreakpoints" corresponding to each breakpoint in the active session. If the Breakpoint has a source, the source URI will be displayed as well (Actual data depends on the debug adapter)

Review checklist

Reminder for reviewers

refs #10011

@CamilleLetavernier
Copy link
Contributor Author

Note: I wasn't sure how to actually match Breakpoints to DebugProtocolBreakpoint in debug-session.tsx#getBreakpoint(id), as it seems they don't use matching IDs.

I've modified the Breakpoint constructor to accept an optional initial ID (that can be copied from the plug-in Breakpoint), but I'm not sure that's the right way to go. I couldn't figure out a better way to match the various breakpoints, though.

@colin-grant-work
Copy link
Contributor

@CamilleLetavernier, are you familiar with any existing plugins that use this API? Your test extension is a good proof of functionality, but to address your question about matching breakpoints, it would be good to be able to see what the API is used for elsewhere.

@msujew
Copy link
Member

msujew commented Mar 28, 2022

@colin-grant-work It looks like the profiling feature of the vscode-js-debug extension uses getDebugProtocolBreakpoint. The debug.asDebugSourceUri is also used in there.

@JonasHelming
Copy link
Contributor

@colin-grant-work

@colin-grant-work
Copy link
Contributor

@CamilleLetavernier, @JonasHelming, I'll take a look at this this week, either today or tomorrow.

@vince-fugnitto
Copy link
Member

@CamilleLetavernier do you mind rebasing? Hopefully CI will kick in again after (currently does not show up on the pull-request).

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 made some comments on the code. It would be helpful if you could provide more details about how to use the plugin - what command to run to trigger its functionality and what output should be expected under different conditions. The plugin probably shouldn't add new listeners every time its command is run, since that can lead to confusing output if the same information is printed more than once.

packages/plugin-ext/src/plugin/node/debug/debug.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/plugin/node/debug/debug.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/plugin/node/debug/debug.ts Outdated Show resolved Hide resolved
@CamilleLetavernier
Copy link
Contributor Author

@CamilleLetavernier CamilleLetavernier requested a review from colin-grant-work 10 seconds ago

Sorry, that was a mis-click. No changes just yet!

@JonasHelming JonasHelming added the vscode issues related to VSCode compatibility label May 2, 2022
@CamilleLetavernier CamilleLetavernier force-pushed the issues/10011 branch 2 times, most recently from d75ba90 to 2d060fb Compare May 5, 2022 15:04
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.

@CamilleLetavernier can you expand on #10926 (review) by updating the pull-request description on on how to properly test the features using the plugin provided, the steps are a bit vague at the moment.

CHANGELOG.md Outdated
@@ -146,6 +146,7 @@
- [vsx-registry] updated `requestretry` from `v3.1.0` to `v7.0.0` [#10831](https://github.com/eclipse-theia/theia/pull/10831)
- [workspace] fixed `'save as'` for `untitled` schemes [#10608](https://github.com/eclipse-theia/theia/pull/10608)
- [workspace] fixed the styling of the `path` in the dialog [#10814](https://github.com/eclipse-theia/theia/pull/10814)
- [plugin] added support for `DebugProtocolBreakpoint` and `DebugProtocolSource` [#10011](https://github.com/eclipse-theia/theia/issues/10011) - Contributed on behalf of STMicroelectronics
Copy link
Member

Choose a reason for hiding this comment

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

The entry should be moved under 1.26.0.


const debug = new DebugExtImpl(mockRPCProtocol);

it('Should use sourceReference, path and sessionId', () => {
Copy link
Member

Choose a reason for hiding this comment

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

minor: consistency

Suggested change
it('Should use sourceReference, path and sessionId', () => {
it('should use sourceReference, path and sessionId', () => {

import { DebugSession } from '@theia/plugin';
import * as chai from 'chai';
import { ProxyIdentifier, RPCProtocol } from '../../../common/rpc-protocol';

Copy link
Member

Choose a reason for hiding this comment

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

minor: remove extra newline.


const expect = chai.expect;

describe('Debug source URI:', () => {
Copy link
Member

Choose a reason for hiding this comment

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

minor: in general we have a parent describe that describes the file, then we have individual tests:

Suggested change
describe('Debug source URI:', () => {
describe('Debug API', () => {
describe('#asDebugSourceUri', () => {

Comment on lines 190 to 191
static SCHEME = 'debug';
static SCHEME_PATTERN = /^[a-zA-Z][a-zA-Z0-9\+\-\.]+:/;
Copy link
Member

Choose a reason for hiding this comment

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

minor: move the static members to the top of the class.

Copy link
Contributor

@colin-grant-work colin-grant-work May 6, 2022

Choose a reason for hiding this comment

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

It also appears that both the scheme and the pattern are already declared in debug-source.ts as DebugSource.SCHEME and DebugSource.SCHEME_PATTERN. Would it be possible to reuse those declarations, perhaps by moving them to the common area of the debug package? In fact the SCHEME_PATTERN should really be somewhere very generally accessible, since it isn't specific to debug at all.

@colin-grant-work colin-grant-work removed their request for review May 31, 2022 21:37
@colin-grant-work
Copy link
Contributor

@CamilleLetavernier, please ping me or Vince when this is ready for another review.

@CamilleLetavernier
Copy link
Contributor Author

CamilleLetavernier commented Jun 3, 2022

Hi @colin-grant-work, @vince-fugnitto,

Thank you for your feedback. I've updated the pull request according to your comments. I also edited the PR description to include some testing steps.

I've also pushed a new version of the small extension I used to print the breakpoints, to avoid installing the listeners multiple times.

Unfortunately, for some reason, I can't get the Java Debugger to work in my local branch anymore; so I can't actually test the behavior of the debug session. I tried with Redhat Java 1.6 and 1.7 (And Java debug 0.40, 0.41), but I'm getting these errors when I start debugging:

root INFO [hosted-plugin: 653754] Debug configuration provider has been registered: java, trigger: 1
root ERROR [hosted-plugin: 653754] Promise rejection not handled in one second: Error: Connection got disposed. , reason: Error: Connection got disposed.
root ERROR [hosted-plugin: 653754] With stack trace: Error: Connection got disposed.
    at Object.dispose (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:1025551)
    at Object.dispose (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:872493)
    at b.handleConnectionClosed (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:872681)
    at b.handleConnectionClosed (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:946354)
    at t (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:870795)
    at invoke (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:1027177)
    at s.fire (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:1027938)
    at Q (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:1014690)
    at invoke (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:1027177)
    at s.fire (/tmp/vscode-unpacked/redhat.java-1.6.0.vsix/extension/dist/extension.js:2:1027938)

@colin-grant-work colin-grant-work self-requested a review June 3, 2022 14:00
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.

@CamilleLetavernier, would you mind rebasing. At the moment #11263 is preventing the execution of debug sessions with your code, but #11268 was merged this morning to fix it.

Comment on lines 203 to 212
return new TheiaURI().withScheme(DEBUG_SCHEME).withPath(raw.path || '').withQuery(query);
}
if (!raw.path) {
throw new Error('Unrecognized source type: ' + JSON.stringify(raw));
}
if (raw.path.match(SCHEME_PATTERN)) {
return new TheiaURI(raw.path);
}
return new TheiaURI(URI.file(raw.path));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to use the Theia URI implementation rather than VSCode-style URI's from the start here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. I have to say, I'm a bit confused with all the classes named "URI" delegating to each other, and are sometimes renamed during import :)

@CamilleLetavernier CamilleLetavernier force-pushed the issues/10011 branch 2 times, most recently from ef2ce1e to 4e66bf9 Compare July 8, 2022 13:54
@CamilleLetavernier
Copy link
Contributor Author

The branch has been rebased (I've also squashed all commits, as the last rebase was a bit more complex). I've been able to run the debug plug-in/command with the current version of Theia, so it should all be good now

@JonasHelming
Copy link
Contributor

@colin-grant-work Are you fine with merging this now?

@colin-grant-work
Copy link
Contributor

@JonasHelming, I'll take a look today

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.

The behavior of the example plugin is compatible between Theia and VSCode 👍. Please see the suggestion for removing use of TheiaURI.

Add "DebugProtocolSource" and "DebugProtocolEndpoint" to the plug-in
API, as well as the methods using these interfaces:

- DebugSession.getDebugProtocolBreakpoint()
- debug.asDebugSourceUri()

10011: Fix asDebugSourceUri

- Rename asDebugSourceURI to getDebugSourceUri to avoid name clash
- Fix the way the debug source query is built
- Add tests

10011: Minor code improvements

- Improve test description to be consistent with other tests
- Move the SCHEME and SCHEME_PATTERN constants to debug/common for
reusability

10011: Rebase on master

- Rebase on master and resolve conflicts

Contributed on behalf of STMicroelectronics
Signed-off-by: Camille Letavernier <[email protected]>
@JonasHelming JonasHelming merged commit 6aa0d78 into eclipse-theia:master Jul 21, 2022
@JonasHelming JonasHelming added this to the 1.28.0 milestone Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants