Skip to content

Commit 4339099

Browse files
committed
disabled remote debugging
1 parent 85f2dcd commit 4339099

File tree

5 files changed

+71
-60
lines changed

5 files changed

+71
-60
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Works on both Windows and Mac.
1010
* View signature and similar by hovering over a function or method
1111
* Debugging with support for local variables, arguments, expressions, watch window, stack information, break points
1212
* Debugging Multiple threads (Web Applications - Flask, etc) and expanding values (on Windows and Mac)
13-
* Debugging remote processes (attaching to local and remote process)
14-
* Debugging with support for shebang
13+
* Debugging with support for shebang (on Windows)
1514
* Debugging with custom environment variables
1615
* Unit testing (unittests and nosetests, with config files)
1716
* Sorting imports
@@ -20,9 +19,9 @@ Works on both Windows and Mac.
2019
##[Wiki](https://github.com/DonJayamanne/pythonVSCode/wiki)
2120

2221
##[Issues and Feature Requests](https://github.com/DonJayamanne/pythonVSCode/issues)
23-
* Support of shebang (testing)
24-
* Remote Debugging (testing)
22+
* Remote Debugging (testing, ironing out a few kinks)
2523
* Support for Virtual Environments (in development)
24+
* Support of shebang (mac)
2625
* More features on the way
2726

2827
## Feature Details (with confiuration)
@@ -106,8 +105,7 @@ Works on both Windows and Mac.
106105

107106
## Change Log
108107

109-
### Version 0.3.0
110-
* Remote debugging (attaching to local and remote processes)
108+
### Version 0.2.10
111109
* Debugging with support for shebang
112110
* Support for passing environment variables to debug program
113111
* Improved error handling in the extension

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "python",
33
"displayName": "Python",
44
"description": "Linting, Debugging (multi-threaded, remote), Intellisense, auto-completion, code formatting, snippets, and more.",
5-
"version": "0.3.0",
5+
"version": "0.2.10",
66
"publisher": "donjayamanne",
77
"license": "SEE LICENSE IN LICENSE or README.MD",
88
"homepage": "https://github.com/DonJayamanne/pythonVSCode/blob/master/README.md",

src/client/debugger/Main.ts

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ export class PythonDebugger extends DebugSession {
7474
private InitializeEventHandlers() {
7575
this.pythonProcess.on("last", arg => this.onDetachDebugger());
7676
this.pythonProcess.on("threadExited", arg => this.onPythonThreadExited(arg));
77-
this.pythonProcess.on("moduleLoaded", arg=> this.onPythonModuleLoaded(arg));
78-
this.pythonProcess.on("threadCreated", arg=> this.onPythonThreadCreated(arg));
79-
this.pythonProcess.on("processLoaded", arg=> this.onPythonProcessLoaded(arg));
77+
this.pythonProcess.on("moduleLoaded", arg => this.onPythonModuleLoaded(arg));
78+
this.pythonProcess.on("threadCreated", arg => this.onPythonThreadCreated(arg));
79+
this.pythonProcess.on("processLoaded", arg => this.onPythonProcessLoaded(arg));
8080
this.pythonProcess.on("output", (pyThread, output) => this.onDebuggerOutput(pyThread, output));
8181
this.pythonProcess.on("exceptionRaised", (pyThread, ex) => this.onPythonException(pyThread, ex));
8282
this.pythonProcess.on("breakpointHit", (pyThread, breakpointId) => this.onBreakpointHit(pyThread, breakpointId));
8383
this.pythonProcess.on("stepCompleted", (pyThread) => this.onStepCompleted(pyThread));
8484
this.pythonProcess.on("detach", () => this.onDetachDebugger());
8585
this.pythonProcess.on("error", ex => this.sendEvent(new OutputEvent(ex, "stderr")));
86-
this.pythonProcess.on("asyncBreakCompleted", arg=> this.onPythonProcessPaused(arg));
86+
this.pythonProcess.on("asyncBreakCompleted", arg => this.onPythonProcessPaused(arg));
8787

8888
this.debugServer.on("detach", () => this.onDetachDebugger());
8989
}
@@ -138,7 +138,7 @@ export class PythonDebugger extends DebugSession {
138138
this.launchArgs = args;
139139
this.debugClient = CreateLaunchDebugClient(args, this);
140140

141-
this.debuggerLoaded = new Promise(resolve=> {
141+
this.debuggerLoaded = new Promise(resolve => {
142142
this.debuggerLoadedPromiseResolve = resolve;
143143
});
144144

@@ -149,12 +149,12 @@ export class PythonDebugger extends DebugSession {
149149
this.startDebugServer().then(dbgServer => {
150150
that.debugClient.LaunchApplicationToDebug(dbgServer).then(() => {
151151

152-
}, error=> {
152+
}, error => {
153153
this.sendEvent(new OutputEvent(error + "\n", "stderr"));
154154
this.sendErrorResponse(that.entryResponse, 2000, error);
155155
});
156156
});
157-
}, error=> {
157+
}, error => {
158158
this.sendEvent(new OutputEvent(error + "\n", "stderr"));
159159
this.sendErrorResponse(that.entryResponse, 2000, error);
160160
});
@@ -163,7 +163,7 @@ export class PythonDebugger extends DebugSession {
163163
this.attachArgs = args;
164164
this.debugClient = CreateAttachDebugClient(args, this);
165165

166-
this.debuggerLoaded = new Promise(resolve=> {
166+
this.debuggerLoaded = new Promise(resolve => {
167167
this.debuggerLoadedPromiseResolve = resolve;
168168
});
169169

@@ -174,7 +174,7 @@ export class PythonDebugger extends DebugSession {
174174
this.startDebugServer().then(dbgServer => {
175175
that.debugClient.LaunchApplicationToDebug(dbgServer);
176176
});
177-
}, error=> {
177+
}, error => {
178178
this.sendEvent(new OutputEvent(error + "\n", "stderr"));
179179
this.sendErrorResponse(that.entryResponse, 2000, error);
180180
});
@@ -210,6 +210,14 @@ export class PythonDebugger extends DebugSession {
210210
Enabled: true
211211
};
212212
}
213+
// protected convertClientPathToDebugger(localPath: string): string {
214+
// var relativePath = this.attachArgs.remoteRoot + localPath.substring(this.attachArgs.localRoot.length);
215+
// return relativePath;
216+
// }
217+
// protected convertDebuggerPathToClient(serverPath:string):string{
218+
// var relativePath = this.attachArgs.localRoot + serverPath.substring(this.attachArgs.remoteRoot.length);
219+
// return relativePath;
220+
// }
213221
protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments): void {
214222
this.debuggerLoaded.then(() => {
215223
if (!this.registeredBreakpointsByFileName.has(args.source.path)) {
@@ -218,35 +226,38 @@ export class PythonDebugger extends DebugSession {
218226

219227
var breakpoints: { verified: boolean, line: number }[] = [];
220228
var breakpointsToRemove = [];
221-
var linesToAdd = args.breakpoints.map(b=> b.line);
229+
var linesToAdd = args.breakpoints.map(b => b.line);
222230
var registeredBks = this.registeredBreakpointsByFileName.get(args.source.path);
223-
var linesToRemove = registeredBks.map(b=> b.LineNo).filter(oldLine=> linesToAdd.indexOf(oldLine) === -1);
224-
var linesToUpdate = registeredBks.map(b=> b.LineNo).filter(oldLine=> linesToAdd.indexOf(oldLine) >= 0);
225-
231+
var linesToRemove = registeredBks.map(b => b.LineNo).filter(oldLine => linesToAdd.indexOf(oldLine) === -1);
232+
var linesToUpdate = registeredBks.map(b => b.LineNo).filter(oldLine => linesToAdd.indexOf(oldLine) >= 0);
233+
226234
//Always add new breakpoints, don't re-enable previous breakpoints
227235
//Cuz sometimes some breakpoints get added too early (e.g. in django) and don't get registeredBks
228236
//and the response comes back indicating it wasn't set properly
229237
//However, at a later point in time, the program breaks at that point!!!
230-
var linesToAddPromises = args.breakpoints.map(bk=> {
231-
return new Promise(resolve=> {
238+
var linesToAddPromises = args.breakpoints.map(bk => {
239+
return new Promise(resolve => {
232240
var breakpoint: IPythonBreakpoint;
233-
var existingBreakpointsForThisLine = registeredBks.filter(registeredBk=> registeredBk.LineNo === bk.line);
241+
var existingBreakpointsForThisLine = registeredBks.filter(registeredBk => registeredBk.LineNo === bk.line);
234242
if (existingBreakpointsForThisLine.length > 0) {
235243
//We have an existing breakpoint for this line
236244
//just enable that
237245
breakpoint = existingBreakpointsForThisLine[0]
238246
breakpoint.Enabled = true;
239247
}
240248
else {
241-
breakpoint = this.buildBreakpointDetails(args.source.path, bk.line, bk.condition);
249+
var serverPath = args.source.path;// this.convertClientPathToDebugger(args.source.path);
250+
var serverLine = bk.line;// this.convertClientLineToDebugger(bk.line);
251+
252+
breakpoint = this.buildBreakpointDetails(serverPath, serverLine, bk.condition);
242253
}
243254

244255
this.pythonProcess.BindBreakpoint(breakpoint).then(() => {
245256
this.registeredBreakpoints.set(breakpoint.Id, breakpoint);
246257
breakpoints.push({ verified: true, line: bk.line });
247258
registeredBks.push(breakpoint);
248259
resolve();
249-
}, reason=> {
260+
}, reason => {
250261
this.registeredBreakpoints.set(breakpoint.Id, breakpoint);
251262
breakpoints.push({ verified: false, line: bk.line });
252263
registeredBks.push(breakpoint);
@@ -255,10 +266,10 @@ export class PythonDebugger extends DebugSession {
255266
});
256267
});
257268

258-
var linesToRemovePromises = linesToRemove.map(line=> {
259-
return new Promise(resolve=> {
269+
var linesToRemovePromises = linesToRemove.map(line => {
270+
return new Promise(resolve => {
260271
var registeredBks = this.registeredBreakpointsByFileName.get(args.source.path);
261-
var bk = registeredBks.filter(b=> b.LineNo === line)[0];
272+
var bk = registeredBks.filter(b => b.LineNo === line)[0];
262273
//Ok, we won't get a response back, so update the breakpoints list indicating this has been disabled
263274
bk.Enabled = false;
264275
this.pythonProcess.DisableBreakPoint(bk);
@@ -279,7 +290,7 @@ export class PythonDebugger extends DebugSession {
279290

280291
protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
281292
var threads = [];
282-
this.pythonProcess.Threads.forEach(t=> {
293+
this.pythonProcess.Threads.forEach(t => {
283294
threads.push(new Thread(t.Id, t.Name));
284295
});
285296

@@ -346,8 +357,8 @@ export class PythonDebugger extends DebugSession {
346357
return this.sendResponse(response);
347358
}
348359

349-
this.pythonProcess.ExecuteText(args.expression, PythonEvaluationResultReprKind.Normal, frame).then(result=> {
350-
let variablesReference = 0;
360+
this.pythonProcess.ExecuteText(args.expression, PythonEvaluationResultReprKind.Normal, frame).then(result => {
361+
let variablesReference = 0;
351362
//If this value can be expanded, then create a vars ref for user to expand it
352363
if (result.IsExpandable) {
353364
const parentVariable: IDebugVariable = {
@@ -398,7 +409,7 @@ export class PythonDebugger extends DebugSession {
398409

399410
if (varRef.evaluateChildren !== true) {
400411
let variables = [];
401-
varRef.variables.forEach(variable=> {
412+
varRef.variables.forEach(variable => {
402413
let variablesReference = 0;
403414
//If this value can be expanded, then create a vars ref for user to expand it
404415
if (variable.IsExpandable) {
@@ -422,12 +433,12 @@ export class PythonDebugger extends DebugSession {
422433

423434
return this.sendResponse(response);
424435
}
425-
436+
426437
//Ok, we need to evaluate the children of the current variable
427438
var variables = [];
428-
var promises = varRef.variables.map(variable=> {
429-
return variable.Process.EnumChildren(variable.Expression, variable.Frame, CHILD_ENUMEARATION_TIMEOUT).then(children=> {
430-
children.forEach(child=> {
439+
var promises = varRef.variables.map(variable => {
440+
return variable.Process.EnumChildren(variable.Expression, variable.Frame, CHILD_ENUMEARATION_TIMEOUT).then(children => {
441+
children.forEach(child => {
431442
let variablesReference = 0;
432443
//If this value can be expanded, then create a vars ref for user to expand it
433444
if (child.IsExpandable) {
@@ -444,7 +455,7 @@ export class PythonDebugger extends DebugSession {
444455
variablesReference: variablesReference
445456
});
446457
});
447-
}, error=> {
458+
}, error => {
448459
this.sendErrorResponse(response, 2001, error);
449460
});
450461
});

src/client/debugger/PythonProcess.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,20 @@ export class PythonProcess extends EventEmitter implements IPythonProcess {
121121
this.callbackHandler = new PythonProcessCallbackHandler(this, this.stream, this._idDispenser);
122122
this.callbackHandler.on("detach", () => this.emit("detach"));
123123
this.callbackHandler.on("last", () => this.emit("last"));
124-
this.callbackHandler.on("moduleLoaded", arg=> this.emit("moduleLoaded", arg));
125-
this.callbackHandler.on("asyncBreakCompleted", arg=> this.emit("asyncBreakCompleted", arg));
126-
this.callbackHandler.on("threadCreated", arg=> this.emit("threadCreated", arg));
127-
this.callbackHandler.on("threadExited", arg=> this.emit("threadExited", arg));
128-
this.callbackHandler.on("stepCompleted", arg=> this.onPythonStepCompleted(arg));
129-
this.callbackHandler.on("breakpointSet", arg=> this.onBreakpointSet(arg, true));
130-
this.callbackHandler.on("breakpointNotSet", arg=> this.onBreakpointSet(arg, false));
124+
this.callbackHandler.on("moduleLoaded", arg => this.emit("moduleLoaded", arg));
125+
this.callbackHandler.on("asyncBreakCompleted", arg => this.emit("asyncBreakCompleted", arg));
126+
this.callbackHandler.on("threadCreated", arg => this.emit("threadCreated", arg));
127+
this.callbackHandler.on("threadExited", arg => this.emit("threadExited", arg));
128+
this.callbackHandler.on("stepCompleted", arg => this.onPythonStepCompleted(arg));
129+
this.callbackHandler.on("breakpointSet", arg => this.onBreakpointSet(arg, true));
130+
this.callbackHandler.on("breakpointNotSet", arg => this.onBreakpointSet(arg, false));
131131
this.callbackHandler.on("output", (pyThread, output) => this.emit("output", pyThread, output));
132132
this.callbackHandler.on("exceptionRaised", (pyThread, ex, brkType) => {
133133
this._lastExecutedThread = pyThread;
134134
this.emit("exceptionRaised", pyThread, ex, brkType);
135135
});
136136
this.callbackHandler.on("breakpointHit", (pyThread, breakpointId) => this.onBreakpointHit(pyThread, breakpointId));
137-
this.callbackHandler.on("processLoaded", arg=> {
137+
this.callbackHandler.on("processLoaded", arg => {
138138
this._mainThread = <IPythonThread>arg;
139139
this._lastExecutedThread = this._mainThread;
140140
this.emit("processLoaded", arg);
@@ -182,7 +182,7 @@ export class PythonProcess extends EventEmitter implements IPythonProcess {
182182

183183
this.callbackHandler.HandleIncomingData();
184184
}
185-
185+
186186
//#region Step Commands
187187
private onPythonStepCompleted(pyThread: IPythonThread) {
188188
this._lastExecutedThread = pyThread;
@@ -224,7 +224,7 @@ export class PythonProcess extends EventEmitter implements IPythonProcess {
224224
}
225225
private onBreakpointSet(breakpointId: number, success: boolean) {
226226
//Find the last breakpoint command associated with this breakpoint
227-
var index = this.breakpointCommands.findIndex(cmd=> cmd.Id === breakpointId);
227+
var index = this.breakpointCommands.findIndex(cmd => cmd.Id === breakpointId);
228228
if (index === -1) {
229229
//Hmm this is not possible, log this exception and carry on
230230
this.emit("error", "command.breakpoint.hit", `Uknown Breakpoit Id ${breakpointId}`);

0 commit comments

Comments
 (0)