Skip to content

Commit 2f9bdcb

Browse files
committed
Rename launch argument target to executable
As the target argument for launch configurations is an executable, let's name it as such to avoid confusion. The target argument is deprecated but kept for backwards compatibility.
1 parent 54bdc89 commit 2f9bdcb

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,17 @@
7373
"configurationAttributes": {
7474
"launch": {
7575
"required": [
76-
"target"
76+
"executable"
7777
],
7878
"properties": {
79-
"target": {
79+
"executable": {
8080
"type": "string",
8181
"description": "Path of executable"
8282
},
83+
"target": {
84+
"type": "string",
85+
"description": "Path of executable (DEPRECATED use executable argument instead)"
86+
},
8387
"arguments": {
8488
"type": "string",
8589
"description": "Arguments to append after the executable. You can also use pipes."

src/backend/mi2/mi2.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export class MI2 extends EventEmitter implements IBackend {
5050
}
5151
}
5252

53-
load(cwd: string, target: string, procArgs: string, separateConsole: string): Thenable<any> {
54-
if (!nativePath.isAbsolute(target))
55-
target = nativePath.join(cwd, target);
53+
load(cwd: string, executable: string, procArgs: string, separateConsole: string): Thenable<any> {
54+
if (!nativePath.isAbsolute(executable))
55+
executable = nativePath.join(cwd, executable);
5656
return new Promise((resolve, reject) => {
5757
this.isSSH = false;
5858
const args = this.preargs.concat(this.extraargs || []);
@@ -61,7 +61,7 @@ export class MI2 extends EventEmitter implements IBackend {
6161
this.process.stderr.on("data", this.stderr.bind(this));
6262
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
6363
this.process.on("error", ((err) => { this.emit("launcherror", err); }).bind(this));
64-
const promises = this.initCommands(target, cwd);
64+
const promises = this.initCommands(executable, cwd);
6565
if (procArgs && procArgs.length)
6666
promises.push(this.sendCommand("exec-arguments " + procArgs));
6767
if (process.platform == "win32") {
@@ -181,20 +181,20 @@ export class MI2 extends EventEmitter implements IBackend {
181181
});
182182
}
183183

184-
protected initCommands(target: string, cwd: string, ssh: boolean = false, attach: boolean = false) {
184+
protected initCommands(executable: string, cwd: string, ssh: boolean = false, attach: boolean = false) {
185185
if (ssh) {
186-
if (!path.isAbsolute(target))
187-
target = path.join(cwd, target);
186+
if (!path.isAbsolute(executable))
187+
executable = path.join(cwd, executable);
188188
} else {
189-
if (!nativePath.isAbsolute(target))
190-
target = nativePath.join(cwd, target);
189+
if (!nativePath.isAbsolute(executable))
190+
executable = nativePath.join(cwd, executable);
191191
}
192192
const cmds = [
193193
this.sendCommand("gdb-set target-async on", true),
194194
this.sendCommand("environment-directory \"" + escape(cwd) + "\"", true)
195195
];
196196
if (!attach)
197-
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
197+
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(executable) + "\""));
198198
if (this.prettyPrint)
199199
cmds.push(this.sendCommand("enable-pretty-printing"));
200200

src/gdb.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SSHArguments, ValuesFormattingMode } from './backend/backend';
66

77
export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
88
cwd: string;
9+
executable: string;
910
target: string;
1011
gdbpath: string;
1112
env: any;
@@ -60,6 +61,8 @@ class GDBDebugSession extends MI2DebugSession {
6061
this.setValuesFormattingMode(args.valuesFormatting);
6162
this.miDebugger.printCalls = !!args.printCalls;
6263
this.miDebugger.debugOutput = !!args.showDevDebugOutput;
64+
if (args.executable == undefined)
65+
args.executable = args.target; // legacy compatibility
6366
if (args.ssh !== undefined) {
6467
if (args.ssh.forwardX11 === undefined)
6568
args.ssh.forwardX11 = true;
@@ -74,7 +77,7 @@ class GDBDebugSession extends MI2DebugSession {
7477
this.isSSH = true;
7578
this.trimCWD = args.cwd.replace(/\\/g, "/");
7679
this.switchCWD = args.ssh.cwd;
77-
this.miDebugger.ssh(args.ssh, args.ssh.cwd, args.target, args.arguments, args.terminal, false).then(() => {
80+
this.miDebugger.ssh(args.ssh, args.ssh.cwd, args.executable, args.arguments, args.terminal, false).then(() => {
7881
if (args.autorun)
7982
args.autorun.forEach(command => {
8083
this.miDebugger.sendUserInput(command);
@@ -94,7 +97,7 @@ class GDBDebugSession extends MI2DebugSession {
9497
this.sendErrorResponse(response, 102, `Failed to SSH: ${err.toString()}`);
9598
});
9699
} else {
97-
this.miDebugger.load(args.cwd, args.target, args.arguments, args.terminal).then(() => {
100+
this.miDebugger.load(args.cwd, args.executable, args.arguments, args.terminal).then(() => {
98101
if (args.autorun)
99102
args.autorun.forEach(command => {
100103
this.miDebugger.sendUserInput(command);

0 commit comments

Comments
 (0)