|
3 | 3 | * See 'LICENSE' in the project root for license information. |
4 | 4 | * ------------------------------------------------------------------------------------------ */ |
5 | 5 |
|
6 | | -import * as vscode from 'vscode'; |
7 | 6 | import { execChildProcess } from '../common'; |
8 | 7 | import { PsProcessParser } from './nativeAttach'; |
| 8 | + |
| 9 | +import * as debugUtils from './utils'; |
| 10 | +import * as fs from 'fs'; |
| 11 | +import * as os from 'os'; |
| 12 | +import * as path from 'path'; |
9 | 13 | import * as util from '../common'; |
| 14 | +import * as vscode from 'vscode'; |
10 | 15 |
|
11 | 16 | export interface AttachItem extends vscode.QuickPickItem { |
12 | 17 | id: string; |
@@ -49,20 +54,47 @@ export class RemoteAttachPicker { |
49 | 54 |
|
50 | 55 | private _channel: vscode.OutputChannel = null; |
51 | 56 |
|
52 | | - public ShowAttachEntries(args: any): Promise<string> { |
| 57 | + public ShowAttachEntries(config: any): Promise<string> { |
53 | 58 | return util.isExtensionReady().then(ready => { |
54 | 59 | if (!ready) { |
55 | 60 | util.displayExtensionNotReadyPrompt(); |
56 | 61 | } else { |
57 | 62 | this._channel.clear(); |
58 | 63 |
|
59 | | - let pipeTransport: any = args ? args.pipeTransport : null; |
| 64 | + let pipeTransport: any = config ? config.pipeTransport : null; |
60 | 65 |
|
61 | 66 | if (pipeTransport === null) { |
62 | 67 | return Promise.reject<string>(new Error("Chosen debug configuration does not contain pipeTransport")); |
63 | 68 | } |
64 | 69 |
|
65 | | - let pipeProgram: string = pipeTransport.pipeProgram; |
| 70 | + let pipeProgram: string = null; |
| 71 | + |
| 72 | + if (os.platform() === 'win32' && |
| 73 | + pipeTransport.pipeProgram && |
| 74 | + !fs.existsSync(pipeTransport.pipeProgram)) { |
| 75 | + const pipeProgramStr: string = pipeTransport.pipeProgram.toLowerCase().trim(); |
| 76 | + const expectedArch: debugUtils.ArchType = debugUtils.ArchType[process.arch]; |
| 77 | + |
| 78 | + // Check for pipeProgram |
| 79 | + if (!fs.existsSync(config.pipeTransport.pipeProgram)) { |
| 80 | + pipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(pipeProgramStr, expectedArch); |
| 81 | + } |
| 82 | + |
| 83 | + // If pipeProgram does not get replaced and there is a pipeCwd, concatenate with pipeProgramStr and attempt to replace. |
| 84 | + if (!pipeProgram && config.pipeTransport.pipeCwd) { |
| 85 | + const pipeCwdStr: string = config.pipeTransport.pipeCwd.toLowerCase().trim(); |
| 86 | + const newPipeProgramStr: string = path.join(pipeCwdStr, pipeProgramStr); |
| 87 | + |
| 88 | + if (!fs.existsSync(newPipeProgramStr)) { |
| 89 | + pipeProgram = debugUtils.ArchitectureReplacer.checkAndReplaceWSLPipeProgram(newPipeProgramStr, expectedArch); |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + if (!pipeProgram) { |
| 95 | + pipeProgram = pipeTransport.pipeProgram; |
| 96 | + } |
| 97 | + |
66 | 98 | let pipeArgs: string[] = pipeTransport.pipeArgs; |
67 | 99 |
|
68 | 100 | let argList: string = RemoteAttachPicker.createArgumentList(pipeArgs); |
|
0 commit comments