diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-13 15:10:16 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-13 15:10:16 -0300 |
| commit | 9656105cb4c902213f281e658dd88286cc2df8ed (patch) | |
| tree | def1582280f4925688646dcfd14619f3c727b199 /gui | |
| parent | 4b76c25dc90417a9d6c3d4cd5af0dd3d4c087520 (diff) | |
| download | computeranim-9656105cb4c902213f281e658dd88286cc2df8ed.tar.gz computeranim-9656105cb4c902213f281e658dd88286cc2df8ed.zip | |
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/README.md | 28 | ||||
| -rw-r--r-- | gui/bench/RESULTS.md | 72 | ||||
| -rw-r--r-- | gui/bench/frames.py | 79 | ||||
| -rw-r--r-- | gui/build.zig | 6 | ||||
| -rw-r--r-- | gui/src/Navigation.zig | 32 | ||||
| -rw-r--r-- | gui/src/app.zig | 34 | ||||
| -rw-r--r-- | gui/test/lenses.py | 33 |
7 files changed, 273 insertions, 11 deletions
diff --git a/gui/README.md b/gui/README.md index 36e4a1c..b77a546 100644 --- a/gui/README.md +++ b/gui/README.md @@ -14,7 +14,7 @@ zig build run -Doptimize=ReleaseFast -- --fresh ``` Use the repository's Zig toolchain and existing sibling `sketchbook` and `pardes` -checkouts (Sketchbook `409c1ac` or newer for native backdrop filtering). Keep the +checkouts (Sketchbook `d307463` or newer for native profiling and upload fixes). Keep the installed `ztrace` beside `ztrace-gui`. ## Controls @@ -69,7 +69,8 @@ Wide windows keep code beside registers and memory beside stack. Smaller windows stack these panes; wheel over a header/gutter or use PageUp/PageDown to reach them. Font scaling changes drawing scale, geometry, visible rows and pointer hit regions; it never changes the native window dimensions or backing size. Every new -execution stop reveals PC and its source group. Manual scrolling lasts until the +execution stop reveals PC and its source group. Nearby scrolling settles in +200 ms using elapsed time, including when the frame rate changes. Manual scrolling lasts until the next stop; an explicit address jump stays pinned until Follow is enabled. Stack, memory and disassembly navigation span the **entire selected mapping**. @@ -97,6 +98,8 @@ including `lea`, using the selected stop's registers only at its PC. RIP-relativ and absolute addresses work on other rows too. Future/past register values, segment overrides and 32-bit addressing are not inferred. Truncated brackets have no hidden hit target. These links work in executable lenses too. +Address values in the right-hand register hints use the same hover and mouse +actions, at the displayed register width. Ordinary scalar hints stay inactive. Memory's two header controls choose 8/16/32/64-bit groups and hexadecimal, unsigned, signed or floating-point values (little endian). `memory-format SIZE @@ -198,3 +201,24 @@ python3 gui/test/restart.py --native This checks the actual SDL window dimensions across zoom levels, in addition to the headless checks included in `zig build test`. + +## Frame profiling + +Tracy is optional and shared with Sketchbook. A normal build has no Tracy client. +To measure native scrolling, lenses and live stepping: + +```sh +cd gui +zig build -Doptimize=ReleaseFast -Dtracy=/absolute/path/to/tracy +cd .. +python3 gui/bench/frames.py --tracy /absolute/path/to/tracy --out /tmp/ztrace-frames +# Repeat with --size 1440x900 or --size 800x700 --zoom 200. +``` + +The checkout needs `build-capture/tracy-capture` and +`build-csvexport/tracy-csvexport`. The harness writes a reproducible input script, +`.tracy` capture, event CSV and percentile summary. It excludes the first two +seconds from warm interaction statistics. Host frame/presentation times include +VSync and driver waits; GUI `draw` measures construction of drawing commands. +Source loading and debugger transition capture have separate measurements in +[the benchmark results](bench/RESULTS.md). Rebuild without `-Dtracy` for ordinary use. diff --git a/gui/bench/RESULTS.md b/gui/bench/RESULTS.md index af16175..97e255a 100644 --- a/gui/bench/RESULTS.md +++ b/gui/bench/RESULTS.md @@ -213,3 +213,75 @@ Reloaded live session: GUI25666, d8 25705, recording `Deoptimizer::New+4`, `0x7f99e5be3f74`, on `deoptimizer.cc:290`. `rdx = 0x7f9984c00ffa` exactly matches the naturally optimized `jitWork` wrong-map exit return; originating JS context uses guard `0x7f9984c00c14` at `jit.js:3`. + +## 2026-11-13: hints, frame timing and Tracy + +Register-value hints on the right of disassembly now share address hover and +left/right-click behavior, using the displayed register width. Tests also caught +and corrected the `di`/`bp`/`sp` and low-byte register aliases. Scalar hints remain +inactive. Scroll reveals now finish exactly 200 ms after the latest target change, +with a cubic ease-out and continuous retargeting; large address jumps still snap. + +Tracy is optional in Sketchbook and the GUI (`-Dtracy=CHECKOUT`), following +Pardes's minimal Zig binding. Disabled builds omit the client. Host zones cover +input, commands, frame construction, painting and presentation; GUI zones split +panes, minimaps, recording refresh and overlays. `gui/bench/frames.py` captures a +native session and exports the input script, trace, CSV and percentile summary. + +The main hitch was Vulkan allocation cleanup. Temporary SDL probes separated +swapchain acquisition, submission, presentation and cleanup: freeing dedicated +transfer-buffer allocations cost 25–48 ms in affected frames. The existing +Sketchbook SDL patch already disables relocation. The same patch now allows +small transfer buffers to share aligned allocations; mapped pointers retain their +resource offsets. The patch fails if either expected source fragment changes. +The probe sources were restored; no experimental renderer or shape cache ships. +ASCII text also reuses white coverage masks across ink/opacity changes, while +Unicode keeps painted glyphs, including emoji. + +Measured on this workstation (i7-11700, RTX 3050, native Vulkan, ReleaseFast, +VSync, Tracy 0.13.4), excluding the first two seconds of cold loading: + +| Native scenario | Median frame interval | p95 | p99 | Maximum | +| --- | ---: | ---: | ---: | ---: | +| Original interaction script, before | 16.67 ms | 21.53 ms | 107.56 ms | 130.36 ms | +| Same script, final renderer | 16.67 ms | 18.15 ms | 20.56 ms | 38.56 ms | +| Reproducible harness, 2240×1260 / 100% | 16.67 ms | 18.47 ms | 21.79 ms | 37.11 ms | +| Reproducible harness, 1440×900 / 100% | 16.65 ms | 18.24 ms | 19.53 ms | 22.83 ms | +| Reproducible harness, 800×700 / 200% | 16.66 ms | 18.23 ms | 20.03 ms | 33.39 ms | + +The harness verifies 20 actual instruction steps while scrolling and opening +lenses. Presentation in the final matching-script run stayed below 15.13 ms. +These are CPU wall timings, including VSync/driver waits, not GPU timestamps. +The result is approximately 60 Hz through ordinary interaction, not a guarantee +that every frame meets 16.67 ms: cold font/source loading and occasional scheduling +or stop-refresh frames still exceed it. Captures and the discarded probes remain +under `/tmp/ztrace-perf/`; rerun the checked-in harness for durable new captures. + +Final checks passed: the GUI suite, shared canim renderer suite, Sketchbook suite, +native hint/lens interactions, restart, fixed-backing 60–200% zoom and font-cache +pixel tests. Independent code and native screenshot review found no remaining +issues. The committed Sketchbook files also build in isolation from the checkout's +unrelated pending GPU refactor. Normal GUI builds contain no Tracy client symbols. +Sketchbook changes are committed as `d307463`. + +A fresh 1,000-step source-enabled benchmark (`steps.py`) measured capture median / +p95 of 45.98 / 62.28 µs for C and 150.78 / 245.49 µs inside optimized `jitWork`. +Controller round trips measured 62.43 / 94.60 µs and 180.00 / 288.76 µs respectively. +This run naturally compiled through Maglev and TurboFan, then verified `wrong map` +at the generated exit, `Deoptimizer::New`, `Runtime_NotifyDeoptimized`, and +`Builtins_InterpreterEnterAtBytecode`, followed by the Ignition named-property +bytecode handler. Its observed fallback was Ignition; default tiers were unchanged. + +Transition capture costs are separate: generated exit 351.74 µs, deoptimizer +entry 224.82 µs, notification 245.63 µs, interpreter entry 404.48 µs, and first +property handler 14.16 ms (including that handler's first capture/source work). +Launch, natural warmup, initial symbols and first generated stop together took +1.295 s. Results and recordings are in `/tmp/ztrace-perf/steps/`. + +Final restored live session: GUI PID45357, d8 PID46062, recording +`/tmp/ztrace-gui-45357-18763846210612.ztrace`. Generated wrong-map exit +`0x7f4062dc0ff6` was captured before stopping at `Deoptimizer::New+4`, +`0x7f4004be3f74`, on `deoptimizer.cc:290`. Its `rdx = 0x7f4062dc0ffa` +exactly matches the printed wrong-map return for naturally optimized `jitWork`. +Originating JS context uses guard `0x7f4062dc0c14` at `jit.js:3`. +The native window remains at that live stop with C++ and JS context visible. diff --git a/gui/bench/frames.py b/gui/bench/frames.py new file mode 100644 index 0000000..6131183 --- /dev/null +++ b/gui/bench/frames.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +"""Capture native scrolling, lenses and live stepping with an opt-in Tracy build.""" +import argparse +import csv +import json +from pathlib import Path +import re +import subprocess as sp + +ROOT = Path(__file__).resolve().parents[2] +p = argparse.ArgumentParser(description=__doc__) +p.add_argument('--tracy', type=Path, required=True, help='Tracy checkout with build-capture/ and build-csvexport/') +p.add_argument('--gui', type=Path, default=ROOT / 'gui/zig-out/bin/ztrace-gui') +p.add_argument('--out', type=Path, required=True) +p.add_argument('--size', default='2240x1260') +p.add_argument('--zoom', type=int, default=100) +a = p.parse_args() +a.out = a.out.resolve() +a.out.mkdir(parents=True, exist_ok=True) +for tool in (a.gui, a.tracy / "build-capture/tracy-capture", a.tracy / "build-csvexport/tracy-csvexport"): + assert tool.is_file(), f"Missing executable: {tool}" +target = a.out / 'segments' +sp.run(['cc', '-g', '-O0', '-no-pie', str(ROOT / 'gui/targets/segments.c'), '-o', str(target)], check=True) +symbols = dict((name, int(address, 16)) for address, name in re.findall(r'^([0-9a-f]+) \w (\w+)$', sp.check_output(['nm', '-n', str(target)], text=True), re.M)) +script = f'''console launch {target} +await stops 1 +console break checkpoint +console continue +await execution 1 +console set zoom {a.zoom} +frames 100 +console goto memory {hex(symbols['head'])} +console set focus memory +frames 30 +''' +for _ in range(6): + for key in ('j', 'k'): + script += (f'key {key}\nframes 2\n' * 8) +for _ in range(6): + script += f'console lens {hex(symbols["head"])}\nframes 15\nkey escape\nframes 3\n' +for i in range(20): + script += f'key s\nawait execution {i + 2}\nframes 6\n' +script += 'frames 60\nexpect execution 21\nexpect status stopped\n' +(a.out / 'input.script').write_text(script) +with (a.out / 'gui.log').open('w') as log, (a.out / 'capture.log').open('w') as cap: + app = sp.Popen([str(a.gui.resolve()), '--fresh', '--size', a.size, '--state', str(a.out / 'gui.state'), '--script', str(a.out / 'input.script')], stdout=log, stderr=log) + capture = sp.Popen([str(a.tracy / 'build-capture/tracy-capture'), '-o', str(a.out / 'frames.tracy'), '-f', '-s', '25'], stdout=cap, stderr=cap) + try: + assert app.wait(timeout=90) == 0, (a.out / 'gui.log').read_text() + assert capture.wait(timeout=30) == 0, (a.out / 'capture.log').read_text() + finally: + for proc in (app, capture): + if proc.poll() is None: + proc.terminate() + proc.wait() +with (a.out / 'events.csv').open('w') as out: + sp.run([str(a.tracy / 'build-csvexport/tracy-csvexport'), '-u', str(a.out / 'frames.tracy')], stdout=out, check=True) +values = {} +starts = [] +with (a.out / 'events.csv').open() as f: + for row in csv.DictReader(f): + at = int(row['ns_since_start']) / 1e9 + if at < 2: + continue # Cold font/source loading is separate from warm interaction. + name = row['name'] + if name not in ('frame', 'draw', 'paint commands', 'present', 'trace refresh'): + continue + values.setdefault(name, []).append(int(row['exec_time_ns']) / 1e6) + if name == 'frame': + starts.append(at) +starts.sort() +values['frame interval'] = [(b - a) * 1000 for a, b in zip(starts, starts[1:])] +result = {} +for name, v in values.items(): + v.sort() + assert v, 'No Tracy frames: rebuild with -Dtracy=CHECKOUT' + result[name] = dict(samples=len(v), **{label: v[min(len(v)-1, int(len(v)*q))] for label, q in [('median_ms', .5), ('p95_ms', .95), ('p99_ms', .99), ('max_ms', 1)]}, over_20ms=sum(x > 20 for x in v)) +(a.out / 'results.json').write_text(json.dumps(result, indent=2) + '\n') +print(json.dumps(result, indent=2)) diff --git a/gui/build.zig b/gui/build.zig index 0cb956f..d3f75d4 100644 --- a/gui/build.zig +++ b/gui/build.zig @@ -4,13 +4,15 @@ const sketchbook = @import("sketchbook"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize }); - const canim = b.dependency("canim", .{ .target = target, .optimize = optimize }); + const tracy_path = b.option([]const u8, "tracy", "Enable Tracy profiling using this source checkout"); + const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize, .tracy = tracy_path }); + const canim = b.dependency("canim", .{ .target = target, .optimize = optimize, .tracy = tracy_path orelse "" }); const zt = b.dependency("ztrace", .{ .target = target, .optimize = optimize }); const glass = sb.addGlslc(.{ .source = b.path("src/glass.frag") }); const app = sb.app(.{ .name = "ztrace-gui", .root_source_file = b.path("src/app.zig"), .imports = &.{ .{ .name = "canim", .module = canim.module("canim") }, .{ .name = "ztrace", .module = zt.module("ztrace") }, + .{ .name = "tracy", .module = sb.modules.tracy }, } }); app.module.addAnonymousImport("glass", .{ .root_source_file = glass.spirv }); b.installArtifact(zt.artifact("ztrace")); diff --git a/gui/src/Navigation.zig b/gui/src/Navigation.zig index 7edd4d9..da888ad 100644 --- a/gui/src/Navigation.zig +++ b/gui/src/Navigation.zig @@ -64,3 +64,35 @@ test "large mapping row history keeps individual words reachable" { n.back(); try std.testing.expectEqual(@as(f64, 268435454), n.place.row); } + +/// A retargetable scroll with a fixed 200 ms deadline, independent of frame rate. +pub const Scroll = struct { + from: f64 = 0, + target: f64 = 0, + started: u64 = 0, + + pub fn sample(s: *Scroll, current: f64, target: f64, now: u64, max_travel: f64) f64 { + if (s.target != target) s.* = .{ .from = current, .target = target, .started = now }; + if (@abs(current - target) > max_travel) s.from = target; + const t = @min(1, @as(f64, @floatFromInt(now -| s.started)) / 200_000_000); + const remaining = 1 - t; + return std.math.lerp(s.from, target, 1 - remaining * remaining * remaining); + } +}; + +test "scroll timing is independent of cadence, settles exactly and retargets continuously" { + var a: Scroll = .{}; + var b: Scroll = .{}; + var x = a.sample(0, 12, 1_000_000_000, 100); + var y = b.sample(0, 12, 1_000_000_000, 100); + for (1..21) |i| x = a.sample(x, 12, 1_000_000_000 + i * 10_000_000, 100); + y = b.sample(y, 12, 1_200_000_000, 100); + try std.testing.expectEqual(@as(f64, 12), x); + try std.testing.expectEqual(x, y); + try std.testing.expectEqual(x, a.sample(x, 24, 1_250_000_000, 100)); + x = a.sample(x, 24, 1_350_000_000, 100); + try std.testing.expectEqual(@as(f64, 22.5), x); + try std.testing.expectEqual(x, a.sample(x, 6, 1_350_000_000, 100)); + try std.testing.expectEqual(@as(f64, 6), a.sample(x, 6, 1_550_000_000, 100)); + try std.testing.expectEqual(@as(f64, 1000000), a.sample(6, 1000000, 1_600_000_000, 100)); +} diff --git a/gui/src/app.zig b/gui/src/app.zig index f5ebf3d..8f4f4b5 100644 --- a/gui/src/app.zig +++ b/gui/src/app.zig @@ -7,6 +7,7 @@ const Client = @import("Client.zig"); const Navigation = @import("Navigation.zig"); const Geometry = @import("Geometry.zig"); const Sources = @import("Sources.zig"); +const tracy = @import("tracy"); var sources: Sources = .{}; pub const name = "ztrace debugger"; pub const width = 2240; @@ -71,6 +72,7 @@ pub const Session = struct { action: sk.Handled = .{}, graph: bool = false, scroll: [3]f64 = @splat(0), + scroll_motion: [3]Navigation.Scroll = @splat(.{}), base: [3]u64 = @splat(0), mini: [3]ui.Collected = @splat(.{}), mini_key: [3]u64 = @splat(0), @@ -542,6 +544,8 @@ fn pointer(s: *State, mouse_button: u16, x: f32, y: f32) void { } pub fn update(s: *State, in: *const sk.Input) void { + const zone = tracy.zone(@src(), "update"); + defer zone.end(); if (in.console) return; s.page_scroll = std.math.clamp(s.page_scroll, 0, @max(0, geometry.content - geometry.h)); for (in.events) |event| { @@ -832,6 +836,8 @@ fn paneButtons(u: ui.Ui, s: *const State, pane: Pane) void { } pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { + const zone = tracy.zone(@src(), "draw"); + defer zone.end(); if (ss.launches != s.launches) ss.* = .{ .launches = s.launches }; if (ss.action.take(s.action)) |action| switch (action.kind) { .restart => f.run("restart"), @@ -847,6 +853,8 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { if (client) |c| if (c.poll()) |update_| if (update_.generation != latest.generation) { latest = update_; if (latest.status != .running and latest.moments > loaded) { + const refresh_zone = tracy.zone(@src(), "trace refresh"); + defer refresh_zone.end(); if (zt.Trace.open(gpa, io, c.path)) |next| { if (trace) |*t| t.close(); trace = next; @@ -924,6 +932,7 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { if (ss.graph != s.graph) { ss.graph = s.graph; ss.scroll[0] = 0; + ss.scroll_motion[0] = .{}; } const seconds = @as(f32, @floatFromInt(f.in.now -| ss.changed_at)) / 1e9; const heat = changedHeat(seconds); @@ -940,14 +949,14 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { bases[p] = if (p == 0) address else ranges[p].addr; if (ss.base[p] != bases[p]) { ss.scroll[p] = 0; + ss.scroll_motion[p] = .{}; ss.base[p] = bases[p]; } if (p > 0) extents[p] = @max(0, @as(f64, @floatFromInt(ranges[p].len / (if (p == 1) @as(u64, 8) else 16))) - Geometry.visible(panes[p])); const target = if (nav.manual) nav.row else if (p == 0) @as(f64, 0) else @as(f64, @floatFromInt((address -| bases[p]) / (if (p == 1) @as(u64, 8) else 16))); - const dt = @as(f32, @floatFromInt(f.in.dt)) / 1e9; // Avoid animating across millions of uncaptured rows after an address jump. if (p == 0 and nav.follow and !nav.manual) continue; - if (@abs(ss.scroll[p] - target) > Geometry.visible(panes[p]) * 2) ss.scroll[p] = target else ss.scroll[p] = std.math.lerp(ss.scroll[p], target, 1 - @exp(-dt * 18)); + ss.scroll[p] = ss.scroll_motion[p].sample(ss.scroll[p], target, f.in.now, Geometry.visible(panes[p]) * 2); shown_scroll[p] = ss.scroll[p]; } listing(ss, m, bases[0]); @@ -989,6 +998,8 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { ties(u, s, ss); } fn listing(ss: *Session, m: zt.store.Moment, base: u64) void { + const zone = tracy.zone(@src(), "listing"); + defer zone.end(); if (ss.listing_at == m.index and ss.listing_base == base) return; ss.listing_at = m.index; ss.listing_base = base; @@ -1091,6 +1102,8 @@ fn codeRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z }; } fn drawCode(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, heat: ui.Heat, fire: f32, travel: f32) void { + const zone = tracy.zone(@src(), "drawCode"); + defer zone.end(); code_top = 32; const actual_height = @min(panes[0].h, geometry.h - 40 - panes[0].y); origin_height = if (actual_height < 250) 48 else 72; @@ -1128,8 +1141,7 @@ fn drawCode(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z } const visible = codeVisible(); const target = @max(0, @max(start - 2, ss.marker_to - visible + @min(3, visible))); - const dt = @as(f32, @floatFromInt(u.f.in.dt)) / 1e9; - ss.scroll[0] = std.math.lerp(ss.scroll[0], target, 1 - @exp(-dt * 18)); + ss.scroll[0] = ss.scroll_motion[0].sample(ss.scroll[0], target, u.f.in.now, std.math.inf(f64)); shown_scroll[0] = ss.scroll[0]; } const marker_time = @as(f32, @floatFromInt(u.f.in.now -| ss.marker_at)) / 1e9; @@ -1202,6 +1214,8 @@ fn drawCode(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z } } fn drawRegisters(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, heat: ui.Heat, seconds: f32, fire: f32) void { + const zone = tracy.zone(@src(), "drawRegisters"); + defer zone.end(); _ = u.panel(geometry.registers.w, geometry.registers.h, "registers / call stack", .{ .note = u.print("{d} changed", .{@popCount(ss.changed_regs)}) }); u.clip(.{ .x = 2, .y = 30, .w = geometry.registers.w - 4, .h = geometry.registers.h - 34 }); const v = u.moved(0, -s.register_scroll * 24); @@ -1247,6 +1261,8 @@ fn stackRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: } } fn drawStack(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, heat: ui.Heat, seconds: f32) void { + const zone = tracy.zone(@src(), "drawStack"); + defer zone.end(); _ = u.panel(panes[1].w, panes[1].h, if (panes[1].w < 600) "stack" else "stack / telescope", .{ .focus = s.focus == .stack }); if (panes[1].w > 800) u.text(.sans, 17, 235, 19, u.print("{d} pointer hops", .{s.depth}), ui.theme.color.text.dim); paneButtons(u, s, .stack); @@ -1309,6 +1325,8 @@ fn memoryRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, first } } fn drawMemory(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, heat: ui.Heat) void { + const zone = tracy.zone(@src(), "drawMemory"); + defer zone.end(); _ = u.panel(panes[2].w, panes[2].h, "memory", .{ .focus = s.focus == .memory }); paneButtons(u, s, .memory); button(u, 112, -3, .{ .kind = .unit, .address = s.unit }, "Group size: 8 / 16 / 32 / 64 bits", true, false); @@ -1323,6 +1341,8 @@ fn drawMemory(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, heat: } } fn memoryMini(u: ui.Ui, ss: *Session, m: zt.store.Moment, p: usize) void { + const zone = tracy.zone(@src(), "memoryMini"); + defer zone.end(); const stride: u64 = if (p == 1) 8 else 16; const current = bases[p] + @as(u64, @intFromFloat(ss.scroll[p])) * stride; const first = @max(bases[p], current -| 32 * stride); @@ -1384,6 +1404,8 @@ fn visibleHit(hit: Hit) bool { return true; } fn ties(u: ui.Ui, s: *const State, ss: *Session) void { + const zone = tracy.zone(@src(), "ties"); + defer zone.end(); if (s.help or s.segments or s.command_open) return; const hovered = addressAt(u.f.in.mouse_x / display_scale, u.f.in.mouse_y / display_scale); const address = if (hovered) |hit| hit.address else if (s.selected_address != 0) s.selected_address else if (ss.touch) |touch| touch.addr else return; @@ -1414,6 +1436,8 @@ fn ties(u: ui.Ui, s: *const State, ss: *Session) void { }; } fn overlays(u: ui.Ui, s: *const State, ss: *Session, moment: ?zt.store.Moment) void { + const zone = tracy.zone(@src(), "overlays"); + defer zone.end(); const ink = ui.theme.color.text; if (!s.lens) ss.lens_previous = 0; if (s.lens and moment != null) { @@ -1573,6 +1597,8 @@ fn rowOf(m: zt.store.Moment, start: u64, address: u64) ?usize { } fn selected(ss: *Session, t: *zt.Trace, m: zt.store.Moment, regs: zt.Regs, tid: u32, low: u64, now: u64) void { + const zone = tracy.zone(@src(), "selected"); + defer zone.end(); if (rowOf(m, ss.code_start, regs.rip) == null) { ss.code_start = regs.rip; for (0..6) |_| { diff --git a/gui/test/lenses.py b/gui/test/lenses.py index 528c656..e42e6fe 100644 --- a/gui/test/lenses.py +++ b/gui/test/lenses.py @@ -213,6 +213,33 @@ key escape console mouse-button 3 400 180 expect focus memory expect nav[2].place.address {head + 16} +# Register hints use the displayed value and the same address interactions. +console set annotations true +frames 40 +move 0 0 +frames 30 +screenshot {out / 'hint-before.png'} +move 640 180 +frames 30 +screenshot {out / 'hint-hover.png'} +expect-different-screenshot {out / 'hint-before.png'} {out / 'hint-hover.png'} 612 168 144 24 +click 640 180 +expect lens_count 1 +print lenses[0].address +key escape +console mouse-button 3 640 180 +expect focus stack +print nav[1].place.address +click 850 180 +expect lenses[0].address {head} +key escape +console mouse-button 3 850 180 +expect focus memory +expect nav[2].place.address {head} +# The scalar index is not an address. +click 1000 180 +expect lens_count 0 +console set annotations false # Historical operands use historical registers, without another execution. key left_bracket expect following false @@ -236,11 +263,11 @@ expect-no-log backdrop shader first = int(re.search(r'lenses\[0\].first = (\d+)', stderr)[1]) assert first > code, (first, code) stack_addresses = re.findall(r'(?:lenses\[0\].address|nav\[1\].place.address) = (\d+)', stderr) - assert len(stack_addresses) == 10, stack_addresses - base, negative, followed, zero, positive, pointer, pointer_followed, operand, operand_followed, historical = map(int, stack_addresses) + assert len(stack_addresses) == 12, stack_addresses + base, negative, followed, zero, positive, pointer, pointer_followed, operand, operand_followed, hint, hint_followed, historical = map(int, stack_addresses) assert base == negative == followed and zero == base + 24 and positive == base + 32, stack_addresses assert pointer == pointer_followed, stack_addresses - assert operand == operand_followed == historical == pointer + 8, stack_addresses + assert operand == operand_followed == hint == hint_followed == historical == pointer + 8, stack_addresses stops = re.findall(r'stops = (\d+)', stderr) assert len(stops) == 2 and stops[0] == stops[1], stops for recording in Path('/tmp').glob(f'ztrace-gui-{run.pid}-*.ztrace'): |
