Skip to content

Commit

Permalink
Allow to modify env for gdbserver process
Browse files Browse the repository at this point in the history
  • Loading branch information
arekzaluski authored and thegecko committed Nov 25, 2020
1 parent b020c8a commit 5994062
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
"type": "array",
"default": []
},
"gdbServerEnv": {
"description": "GDB server process env",
"type": "object"
},
"objdump": {
"type": "string",
"description": "Path to objdump executable",
Expand Down Expand Up @@ -158,6 +162,10 @@
"type": "array",
"default": []
},
"gdbServerEnv": {
"description": "GDB server process env",
"type": "object"
},
"objdump": {
"type": "string",
"description": "Path to objdump executable",
Expand Down
6 changes: 6 additions & 0 deletions src/abstract-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { spawn, ChildProcess } from 'child_process';
import { EventEmitter } from 'events';
import { dirname } from 'path';
import { CmsisRequestArguments } from './cmsis-debug-session';
import * as nodeProcess from 'process';

const TIMEOUT = 1000 * 10; // 10 seconds

Expand Down Expand Up @@ -57,6 +58,7 @@ export abstract class AbstractServer extends EventEmitter {
const serverArguments = await this.resolveServerArguments(this.args.gdbServerArguments);
this.process = spawn(command, serverArguments, {
cwd: dirname(command),
env: this.resolveServerEnv(this.args.gdbServerEnv ? this.args.gdbServerEnv as NodeJS.ProcessEnv : undefined )
});

if (!this.process) {
Expand Down Expand Up @@ -92,6 +94,10 @@ export abstract class AbstractServer extends EventEmitter {
return serverArguments || [];
}

private resolveServerEnv(serverEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
return serverEnv || nodeProcess.env;
}

protected onExit(code: number, signal: string) {
this.emit('exit', code, signal);

Expand Down
1 change: 1 addition & 0 deletions src/cmsis-debug-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface CmsisRequestArguments extends RequestArguments {
gdbCore?: number;
gdbServer?: string;
gdbServerArguments?: string[];
gdbServerEnv?: object;
objdump?: string;
}

Expand Down

0 comments on commit 5994062

Please sign in to comment.