Skip to content

Commit a21e2e6

Browse files
author
WebFreak001
committed
Fix #98
1 parent edfac8e commit a21e2e6

File tree

6 files changed

+47
-11
lines changed

6 files changed

+47
-11
lines changed

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+
"env": {
95+
"type": "object",
96+
"description": "Environment overriding the gdb (and in turn also the process) environment",
97+
"default": null
98+
},
9499
"debugger_args": {
95100
"type": "array",
96101
"description": "Additional arguments to pass to GDB",
@@ -206,6 +211,11 @@
206211
"description": "Path to the gdb executable or the command if in PATH",
207212
"default": "gdb"
208213
},
214+
"env": {
215+
"type": "object",
216+
"description": "Environment overriding the gdb (and in turn also the process) environment",
217+
"default": null
218+
},
209219
"debugger_args": {
210220
"type": "array",
211221
"description": "Additional arguments to pass to GDB",
@@ -446,6 +456,11 @@
446456
"description": "Path to the lldb-mi executable or the command if in PATH",
447457
"default": "lldb-mi"
448458
},
459+
"env": {
460+
"type": "object",
461+
"description": "Environment overriding the lldb-mi (and in turn also the process) environment",
462+
"default": null
463+
},
449464
"debugger_args": {
450465
"type": "array",
451466
"description": "Additional arguments to pass to LLDB",
@@ -556,6 +571,11 @@
556571
"description": "Path to the lldb-mi executable or the command if in PATH",
557572
"default": "lldb-mi"
558573
},
574+
"env": {
575+
"type": "object",
576+
"description": "Environment overriding the lldb-mi (and in turn also the process) environment",
577+
"default": null
578+
},
559579
"debugger_args": {
560580
"type": "array",
561581
"description": "Additional arguments to pass to LLDB",
@@ -683,6 +703,11 @@
683703
"description": "Path to the mago-mi executable or the command if in PATH",
684704
"default": "mago-mi"
685705
},
706+
"env": {
707+
"type": "object",
708+
"description": "Environment overriding the mago-mi (and in turn also the process) environment",
709+
"default": null
710+
},
686711
"debugger_args": {
687712
"type": "array",
688713
"description": "Additional arguments to pass to mago",
@@ -733,6 +758,11 @@
733758
"description": "Path to the mago-mi executable or the command if in PATH",
734759
"default": "mago-mi"
735760
},
761+
"env": {
762+
"type": "object",
763+
"description": "Environment overriding the mago-mi (and in turn also the process) environment",
764+
"default": null
765+
},
736766
"debugger_args": {
737767
"type": "array",
738768
"description": "Additional arguments to pass to mago",

src/backend/mi2/mi2.ts

Lines changed: 4 additions & 4 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[], public extraargs: string[]) {
30+
constructor(public application: string, public preargs: string[], public extraargs: string[], public procEnv: any) {
3131
super();
3232
}
3333

@@ -37,7 +37,7 @@ export class MI2 extends EventEmitter implements IBackend {
3737
return new Promise((resolve, reject) => {
3838
this.isSSH = false;
3939
let args = this.preargs.concat(this.extraargs || []);
40-
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd });
40+
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
4141
this.process.stdout.on("data", this.stdout.bind(this));
4242
this.process.stderr.on("data", this.stderr.bind(this));
4343
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
@@ -193,7 +193,7 @@ export class MI2 extends EventEmitter implements IBackend {
193193
args = this.preargs;
194194
} else
195195
args = args.concat([executable, target], this.preargs);
196-
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd });
196+
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
197197
this.process.stdout.on("data", this.stdout.bind(this));
198198
this.process.stderr.on("data", this.stderr.bind(this));
199199
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
@@ -222,7 +222,7 @@ export class MI2 extends EventEmitter implements IBackend {
222222
args = args.concat([executable], this.preargs);
223223
else
224224
args = this.preargs;
225-
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd });
225+
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd, env: this.procEnv });
226226
this.process.stdout.on("data", this.stdout.bind(this));
227227
this.process.stderr.on("data", this.stderr.bind(this));
228228
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));

src/backend/mi2/mi2lldb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class MI2_LLDB extends MI2 {
2525

2626
attach(cwd: string, executable: string, target: string): Thenable<any> {
2727
return new Promise((resolve, reject) => {
28-
this.process = ChildProcess.spawn(this.application, this.preargs, { cwd: cwd });
28+
this.process = ChildProcess.spawn(this.application, this.preargs, { cwd: cwd, env: this.procEnv });
2929
this.process.stdout.on("data", this.stdout.bind(this));
3030
this.process.stderr.on("data", this.stderr.bind(this));
3131
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+
env: any;
1112
debugger_args: string[];
1213
arguments: string;
1314
terminal: string;
@@ -21,6 +22,7 @@ export interface AttachRequestArguments {
2122
cwd: string;
2223
target: string;
2324
gdbpath: string;
25+
env: any;
2426
debugger_args: string[];
2527
executable: string;
2628
remote: boolean;
@@ -43,7 +45,7 @@ class GDBDebugSession extends MI2DebugSession {
4345
}
4446

4547
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
46-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args);
48+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env);
4749
this.initDebugger();
4850
this.quit = false;
4951
this.attached = false;
@@ -112,7 +114,7 @@ class GDBDebugSession extends MI2DebugSession {
112114
}
113115

114116
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
115-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args);
117+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env);
116118
this.initDebugger();
117119
this.quit = false;
118120
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+
env: any;
1112
debugger_args: string[];
1213
arguments: string;
1314
autorun: string[];
@@ -20,6 +21,7 @@ export interface AttachRequestArguments {
2021
cwd: string;
2122
target: string;
2223
lldbmipath: string;
24+
env: any;
2325
debugger_args: string[];
2426
executable: string;
2527
autorun: string[];
@@ -38,7 +40,7 @@ class LLDBDebugSession extends MI2DebugSession {
3840
}
3941

4042
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
41-
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args);
43+
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args, args.env);
4244
this.initDebugger();
4345
this.quit = false;
4446
this.attached = false;
@@ -99,7 +101,7 @@ class LLDBDebugSession extends MI2DebugSession {
99101
}
100102

101103
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
102-
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args);
104+
this.miDebugger = new MI2_LLDB(args.lldbmipath || "lldb-mi", [], args.debugger_args, args.env);
103105
this.initDebugger();
104106
this.quit = false;
105107
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+
env: any;
1112
debugger_args: string[];
1213
arguments: string;
1314
autorun: string[];
@@ -19,6 +20,7 @@ export interface AttachRequestArguments {
1920
cwd: string;
2021
target: string;
2122
magomipath: string;
23+
env: any;
2224
debugger_args: string[];
2325
executable: string;
2426
autorun: string[];
@@ -45,7 +47,7 @@ class MagoDebugSession extends MI2DebugSession {
4547
}
4648

4749
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
48-
this.miDebugger = new MI2_Mago(args.magomipath || "mago-mi", ["-q"], args.debugger_args);
50+
this.miDebugger = new MI2_Mago(args.magomipath || "mago-mi", ["-q"], args.debugger_args, args.env);
4951
this.initDebugger();
5052
this.quit = false;
5153
this.attached = false;
@@ -74,7 +76,7 @@ class MagoDebugSession extends MI2DebugSession {
7476
}
7577

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

0 commit comments

Comments
 (0)