Skip to content

Commit a651f9e

Browse files
committed
Reimplement the sidebar UI.
1 parent c1befb8 commit a651f9e

File tree

14 files changed

+654
-352
lines changed

14 files changed

+654
-352
lines changed

package.json

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,20 @@
4949
{
5050
"command": "rtlDebugger.startSession",
5151
"category": "RTL Debugger",
52-
"title": "Start Session"
52+
"title": "Start Session",
53+
"icon": "$(debug-start)"
5354
},
5455
{
5556
"command": "rtlDebugger.stopSession",
5657
"category": "RTL Debugger",
57-
"title": "Stop Session"
58+
"title": "Stop Session",
59+
"icon": "$(debug-stop)"
5860
},
5961
{
6062
"command": "rtlDebugger.runSimulation",
6163
"category": "RTL Debugger",
62-
"title": "Run Simulation"
64+
"title": "Run Simulation",
65+
"icon": "$(debug-continue)"
6366
},
6467
{
6568
"command": "rtlDebugger.runSimulationUntil",
@@ -69,17 +72,20 @@
6972
{
7073
"command": "rtlDebugger.pauseSimulation",
7174
"category": "RTL Debugger",
72-
"title": "Pause Simulation"
75+
"title": "Pause Simulation",
76+
"icon": "$(debug-pause)"
7377
},
7478
{
7579
"command": "rtlDebugger.stepForward",
7680
"category": "RTL Debugger",
77-
"title": "Step Forward"
81+
"title": "Step Forward",
82+
"icon": "$(debug-step-over)"
7883
},
7984
{
8085
"command": "rtlDebugger.stepBackward",
8186
"category": "RTL Debugger",
82-
"title": "Step Backward"
87+
"title": "Step Backward",
88+
"icon": "$(debug-step-back)"
8389
}
8490
],
8591
"viewsContainers": {
@@ -94,34 +100,21 @@
94100
"views": {
95101
"rtlDebugger": [
96102
{
97-
"id": "rtlDebugger.hierarchy",
98-
"name": "Hierarchy"
99-
},
100-
{
101-
"id": "rtlDebugger.variables",
102-
"name": "Variables"
103+
"id": "rtlDebugger.sidebar",
104+
"name": "Session"
103105
}
104106
]
105107
},
106108
"viewsWelcome": [
107109
{
108-
"view": "rtlDebugger.hierarchy",
110+
"view": "rtlDebugger.sidebar",
109111
"contents": "The debug session is not running.\n[Start Session](command:rtlDebugger.startSession)",
110112
"when": "rtlDebugger.sessionStatus == absent"
111113
},
112114
{
113-
"view": "rtlDebugger.hierarchy",
115+
"view": "rtlDebugger.sidebar",
114116
"contents": "The debug session is initializing...",
115117
"when": "rtlDebugger.sessionStatus == starting"
116-
},
117-
{
118-
"view": "rtlDebugger.hierarchy",
119-
"contents": "There are no scopes in the simulation.",
120-
"when": "rtlDebugger.sessionStatus == running"
121-
},
122-
{
123-
"view": "rtlDebugger.variables",
124-
"contents": "The selected scope is empty."
125118
}
126119
],
127120
"menus": {
@@ -154,6 +147,38 @@
154147
"command": "rtlDebugger.stepBackward",
155148
"when": "rtlDebugger.sessionStatus == running"
156149
}
150+
],
151+
"view/title": [
152+
{
153+
"command": "rtlDebugger.stepBackward",
154+
"when": "view == rtlDebugger.sidebar && rtlDebugger.sessionStatus == running",
155+
"group": "navigation@1"
156+
},
157+
{
158+
"command": "rtlDebugger.stepForward",
159+
"when": "view == rtlDebugger.sidebar && rtlDebugger.sessionStatus == running",
160+
"group": "navigation@2"
161+
},
162+
{
163+
"command": "rtlDebugger.runSimulation",
164+
"when": "view == rtlDebugger.sidebar && rtlDebugger.sessionStatus == running && rtlDebugger.simulationStatus == paused",
165+
"group": "navigation@3"
166+
},
167+
{
168+
"command": "rtlDebugger.pauseSimulation",
169+
"when": "view == rtlDebugger.sidebar && rtlDebugger.sessionStatus == running && rtlDebugger.simulationStatus == running",
170+
"group": "navigation@3"
171+
},
172+
{
173+
"command": "rtlDebugger.startSession",
174+
"when": "view == rtlDebugger.sidebar && rtlDebugger.sessionStatus == absent",
175+
"group": "navigation@4"
176+
},
177+
{
178+
"command": "rtlDebugger.stopSession",
179+
"when": "view == rtlDebugger.sidebar && rtlDebugger.sessionStatus == running",
180+
"group": "navigation@5"
181+
}
157182
]
158183
}
159184
},

src/connection.ts

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,13 @@
11
import * as cxxrtlLink from './cxxrtl/link';
2-
import * as cxxrtlServer from './cxxrtl/server';
3-
import { TimeInterval, TimePoint } from './time';
4-
5-
export interface ICXXRTLAgentError {
6-
name: string;
7-
message: string;
8-
}
9-
10-
export interface ICXXRTLSourceLocation {
11-
file: string;
12-
startLine: number;
13-
startColumn?: number;
14-
endLine?: number;
15-
endColumn?: number;
16-
}
17-
18-
class YosysSourceLocation implements ICXXRTLSourceLocation {
19-
constructor(
20-
public file: string,
21-
public startLine: number,
22-
public startColumn?: number,
23-
public endLine?: number,
24-
public endColumn?: number,
25-
) {}
26-
27-
public static parse(src: string): YosysSourceLocation | null {
28-
const matches = src.match(/^(.+?):(\d+)(?:\.(\d+)(?:-(\d+)\.(\d+)))?$/);
29-
if (!matches) {
30-
return null;
31-
}
32-
return new YosysSourceLocation(
33-
matches[1],
34-
parseInt(matches[2]),
35-
matches.length >= 4 ? parseInt(matches[3]) : undefined,
36-
matches.length >= 4 ? parseInt(matches[4]) : undefined,
37-
matches.length >= 6 ? parseInt(matches[5]) : undefined,
38-
);
39-
}
40-
}
2+
import * as cxxrtlClient from './cxxrtl/client';
3+
import { TimeInterval, TimePoint } from './model/time';
414

425
export enum CXXRTLDebugItemType {
436
Node = "node",
447
Memory = "memory"
458
}
469

4710
export class CXXRTLDebugItem {
48-
sourceLocations: ICXXRTLSourceLocation[] = [];
49-
5011
constructor(
5112
public readonly name: string,
5213
public readonly type: CXXRTLDebugItemType,
@@ -156,10 +117,10 @@ export class CXXRTLSample {
156117
}
157118

158119
export class CXXRTLConnection {
159-
private connection: cxxrtlServer.Connection;
120+
public connection: cxxrtlClient.Connection;
160121

161122
constructor(link: cxxrtlLink.ILink) {
162-
this.connection = new cxxrtlServer.Connection(link);
123+
this.connection = new cxxrtlClient.Connection(link);
163124
this.connection.onEvent = async (event) => {
164125
console.log("event received", event);
165126
};
@@ -169,31 +130,7 @@ export class CXXRTLConnection {
169130
this.connection.dispose();
170131
}
171132

172-
public async listScopes(): Promise<string[]> {
173-
const response = await this.connection.listScopes({
174-
type: 'command',
175-
command: 'list_scopes'
176-
});
177-
return Object.keys(response.scopes);
178-
}
179-
180-
public async listItems(scope: string | null): Promise<Map<string, CXXRTLDebugItem>> {
181-
const response = await this.connection.listItems({
182-
type: 'command',
183-
command: 'list_items',
184-
scope
185-
});
186-
return new Map(Object.entries(response.items).map(([name, itemDesc]: [string, any]) => {
187-
const debugItem = new CXXRTLDebugItem(name, itemDesc.type, itemDesc.width, itemDesc.lsb_at, itemDesc.depth, itemDesc.zero_at);
188-
for (const rawSrc of (<{src: string}>itemDesc).src?.split('|') ?? []) {
189-
const sourceLocation = YosysSourceLocation.parse(rawSrc);
190-
if (sourceLocation !== null) {
191-
debugItem.sourceLocations.push(sourceLocation);
192-
}
193-
}
194-
return [name, debugItem];
195-
}));
196-
}
133+
// Everything below is deprecated
197134

198135
public async referenceItems(name: string, designations: ICXXRTLDesignation[]): Promise<ICXXRTLReference> {
199136
await this.connection.referenceItems({

src/cxxrtl/client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,18 @@ export class Connection {
8787
}
8888

8989
private rejectPromises(error: Error): void {
90-
for (const commandPromise of this.promises.splice(0, this.promises.length)) {
91-
commandPromise.reject(error);
90+
for (const promise of this.promises.splice(0, this.promises.length)) {
91+
promise.reject(error);
9292
}
9393
}
9494

95+
private async perform(command: proto.AnyCommand): Promise<proto.AnyResponse> {
96+
await this.send(command);
97+
return new Promise((resolve, reject) => {
98+
this.promises.push({ resolve, reject });
99+
});
100+
}
101+
95102
public async onConnected(): Promise<void> {}
96103

97104
public async onDisconnected(): Promise<void> {}
@@ -114,13 +121,6 @@ export class Connection {
114121
return this._itemValuesEncodings.slice();
115122
}
116123

117-
private async perform(command: proto.AnyCommand): Promise<proto.AnyResponse> {
118-
await this.send(command);
119-
return new Promise((resolve, reject) => {
120-
this.promises.push({ resolve, reject });
121-
});
122-
}
123-
124124
public async listScopes(command: proto.CommandListScopes): Promise<proto.ResponseListScopes> {
125125
return await this.perform(command) as proto.ResponseListScopes;
126126
}

src/cxxrtl/link.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import * as stream from 'node:stream';
2-
import * as wire from './proto';
2+
import * as proto from './proto';
33

44
export interface ILink {
55
dispose(): void;
66

7-
onRecv: (packet: wire.ServerPacket) => Promise<void>;
7+
onRecv: (packet: proto.ServerPacket) => Promise<void>;
88
onDone: () => Promise<void>;
99

10-
send(packet: wire.ClientPacket): Promise<void>;
10+
send(packet: proto.ClientPacket): Promise<void>;
1111
};
1212

1313
export class MockLink implements ILink {
1414
constructor(
15-
private conversation: [wire.ClientPacket, wire.ServerPacket | wire.ServerPacket[]][]
15+
private conversation: [proto.ClientPacket, proto.ServerPacket | proto.ServerPacket[]][]
1616
) {}
1717

1818
public dispose(): void {
@@ -21,11 +21,11 @@ export class MockLink implements ILink {
2121
}
2222
}
2323

24-
public async onRecv(_serverPacket: wire.ServerPacket): Promise<void> {}
24+
public async onRecv(_serverPacket: proto.ServerPacket): Promise<void> {}
2525

2626
public async onDone(): Promise<void> {}
2727

28-
public async send(clientPacket: wire.ClientPacket): Promise<void> {
28+
public async send(clientPacket: proto.ClientPacket): Promise<void> {
2929
if (this.conversation.length === 0) {
3030
throw new Error('premature end of conversation');
3131
}
@@ -84,7 +84,7 @@ export class NodeStreamLink implements ILink {
8484
this.stream.pause();
8585
for (const packetText of packetTexts) {
8686
try {
87-
const packet = JSON.parse(packetText) as wire.ServerPacket;
87+
const packet = JSON.parse(packetText) as proto.ServerPacket;
8888
try {
8989
await this.onRecv(packet);
9090
this.stream.resume();
@@ -112,11 +112,11 @@ export class NodeStreamLink implements ILink {
112112
this.stream.destroy();
113113
}
114114

115-
public async onRecv(_serverPacket: wire.ServerPacket): Promise<void> {}
115+
public async onRecv(_serverPacket: proto.ServerPacket): Promise<void> {}
116116

117117
public async onDone(): Promise<void> {}
118118

119-
public async send(clientPacket: wire.ClientPacket): Promise<void> {
119+
public async send(clientPacket: proto.ClientPacket): Promise<void> {
120120
this.stream.write(JSON.stringify(clientPacket) + '\0');
121121
}
122122
}

0 commit comments

Comments
 (0)