-
Notifications
You must be signed in to change notification settings - Fork 8
Component Viewer initial commit #725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
115 commits
Select commit
Hold shift + click to select a range
5a61fba
Component Viewer initial commit
thorstendb-ARM db0edef
fixed mock file paths
thorstendb-ARM d0a388b
removed paralelism, added functions for Debug IF, added minimal scvd …
thorstendb-ARM 58af03e
removed "any" from parser, added parser tests
thorstendb-ARM 916c093
fixed parser for const folding, added tests
thorstendb-ARM a460a5e
moved test files, updated evaluator and cache, removed bigInt handling
thorstendb-ARM 8080fc9
removed "any"
thorstendb-ARM bc32470
added test for pseudo members _count, _addr
thorstendb-ARM b1ae4bb
fixed evaluator func call
thorstendb-ARM e96a6b4
minor evaluator fixes, added tests
thorstendb-ARM a6ecf34
readded gdbtargetDebugTracker, fixed evaluator for context
thorstendb-ARM 9a80f69
fix for potential issue in evaluator.ts
thorstendb-ARM b3e82ec
fixed unused in test
thorstendb-ARM a869b4e
fixed memory read, removed most console log, refactored CalcMem
thorstendb-ARM 5d56755
changes to printf return
thorstendb-ARM 902a058
cache refactor and test
thorstendb-ARM 04d9675
added tests for scvd-eval-interface.ts
thorstendb-ARM 7aa9465
cleanup
thorstendb-ARM a3e297d
refactored
thorstendb-ARM cb66e7e
refactor
thorstendb-ARM 14a7036
refactored register host
thorstendb-ARM 822e038
added async to readRegister
thorstendb-ARM 9015331
fixed async
thorstendb-ARM c90bb4a
added class member access modifiers public, private etc.
thorstendb-ARM 46534b5
refactor, moved if/else to multiline with braces
thorstendb-ARM 7c451aa
refactored eval-interface, generalized name check
thorstendb-ARM 75f21d5
refactored eval interface
thorstendb-ARM 3782869
refactored tests and minimized files
thorstendb-ARM 04dfc66
refactor
thorstendb-ARM f0d2d12
refactured and simplified data host
thorstendb-ARM 40ffba1
renamed TODO to TOIMPL to outsmart qltysh bot
thorstendb-ARM daf6d1f
refactor, implemented review comments
thorstendb-ARM 1625892
Merge branch 'main' into componentViewer
thorstendb-ARM 7eaea38
added copyright headers
thorstendb-ARM d478af7
changed to multiline if/else
thorstendb-ARM de426a3
simplified cache
thorstendb-ARM 01cd2d5
cleaned AI comments
thorstendb-ARM bbd2785
fixed copyrights
thorstendb-ARM ad6cb66
Merge branch 'main' into componentViewer
thorstendb-ARM a2ec3a1
refactor, if SPACE (
thorstendb-ARM dd90a6d
refactored for linter: Object injection sink
thorstendb-ARM 7631b49
fixed errors
thorstendb-ARM d6e7afc
linter object sink
thorstendb-ARM aa2b3e6
fixed linter
thorstendb-ARM 8b7fade
added calculateMemoryUsage() tests (normal, full, overflow, corrupt, …
thorstendb-ARM 5b19514
added remaining printf spec and tests
thorstendb-ARM 2a7cc01
added proposal for __size_of
thorstendb-ARM c223e5a
added implementation for getNumArrayElements()
thorstendb-ARM 8a91c94
removed unnecessary guards
thorstendb-ARM 330fb7c
fixed printf padding logic
thorstendb-ARM 6148ec0
simplified padding
thorstendb-ARM 2e4571f
retrieve file context from gdb
thorstendb-ARM be9346f
added printf test IPv6
thorstendb-ARM 7ce2878
added bigint support for float64
thorstendb-ARM d7341ca
Component viewer target access addition (#732)
omarArm 8275267
remove all global mocks from component viewer (#734)
omarArm e386bb5
for HEX display, removed padding and truncated float
thorstendb-ARM e6f09c6
fixed test
thorstendb-ARM 5b66de0
fixed findSymbol error return
thorstendb-ARM ed873bc
refactoring expression
thorstendb-ARM c1da5c9
refactored expression
thorstendb-ARM 88c5e73
huge refactor, divided ScvdBase into Base and Node
thorstendb-ARM e161587
refactored: removed model invalidate
thorstendb-ARM 3e5df99
refactored expression
thorstendb-ARM a561ebd
refactored xml read, removed any
thorstendb-ARM 5daec54
refactored castToDerived
thorstendb-ARM efd1d8a
added printf test
thorstendb-ARM 2d313bb
removed unused code
thorstendb-ARM 2326061
added condition to <break> "instruction"
thorstendb-ARM b0c764b
added missing copyrights
thorstendb-ARM 9fcd1f0
added TPIP for xml2js
thorstendb-ARM 26a1ea5
Add register reads (#737)
omarArm 9859182
fixing collapsible state maintainence in tree view (#738)
omarArm 6e1536e
refactored GUI tree to display a stable tree over multiple run/stop o…
thorstendb-ARM 03bdb35
Catch unable to read memory errors (#739)
omarArm 132cb78
added tests, added type awareness to evaluator
thorstendb-ARM f6df80f
refactor, added tests
thorstendb-ARM 03345f5
refactured evaluator
thorstendb-ARM 6368427
inline refactor
thorstendb-ARM 06b830d
evaluator coverage test
thorstendb-ARM 9278129
more tests added
thorstendb-ARM 481d0e1
added tests
thorstendb-ARM dae6c5f
added tests for data-host (memory and registers)
thorstendb-ARM 3870fa1
added tests
thorstendb-ARM 87a50e6
remaining coverage
thorstendb-ARM 7645fba
test cleanup
thorstendb-ARM 649b946
prettify
thorstendb-ARM 341d78f
fixed copyright headers
thorstendb-ARM 2e80ba2
Merge branch 'main' into componentViewer
thorstendb-ARM a6cb0f8
fix view do display data
thorstendb-ARM 558f03b
moved tests to unit and integration folders, renamed test files
thorstendb-ARM 7bdd35e
added small description to copyright header for tests
thorstendb-ARM 623e034
Code cleanup (#746)
omarArm 09c68fe
removed wording "coverage"
thorstendb-ARM 30f2ef6
fixed comments
thorstendb-ARM a780cb7
updated TPIP
thorstendb-ARM b2dbb8f
no need to set tree view functions as async functions (#747)
omarArm bf818df
removing jest timeout but leaving a comment (also logged)
thorstendb-ARM 48d999f
Renaming Controller as Main (#748)
omarArm bfabc75
Merge branch 'main' into componentViewer
thorstendb-ARM 19e74e7
Remove unneeded test file (#750)
omarArm 541e28d
simplifying snapshotContainer()
thorstendb-ARM b6b1ec9
updated for snapshotContainer
thorstendb-ARM cfcf356
set "get classname" to a string, use instanceof where logic is needed
thorstendb-ARM d771f8f
removed unused function
thorstendb-ARM 8431524
fixed checks for valid GDB data
thorstendb-ARM f9a6718
minor fixes on readMemory handling
thorstendb-ARM b3aa9b2
declaring member variable at the beginning of the class (#751)
omarArm 625ff0a
fixed test
thorstendb-ARM 4657a17
refactoring and code cleanup (#755)
omarArm 163723b
adjust copyright message (#756)
omarArm 3758187
fixed copyright headers
thorstendb-ARM 81e5d88
review work
thorstendb-ARM 36accaf
adjusting tests to new private members names
omarArm 46f8f7d
minor file cleanup
thorstendb-ARM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| # TPIP Report for vscode-cmsis-debugger | ||
|
|
||
| Report prepared at: 13/01/2026, 08:36:58 | ||
| Report prepared at: 20/01/2026, 15:39:57 | ||
|
|
||
| | *Package* | *Version* | *Repository* | *License* | | ||
| |---|---|---|---| | ||
| | arm-none-eabi-gdb | 14.3.1 | https://artifacts.tools.arm.com/arm-none-eabi-gdb/14.3.1/ | https://developer.arm.com/GetEula?Id=15d9660a-2059-4985-85e9-c01cdd4b1ba0 | | ||
| | pyocd | 0.42.0 | https://github.com/pyocd/pyOCD | https://github.com/pyocd/pyOCD/blob/v0.42.0/LICENSE | | ||
| | xml2js | 0.6.2 | https://github.com/Leonidas-from-XIV/node-xml2js | https://github.com/Leonidas-from-XIV/node-xml2js/blob/master/LICENSE | | ||
| | yaml | 2.8.2 | https://github.com/eemeli/yaml | https://github.com/eemeli/yaml/blob/main/LICENSE | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
199 changes: 199 additions & 0 deletions
199
src/views/component-viewer/component-viewer-instance.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,199 @@ | ||
| /** | ||
| * Copyright 2026 Arm Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as vscode from 'vscode'; | ||
| import { URI } from 'vscode-uri'; | ||
| import { parseStringPromise, ParserOptions } from 'xml2js'; | ||
| import { Json } from './model/scvd-base'; | ||
| import { Resolver } from './resolver'; | ||
| import { ScvdComponentViewer } from './model/scvd-component-viewer'; | ||
| import { ScvdBase } from './model/scvd-base'; | ||
| import { StatementEngine } from './statement-engine/statement-engine'; | ||
| import { ScvdEvalContext } from './scvd-eval-context'; | ||
| import { GDBTargetDebugSession, GDBTargetDebugTracker } from '../../debug-session'; | ||
| import { ScvdGuiTree } from './scvd-gui-tree'; | ||
|
|
||
|
|
||
| const xmlOpts: ParserOptions = { | ||
| explicitArray: false, | ||
| mergeAttrs: true, | ||
| explicitRoot: true, | ||
| trim: true, | ||
| // Add child objects that carry their original tag name via '#name' | ||
| explicitChildren: true, | ||
| preserveChildrenOrder: true | ||
| }; | ||
|
|
||
| export class ComponentViewerInstance { | ||
| private _model: ScvdComponentViewer | undefined; | ||
| private _memUsageStart: number = 0; | ||
| private _memUsageLast: number = 0; | ||
| private _timeUsageLast: number = 0; | ||
| private _statementEngine: StatementEngine | undefined; | ||
| private _guiTree: ScvdGuiTree | undefined; | ||
|
|
||
| public constructor( | ||
| ) { | ||
| } | ||
|
|
||
| private injectLineNumbers(xml: string): string { | ||
| const lines = xml.split(/\r?\n/); | ||
| const result: string[] = []; | ||
| for (const [idx, line] of lines.entries()) { | ||
| result.push(line.replace( | ||
| /<((?!\/|!|\?)([A-Za-z_][A-Za-z0-9._:-]*))/g, | ||
| `<$1 __line="${idx + 1}"` | ||
| )); | ||
| } | ||
| return result.join('\n'); | ||
| } | ||
|
|
||
| public getGuiTree(): ScvdGuiTree[] | undefined { | ||
| return this._guiTree?.children; | ||
| } | ||
|
|
||
| public getStats(text: string): string { | ||
| const mem = process.memoryUsage(); | ||
| const memCurrent = Math.round(mem.heapUsed / 1024 / 1024); | ||
| const timeCurrent = Date.now(); | ||
|
|
||
| if (this._timeUsageLast === 0) { | ||
| this._timeUsageLast = timeCurrent; | ||
| } | ||
| if (this._memUsageStart === 0) { | ||
| this._memUsageStart = memCurrent; | ||
| this._memUsageLast = memCurrent; | ||
| } | ||
|
|
||
| const memUsage = memCurrent - this._memUsageLast; | ||
| const timeUsage = timeCurrent - this._timeUsageLast; | ||
| const memIncrease = memCurrent - this._memUsageStart; | ||
|
|
||
| this._memUsageLast = memCurrent; | ||
| this._timeUsageLast = timeCurrent; | ||
|
|
||
| return `${text}, Time: ${timeUsage} ms, Mem: ${memUsage}, Mem Increase: ${memIncrease} MB, (Total: ${memCurrent} MB)`; | ||
| } | ||
|
|
||
| public async readModel(filename: URI, debugSession: GDBTargetDebugSession, debugTracker: GDBTargetDebugTracker): Promise<void> { | ||
| const stats: string[] = []; | ||
|
|
||
| stats.push(this.getStats(` Start reading SCVD file ${filename}`)); | ||
| const buf = (await this.readFileToBuffer(filename)).toString('utf-8'); | ||
| stats.push(this.getStats(' read')); | ||
| const bufLineNo = this.injectLineNumbers(buf); | ||
| stats.push(this.getStats(' inject')); | ||
| const xml: Json = await this.parseXml(bufLineNo); | ||
| stats.push(this.getStats(' parse')); | ||
|
|
||
| if (xml === undefined) { | ||
| console.error('Failed to parse SCVD XML'); | ||
| return; | ||
| } | ||
|
|
||
| ScvdBase.resetIds(); | ||
| this.model = new ScvdComponentViewer(undefined); | ||
| if (!this.model) { | ||
| console.error('Failed to create SCVD model'); | ||
| return; | ||
| } | ||
|
|
||
| this.model.readXml(xml); | ||
| stats.push(this.getStats(' model.readXml')); | ||
|
|
||
| const scvdEvalContext = new ScvdEvalContext(this.model); | ||
| scvdEvalContext.init(debugSession, debugTracker); | ||
| stats.push(this.getStats(' evalContext.init')); | ||
|
|
||
| const executionContext = scvdEvalContext.getExecutionContext(); | ||
| this.model.setExecutionContextAll(executionContext); | ||
| stats.push(this.getStats(' model.setExecutionContextAll')); | ||
|
|
||
| this.model.configureAll(); | ||
| stats.push(this.getStats(' model.configureAll')); | ||
| this.model.validateAll(true); | ||
| stats.push(this.getStats(' model.validateAll')); | ||
|
|
||
| const resolver = new Resolver(this.model); | ||
| resolver.resolve(); | ||
| stats.push(this.getStats(' resolver.resolve')); | ||
|
|
||
| await this.model.calculateTypedefs(); | ||
| stats.push(this.getStats(' model.calculateTypedefs')); | ||
|
|
||
| this.statementEngine = new StatementEngine(this.model, executionContext); | ||
| this.statementEngine.initialize(); | ||
| stats.push(this.getStats(' statementEngine.initialize')); | ||
| this._guiTree = new ScvdGuiTree(undefined, 'component-viewer-root'); | ||
|
|
||
| console.log('ComponentViewerInstance readModel stats:\n' + stats.join('\n ')); | ||
| } | ||
|
|
||
| public async update(): Promise<void> { | ||
| const stats: string[] = []; | ||
| stats.push(this.getStats(' start')); | ||
| if (this._statementEngine === undefined || this._guiTree === undefined) { | ||
| return; | ||
| } | ||
| const epoch = this._guiTree.beginUpdate(); | ||
| await this._statementEngine.executeAll(this._guiTree); | ||
| this._guiTree.finalizeUpdate(epoch); | ||
| stats.push(this.getStats('end')); | ||
| console.log('ComponentViewerInstance update stats:\n' + stats.join('\n ')); | ||
| } | ||
|
|
||
| private async readFileToBuffer(filePath: URI): Promise<Buffer> { | ||
| try { | ||
| const buffer = await vscode.workspace.fs.readFile(filePath); | ||
| return Buffer.from(buffer); | ||
| } catch (error) { | ||
| console.error('Error reading file:', error); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| private async parseXml(text: string) { | ||
| try { | ||
| const json = await parseStringPromise(text, xmlOpts); | ||
| //console.log(JSON.stringify(json, null, 2)); | ||
| return json; | ||
| } catch (err) { | ||
| console.error('Error parsing XML:', err); | ||
| } | ||
| } | ||
|
|
||
| public get model(): ScvdComponentViewer | undefined { | ||
| return this._model; | ||
| } | ||
|
|
||
| private set model(value: ScvdComponentViewer | undefined) { | ||
| this._model = value; | ||
| } | ||
|
|
||
| public get statementEngine(): StatementEngine | undefined { | ||
| return this._statementEngine; | ||
| } | ||
|
|
||
| private set statementEngine(value: StatementEngine | undefined) { | ||
| this._statementEngine = value; | ||
| } | ||
|
|
||
| public async executeStatements(guiTree: ScvdGuiTree): Promise<void> { | ||
| if (this._statementEngine !== undefined) { | ||
| await this._statementEngine.executeAll(guiTree); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Copyright 2025-2026 Arm Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as vscode from 'vscode'; | ||
| import * as manifest from '../../manifest'; | ||
|
|
||
| export const componentViewerLogger = vscode.window.createOutputChannel(manifest.COMPONENT_VIEWER_DISPLAY_NAME, { log: true }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.