|
1 | 1 | import { DebugProtocol } from 'vscode-debugprotocol'; |
2 | | -import { GDBServerController, ConfigurationArguments, calculatePortMask, createPortName,SWOConfigureEvent, getAnyFreePort, parseHexOrDecInt, RTTConfigureEvent, RTTServerHelper } from './common'; |
| 2 | +import { GDBServerController, ConfigurationArguments, calculatePortMask, createPortName,SWOConfigureEvent, parseHexOrDecInt, RTTServerHelper } from './common'; |
3 | 3 | import * as os from 'os'; |
4 | 4 | import { EventEmitter } from 'events'; |
5 | 5 |
|
@@ -28,7 +28,16 @@ export class JLinkServerController extends EventEmitter implements GDBServerCont |
28 | 28 |
|
29 | 29 | // JLink only support one TCP port and that too for channel 0 only. The config provider |
30 | 30 | // makes sure that the rttConfig conforms. |
31 | | - this.rttHelper.allocateRTTPorts(args.rttConfig, this.defaultRttPort); |
| 31 | + if (args.rttConfig && args.rttConfig.enabled && (!args.rttConfig.decoders || (args.rttConfig.decoders.length === 0))) { |
| 32 | + // We do the RTT setup and pass the right args to JLink but not actually use the TCP Port ourselves. Decided |
| 33 | + // Not to allocate a free port in this case either. |
| 34 | + |
| 35 | + // getAnyFreePort(this.defaultRttPort).then((p) => { |
| 36 | + // this.defaultRttPort = p; |
| 37 | + // }); |
| 38 | + } else { |
| 39 | + this.rttHelper.allocateRTTPorts(args.rttConfig, this.defaultRttPort); |
| 40 | + } |
32 | 41 | } |
33 | 42 |
|
34 | 43 | public customRequest(command: string, response: DebugProtocol.Response, args: any): boolean { |
@@ -156,7 +165,7 @@ export class JLinkServerController extends EventEmitter implements GDBServerCont |
156 | 165 | // If we are getting here, we will need some serious re-factoring |
157 | 166 | throw new Error('Asynchronous timing error. Could not allocate all the ports needed in time.'); |
158 | 167 | } |
159 | | - cmdargs.push('-rtttelnetport', this.rttHelper.rttLocalPortMap[0]); |
| 168 | + cmdargs.push('-rtttelnetport', this.rttHelper.rttLocalPortMap[0] || this.defaultRttPort.toString()); |
160 | 169 | } |
161 | 170 |
|
162 | 171 | if (this.args.serialNumber) { |
|
0 commit comments