Skip to content

Commit e0253ea

Browse files
Component Viewer initial commit (#725)
* Component Viewer initial commit --------- Authored-by: Thorsten de Buhr <thorsten.deBuhr@arm.com> Co-authored-by: Omar Elkhouly <omar.elkhouly@arm.com>
1 parent c4813ba commit e0253ea

114 files changed

Lines changed: 1013 additions & 287 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/views/component-viewer/component-viewer-main.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2026 Arm Limited
2+
* Copyright 2025-2026 Arm Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@ import { ComponentViewerTreeDataProvider } from './component-viewer-tree-view';
2222

2323

2424
export class ComponentViewer {
25-
private activeSession: GDBTargetDebugSession | undefined;
26-
private instances: ComponentViewerInstance[] = [];
27-
private componentViewerTreeDataProvider: ComponentViewerTreeDataProvider | undefined;
25+
private _activeSession: GDBTargetDebugSession | undefined;
26+
private _instances: ComponentViewerInstance[] = [];
27+
private _componentViewerTreeDataProvider: ComponentViewerTreeDataProvider | undefined;
2828
private _context: vscode.ExtensionContext;
2929
private _instanceUpdateCounter: number = 0;
3030
private _updateSemaphoreFlag: boolean = false;
@@ -36,8 +36,8 @@ export class ComponentViewer {
3636

3737
public activate(tracker: GDBTargetDebugTracker): void {
3838
/* Create Tree Viewer */
39-
this.componentViewerTreeDataProvider = new ComponentViewerTreeDataProvider();
40-
const treeProviderDisposable = vscode.window.registerTreeDataProvider('cmsis-debugger.componentViewer', this.componentViewerTreeDataProvider);
39+
this._componentViewerTreeDataProvider = new ComponentViewerTreeDataProvider();
40+
const treeProviderDisposable = vscode.window.registerTreeDataProvider('cmsis-debugger.componentViewer', this._componentViewerTreeDataProvider);
4141
this._context.subscriptions.push(
4242
treeProviderDisposable);
4343
// Subscribe to debug tracker events to update active session
@@ -60,12 +60,12 @@ export class ComponentViewer {
6060
const cbuildRunInstances: ComponentViewerInstance[] = [];
6161
for (const scvdFilePath of scvdFilesPaths) {
6262
const instance = new ComponentViewerInstance();
63-
if (this.activeSession !== undefined) {
64-
await instance.readModel(URI.file(scvdFilePath), this.activeSession, tracker);
63+
if (this._activeSession !== undefined) {
64+
await instance.readModel(URI.file(scvdFilePath), this._activeSession, tracker);
6565
cbuildRunInstances.push(instance);
6666
}
6767
}
68-
this.instances = cbuildRunInstances;
68+
this._instances = cbuildRunInstances;
6969
}
7070

7171
private async loadCbuildRunInstances(session: GDBTargetDebugSession, tracker: GDBTargetDebugTracker) : Promise<void> {
@@ -74,8 +74,8 @@ export class ComponentViewer {
7474
// Try to read SCVD files from cbuild-run file first
7575
await this.readScvdFiles(tracker, session);
7676
// Are there any SCVD files found in cbuild-run?
77-
if (this.instances.length > 0) {
78-
//await this.updateInstances();
77+
if (this._instances.length > 0) {
78+
await this.updateInstances();
7979
return;
8080
}
8181
}
@@ -93,50 +93,50 @@ export class ComponentViewer {
9393
const onDidChangeActiveDebugSessionDisposable = tracker.onDidChangeActiveDebugSession(async (session) => {
9494
await this.handleOnDidChangeActiveDebugSession(session);
9595
});
96-
const onStackTrace = tracker.onStackTrace(async (session) => {
97-
await this.handleOnStackTrace(session.session);
96+
const onStopped = tracker.onStopped(async (session) => {
97+
await this.handleOnStopped(session.session);
9898
});
9999
// clear all disposables on extension deactivation
100100
context.subscriptions.push(
101101
onWillStopSessionDisposable,
102102
onConnectedDisposable,
103103
onDidChangeActiveStackItemDisposable,
104104
onDidChangeActiveDebugSessionDisposable,
105-
onStackTrace
105+
onStopped
106106
);
107107
}
108108

109-
private async handleOnStackTrace(session: GDBTargetDebugSession): Promise<void> {
109+
private async handleOnStopped(session: GDBTargetDebugSession): Promise<void> {
110110
// Clear active session if it is NOT the one being stopped
111-
if (this.activeSession?.session.id !== session.session.id) {
112-
this.activeSession = undefined;
111+
if (this._activeSession?.session.id !== session.session.id) {
112+
this._activeSession = undefined;
113113
}
114114
// Update component viewer instance(s)
115115
await this.updateInstances();
116116
}
117117

118118
private async handleOnWillStopSession(session: GDBTargetDebugSession): Promise<void> {
119119
// Clear active session if it is the one being stopped
120-
if (this.activeSession?.session.id === session.session.id) {
121-
this.activeSession = undefined;
120+
if (this._activeSession?.session.id === session.session.id) {
121+
this._activeSession = undefined;
122122
}
123123
// Update component viewer instance(s)
124-
//await this.updateInstances();
124+
await this.updateInstances();
125125
}
126126

127127
private async handleOnConnected(session: GDBTargetDebugSession, tracker: GDBTargetDebugTracker): Promise<void> {
128128
// if new session is not the current active session, erase old instances and read the new ones
129-
if (this.activeSession?.session.id !== session.session.id) {
130-
this.instances = [];
131-
this.componentViewerTreeDataProvider?.deleteModels();
129+
if (this._activeSession?.session.id !== session.session.id) {
130+
this._instances = [];
131+
this._componentViewerTreeDataProvider?.deleteModels();
132132
}
133133
// Update debug session
134-
this.activeSession = session;
134+
this._activeSession = session;
135135
// Load SCVD files from cbuild-run
136136
await this.loadCbuildRunInstances(session, tracker);
137137
// Subscribe to refresh events of the started session
138138
session.refreshTimer.onRefresh(async (refreshSession) => {
139-
if (this.activeSession?.session.id === refreshSession.session.id) {
139+
if (this._activeSession?.session.id === refreshSession.session.id) {
140140
// Update component viewer instance(s)
141141
await this.updateInstances();
142142
}
@@ -146,13 +146,13 @@ export class ComponentViewer {
146146
private async handleOnDidChangeActiveStackItem(stackTraceItem: SessionStackItem): Promise<void> {
147147
if ((stackTraceItem.item as vscode.DebugStackFrame).frameId !== undefined) {
148148
// Update instance(s) with new stack frame info
149-
//await this.updateInstances();
149+
await this.updateInstances();
150150
}
151151
}
152152

153153
private async handleOnDidChangeActiveDebugSession(session: GDBTargetDebugSession | undefined): Promise<void> {
154154
// Update debug session
155-
this.activeSession = session;
155+
this._activeSession = session;
156156
// Update component viewer instance(s)
157157
await this.updateInstances();
158158
}
@@ -163,23 +163,23 @@ export class ComponentViewer {
163163
}
164164
this._updateSemaphoreFlag = true;
165165
this._instanceUpdateCounter = 0;
166-
if (!this.activeSession) {
167-
this.componentViewerTreeDataProvider?.deleteModels();
166+
if (!this._activeSession) {
167+
this._componentViewerTreeDataProvider?.deleteModels();
168168
this._updateSemaphoreFlag = false;
169169
return;
170170
}
171-
if (this.instances.length === 0) {
171+
if (this._instances.length === 0) {
172172
this._updateSemaphoreFlag = false;
173173
return;
174174
}
175-
this.componentViewerTreeDataProvider?.resetModelCache();
176-
for (const instance of this.instances) {
175+
this._componentViewerTreeDataProvider?.resetModelCache();
176+
for (const instance of this._instances) {
177177
this._instanceUpdateCounter++;
178178
console.log(`Updating Component Viewer Instance #${this._instanceUpdateCounter}`);
179179
await instance.update();
180-
this.componentViewerTreeDataProvider?.addGuiOut(instance.getGuiTree());
180+
this._componentViewerTreeDataProvider?.addGuiOut(instance.getGuiTree());
181181
}
182-
this.componentViewerTreeDataProvider?.showModelData();
182+
this._componentViewerTreeDataProvider?.showModelData();
183183
this._updateSemaphoreFlag = false;
184184
}
185185
}

src/views/component-viewer/component-viewer-tree-view.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2026 Arm Limited
2+
* Copyright 2025-2026 Arm Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,24 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
/*
18-
* Component Viewer Tree (ordered exactly as provided by getGuiChildren())
19-
* - Root = model.objects?.objects?.[0]?.out?.[0]
20-
* - Label/description from node.getGuiEntry() -> { name, value }
21-
* - Children from node.getGuiChildren() (returned AS-IS, in order)
22-
* - Each item id = node.nodeId (no fallbacks)
23-
* - Activation via `await provider.activate()`; no constructor args
24-
* - View ID defaults to 'cmsis-debugger.componentViewer'
25-
*/
2617

2718
import * as vscode from 'vscode';
2819
import { ScvdGuiInterface } from './model/scvd-gui-interface';
2920

3021

3122
export class ComponentViewerTreeDataProvider implements vscode.TreeDataProvider<ScvdGuiInterface> {
3223
private readonly _onDidChangeTreeData = new vscode.EventEmitter<ScvdGuiInterface | void>();
33-
readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
34-
//private _activeSession: GDBTargetDebugSession | undefined;
24+
public readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
3525
private _objectOutRoots: ScvdGuiInterface[] = [];
3626
private _scvdModel: ScvdGuiInterface[] = [];
3727

src/views/component-viewer/model/number-type.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
1817
import * as utils from './scvd-utils';
1918

2019
export enum NumFormat {

src/views/component-viewer/model/scvd-base.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
15-
*
15+
*/
16+
17+
/**
1618
* Minimal core for SCVD tree nodes: parent/child wiring and basic metadata.
1719
* Model-specific behaviour lives in ScvdNode.
1820
*/
1921

20-
2122
export type Json = Record<string, unknown>;
2223

2324
// Constructor type used for runtime instanceof checks; kept loose to cover differing ctor shapes.

src/views/component-viewer/model/scvd-component-identifier.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
// /component_viewer/component
1817
// https://arm-software.github.io/CMSIS-View/main/elem_component.html
1918

2019
import { Json } from './scvd-base';

src/views/component-viewer/model/scvd-component-viewer.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@ export class ScvdComponentViewer extends ScvdNode {
4343
return 'ScvdComponentViewer';
4444
}
4545

46-
/* template for readXml
47-
public override readXml(xml: Json): boolean {
48-
if (xml === undefined ) {
49-
return super.readXml(xml);
50-
}
51-
52-
//this.tag = xml.tag;
53-
54-
return super.readXml(xml);
55-
}
56-
*/
57-
5846
public override readXml(xml: Json): boolean {
5947
if (xml === undefined ) {
6048
return super.readXml(xml);

src/views/component-viewer/model/scvd-component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
// /component_viewer/events
1817
// https://arm-software.github.io/CMSIS-View/main/elem_events.html
1918

2019
import { NumberType, NumberTypeInput } from './number-type';

src/views/component-viewer/model/scvd-event-level.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { ScvdNode } from './scvd-node';
18-
1917
// https://arm-software.github.io/CMSIS-View/main/elem_component_viewer.html
2018

19+
import { ScvdNode } from './scvd-node';
20+
2121
export enum EventLevel {
2222
EventLevelError = 0, // Run-time error
2323
EventLevelAPI = 1, // API function call

src/views/component-viewer/model/scvd-event-state.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17+
// https://arm-software.github.io/CMSIS-View/main/elem_component_viewer.html
18+
19+
1720
import { Json } from './scvd-base';
1821
import { ScvdNode } from './scvd-node';
1922
import { getStringFromJson } from './scvd-utils';
@@ -24,8 +27,6 @@ function isEventColor(v: string): v is EventColor {
2427
return EVENT_COLORS.includes(v as EventColor);
2528
}
2629

27-
// https://arm-software.github.io/CMSIS-View/main/elem_component_viewer.html
28-
2930
export class ScvdEventState extends ScvdNode {
3031
private _plot: 'off' | 'line' | 'box' = 'off';
3132
private _color: EventColor = 'blue';

src/views/component-viewer/model/scvd-event-tracking.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { ScvdNode } from './scvd-node';
18-
1917
// https://arm-software.github.io/CMSIS-View/main/elem_component_viewer.html
2018

19+
import { ScvdNode } from './scvd-node';
20+
2121
/**
2222
* Specifies the tracking for an event handle.
2323
* - Start: start the state tracking for an event handle.

0 commit comments

Comments
 (0)