Skip to content

Commit f23addd

Browse files
committed
Factor out debug session management.
Also, replace the stub implementation of step forwards/backwards with a real one.
1 parent ede2a3d commit f23addd

File tree

9 files changed

+470
-296
lines changed

9 files changed

+470
-296
lines changed

src/cxxrtl/proto.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ export type ScopeDescriptionModule = {
101101
export type ScopeDescription =
102102
| ScopeDescriptionModule;
103103

104+
export type ScopeDescriptionMap = {
105+
[identifier: string]: ScopeDescription
106+
};
107+
104108
export type CommandListScopes = {
105109
type: 'command';
106110
command: 'list_scopes';
@@ -109,9 +113,7 @@ export type CommandListScopes = {
109113
export type ResponseListScopes = {
110114
type: 'response';
111115
command: 'list_scopes';
112-
scopes: {
113-
[identifier: string]: ScopeDescription;
114-
};
116+
scopes: ScopeDescriptionMap;
115117
};
116118

117119
// ## Command: List Items
@@ -142,6 +144,10 @@ export type ItemDescription =
142144
| ItemDescriptionNode
143145
| ItemDescriptionMemory;
144146

147+
export type ItemDescriptionMap = {
148+
[identifier: string]: ItemDescription
149+
};
150+
145151
export type CommandListItems = {
146152
type: 'command';
147153
command: 'list_items';
@@ -151,9 +157,7 @@ export type CommandListItems = {
151157
export type ResponseListItems = {
152158
type: 'response';
153159
command: 'list_items';
154-
items: {
155-
[identifier: string]: ItemDescription;
156-
};
160+
items: ItemDescriptionMap;
157161
};
158162

159163
// ## Command: Reference Items
@@ -201,8 +205,8 @@ export type CommandQueryInterval = {
201205
command: 'query_interval';
202206
interval: [TimePoint, TimePoint];
203207
collapse: boolean;
204-
items: string;
205-
item_values_encoding: string;
208+
items: string | null;
209+
item_values_encoding: string | null;
206210
diagnostics: boolean;
207211
};
208212

src/observer.ts renamed to src/debug/observer.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as vscode from 'vscode';
22

3-
import { UnboundReference, Designation, Reference } from './model/sample';
4-
import { CXXRTLDebugger } from './debugger';
5-
import { TimeInterval } from './model/time';
3+
import { UnboundReference, Designation, Reference } from '../model/sample';
4+
import { TimeInterval } from '../model/time';
5+
import { Session } from './session';
66

77
class Observable<T> {
88
private callbacks: ((value: T) => void)[] = [];
@@ -42,14 +42,15 @@ export class Observer {
4242
private subscription: vscode.Disposable;
4343

4444
constructor(
45-
private rtlDebugger: CXXRTLDebugger,
45+
private session: Session,
4646
private referenceName: string,
4747
) {
48-
this.subscription = rtlDebugger.onDidChangeCurrentTime((_time) =>
48+
this.subscription = this.session.onDidChangeTimeCursor((_time) =>
4949
this.invalidate());
5050
}
5151

5252
dispose() {
53+
this.observables.clear();
5354
this.subscription.dispose();
5455
}
5556

@@ -84,11 +85,11 @@ export class Observer {
8485
for (const observable of this.observables.values()) {
8586
unboundReference.add(observable.designation);
8687
}
87-
this.reference = this.rtlDebugger.bindReference(this.referenceName, unboundReference);
88+
this.reference = this.session.bindReference(this.referenceName, unboundReference);
8889
}
89-
const interval = new TimeInterval(this.rtlDebugger.currentTime, this.rtlDebugger.currentTime);
90+
const interval = new TimeInterval(this.session.timeCursor, this.session.timeCursor);
9091
const reference = this.reference; // could get invalidated in the meantime
91-
const [sample] = await this.rtlDebugger.queryInterval(interval, reference);
92+
const [sample] = await this.session.queryInterval(interval, reference);
9293
for (const [designation, handle] of reference.allHandles()) {
9394
const observable = this.observables.get(designation.canonicalKey)!;
9495
observable.update(sample.extract(handle));

0 commit comments

Comments
 (0)