forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for remote debugging with experimental debugger (#1230)
- Loading branch information
1 parent
60ff772
commit 3e40ce2
Showing
13 changed files
with
677 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add prelimnary support for remote debugging using the experimental debugger. | ||
Attach to a Python program started using the command `python -m ptvsd --server --port 9091 --file pythonFile.py` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { connect, Socket } from 'net'; | ||
import { DebugSession } from 'vscode-debugadapter'; | ||
import { AttachRequestArguments, IDebugServer, IPythonProcess } from '../Common/Contracts'; | ||
import { BaseDebugServer } from './BaseDebugServer'; | ||
|
||
export class RemoteDebugServerV2 extends BaseDebugServer { | ||
private args: AttachRequestArguments; | ||
private socket?: Socket; | ||
constructor(debugSession: DebugSession, pythonProcess: IPythonProcess, args: AttachRequestArguments) { | ||
super(debugSession, pythonProcess); | ||
this.args = args; | ||
} | ||
|
||
public Stop() { | ||
if (this.socket) { | ||
this.socket.destroy(); | ||
} | ||
} | ||
public Start(): Promise<IDebugServer> { | ||
return new Promise<IDebugServer>((resolve, reject) => { | ||
const port = this.args.port!; | ||
const options = { port }; | ||
if (typeof this.args.host === 'string' && this.args.host.length > 0) { | ||
// tslint:disable-next-line:no-any | ||
(<any>options).host = this.args.host; | ||
} | ||
try { | ||
let connected = false; | ||
const socket = connect(options, () => { | ||
connected = true; | ||
this.socket = socket; | ||
this.clientSocket.resolve(socket); | ||
resolve(options); | ||
}); | ||
socket.on('error', ex => { | ||
if (connected) { | ||
return; | ||
} | ||
reject(ex); | ||
}); | ||
} catch (ex) { | ||
reject(ex); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.