Skip to content

Commit d254399

Browse files
authored
Merge pull request #87 from Mrmaxmeier/add-gdbargs-config-option
Add config option to pass arguments to GDB
2 parents a32c8b5 + c53c85e commit d254399

6 files changed

Lines changed: 48 additions & 9 deletions

File tree

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
sudo: false
2-
2+
language: node_js
3+
node_js:
4+
- stable
35
os:
46
- osx
57
- linux

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
"description": "Path to the gdb executable or the command if in PATH",
9292
"default": "gdb"
9393
},
94+
"debugger_args": {
95+
"type": "array",
96+
"description": "Additional arguments to pass to GDB",
97+
"default": []
98+
},
9499
"printCalls": {
95100
"type": "boolean",
96101
"description": "Prints all GDB calls to the console",
@@ -201,6 +206,11 @@
201206
"description": "Path to the gdb executable or the command if in PATH",
202207
"default": "gdb"
203208
},
209+
"debugger_args": {
210+
"type": "array",
211+
"description": "Additional arguments to pass to GDB",
212+
"default": []
213+
},
204214
"cwd": {
205215
"type": "string",
206216
"description": "Path of project",
@@ -284,6 +294,11 @@
284294
"description": "Path to the lldb-mi executable or the command if in PATH",
285295
"default": "lldb-mi"
286296
},
297+
"debugger_args": {
298+
"type": "array",
299+
"description": "Additional arguments to pass to LLDB",
300+
"default": []
301+
},
287302
"printCalls": {
288303
"type": "boolean",
289304
"description": "Prints all lldb calls to the console",
@@ -389,6 +404,11 @@
389404
"description": "Path to the lldb-mi executable or the command if in PATH",
390405
"default": "lldb-mi"
391406
},
407+
"debugger_args": {
408+
"type": "array",
409+
"description": "Additional arguments to pass to LLDB",
410+
"default": []
411+
},
392412
"cwd": {
393413
"type": "string",
394414
"description": "Path of project",
@@ -450,6 +470,11 @@
450470
"description": "Path to the mago-mi executable or the command if in PATH",
451471
"default": "mago-mi"
452472
},
473+
"debugger_args": {
474+
"type": "array",
475+
"description": "Additional arguments to pass to mago",
476+
"default": []
477+
},
453478
"printCalls": {
454479
"type": "boolean",
455480
"description": "Prints all mago calls to the console",
@@ -495,6 +520,11 @@
495520
"description": "Path to the mago-mi executable or the command if in PATH",
496521
"default": "mago-mi"
497522
},
523+
"debugger_args": {
524+
"type": "array",
525+
"description": "Additional arguments to pass to mago",
526+
"default": []
527+
},
498528
"cwd": {
499529
"type": "string",
500530
"description": "Path of project",

src/backend/mi2/mi2.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function couldBeOutput(line: string) {
2727
const trace = false;
2828

2929
export class MI2 extends EventEmitter implements IBackend {
30-
constructor(public application: string, public preargs: string[]) {
30+
constructor(public application: string, public preargs: string[], public extraargs: string[]) {
3131
super();
3232
}
3333

@@ -36,7 +36,8 @@ export class MI2 extends EventEmitter implements IBackend {
3636
target = nativePath.join(cwd, target);
3737
return new Promise((resolve, reject) => {
3838
this.isSSH = false;
39-
this.process = ChildProcess.spawn(this.application, this.preargs, { cwd: cwd });
39+
let args = this.preargs.concat(this.extraargs || []);
40+
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd });
4041
this.process.stdout.on("data", this.stdout.bind(this));
4142
this.process.stderr.on("data", this.stderr.bind(this));
4243
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));

src/gdb.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface LaunchRequestArguments {
88
cwd: string;
99
target: string;
1010
gdbpath: string;
11+
debugger_args: string[];
1112
arguments: string;
1213
terminal: string;
1314
autorun: string[];
@@ -20,6 +21,7 @@ export interface AttachRequestArguments {
2021
cwd: string;
2122
target: string;
2223
gdbpath: string;
24+
debugger_args: string[];
2325
executable: string;
2426
remote: boolean;
2527
autorun: string[];
@@ -40,7 +42,7 @@ class GDBDebugSession extends MI2DebugSession {
4042
}
4143

4244
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
43-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"]);
45+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args);
4446
this.initDebugger();
4547
this.quit = false;
4648
this.attached = false;
@@ -109,7 +111,7 @@ class GDBDebugSession extends MI2DebugSession {
109111
}
110112

111113
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
112-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"]);
114+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args);
113115
this.initDebugger();
114116
this.quit = false;
115117
this.attached = !args.remote;

src/lldb.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface LaunchRequestArguments {
88
cwd: string;
99
target: string;
1010
lldbmipath: string;
11+
debugger_args: string[];
1112
arguments: string;
1213
autorun: string[];
1314
ssh: SSHArguments;
@@ -19,6 +20,7 @@ export interface AttachRequestArguments {
1920
cwd: string;
2021
target: string;
2122
lldbmipath: string;
23+
debugger_args: string[];
2224
executable: string;
2325
autorun: string[];
2426
printCalls: boolean;
@@ -36,7 +38,7 @@ class LLDBDebugSession extends MI2DebugSession {
3638
}
3739

3840
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
39-
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", []);
41+
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args);
4042
this.initDebugger();
4143
this.quit = false;
4244
this.attached = false;
@@ -97,7 +99,7 @@ class LLDBDebugSession extends MI2DebugSession {
9799
}
98100

99101
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
100-
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", []);
102+
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args);
101103
this.initDebugger();
102104
this.quit = false;
103105
this.attached = true;

src/mago.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface LaunchRequestArguments {
88
cwd: string;
99
target: string;
1010
magomipath: string;
11+
debugger_args: string[];
1112
arguments: string;
1213
autorun: string[];
1314
printCalls: boolean;
@@ -18,6 +19,7 @@ export interface AttachRequestArguments {
1819
cwd: string;
1920
target: string;
2021
magomipath: string;
22+
debugger_args: string[];
2123
executable: string;
2224
autorun: string[];
2325
printCalls: boolean;
@@ -43,7 +45,7 @@ class MagoDebugSession extends MI2DebugSession {
4345
}
4446

4547
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
46-
this.miDebugger = new MI2_Mago(args.magomipath || "mago-mi", ["-q"]);
48+
this.miDebugger = new MI2_Mago(args.magomipath || "mago-mi", ["-q"], args.debugger_args);
4749
this.initDebugger();
4850
this.quit = false;
4951
this.attached = false;
@@ -72,7 +74,7 @@ class MagoDebugSession extends MI2DebugSession {
7274
}
7375

7476
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
75-
this.miDebugger = new MI2_Mago(args.magomipath || "mago-mi", []);
77+
this.miDebugger = new MI2_Mago(args.magomipath || "mago-mi", [], args.debugger_args);
7678
this.initDebugger();
7779
this.quit = false;
7880
this.attached = true;

0 commit comments

Comments
 (0)