Skip to content

Commit 318ece4

Browse files
author
WebFreak001
committed
Added special commands for extended-remote fix WebFreak001#91
1 parent 3738f4f commit 318ece4

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,24 @@
365365
"x11port": 6000
366366
}
367367
}
368+
},
369+
{
370+
"label": "GDB: Debug external embedded device",
371+
"description": "Debugs an embedded microcontroller supported by GDB by attaching over extended-remote",
372+
"body": {
373+
"type": "gdb",
374+
"request": "launch",
375+
"name": "${6:Debug Microcontroller}",
376+
"target": "extended-remote ${2:/dev/cu.usbmodem00000000}",
377+
"executable": "${1:./bin/executable.elf}",
378+
"cwd": "^\"\\${workspaceRoot}\"",
379+
"autorun": [
380+
"monitor tpwr enable",
381+
"monitor swdp_scan",
382+
"attach 1",
383+
"load ${1:./bin/executable.elf}"
384+
]
385+
}
368386
}
369387
]
370388
},

src/backend/mi2/mi2.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,25 @@ export class MI2 extends EventEmitter implements IBackend {
186186
executable = nativePath.join(cwd, executable);
187187
if (!executable)
188188
executable = "-p";
189-
args = args.concat([executable, target], this.preargs);
189+
var isExtendedRemote = false;
190+
if (target.startsWith("extended-remote")) {
191+
isExtendedRemote = true;
192+
args = this.preargs;
193+
} else
194+
args = args.concat([executable, target], this.preargs);
190195
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd });
191196
this.process.stdout.on("data", this.stdout.bind(this));
192197
this.process.stderr.on("data", this.stderr.bind(this));
193198
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
194-
Promise.all([
199+
var commands = [
195200
this.sendCommand("gdb-set target-async on"),
196201
this.sendCommand("environment-directory \"" + escape(cwd) + "\"")
197-
]).then(() => {
202+
];
203+
if (isExtendedRemote) {
204+
commands.push(this.sendCommand("target-select " + target));
205+
commands.push(this.sendCommand("file-symbol-file \"" + escape(executable) + "\""));
206+
}
207+
Promise.all(commands).then(() => {
198208
this.emit("debug-ready")
199209
resolve();
200210
}, reject);

0 commit comments

Comments
 (0)