Skip to content

Commit 72f20ad

Browse files
committed
modifications to map paths during remote debugging
1 parent 85f2dcd commit 72f20ad

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Python
2-
Linting, Debugging (multi threaded, web apps), Intellisense, auto-completion, code formatting, snippets, unit testing, and more.
3-
Works on both Windows and Mac.
2+
Linting, Debugging (multi-threaded, web apps, remote), Intellisense, auto-completion, code formatting, snippets, unit testing, and more.
43

54
##Features
65
* Linting (PyLint, Pep8, Flake8 with config files and plugins)
@@ -20,10 +19,7 @@ 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)
2522
* Support for Virtual Environments (in development)
26-
* More features on the way
2723

2824
## Feature Details (with confiuration)
2925
* IDE Features
@@ -67,6 +63,7 @@ Works on both Windows and Mac.
6763
+ Multiple Threads and Web Applications (such as Flask) (Windows and Mac)
6864
+ Expanding values (viewing children, properties, etc) (Windows and Mac)
6965
+ Conditional breakpoints
66+
+ Remote debugging
7067
* Unit Testing
7168
+ unittests (default is on)
7269
+ nosetests (default is off)
@@ -106,6 +103,9 @@ Works on both Windows and Mac.
106103

107104
## Change Log
108105

106+
### Version 0.3.1
107+
* Remote debugging (updated documentation and fixed minor issues)
108+
109109
### Version 0.3.0
110110
* Remote debugging (attaching to local and remote processes)
111111
* Debugging with support for shebang

src/client/debugger/Main.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class PythonDebugger extends DebugSession {
238238
breakpoint.Enabled = true;
239239
}
240240
else {
241-
breakpoint = this.buildBreakpointDetails(args.source.path, bk.line, bk.condition);
241+
breakpoint = this.buildBreakpointDetails(this.convertClientPathToDebugger(args.source.path), bk.line, bk.condition);
242242
}
243243

244244
this.pythonProcess.BindBreakpoint(breakpoint).then(() => {
@@ -288,7 +288,28 @@ export class PythonDebugger extends DebugSession {
288288
};
289289
this.sendResponse(response);
290290
}
291-
291+
/** converts the remote path to local path */
292+
protected convertDebuggerPathToClient(remotePath: string): string {
293+
if (this.attachArgs && this.attachArgs.localRoot && this.attachArgs.remoteRoot) {
294+
// get the part of the path that is relative to the source root
295+
const pathRelativeToSourceRoot = path.relative(this.attachArgs.remoteRoot, remotePath);
296+
// resolve from the local source root
297+
return path.resolve(this.attachArgs.localRoot, pathRelativeToSourceRoot);
298+
} else {
299+
return remotePath;
300+
}
301+
}
302+
/** converts the local path to remote path */
303+
protected convertClientPathToDebugger(clientPath: string): string {
304+
if (this.attachArgs && this.attachArgs.localRoot && this.attachArgs.remoteRoot) {
305+
// get the part of the path that is relative to the client root
306+
const pathRelativeToClientRoot = path.relative(this.attachArgs.localRoot, clientPath);
307+
// resolve from the remote source root
308+
return path.resolve(this.attachArgs.remoteRoot, pathRelativeToClientRoot);
309+
} else {
310+
return clientPath;
311+
}
312+
}
292313
protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments): void {
293314
this.debuggerLoaded.then(() => {
294315
if (!this.pythonProcess.Threads.has(args.threadId)) {

0 commit comments

Comments
 (0)