Skip to content

Commit ede2a3d

Browse files
committed
Implement observer-based debug item value display.
1 parent 324949c commit ede2a3d

14 files changed

+448
-296
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"eslint.useFlatConfig": true,
44
"[typescript]": {
55
"editor.codeActionsOnSave": {
6-
"source.fixAll": "explicit",
6+
"source.removeUnusedImports": "always",
7+
"source.fixAll.eslint": "always"
78
}
89
},
910
}

eslint.config.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,29 @@ module.exports = [
1010
'parser': require('@typescript-eslint/parser'),
1111
},
1212
'plugins': {
13-
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
13+
'@stylistic': require('@stylistic/eslint-plugin'),
14+
'@typescript': require('@typescript-eslint/eslint-plugin'),
1415
},
1516
'rules': {
16-
'semi': 'error',
1717
'no-throw-literal': 'error',
18+
'semi': 'error',
19+
'no-extra-semi': 'error',
20+
'eqeqeq': 'error',
21+
'prefer-const': 'warn',
1822
'curly': 'warn',
19-
'eqeqeq': 'warn',
20-
'@typescript-eslint/naming-convention': [
23+
'@typescript/naming-convention': [
2124
'warn',
2225
{
2326
'selector': 'import',
2427
'format': [ 'camelCase', 'PascalCase' ]
2528
}
2629
],
30+
'@stylistic/indent': ['warn', 4],
31+
'@stylistic/quotes': ['warn', 'single'],
32+
'@stylistic/brace-style': ['warn', '1tbs'],
33+
'@stylistic/curly-newline': ['warn', {'minElements': 1, 'consistent': true}],
34+
'@stylistic/keyword-spacing': 'warn',
35+
'@stylistic/space-before-blocks': 'warn',
2736
},
2837
}
2938
];

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,12 @@
214214
"@types/vscode": "^1.94",
215215
"@typescript-eslint/eslint-plugin": "^8",
216216
"@typescript-eslint/parser": "^8",
217+
"@vscode/vsce": "^3.x",
217218
"esbuild": "^0.24",
218219
"eslint": "^9.12",
219-
"typescript": "5.5.x",
220-
"@vscode/vsce": "^3.x"
220+
"typescript": "5.5.x"
221+
},
222+
"dependencies": {
223+
"@stylistic/eslint-plugin": "^2.9.0"
221224
}
222225
}

src/cxxrtl/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ export class Connection {
4545
}
4646

4747
private traceSend(packet: proto.ClientPacket) {
48-
this.timestamps.push(new Date());
4948
if (packet.type === 'greeting') {
50-
console.debug(`[CXXRTL] C>S`, packet);
49+
console.debug('[CXXRTL] C>S', packet);
5150
} else if (packet.type === 'command') {
51+
this.timestamps.push(new Date());
5252
console.debug(`[CXXRTL] C>S#${this.sendIndex++}`, packet);
5353
}
5454
}
5555

5656
private traceRecv(packet: proto.ServerPacket) {
5757
if (packet.type === 'greeting') {
58-
console.debug(`[CXXRTL] S>C`, packet);
58+
console.debug('[CXXRTL] S>C', packet);
5959
} else if (packet.type === 'response') {
6060
const elapsed = new Date().getTime() - this.timestamps.shift()!.getTime();
6161
console.debug(`[CXXRTL] S>C#${this.recvIndex++}`, packet, `(${elapsed}ms)`);
6262
} else if (packet.type === 'error') {
6363
this.timestamps.shift();
6464
console.error(`[CXXRTL] S>C#${this.recvIndex++}`, packet);
6565
} else if (packet.type === 'event') {
66-
console.debug(`[CXXRTL] S>C`, packet);
66+
console.debug('[CXXRTL] S>C', packet);
6767
}
6868
}
6969

src/cxxrtl/link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface ILink {
99
onDone: () => Promise<void>;
1010

1111
send(packet: proto.ClientPacket): Promise<void>;
12-
};
12+
}
1313

1414
export class MockLink implements ILink {
1515
constructor(

src/debugger.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TimeInterval, TimePoint } from './model/time';
66
import { Scope } from './model/scope';
77
import { Variable } from './model/variable';
88
import { StatusBarItem } from './ui/status';
9-
import { BoundReference, Reference, Sample } from './model/sample';
9+
import { Reference, UnboundReference, Sample } from './model/sample';
1010

1111
export enum CXXRTLSimulationStatus {
1212
Paused = 'paused',
@@ -28,12 +28,16 @@ export class CXXRTLDebugger {
2828
// Session properties.
2929

3030
private _sessionStatus: CXXRTLSessionStatus = CXXRTLSessionStatus.Absent;
31-
public get sessionStatus() { return this._sessionStatus;}
31+
public get sessionStatus() {
32+
return this._sessionStatus;
33+
}
3234
private _onDidChangeSessionStatus: vscode.EventEmitter<CXXRTLSessionStatus> = new vscode.EventEmitter<CXXRTLSessionStatus>();
3335
readonly onDidChangeSessionStatus: vscode.Event<CXXRTLSessionStatus> = this._onDidChangeSessionStatus.event;
3436

3537
private _currentTime: TimePoint = new TimePoint(0n, 0n);
36-
public get currentTime() { return this._currentTime;}
38+
public get currentTime() {
39+
return this._currentTime;
40+
}
3741
private _onDidChangeCurrentTime: vscode.EventEmitter<TimePoint> = new vscode.EventEmitter<TimePoint>();
3842
readonly onDidChangeCurrentTime: vscode.Event<TimePoint> = this._onDidChangeCurrentTime.event;
3943

@@ -42,12 +46,16 @@ export class CXXRTLDebugger {
4246
private simulationStatusUpdateTimeout: NodeJS.Timeout | null = null;
4347

4448
private _simulationStatus: CXXRTLSimulationStatus = CXXRTLSimulationStatus.Finished;
45-
public get simulationStatus() { return this._simulationStatus; }
49+
public get simulationStatus() {
50+
return this._simulationStatus;
51+
}
4652
private _onDidChangeSimulationStatus: vscode.EventEmitter<CXXRTLSimulationStatus> = new vscode.EventEmitter<CXXRTLSimulationStatus>();
4753
readonly onDidChangeSimulationStatus: vscode.Event<CXXRTLSimulationStatus> = this._onDidChangeSimulationStatus.event;
4854

4955
private _latestTime: TimePoint = new TimePoint(0n, 0n);
50-
public get latestTime() { return this._latestTime;}
56+
public get latestTime() {
57+
return this._latestTime;
58+
}
5159
private _onDidChangeLatestTime: vscode.EventEmitter<TimePoint> = new vscode.EventEmitter<TimePoint>();
5260
readonly onDidChangeLatestTime: vscode.Event<TimePoint> = this._onDidChangeLatestTime.event;
5361

@@ -63,7 +71,7 @@ export class CXXRTLDebugger {
6371

6472
public async startSession(): Promise<void> {
6573
if (this.terminal !== null) {
66-
vscode.window.showErrorMessage("A debug session is already in the process of being started.");
74+
vscode.window.showErrorMessage('A debug session is already in the process of being started.');
6775
return;
6876
}
6977

@@ -81,39 +89,39 @@ export class CXXRTLDebugger {
8189
this.setSessionStatus(CXXRTLSessionStatus.Starting);
8290

8391
const processId = await this.terminal.processId;
84-
console.log("[RTL Debugger] Launched process %d", processId);
92+
console.log('[RTL Debugger] Launched process %d', processId);
8593

8694
setTimeout(() => {
8795
const socket = net.createConnection({ port: configuration.port, host: '::1' }, () => {
88-
vscode.window.showInformationMessage("Connected to the CXXRTL server.");
96+
vscode.window.showInformationMessage('Connected to the CXXRTL server.');
8997

9098
(async () => {
9199
this.connection = new Connection(new NodeStreamLink(socket));
92100
this.setSessionStatus(CXXRTLSessionStatus.Running);
93101
this.updateSimulationStatus();
94-
console.log("[RTL Debugger] Initialized");
102+
console.log('[RTL Debugger] Initialized');
95103
})().catch(() => {
96104
this.stopSession();
97105
});
98106
});
99107
socket.on('error', (err: any) => {
100108
if (err.code === 'ECONNREFUSED') {
101-
vscode.window.showErrorMessage("The connection to the CXXRTL server was refused.");
109+
vscode.window.showErrorMessage('The connection to the CXXRTL server was refused.');
102110
} else {
103111
vscode.window.showErrorMessage(`The connection to the CXXRTL server has failed: ${err.code}.`);
104112
}
105113
this.stopSession();
106114
});
107115
socket.on('close', (hadError) => {
108116
if (!hadError) {
109-
vscode.window.showInformationMessage("Disconnected from the CXXRTL server.");
117+
vscode.window.showInformationMessage('Disconnected from the CXXRTL server.');
110118
}
111119
this.stopSession();
112120
});
113121
}, 500); // FIXME
114122
} else {
115-
const OpenSettings = "Open Settings";
116-
const selection = await vscode.window.showErrorMessage("Configure the launch command to start a debug session.", OpenSettings);
123+
const OpenSettings = 'Open Settings';
124+
const selection = await vscode.window.showErrorMessage('Configure the launch command to start a debug session.', OpenSettings);
117125
if (selection === OpenSettings) {
118126
vscode.commands.executeCommand('workbench.action.openSettings', 'rtlDebugger.command');
119127
}
@@ -254,7 +262,7 @@ export class CXXRTLDebugger {
254262
for (const [cxxrtlName, cxxrtlDesc] of Object.entries(cxxrtlResponse.scopes)) {
255263
const nestedScopes: Scope[] = [];
256264
const nestedVariables: Thenable<Variable[]> = {
257-
// NormallyPromises are evaluated eagerly; this Thenable does it lazily.
265+
// Normally Promises are evaluated eagerly; this Thenable does it lazily.
258266
then: (onfulfilled, onrejected) => {
259267
return this.getVariablesForScope(cxxrtlName).then(onfulfilled, onrejected);
260268
}
@@ -292,7 +300,7 @@ export class CXXRTLDebugger {
292300
}
293301
}
294302

295-
public bindReference(name: string, reference: Reference): BoundReference {
303+
public bindReference(name: string, reference: UnboundReference): Reference {
296304
const epoch = this.advanceReferenceEpoch(name);
297305
// Note that we do not wait for the command to complete. Although it is possible for
298306
// the command to fail, this would only happen if one of the designations is invalid,
@@ -303,13 +311,13 @@ export class CXXRTLDebugger {
303311
reference: name,
304312
items: reference.cxxrtlItemDesignations()
305313
}).catch((error) => {
306-
console.error(`[CXXRTL] invalid designation while binding reference`,
314+
console.error('[CXXRTL] invalid designation while binding reference',
307315
`${name}#${epoch}`, error);
308316
});
309-
return new BoundReference(name, epoch, reference);
317+
return new Reference(name, epoch, reference);
310318
}
311319

312-
public async queryInterval(interval: TimeInterval, reference: BoundReference): Promise<Sample[]> {
320+
public async queryInterval(interval: TimeInterval, reference: Reference): Promise<Sample[]> {
313321
this.verifyReferenceEpoch(reference.name, reference.epoch);
314322
const cxxrtlResponse = await this.connection!.queryInterval({
315323
type: 'command',

0 commit comments

Comments
 (0)