forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Remove TS debug adapter subprocess support #12008
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
Merged
karthiknadig
merged 4 commits into
microsoft:logging-changes-and-drop-old-debugger
from
karthiknadig:remove-old-subproc-handler
May 27, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,11 +7,10 @@ import { inject, injectable } from 'inversify'; | |||||||||||||||
| import { DebugConfiguration, DebugSession, WorkspaceFolder } from 'vscode'; | ||||||||||||||||
| import { IApplicationShell, IDebugService, IWorkspaceService } from '../../../common/application/types'; | ||||||||||||||||
| import { noop } from '../../../common/utils/misc'; | ||||||||||||||||
| import { SystemVariables } from '../../../common/variables/systemVariables'; | ||||||||||||||||
| import { captureTelemetry } from '../../../telemetry'; | ||||||||||||||||
| import { EventName } from '../../../telemetry/constants'; | ||||||||||||||||
| import { AttachRequestArguments, LaunchRequestArguments } from '../../types'; | ||||||||||||||||
| import { ChildProcessLaunchData, IChildProcessAttachService } from './types'; | ||||||||||||||||
| import { AttachRequestArguments } from '../../types'; | ||||||||||||||||
| import { IChildProcessAttachService } from './types'; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * This class is responsible for attaching the debugger to any | ||||||||||||||||
|
|
@@ -29,49 +28,16 @@ export class ChildProcessAttachService implements IChildProcessAttachService { | |||||||||||||||
| ) {} | ||||||||||||||||
|
|
||||||||||||||||
| @captureTelemetry(EventName.DEBUGGER_ATTACH_TO_CHILD_PROCESS) | ||||||||||||||||
| public async attach( | ||||||||||||||||
| data: ChildProcessLaunchData | (AttachRequestArguments & DebugConfiguration), | ||||||||||||||||
| parentSession: DebugSession | ||||||||||||||||
| ): Promise<void> { | ||||||||||||||||
| let debugConfig: AttachRequestArguments & DebugConfiguration; | ||||||||||||||||
| let processId: number; | ||||||||||||||||
| if (this.isChildProcessLaunchData(data)) { | ||||||||||||||||
| processId = data.processId; | ||||||||||||||||
| debugConfig = this.getAttachConfiguration(data); | ||||||||||||||||
| } else { | ||||||||||||||||
| debugConfig = data; | ||||||||||||||||
| processId = debugConfig.subProcessId!; | ||||||||||||||||
| } | ||||||||||||||||
| public async attach(data: AttachRequestArguments & DebugConfiguration, parentSession: DebugSession): Promise<void> { | ||||||||||||||||
| const debugConfig: AttachRequestArguments & DebugConfiguration = data; | ||||||||||||||||
|
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
or
Suggested change
|
||||||||||||||||
| const processId = debugConfig.subProcessId!; | ||||||||||||||||
| const folder = this.getRelatedWorkspaceFolder(debugConfig); | ||||||||||||||||
| const launched = await this.debugService.startDebugging(folder, debugConfig, parentSession); | ||||||||||||||||
| if (!launched) { | ||||||||||||||||
| this.appShell.showErrorMessage(`Failed to launch debugger for child process ${processId}`).then(noop, noop); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| /** | ||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm loving all this deleted code. 😄 |
||||||||||||||||
| * Since we're attaching we need to provide path mappings. | ||||||||||||||||
| * If not provided, we cannot add breakpoints as we don't have mappings to the actual source. | ||||||||||||||||
| * This is because attach automatically assumes remote debugging. | ||||||||||||||||
| * Also remember, this code gets executed only when dynamically attaching to child processes. | ||||||||||||||||
| * Resolves https://github.com/microsoft/vscode-python/issues/3568 | ||||||||||||||||
| */ | ||||||||||||||||
| public fixPathMappings(config: LaunchRequestArguments & AttachRequestArguments & DebugConfiguration) { | ||||||||||||||||
| if (!config.workspaceFolder) { | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
| if (Array.isArray(config.pathMappings) && config.pathMappings.length > 0) { | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
| // If user has provided a `cwd` in their `launch.json`, then we need to use | ||||||||||||||||
| // the `cwd` as the localRoot. | ||||||||||||||||
| // We cannot expect the debugger to assume remote root is the same as the cwd, | ||||||||||||||||
| // As debugger doesn't necessarily know whether the process being attached to is | ||||||||||||||||
| // a child process or not. | ||||||||||||||||
| const systemVariables = new SystemVariables(undefined, config.workspaceFolder); | ||||||||||||||||
| const localRoot = | ||||||||||||||||
| config.cwd && config.cwd.length > 0 ? systemVariables.resolveAny(config.cwd) : config.workspaceFolder; | ||||||||||||||||
| config.pathMappings = [{ remoteRoot: '.', localRoot }]; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| private getRelatedWorkspaceFolder( | ||||||||||||||||
| config: AttachRequestArguments & DebugConfiguration | ||||||||||||||||
| ): WorkspaceFolder | undefined { | ||||||||||||||||
|
|
@@ -81,21 +47,4 @@ export class ChildProcessAttachService implements IChildProcessAttachService { | |||||||||||||||
| } | ||||||||||||||||
| return this.workspaceService.workspaceFolders!.find((ws) => ws.uri.fsPath === workspaceFolder); | ||||||||||||||||
| } | ||||||||||||||||
| private getAttachConfiguration(data: ChildProcessLaunchData): AttachRequestArguments & DebugConfiguration { | ||||||||||||||||
| const args = data.rootStartRequest.arguments; | ||||||||||||||||
| // tslint:disable-next-line:no-any | ||||||||||||||||
| const config = (JSON.parse(JSON.stringify(args)) as any) as AttachRequestArguments & DebugConfiguration; | ||||||||||||||||
| // tslint:disable-next-line: no-any | ||||||||||||||||
| this.fixPathMappings(config as any); | ||||||||||||||||
| config.host = args.request === 'attach' ? args.host! : 'localhost'; | ||||||||||||||||
| config.port = data.port; | ||||||||||||||||
| config.name = `Child Process ${data.processId}`; | ||||||||||||||||
| config.request = 'attach'; | ||||||||||||||||
| return config; | ||||||||||||||||
| } | ||||||||||||||||
| private isChildProcessLaunchData( | ||||||||||||||||
| data: ChildProcessLaunchData | (AttachRequestArguments & DebugConfiguration) | ||||||||||||||||
| ): data is ChildProcessLaunchData { | ||||||||||||||||
| return data.rootStartRequest !== undefined; | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
With a single case we can simplify: