| 191 | } |
| 192 | |
| 193 | protected initCommands(target: string, cwd: string, attach: boolean = false) { |
| 194 | // We need to account for the possibility of the path type used by the debugger being different |
| 195 | // from the path type where the extension is running (e.g., SSH from Linux to Windows machine). |
| 196 | // Since the CWD is expected to be an absolute path in the debugger's environment, we can test |
| 197 | // that to determine the path type used by the debugger and use the result of that test to |
| 198 | // select the correct API to check whether the target path is an absolute path. |
| 199 | const debuggerPath = path.posix.isAbsolute(cwd) ? path.posix : path.win32; |
| 200 | |
| 201 | if (!debuggerPath.isAbsolute(target)) |
| 202 | target = debuggerPath.join(cwd, target); |
| 203 | |
| 204 | const cmds = [ |
| 205 | this.sendCommand("gdb-set target-async on", true), |
| 206 | new Promise(resolve => { |
| 207 | this.sendCommand("list-features").then(done => { |
| 208 | this.features = done.result("features"); |
| 209 | resolve(undefined); |
| 210 | }, () => { |
| 211 | // Default to no supported features on error |
| 212 | this.features = []; |
| 213 | resolve(undefined); |
| 214 | }); |
| 215 | }), |
| 216 | this.sendCommand("environment-directory \"" + escape(cwd) + "\"", true) |
| 217 | ]; |
| 218 | if (!attach) |
| 219 | cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\"")); |
| 220 | if (this.prettyPrint) |
| 221 | cmds.push(this.sendCommand("enable-pretty-printing")); |
| 222 | for (const cmd of this.extraCommands) { |
| 223 | cmds.push(this.sendCommand(cmd)); |
| 224 | } |
| 225 | |
| 226 | return cmds; |
| 227 | } |
| 228 | |
| 229 | attach(cwd: string, executable: string, target: string, autorun: string[]): Thenable<any> { |
| 230 | return new Promise((resolve, reject) => { |