-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add support for remote debugging with experimental debugger #1230
Add support for remote debugging with experimental debugger #1230
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1230 +/- ##
==========================================
+ Coverage 70.94% 71.07% +0.13%
==========================================
Files 266 267 +1
Lines 12284 12350 +66
Branches 2172 2188 +16
==========================================
+ Hits 8715 8778 +63
+ Misses 3445 3432 -13
- Partials 124 140 +16
Continue to review full report at Codecov.
|
fcf15dd
to
673ef14
Compare
673ef14
to
9032acf
Compare
// tslint:disable:quotemark ordered-imports no-any no-empty curly member-ordering one-line max-func-body-length no-var-self prefer-const cyclomatic-complexity prefer-template | ||
|
||
import { DebugSession } from "vscode-debugadapter"; | ||
import { IPythonProcess, IDebugServer, AttachRequestArguments } from "../Common/Contracts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evil double quotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aaah, copy paste.
this.provideDefaults(workspaceFolder, config); | ||
if (config.request === 'attach') { | ||
// tslint:disable-next-line:no-any | ||
this.provideAttachDefaults(workspaceFolder, config as any as PythonAttachDebugConfiguration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - why is getting casted twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config
can be of two types. Modified code accordingly to make it clearer (using a union type).
src/client/debugger/mainV2.ts
Outdated
@@ -87,14 +81,24 @@ export class PythonDebugger extends DebugSession { | |||
this.sendResponse(response); | |||
} | |||
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void { | |||
this.sendResponse(response); | |||
const launcher = CreateAttachDebugClient(args as AttachRequestArguments, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args seems to be of that type already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/client/debugger/mainV2.ts
Outdated
@@ -211,6 +230,7 @@ class DebugManager implements Disposable { | |||
|
|||
this.initializeRequestDeferred = createDeferred<DebugProtocol.InitializeRequest>(); | |||
this.launchRequestDeferred = createDeferred<DebugProtocol.LaunchRequest>(); | |||
this.attachRequestDeferred = createDeferred<DebugProtocol.LaunchRequest>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DebugProtocol.AttachRequest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
const numberOfSettings = Object.keys(config); | ||
const workspaceFolder = this.getWorkspaceFolder(folder, config); | ||
const workspaceFolder = this.getWorkspaceFolder(folder, config as PythonLaunchDebugConfiguration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getWorkspaceFolder
doesn't seem to be using config
(it passes it to getProgram
which does not use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
||
// tslint:disable:no-invalid-template-strings | ||
|
||
export type PythonDebugConfiguration = DebugConfiguration & LaunchRequestArguments; | ||
export type PythonLaunchDebugConfiguration = DebugConfiguration & LaunchRequestArguments; | ||
export type PythonAttachDebugConfiguration = DebugConfiguration & AttachRequestArguments; | ||
|
||
@injectable() | ||
export abstract class BaseConfigurationProvider implements DebugConfigurationProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth splitting into AttachConfigurationProvider
and LaunchConfigurationProvider
and have static factory like getConfigurationProvider(mode)
. Class has bunch of getLaunchX
and getAttachX
and casts and checks for the debug mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately there can only be one debug configuration, that handles both launch
and attach
(& more in the future).
I've cleaned up the code,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be one class that contains a handler
specific to the mode. I.e. debug configuration class acts as a proxy and simply forwards calls to 'launch or 'attach
handler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -263,7 +283,7 @@ class DebugManager implements Disposable { | |||
this.terminatedEventSent = true; | |||
} | |||
|
|||
if (this.killPTVSDProcess && this.ptvsdProcessId) { | |||
if (this.launchOrAttach === 'launch' && this.ptvsdProcessId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In big VS Stop Debugging
terminates debuggee even on attach. There is separate Detach
command if user wants to keep debuggee running. I guess VSC does it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In VSC, we don't have the ability to kill for attach
scenarios, at least not yet (the protocol supports it for VS), the UI doesn't.
I'll create an issue so we add support for this, this way if the UI does add support for this in VSC, it'll work without much changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, we won't need to do anything. There's a ticket item in PTVSD to support this functionality ( required by VS).
in reality PTVSD is the debug adapter, hence it will kill the process if it needs to (the stuff we have here, is a temporary bridge to connect VSC to PTVSD - to perform initial handshake).
I.e. nothing to do here.
src/client/debugger/mainV2.ts
Outdated
if (this.launchOrAttach === 'launch') { | ||
const debugSoketProtocolParser = this.serviceContainer.get<IProtocolParser>(IProtocolParser); | ||
debugSoketProtocolParser.connect(this.ptvsdSocket); | ||
debugSoketProtocolParser.once('event_process', (proc: DebugProtocol.ProcessEvent) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Socket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/test/.vscode/settings.json
Outdated
@@ -17,6 +17,5 @@ | |||
"python.linting.pylamaEnabled": false, | |||
"python.linting.mypyEnabled": false, | |||
"python.formatting.provider": "yapf", | |||
"python.linting.pylintUseMinimalCheckers": false, | |||
"python.pythonPath": "python" | |||
"python.linting.pylintUseMinimalCheckers": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
Fixes #1229
Fixes #1265
This pull request: