Added support for program arguments (fix #27)
This commit is contained in:
parent
0d8ae8d7bb
commit
cb9e36d6db
4 changed files with 21 additions and 10 deletions
|
|
@ -45,6 +45,10 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Path of executable"
|
"description": "Path of executable"
|
||||||
},
|
},
|
||||||
|
"arguments": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Arguments to append after the executable. You can also use pipes."
|
||||||
|
},
|
||||||
"cwd": {
|
"cwd": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Path of project"
|
"description": "Path of project"
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ export interface SSHArguments {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IBackend {
|
export interface IBackend {
|
||||||
load(cwd: string, target: string): Thenable<any>;
|
load(cwd: string, target: string, procArgs: string): Thenable<any>;
|
||||||
ssh(args: SSHArguments, cwd: string, target: string): Thenable<any>;
|
ssh(args: SSHArguments, cwd: string, target: string, procArgs: string): Thenable<any>;
|
||||||
attach(cwd: string, executable: string, target: string): Thenable<any>;
|
attach(cwd: string, executable: string, target: string): Thenable<any>;
|
||||||
connect(cwd: string, executable: string, target: string): Thenable<any>;
|
connect(cwd: string, executable: string, target: string): Thenable<any>;
|
||||||
start(): Thenable<boolean>;
|
start(): Thenable<boolean>;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
load(cwd: string, target: string): Thenable<any> {
|
load(cwd: string, target: string, procArgs: string): Thenable<any> {
|
||||||
if (!nativePath.isAbsolute(target))
|
if (!nativePath.isAbsolute(target))
|
||||||
target = nativePath.join(cwd, target);
|
target = nativePath.join(cwd, target);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
@ -35,17 +35,20 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
this.process.stdout.on("data", this.stdout.bind(this));
|
this.process.stdout.on("data", this.stdout.bind(this));
|
||||||
this.process.stderr.on("data", this.stdout.bind(this));
|
this.process.stderr.on("data", this.stdout.bind(this));
|
||||||
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
|
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
|
||||||
Promise.all([
|
let promises = [
|
||||||
this.sendCommand("gdb-set target-async on"),
|
this.sendCommand("gdb-set target-async on"),
|
||||||
this.sendCommand("environment-directory \"" + escape(cwd) + "\"")
|
this.sendCommand("environment-directory \"" + escape(cwd) + "\"")
|
||||||
]).then(() => {
|
];
|
||||||
|
if (procArgs && procArgs.length)
|
||||||
|
promises.push(this.sendCommand("exec-arguments " + procArgs));
|
||||||
|
Promise.all(promises).then(() => {
|
||||||
this.emit("debug-ready")
|
this.emit("debug-ready")
|
||||||
resolve();
|
resolve();
|
||||||
}, reject);
|
}, reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh(args: SSHArguments, cwd: string, target: string): Thenable<any> {
|
ssh(args: SSHArguments, cwd: string, target: string, procArgs: string): Thenable<any> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.isSSH = true;
|
this.isSSH = true;
|
||||||
this.sshReady = false;
|
this.sshReady = false;
|
||||||
|
|
@ -111,12 +114,15 @@ export class MI2 extends EventEmitter implements IBackend {
|
||||||
this.emit("quit");
|
this.emit("quit");
|
||||||
this.sshConn.end();
|
this.sshConn.end();
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
Promise.all([
|
let promises = [
|
||||||
this.sendCommand("gdb-set target-async on"),
|
this.sendCommand("gdb-set target-async on"),
|
||||||
this.sendCommand("environment-directory \"" + escape(cwd) + "\""),
|
this.sendCommand("environment-directory \"" + escape(cwd) + "\""),
|
||||||
this.sendCommand("environment-cd \"" + escape(cwd) + "\""),
|
this.sendCommand("environment-cd \"" + escape(cwd) + "\""),
|
||||||
this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\"")
|
this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\"")
|
||||||
]).then(() => {
|
];
|
||||||
|
if (procArgs && procArgs.length)
|
||||||
|
promises.push(this.sendCommand("exec-arguments " + procArgs));
|
||||||
|
Promise.all(promises).then(() => {
|
||||||
this.emit("debug-ready")
|
this.emit("debug-ready")
|
||||||
resolve();
|
resolve();
|
||||||
}, reject);
|
}, reject);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ let relative = posix.relative;
|
||||||
export interface LaunchRequestArguments {
|
export interface LaunchRequestArguments {
|
||||||
cwd: string;
|
cwd: string;
|
||||||
target: string;
|
target: string;
|
||||||
|
arguments: string;
|
||||||
autorun: string[];
|
autorun: string[];
|
||||||
ssh: SSHArguments;
|
ssh: SSHArguments;
|
||||||
printCalls: boolean;
|
printCalls: boolean;
|
||||||
|
|
@ -109,7 +110,7 @@ class MI2DebugSession extends DebugSession {
|
||||||
this.isSSH = true;
|
this.isSSH = true;
|
||||||
this.trimCWD = args.cwd.replace(/\\/g, "/");
|
this.trimCWD = args.cwd.replace(/\\/g, "/");
|
||||||
this.switchCWD = args.ssh.cwd;
|
this.switchCWD = args.ssh.cwd;
|
||||||
this.gdbDebugger.ssh(args.ssh, args.ssh.cwd, args.target).then(() => {
|
this.gdbDebugger.ssh(args.ssh, args.ssh.cwd, args.target, args.arguments).then(() => {
|
||||||
if (args.autorun)
|
if (args.autorun)
|
||||||
args.autorun.forEach(command => {
|
args.autorun.forEach(command => {
|
||||||
this.gdbDebugger.sendUserInput(command);
|
this.gdbDebugger.sendUserInput(command);
|
||||||
|
|
@ -120,7 +121,7 @@ class MI2DebugSession extends DebugSession {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.gdbDebugger.load(args.cwd, args.target).then(() => {
|
this.gdbDebugger.load(args.cwd, args.target, args.arguments).then(() => {
|
||||||
if (args.autorun)
|
if (args.autorun)
|
||||||
args.autorun.forEach(command => {
|
args.autorun.forEach(command => {
|
||||||
this.gdbDebugger.sendUserInput(command);
|
this.gdbDebugger.sendUserInput(command);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue