Skip to content

Commit ae8a296

Browse files
Karl SmeltzerWebFreak001
authored andcommitted
make extra commands generic, use old version num
1 parent 36c8e38 commit ae8a296

File tree

4 files changed

+50
-10
lines changed

4 files changed

+50
-10
lines changed

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"native",
1010
"debug"
1111
],
12-
"version": "0.25.0",
12+
"version": "0.24.0",
1313
"publisher": "webfreak",
1414
"icon": "images/icon.png",
1515
"engines": {
@@ -259,6 +259,13 @@
259259
"description": "Additional arguments to pass to GDB",
260260
"default": []
261261
},
262+
"pathSubstitutions": {
263+
"type": "object",
264+
"description": "Help GDB find your source using path substitutions (GDB `substitute-path` variable",
265+
"default": {
266+
"<fromPath>": "<toPath>"
267+
}
268+
},
262269
"cwd": {
263270
"type": "string",
264271
"description": "Path of project",
@@ -522,6 +529,13 @@
522529
"description": "Additional arguments to pass to LLDB",
523530
"default": []
524531
},
532+
"pathSubstitutions": {
533+
"type": "object",
534+
"description": "Help LLDB find your source using path substitutions (LLDB `target.source-map` variable",
535+
"default": {
536+
"<fromPath>": "<toPath>"
537+
}
538+
},
525539
"valuesFormatting": {
526540
"type": "string",
527541
"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",
@@ -662,6 +676,13 @@
662676
"description": "Additional arguments to pass to LLDB",
663677
"default": []
664678
},
679+
"pathSubstitutions": {
680+
"type": "object",
681+
"description": "Help LLDB find your source using path substitutions (LLDB `target.source-map` variable",
682+
"default": {
683+
"<fromPath>": "<toPath>"
684+
}
685+
},
665686
"cwd": {
666687
"type": "string",
667688
"description": "Path of project",

src/backend/mi2/mi2.ts

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

3333
if (procEnv) {
@@ -197,10 +197,9 @@ 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-
};
200+
for (let cmd of this.extraCommands) {
201+
cmds.push(this.sendCommand(cmd));
202+
}
204203

205204
return cmds;
206205
}

src/gdb.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
1010
gdbpath: string;
1111
env: any;
1212
debugger_args: string[];
13-
pathSubstitutions: any;
13+
pathSubstitutions: { [index: string]: string };
1414
arguments: string;
1515
terminal: string;
1616
autorun: string[];
@@ -26,7 +26,7 @@ export interface AttachRequestArguments extends DebugProtocol.AttachRequestArgum
2626
gdbpath: string;
2727
env: any;
2828
debugger_args: string[];
29-
pathSubstitutions: any;
29+
pathSubstitutions: { [index: string]: string };
3030
executable: string;
3131
remote: boolean;
3232
autorun: string[];
@@ -50,7 +50,8 @@ class GDBDebugSession extends MI2DebugSession {
5050
}
5151

5252
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
53-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env, args.pathSubstitutions);
53+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env);
54+
this.setPathSubstitutions(args.pathSubstitutions);
5455
this.initDebugger();
5556
this.quit = false;
5657
this.attached = false;
@@ -119,7 +120,8 @@ class GDBDebugSession extends MI2DebugSession {
119120
}
120121

121122
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArguments): void {
122-
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env, args.pathSubstitutions);
123+
this.miDebugger = new MI2(args.gdbpath || "gdb", ["-q", "--interpreter=mi2"], args.debugger_args, args.env);
124+
this.setPathSubstitutions(args.pathSubstitutions);
123125
this.initDebugger();
124126
this.quit = false;
125127
this.attached = !args.remote;
@@ -179,6 +181,15 @@ class GDBDebugSession extends MI2DebugSession {
179181
}
180182
}
181183
}
184+
185+
// Add extra commands for source file path substitution in GDB-specific syntax
186+
protected setPathSubstitutions(substitutions: { [index: string]: string }): void {
187+
if (substitutions) {
188+
Object.keys(substitutions).forEach(source => {
189+
this.miDebugger.extraCommands.push("gdb-set substitute-path " + source + " " + substitutions[source]);
190+
})
191+
}
192+
}
182193
}
183194

184195
DebugSession.run(GDBDebugSession);

src/lldb.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ class LLDBDebugSession extends MI2DebugSession {
122122
this.sendResponse(response);
123123
});
124124
}
125+
126+
// Add extra commands for source file path substitution in LLDB-specific syntax
127+
protected setPathSubstitutions(substitutions: { [index: string]: string }): void {
128+
if (substitutions) {
129+
Object.keys(substitutions).forEach(source => {
130+
this.miDebugger.extraCommands.push("settings set target.source-map " + source + " " + substitutions[source]);
131+
})
132+
}
133+
}
125134
}
126135

127136
DebugSession.run(LLDBDebugSession);

0 commit comments

Comments
 (0)