()
| 207 | // from the gdb-server (like OpenOCD) is sent here and sent to the terminal |
| 208 | // and any usr input in the terminal is sent back (like semi-hosting) |
| 209 | public startServer(): Promise<void> { |
| 210 | return new Promise((resolve, reject) => { |
| 211 | getAnyFreePort(55878).then((p) => { |
| 212 | this.toBackendPort = p; |
| 213 | const newServer = net.createServer(this.onBackendConnect.bind(this)); |
| 214 | newServer.listen(this.toBackendPort, '127.0.0.1', () => { |
| 215 | this.toBackendServer = newServer; |
| 216 | GDBServerConsole.BackendPort = this.toBackendPort; |
| 217 | resolve(); |
| 218 | }); |
| 219 | newServer.on(('error'), (e) => { |
| 220 | console.error(e); |
| 221 | reject(e); |
| 222 | }); |
| 223 | newServer.on('close', () => { |
| 224 | this.toBackendServer = null; |
| 225 | }); |
| 226 | }); |
| 227 | }); |
| 228 | } |
| 229 | |
| 230 | // The gdb-server running in the backend (debug adapter) |
| 231 | protected onBackendConnect(socket: net.Socket) { |
no test coverage detected