Skip to content

Commit 74cdeb1

Browse files
committed
RTT timestamp and other minor changes
1 parent 77bbab2 commit 74cdeb1

File tree

7 files changed

+6846
-24
lines changed

7 files changed

+6846
-24
lines changed

package-lock.json

Lines changed: 6798 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,11 @@
673673
"type": "string",
674674
"default": ""
675675
},
676+
"timestamp": {
677+
"description": "Add timestamps while printing for 'console' type. 'binary' type always prints timestamps",
678+
"type": "boolean",
679+
"default": false
680+
},
676681
"encoding": {
677682
"type": "string",
678683
"description": "How binary data bytes are converted into a number. All little-endian",
@@ -1507,6 +1512,11 @@
15071512
"type": "string",
15081513
"default": ""
15091514
},
1515+
"timestamp": {
1516+
"description": "Add timestamps while printing for 'console' type. 'binary' type always prints timestamps",
1517+
"type": "boolean",
1518+
"default": false
1519+
},
15101520
"encoding": {
15111521
"type": "string",
15121522
"description": "How binary data bytes are converted into a number. All little-endian",

src/backend/mi2/mi2.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ export class MI2 extends EventEmitter implements IBackend {
147147
this.handlers[parsed.token](parsed);
148148
delete this.handlers[parsed.token];
149149
handled = true;
150+
} else {
151+
this.log('stderr', `Internal Error? Multiple results or no handler for query token '${parsed.token}''`);
150152
}
151153
}
152154
if (!handled && parsed.resultRecords && parsed.resultRecords.resultClass === 'error') {

src/backend/server.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,35 @@ export class GDBServer extends EventEmitter {
6363
});
6464
}
6565

66+
private exitTimeout: NodeJS.Timeout = null;
6667
public exit(): void {
6768
if (this.process) {
68-
console.log('GDBServer: forcing an exit')
69-
this.process.kill();
70-
this.process = null;
69+
try {
70+
console.log('GDBServer: forcing an exit with SIGNINT');
71+
// A log of gdb-servers want to recieve an Control-C equivalent first, so try that for
72+
// a bit more graceful exit
73+
this.process.kill('SIGINT');
74+
setTimeout(() => {
75+
if (process != null) { // Still not dead?
76+
console.log('GDBServer: forcing an exit with SIGTERM');
77+
this.process.kill();
78+
}
79+
this.process = null;
80+
} , 1000);
81+
}
82+
catch (e) {
83+
console.log(`Tring to force and exit failed ${e}`);
84+
}
7185
}
7286
}
7387

7488
private onExit(code, signal) {
7589
console.log(`GDBServer: exited ${code} ${signal}`);
7690
this.process = null;
91+
if (this.exitTimeout) {
92+
clearTimeout(this.exitTimeout);
93+
this.exitTimeout = null;
94+
}
7795
this.emit('exit', code, signal);
7896
this.disconnectConsole();
7997
}

src/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export interface RTTConsoleDecoderOpts extends RTTCommonDecoderOpts {
105105
logfile: string; // log IO to file
106106
inputmode: TerminalInputMode;
107107
iencoding: TextEncoding; // Encoding used for input
108+
timestamp: boolean;
108109
// Binary only options
109110
scale: number;
110111
encoding: BinaryEncoding;

src/gdb.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ export class GDBDebugSession extends DebugSession {
347347
}
348348

349349
if (executable) {
350-
this.handleMsg('log', `Please check OUTPUT tab (Adapter Output) for output from ${executable}` + '\n');
350+
this.handleMsg('log', `Please check TERMINAL tab (gdb-server) for output from ${executable}` + '\n');
351351
const dbgMsg = `Launching server: "${executable}" ` + args.map((s) => {
352352
return '"' + s.replace(/"/g, '\\"') + '"';
353353
}).join(' ') + '\n';
@@ -1326,8 +1326,7 @@ export class GDBDebugSession extends DebugSession {
13261326
if (brkp instanceof MIError) {
13271327
/* Failed breakpoints should be reported with
13281328
* verified: false, so they can be greyed out
1329-
* in the UI. The attached message will be
1330-
* presented as a tooltip.
1329+
* in the UI.
13311330
*/
13321331
return {
13331332
verified: false,

src/jlink.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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';
33
import * as os from 'os';
44
import { EventEmitter } from 'events';
55

@@ -28,7 +28,16 @@ export class JLinkServerController extends EventEmitter implements GDBServerCont
2828

2929
// JLink only support one TCP port and that too for channel 0 only. The config provider
3030
// 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+
}
3241
}
3342

3443
public customRequest(command: string, response: DebugProtocol.Response, args: any): boolean {
@@ -156,7 +165,7 @@ export class JLinkServerController extends EventEmitter implements GDBServerCont
156165
// If we are getting here, we will need some serious re-factoring
157166
throw new Error('Asynchronous timing error. Could not allocate all the ports needed in time.');
158167
}
159-
cmdargs.push('-rtttelnetport', this.rttHelper.rttLocalPortMap[0]);
168+
cmdargs.push('-rtttelnetport', this.rttHelper.rttLocalPortMap[0] || this.defaultRttPort.toString());
160169
}
161170

162171
if (this.args.serialNumber) {

0 commit comments

Comments
 (0)