-
Notifications
You must be signed in to change notification settings - Fork 122
Closed
Labels
Description
Hi @WebFreak001! Great work on your VS Code plugin! I am trying to replace the dreaded Eclipse for debugging microcontrollers and stumbled upon VS Code and Native Debug. However, the configuration options available did not support the extended-remote target of GDB, which would be nice to have for some debugging hardware.
The following is a works-for-me style hack that enables me to happily debug Cortex M microcontrollers using an external USB debugger like Black Magic Probe:
backend/mi2/mi2.js:176 ff.
attach(cwd, executable, target) {
this.log("stdout", "attaching " + target); // added
return new Promise((resolve, reject) => {
let args = [];
if (executable && !nativePath.isAbsolute(executable))
executable = nativePath.join(cwd, executable);
if (!executable)
executable = "-p";
if (target.startsWith("extended-remote")) // added
args = this.preargs; // added
else // added
args = args.concat([executable, target], this.preargs);
this.process = ChildProcess.spawn(this.application, args, { cwd: cwd });
this.process.stdout.on("data", this.stdout.bind(this));
this.process.stderr.on("data", this.stderr.bind(this));
this.process.on("exit", (() => { this.emit("quit"); }).bind(this));
Promise.all([
this.sendCommand("gdb-set target-async on"),
this.sendCommand("environment-directory \"" + escape(cwd) + "\""), // appended comma
this.sendCommand("target-select " + escape(target)), // added (this should only be here for extended-remote)
this.sendCommand("file-symbol-file \"" + escape(executable) + "\"") // added (this should only be here for extended-remote)
]).then(() => {
this.emit("debug-ready");
resolve();
}, reject);
});
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "BMPv2",
"type": "gdb",
"request": "attach",
"gdbpath": "~/gcc-arm-none-eabi-5_2-2015q4/bin/arm-none-eabi-gdb",
"target": "extended-remote /dev/cu.usbmodemXXXXXXXX",
"executable": "my-arm-executable.elf",
"cwd": "${workspaceRoot}",
"autorun": [
"monitor tpwr enable",
"monitor swdp_scan",
"attach 1",
"load my-arm-executable.elf"
]
}
]
}