Added support to run process in a separate console (fix #28)

This commit is contained in:
WebFreak001 2016-02-23 17:26:12 +01:00
commit 30731c2ba1
6 changed files with 64 additions and 12 deletions

View file

@ -2,6 +2,7 @@ import { Breakpoint, IBackend, Stack, SSHArguments } from "../backend.ts"
import * as ChildProcess from "child_process"
import { EventEmitter } from "events"
import { parseMI, MINode } from '../mi_parse';
import * as linuxTerm from '../linux/console';
import * as net from "net"
import * as fs from "fs"
import { posix } from "path"
@ -26,7 +27,7 @@ export class MI2 extends EventEmitter implements IBackend {
super();
}
load(cwd: string, target: string, procArgs: string): Thenable<any> {
load(cwd: string, target: string, procArgs: string, separateConsole: string): Thenable<any> {
if (!nativePath.isAbsolute(target))
target = nativePath.join(cwd, target);
return new Promise((resolve, reject) => {
@ -41,14 +42,35 @@ export class MI2 extends EventEmitter implements IBackend {
];
if (procArgs && procArgs.length)
promises.push(this.sendCommand("exec-arguments " + procArgs));
Promise.all(promises).then(() => {
this.emit("debug-ready")
resolve();
}, reject);
if (process.platform == "win32") {
if (separateConsole !== undefined)
promises.push(this.sendCommand("gdb-set new-console on"))
Promise.all(promises).then(() => {
this.emit("debug-ready")
resolve();
}, reject);
}
else {
if (separateConsole !== undefined) {
linuxTerm.spawnTerminalEmulator(separateConsole).then(tty => {
promises.push(this.sendCommand("inferior-tty-set " + tty));
Promise.all(promises).then(() => {
this.emit("debug-ready")
resolve();
}, reject);
});
}
else {
Promise.all(promises).then(() => {
this.emit("debug-ready")
resolve();
}, reject);
}
}
});
}
ssh(args: SSHArguments, cwd: string, target: string, procArgs: string): Thenable<any> {
ssh(args: SSHArguments, cwd: string, target: string, procArgs: string, separateConsole: string): Thenable<any> {
return new Promise((resolve, reject) => {
this.isSSH = true;
this.sshReady = false;