From 5011fc15f226ea0e6b2297efe4e14b09f9e33262 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Thu, 1 Oct 2026 13:45:23 +0200 Subject: [PATCH] ui: reset clears call graph, shortened info line --- src/docs/callgraph.md | 12 ++++++------ src/ide/ui.ts | 1 + src/ide/views/baseviews.ts | 1 + src/ide/views/treeviews.ts | 13 +++++++++---- src/ide/windows.ts | 6 ++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/docs/callgraph.md b/src/docs/callgraph.md index 8cff180e..8bdc07b3 100644 --- a/src/docs/callgraph.md +++ b/src/docs/callgraph.md @@ -7,14 +7,14 @@ platforms that implement `startProbing`. Each node represents a routine, and its children are the routines it called. Beside each name is a summary: - 12x 3400 clk (45.2%) self 800 line 20-31 + 12x 45.2% 3400/800 @20-31 - `12x` is how many times the routine was called. -- `3400 clk` is the clocks spent in the routine *and* its callees, and the - percentage is its share of all clocks the graph has seen. -- `self` is the clocks in the routine alone, not counting callees. It is - left out when the routine calls nothing. -- `line` is the scanline range where it last ran (raster platforms). +- `45.2%` is its share of all clocks the graph has seen. +- `3400/800` is the clocks spent in the routine *and* its callees, + then the clocks in the routine alone (`self`), not counting callees. The + `/self` part is left out when the routine calls nothing. +- `@20-31` is the scanline range where it last ran (raster platforms). Interrupt handlers appear as calls from whatever was running when the interrupt fired. A call or return instruction's own clocks are counted in diff --git a/src/ide/ui.ts b/src/ide/ui.ts index 08b31ccd..b10a6045 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -1574,6 +1574,7 @@ export function clearBreakpoint() { function resetPlatform() { platform.reset(); _resetRecording(); + projectWindows.resetViews(); } function resetAndRun() { diff --git a/src/ide/views/baseviews.ts b/src/ide/views/baseviews.ts index e76d5a29..4da26594 100644 --- a/src/ide/views/baseviews.ts +++ b/src/ide/views/baseviews.ts @@ -8,6 +8,7 @@ export interface ProjectView { setVisible?(showing: boolean): void; refresh(moveCursor: boolean): void; tick?(): void; + reset?(): void; // machine was reset: drop accumulated run data getPath?(): string; getValue?(): string; getSelectionText?(): string; diff --git a/src/ide/views/treeviews.ts b/src/ide/views/treeviews.ts index 68a87789..f13798bb 100644 --- a/src/ide/views/treeviews.ts +++ b/src/ide/views/treeviews.ts @@ -209,7 +209,6 @@ export class DebugBrowserView extends TreeViewBase implements ProjectView { getRootObject() { return platform.getDebugTree(); } } -// TODO: clear stack data when reset? export class CallGraphView extends ProbeViewBaseBase implements ProjectView { treeroot : TreeNode; builder = new CallGraphBuilder(pc => this.classify(pc), pc => this.addr2str(pc)); @@ -236,6 +235,12 @@ export class CallGraphView extends ProbeViewBaseBase implements ProjectView { this.kinds.clear(); } + /** Machine reset: the old call stack and profile no longer apply. */ + reset() { + this.builder.clear(); + if (this.probe) this.probe.clear(); + } + /** Call, return or neither, from the disassembly (cached: code rarely changes). */ classify(pc : number) : InsnKind { let kind = this.kinds.get(pc); @@ -271,9 +276,9 @@ export class CallGraphView extends ProbeViewBaseBase implements ProjectView { callees(node : CallGraphNode, base : number) : Object { const out = {}; for (const [name, c] of Object.entries(node.calls)) { - let text = c.count + "x " + c.total + " clk (" + (100 * c.total / base).toFixed(1) + "%)"; - if (c.self != c.total) text += " self " + c.self; - if (c.startLine != null) text += " line " + c.startLine + (c.endLine != null ? "-" + c.endLine : ""); + // count, share of total, clocks (total/self), scanlines + let text = c.count + "x " + (100 * c.total / base).toFixed(1) + "% " + c.total + (c.self != c.total ? "/" + c.self : ""); + if (c.startLine != null) text += " @" + c.startLine + (c.endLine != null && c.endLine != c.startLine ? "-" + c.endLine : ""); out[name] = Object.assign({ $$text: text }, this.callees(c, base)); } return out; diff --git a/src/ide/windows.ts b/src/ide/windows.ts index e58aee5a..17e730f9 100644 --- a/src/ide/windows.ts +++ b/src/ide/windows.ts @@ -126,6 +126,12 @@ export class ProjectWindows { this.activewnd.refresh(moveCursor); } + /** Tells every window (not just the visible one) that the machine was reset. */ + resetViews(): void { + for (const wnd of Object.values(this.id2window)) wnd.reset && wnd.reset(); + this.refresh(false); + } + tick(): void { if (this.activewnd && this.activewnd.tick) this.activewnd.tick();