Added special commands for extended-remote fix #91

This commit is contained in:
WebFreak001 2017-01-09 00:33:21 +01:00
commit 318ece44cf
2 changed files with 31 additions and 3 deletions

View file

@ -365,6 +365,24 @@
"x11port": 6000
}
}
},
{
"label": "GDB: Debug external embedded device",
"description": "Debugs an embedded microcontroller supported by GDB by attaching over extended-remote",
"body": {
"type": "gdb",
"request": "launch",
"name": "${6:Debug Microcontroller}",
"target": "extended-remote ${2:/dev/cu.usbmodem00000000}",
"executable": "${1:./bin/executable.elf}",
"cwd": "^\"\\${workspaceRoot}\"",
"autorun": [
"monitor tpwr enable",
"monitor swdp_scan",
"attach 1",
"load ${1:./bin/executable.elf}"
]
}
}
]
},

View file

@ -186,15 +186,25 @@ export class MI2 extends EventEmitter implements IBackend {
executable = nativePath.join(cwd, executable);
if (!executable)
executable = "-p";
args = args.concat([executable, target], this.preargs);
var isExtendedRemote = false;
if (target.startsWith("extended-remote")) {
isExtendedRemote = true;
args = this.preargs;
} else
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([
var commands = [
this.sendCommand("gdb-set target-async on"),
this.sendCommand("environment-directory \"" + escape(cwd) + "\"")
]).then(() => {
];
if (isExtendedRemote) {
commands.push(this.sendCommand("target-select " + target));
commands.push(this.sendCommand("file-symbol-file \"" + escape(executable) + "\""));
}
Promise.all(commands).then(() => {
this.emit("debug-ready")
resolve();
}, reject);