Skip to content

Commit 36c8e38

Browse files
Karl SmeltzerWebFreak001
authored andcommitted
add support for gdb path substitution
1 parent 5ac331e commit 36c8e38

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"native",
1010
"debug"
1111
],
12-
"version": "0.24.0",
12+
"version": "0.25.0",
1313
"publisher": "webfreak",
1414
"icon": "images/icon.png",
1515
"engines": {
@@ -107,6 +107,13 @@
107107
"description": "Additional arguments to pass to GDB",
108108
"default": []
109109
},
110+
"pathSubstitutions": {
111+
"type": "object",
112+
"description": "Help GDB find your source using path substitutions (GDB `substitute-path` variable",
113+
"default": {
114+
"<fromPath>": "<toPath>"
115+
}
116+
},
110117
"valuesFormatting": {
111118
"type": "string",
112119
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",

src/backend/mi2/mi2.ts

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

3333
if (procEnv) {
@@ -197,6 +197,10 @@ export class MI2 extends EventEmitter implements IBackend {
197197
cmds.push(this.sendCommand("file-exec-and-symbols \"" + escape(target) + "\""));
198198
if (this.prettyPrint)
199199
cmds.push(this.sendCommand("enable-pretty-printing"));
200+
201+
for (const key in this.pathSubstitutions) {
202+
cmds.push(this.sendCommand("gdb-set substitute-path " + key + " " + this.pathSubstitutions[key]));
203+
};
200204

201205
return cmds;
202206
}

src/gdb.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
1010
gdbpath: string;
1111
env: any;
1212
debugger_args: string[];
13+
pathSubstitutions: any;
1314
arguments: string;
1415
terminal: string;
1516
autorun: string[];
@@ -25,6 +26,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
2526
gdbpath: string;
2627
env: any;
2728
debugger_args: string[];
29+
pathSubstitutions: any;
2830
executable: string;
2931
remote: boolean;
3032
autorun: string[];
@@ -48,7 +50,7 @@ class GDBDebugSession extends MI2DebugSession {
4850
}
4951

5052
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
51-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env);
53+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env, args.pathSubstitutions);
5254
this.initDebugger();
5355
this.quit = false;
5456
this.attached = false;
@@ -117,7 +119,7 @@ class GDBDebugSession extends MI2DebugSession {
117119
}
118120

119121
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
120-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env);
122+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env, args.pathSubstitutions);
121123
this.initDebugger();
122124
this.quit = false;
123125
this.attached = !args.remote;

0 commit comments

Comments
 (0)