From 318ece44cf3a5d51222a9c2e8031b7c1fdc46894 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Mon, 9 Jan 2017 00:33:21 +0100 Subject: [PATCH] Added special commands for extended-remote fix #91 --- package.json | 18 ++++++++++++++++++ src/backend/mi2/mi2.ts | 16 +++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a044a76..8824924 100644 --- a/package.json +++ b/package.json @@ -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}" + ] + } } ] }, diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index 22f45de..5f340bb 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -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);