| 50 | } |
| 51 | |
| 52 | export class OpenOCDServerController extends EventEmitter implements GDBServerController { |
| 53 | // We wont need all of these ports but reserve them anyways |
| 54 | public portsNeeded = ['gdbPort', 'tclPort', 'telnetPort', 'swoPort']; |
| 55 | public name = 'OpenOCD'; |
| 56 | private args: ConfigurationArguments; |
| 57 | private ports: { [name: string]: number }; |
| 58 | private rttHelper: RTTServerHelper = new RTTServerHelper(); |
| 59 | |
| 60 | constructor() { |
| 61 | super(); |
| 62 | } |
| 63 | |
| 64 | public setPorts(ports: { [name: string]: number }): void { |
| 65 | this.ports = ports; |
| 66 | } |
| 67 | |
| 68 | public setArguments(args: ConfigurationArguments): void { |
| 69 | this.args = args; |
| 70 | if (args.pvtOpenOCDDebug) { |
| 71 | doLog = true; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | public customRequest(command: string, response: DebugProtocol.Response, args: any): boolean { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | public initCommands(): string[] { |
| 80 | const gdbport = this.ports[createPortName(this.args.targetProcessor)]; |
| 81 | |
| 82 | return [ |
| 83 | `target-select extended-remote localhost:${gdbport}` |
| 84 | ]; |
| 85 | } |
| 86 | |
| 87 | public liveGdbInitCommands(): string[] { |
| 88 | return this.initCommands(); |
| 89 | } |
| 90 | |
| 91 | // ST/OpenOCD HACK: There are two problems. |
| 92 | // ST with their release on Dec 31 2021, released their FW/SW where it no longer works |
| 93 | // when any configuring is done after reset. It is more than likely something that |
| 94 | // was done with OpenOCD. As such, SWO config. fails. Basically, you cannot write to |
| 95 | // memory/registers before at least a fake stepi is done. |
| 96 | // |
| 97 | // OpenOCD itself has issues that it does not report a proper stack until you do a fake |
| 98 | // step. So, in some cases, your PC an the stack don't match resulting in wrong source |
| 99 | // being shown. |
| 100 | // |
| 101 | // OpenOCD provides a hack to synchronize gdb and itself by issuing 'monitor gdb_sync' followed |
| 102 | // by a 'stepi' which doesn't really do a stepi but can emulate a break due to a step that |
| 103 | // gdb expects |
| 104 | public launchCommands(): string[] { |
| 105 | const commands = [ |
| 106 | ...genDownloadCommands(this.args, ['interpreter-exec console "monitor reset halt"']), |
| 107 | 'interpreter-exec console "monitor reset halt"' |
| 108 | ]; |
| 109 | return commands; |
nothing calls this directly
no outgoing calls
no test coverage detected