diff options
| -rw-r--r-- | anim/src/rows.zig | 59 | ||||
| -rw-r--r-- | anim/src/ui.zig | 25 | ||||
| -rw-r--r-- | gui/README.md | 24 | ||||
| -rw-r--r-- | gui/bench/RESULTS.md | 33 | ||||
| -rw-r--r-- | gui/build.zig | 8 | ||||
| -rw-r--r-- | gui/src/app.zig | 227 | ||||
| -rw-r--r-- | gui/src/glass.frag | 27 | ||||
| -rw-r--r-- | gui/test/basic.script | 14 | ||||
| -rw-r--r-- | gui/test/lenses.py | 121 | ||||
| -rw-r--r-- | gui/test/restart.py | 8 |
10 files changed, 483 insertions, 63 deletions
diff --git a/anim/src/rows.zig b/anim/src/rows.zig index 4666ffd..0e4f58c 100644 --- a/anim/src/rows.zig +++ b/anim/src/rows.zig @@ -40,6 +40,65 @@ pub fn baseline(y: f32) f32 { return theme.baseline(y, row_h, size); } +pub const NumberFormat = enum { hex, unsigned, signed, float }; + +pub fn numberText(buf: []u8, octets: []const u8, format: NumberFormat) []const u8 { + var value: u64 = 0; + std.debug.assert(octets.len == 1 or octets.len == 2 or octets.len == 4 or octets.len == 8); + for (octets, 0..) |byte, i| value |= @as(u64, byte) << @intCast(i * 8); + return switch (format) { + .hex => switch (octets.len) { + 1 => std.fmt.bufPrint(buf, "{x:0>2}", .{value}), + 2 => std.fmt.bufPrint(buf, "{x:0>4}", .{value}), + 4 => std.fmt.bufPrint(buf, "{x:0>8}", .{value}), + else => std.fmt.bufPrint(buf, "{x:0>16}", .{value}), + }, + .unsigned => std.fmt.bufPrint(buf, "{d}", .{value}), + .signed => blk: { + const shift: u6 = @intCast(64 - octets.len * 8); + const signed: i64 = @bitCast(value << shift); + break :blk std.fmt.bufPrint(buf, "{d}", .{signed >> shift}); + }, + .float => if (octets.len == 4) std.fmt.bufPrint(buf, "{e}", .{@as(f32, @bitCast(@as(u32, @truncate(value))))}) else if (octets.len == 8) std.fmt.bufPrint(buf, "{e}", .{@as(f64, @bitCast(value))}) else return "—", + } catch "?"; +} + +/// Sixteen octets, grouped as little-endian values; pointer hits use the same geometry as hex rows. +pub fn wordsAt(u: ui.Ui, y: f32, addr: u64, values: *const [16]u8, known: *const [16]bool, unit: u8, format: NumberFormat, moment: Recording.Moment) f32 { + std.debug.assert(unit == 1 or unit == 2 or unit == 4 or unit == 8); + _ = u.address(theme.metric.bytes.address, baseline(y), addr, .{ .ink = ui.rgb(ink(regionOf(moment, addr))) }); + var x = theme.metric.bytes.first + addressRoom(addr); + var at_byte: usize = 0; + while (at_byte < 16) : (at_byte += unit) { + const octets = values[at_byte..][0..unit]; + const captured = std.mem.indexOfScalar(bool, known[at_byte..][0..unit], false) == null; + var buf: [64]u8 = undefined; + const text = if (captured) numberText(&buf, octets, format) else "?"; + const digits: usize = switch (format) { + .hex => unit * 2, + .unsigned => if (unit == 8) 20 else if (unit == 4) 10 else if (unit == 2) 5 else 3, + .signed => if (unit == 8) 20 else if (unit == 4) 11 else if (unit == 2) 6 else 4, + .float => if (unit == 8) 25 else 16, + }; + const width = @as(f32, @floatFromInt(digits)) * adv; + const value = if (unit == 8) std.mem.readInt(u64, octets[0..8], .little) else 0; + const pointer = captured and unit == 8 and format != .float and regionOf(moment, value) != .none; + u.text(.mono, size, x, baseline(y), text, if (pointer) ink(regionOf(moment, value)) else t.primary); + if (pointer) u.hitAddress(value, .{ .x = x, .y = y, .w = width, .h = row_h }); + x += width + adv * 2; + } + return x; +} + +test "memory scalar formats preserve byte order, sign and width" { + var buf: [64]u8 = undefined; + try std.testing.expectEqualStrings("1234", numberText(&buf, &.{ 0x34, 0x12 }, .hex)); + try std.testing.expectEqualStrings("-1", numberText(&buf, &.{ 255, 255 }, .signed)); + try std.testing.expectEqualStrings("18446744073709551615", numberText(&buf, &@as([8]u8, @splat(255)), .unsigned)); + try std.testing.expectEqualStrings("-9223372036854775808", numberText(&buf, &.{ 0, 0, 0, 0, 0, 0, 0, 128 }, .signed)); + try std.testing.expectEqualStrings("1e0", numberText(&buf, &.{ 0, 0, 128, 63 }, .float)); +} + /// The marks on a chain's hops. pub const Marks = struct { /// The first hop: a register (or a word) written: armed, struck, held. diff --git a/anim/src/ui.zig b/anim/src/ui.zig index 282a24f..2c78c04 100644 --- a/anim/src/ui.zig +++ b/anim/src/ui.zig @@ -57,6 +57,17 @@ pub const Collected = struct { }; pub var collected: Collected = .{}; +/// A selected occurrence leads, then its matches arrive in reading order. +pub fn matchProgress(seconds: f32, rank: usize, delay: f32, duration: f32) f32 { + return theme.ease(.standard, std.math.clamp((seconds - @as(f32, @floatFromInt(rank)) * delay) / @max(0.001, duration), 0, 1)); +} + +test "matching highlights reveal the selection before its peers" { + try std.testing.expect(matchProgress(0.05, 0, 0.08, 0.16) > 0); + try std.testing.expectEqual(@as(f32, 0), matchProgress(0.05, 1, 0.08, 0.16)); + try std.testing.expectEqual(@as(f32, 1), matchProgress(1, 3, 0.08, 0.16)); +} + /// A mark on the row whose middle is `y` (in `u`), for the strips; `shows` of it. pub fn collectMark(u: Ui, x: f32, y: f32, kind: Collected.Kind, shows: f32) void { if (!strokes or shows <= 0 or collected.n_marks == collected.marks.len) return; @@ -635,6 +646,20 @@ pub const Ui = struct { if (bound) |b| u.f.clip(b) else u.f.clip(null); } + pub fn matchHighlight(u: Ui, r: Rect, seconds: f32, rank: usize, options: struct { + color: Color = .hex(0x65c9d8), + selected_color: Color = .hex(0xe6bd70), + delay: f32 = 0.075, + duration: f32 = 0.16, + opacity: f32 = 0.23, + }) void { + const progress = matchProgress(seconds, rank, options.delay, options.duration); + const c = if (rank == 0) options.selected_color else options.color; + const box: Rect = .{ .x = r.x, .y = r.y, .w = r.w * progress, .h = r.h }; + u.faded(options.opacity * progress).fill(box, c); + u.faded(progress * 0.6).line(.{ r.x, r.y + r.h - 1 }, .{ r.x + box.w, r.y + r.h - 1 }, c, 1); + } + pub fn hitAddress(u: Ui, addr: u64, r: Rect) void { const hook = address_hit orelse return; if (strokes or mapping or u.at.pose.opacity < 0.1) return; diff --git a/gui/README.md b/gui/README.md index b01c1aa..b355665 100644 --- a/gui/README.md +++ b/gui/README.md @@ -14,7 +14,8 @@ zig build run -Doptimize=ReleaseFast -- --fresh ``` Use the repository's Zig toolchain and existing sibling `sketchbook` and `pardes` -checkouts. Keep the installed `ztrace` beside `ztrace-gui`. +checkouts (Sketchbook `409c1ac` or newer for native backdrop filtering). Keep the +installed `ztrace` beside `ztrace-gui`. ## Controls @@ -36,6 +37,8 @@ goto memory 0x12345678 source-map /remote/build/source /local/source symbols /tmp/current-jit-object.o origin 0x12345678 +lens 0x12345678 +memory-format 8 hex ``` `break` accepts function, file:line and `*address` forms. `origin` retains the @@ -82,8 +85,23 @@ when supplied by recorded code, symbols or a known entry point. Click an address to open a connected lens. Further pointers keep their ancestors; a different pointer in a parent replaces its descendants. Each close button closes that lens and its children. Cycles, unreadable addresses and uncaptured historical -bytes are labeled. Long chains scroll within the overlay. Right-click routes an -address to disassembly, stack telescope or memory according to its mapping/value. +bytes are labeled. Executable mappings open disassembly lenses. Wheel over a +lens body to browse its segment; the original focus area stays bright while +surrounding rows dim. Shift-wheel, headers and gaps scroll the lens chain. +Right-click sends stack addresses to the stack pane and every other address to +memory. Matching addresses get staggered background highlights: the selected +occurrence appears first, followed by its peers. Lens ancestry keeps its connectors. + +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 +FORMAT` sets byte sizes 1/2/4/8 and `hex`, `unsigned`, `signed` or `float` directly; +floats require 4 or 8 bytes. Unknown bytes stay unknown; these controls only +change rendering. Wide values remain reachable with Shift-h/l. + +Lenses keep an opaque reading surface, with a native GPU backdrop shader for +edge refraction, subtle color separation and a cyan rim. A canvas-sized texture and one reusable lens snapshot +are independent of font zoom and lens count. Non-GPU rendering keeps an opaque +fallback. `set glass false` in the renderer console disables the effect. The graph uses recorded basic blocks and shared graph layout. It is scoped to captured code, not a complete static analysis of an entire executable. Gold marks diff --git a/gui/bench/RESULTS.md b/gui/bench/RESULTS.md index 5281ac2..e0c5626 100644 --- a/gui/bench/RESULTS.md +++ b/gui/bench/RESULTS.md @@ -154,3 +154,36 @@ The reboot cleared the historical `/tmp` artifacts listed above. The same V8 revision's runtime, source and all split DWARF artifacts have been restored into `.ws/v8-debug/`, an ignored persistent workspace cache. Historical timing results remain as reported; the fresh UI regression does not remeasure V8 stepping cost. + +## Executable lenses, memory formats and popup rendering + +Executable mappings now open shared disassembly rows in lenses. Wheel browsing +keeps the original focus bright and surrounding rows dim; Shift-wheel scrolls +the chain. Live lenses fetch bounded windows; historical lenses never request +current bytes. Right-click sends stack mappings to stack and other addresses to +memory. Memory controls render little-endian 1/2/4/8-byte values in hexadecimal, +unsigned, signed and floating-point forms. Matching addresses use shared, +staggered background highlights instead of cross-pane arrows. + +Native review caught two issues before completion: the backdrop initially ran +only in headless capture, and full-precision 64-bit floats exceeded their column +width. The shared host now uses a native GPU canvas plus one reused lens snapshot; +float columns reserve enough room for extreme positive and negative values. +The final popup keeps an opaque reading surface and limits refraction to a +16-pixel edge band, following the user's readability feedback. + +Verification: GUI suite (including `test/lenses.py`), shared-renderer suite, +independent native lens/format review, native restart tests and repeated 60–200% +zoom with open lenses. Window/backing sizes stayed fixed. The native review used +DBL_MAX/DBL_MIN and signed/unsigned 64-bit extrema, not only small sample values. +The renderer dependency is Sketchbook `409c1ac`; unrelated pending work in that +checkout was preserved. V8 stepping/capture timings were not remeasured for these +rendering-only changes. + +Final live session after the opaque-popup change: GUI PID17379, d8 PID17420, +recording `/tmp/ztrace-gui-17379-8471380224093.ztrace`. Generated wrong-map exit +`0x7f4c80c01fb6` was captured before continuing to `Deoptimizer::New+4` at +`0x7f4ce1be3f74` (`deoptimizer.cc:290`). Its `rdx` was exactly +`0x7f4c80c01fba`, the printed wrong-map return for the naturally optimized +`jitWork`. Origin context and the executable lens use guard `0x7f4c80c01bd4`. +The target remains stopped; lens inspection only captures bytes and instructions. diff --git a/gui/build.zig b/gui/build.zig index bedba3d..0cb956f 100644 --- a/gui/build.zig +++ b/gui/build.zig @@ -7,10 +7,12 @@ pub fn build(b: *std.Build) void { const sb = sketchbook.init(b, .{ .target = target, .optimize = optimize }); const canim = b.dependency("canim", .{ .target = target, .optimize = optimize }); 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") }, } }); + app.module.addAnonymousImport("glass", .{ .root_source_file = glass.spirv }); b.installArtifact(zt.artifact("ztrace")); const exe = b.addExecutable(.{ .name = "ztrace-gui", .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), @@ -70,4 +72,10 @@ pub fn build(b: *std.Build) void { restart.addFileArg(b.graph.path(.install_bin, "ztrace-gui")); restart.step.dependOn(b.getInstallStep()); tests.dependOn(&restart.step); + const lenses = b.addSystemCommand(&.{"python3"}); + lenses.addFileArg(b.path("test/lenses.py")); + lenses.addArg("--gui"); + lenses.addFileArg(b.graph.path(.install_bin, "ztrace-gui")); + lenses.step.dependOn(b.getInstallStep()); + tests.dependOn(&lenses.step); } diff --git a/gui/src/app.zig b/gui/src/app.zig index bed93f4..c9600b8 100644 --- a/gui/src/app.zig +++ b/gui/src/app.zig @@ -36,6 +36,11 @@ pub const State = struct { annotations: bool = true, depth: u8 = 4, ascii: bool = true, + unit: u8 = 1, + number_format: canim.rows.NumberFormat = .hex, + selected_address: u64 = 0, + selected_box: Box = .{}, + glass: bool = true, zoom: u16 = 100, page_scroll: f32 = 0, register_scroll: f32 = 0, @@ -88,6 +93,10 @@ pub const Session = struct { origin_line: ?zt.store.Line = null, lens_at: u64 = 0, lens_previous: u64 = 0, + lens_inspected: [32]u64 = @splat(0), + match_address: u64 = 0, + match_box: Box = .{}, + match_at: u64 = 0, shown: ?u64 = null, tid: u32 = 0, @@ -102,8 +111,8 @@ pub const Session = struct { branch: ?canim.Recording.Branch = null, }; const Pane = enum { code, stack, memory }; -const Lens = struct { address: u64 = 0, origin: Box = .{}, cycle: bool = false }; -const Kind = enum { restart, graph, dim, segments, select_segment, cont, pause, stepi, step, previous, next, live, follow, back, forward, source, map, annotate, shallower, deeper, ascii, lens, close_lens, help, breakpoint, command, go, submit }; +const Lens = struct { address: u64 = 0, first: u64 = 0, focus_end: u64 = 0, origin: Box = .{}, cycle: bool = false }; +const Kind = enum { unit, number_format, restart, graph, dim, segments, select_segment, cont, pause, stepi, step, previous, next, live, follow, back, forward, source, map, annotate, shallower, deeper, ascii, lens, close_lens, help, breakpoint, command, go, submit }; const Action = struct { kind: Kind, pane: Pane = .code, address: u64 = 0, manual: bool = false }; const Box = sk.Rect; var geometry = Geometry.init(width, height, 0); @@ -173,7 +182,7 @@ pub fn command(s: *State, c: *sk.Console, line: []const u8) !bool { sources.clear(gpa); latest = .{}; loaded = 0; - s.* = .{ .launches = s.launches + 1, .status = .running, .zoom = s.zoom, .maps = s.maps, .source = s.source, .annotations = s.annotations, .depth = s.depth, .ascii = s.ascii, .dim = s.dim }; + s.* = .{ .launches = s.launches + 1, .status = .running, .zoom = s.zoom, .maps = s.maps, .source = s.source, .annotations = s.annotations, .depth = s.depth, .ascii = s.ascii, .unit = s.unit, .number_format = s.number_format, .glass = s.glass, .dim = s.dim }; client = Client.start(gpa, io, argv.items) catch |err| { s.status = .failed; return err; @@ -220,6 +229,21 @@ pub fn command(s: *State, c: *sk.Console, line: []const u8) !bool { if (std.mem.eql(u8, cmd, "continue") or (std.mem.eql(u8, cmd, "stepi") or std.mem.eql(u8, cmd, "nextline"))) s.following = true; return true; } + if (std.mem.eql(u8, cmd, "lens")) { + const address = try std.fmt.parseInt(u64, words.next() orelse return error.MissingAddress, 0); + if (words.next() != null) return error.InvalidAddress; + openLens(s, .{ .address = address, .box = .{}, .lens = null }); + return true; + } + if (std.mem.eql(u8, cmd, "memory-format")) { + const unit = try std.fmt.parseInt(u8, words.next() orelse return error.MissingSize, 10); + if (unit != 1 and unit != 2 and unit != 4 and unit != 8) return error.InvalidSize; + const format = std.meta.stringToEnum(canim.rows.NumberFormat, words.next() orelse return error.MissingFormat) orelse return error.InvalidFormat; + if (words.next() != null or (format == .float and unit < 4)) return error.InvalidFormat; + s.unit = unit; + s.number_format = format; + return true; + } if (std.mem.eql(u8, cmd, "origin")) { s.origin = try std.fmt.parseInt(u64, words.next() orelse return error.MissingAddress, 0); return true; @@ -353,6 +377,14 @@ fn act(s: *State, a: Action) void { .shallower => s.depth = @max(1, s.depth -| 1), .deeper => s.depth = @min(6, s.depth + 1), .ascii => s.ascii = !s.ascii, + .unit => { + s.unit = if (s.unit >= 8) 1 else s.unit * 2; + if (s.number_format == .float and s.unit < 4) s.number_format = .hex; + }, + .number_format => { + s.number_format = @fromBackingInt(@intCast(@backingInt(s.number_format) +% 1)); + if (s.number_format == .float and s.unit < 4) s.unit = 4; + }, .lens => { if (s.lens) { s.lens = false; @@ -375,15 +407,7 @@ fn act(s: *State, a: Action) void { fn semantic(s: *State, address: u64) void { const t = if (trace) |*t| t else return; const m = t.moment(@min(s.moment, t.len -| 1)) catch return; - const region = canim.rows.regionOf(m, address); - const pane: Pane = switch (region) { - .code, .rwx => .code, - .stack => .stack, - else => blk: { - const value = (canim.Recording.word(m, address, 8) catch null) orelse break :blk .memory; - break :blk if (canim.rows.regionOf(m, value) != .none) .stack else .memory; - }, - }; + const pane: Pane = if (canim.rows.regionOf(m, address) == .stack) .stack else .memory; s.lens_address = address; s.focus = pane; s.action.send(.{ .kind = .go, .pane = pane, .address = address }); @@ -415,16 +439,43 @@ fn openLens(s: *State, hit: Hit) void { for (s.lenses[0..at]) |lens| if (lens.address == hit.address) { cycle = true; }; - s.lenses[at] = .{ .address = hit.address, .origin = hit.box, .cycle = cycle }; + const m = if (trace) |*t| t.moment(@min(s.moment, t.len -| 1)) catch return else return; + const first = if (executable(m, hit.address)) hit.address else (hit.address & ~@as(u64, 15)) -| 32; + var focus_end = first +| 80; + if (executable(m, hit.address)) { + focus_end = first; + for (0..6) |_| { + var text: [1024]u8 = undefined; + const insn = (zt.telescope.instruction(m, focus_end, &text) catch null) orelse break; + if (insn.len == 0) break; + focus_end +|= insn.len; + } + if (focus_end == first) focus_end = first +| 24; + } + s.lenses[at] = .{ .address = hit.address, .first = first, .focus_end = focus_end, .origin = hit.box, .cycle = cycle }; s.lens_count = at + 1; s.lens = true; s.lens_address = hit.address; s.lens_scroll = lensScroll(s.lens_count, true); - if (client != null and s.status == .stopped and s.following and !cycle) { - var buf: [96]u8 = undefined; - client.?.send(std.fmt.bufPrint(&buf, "inspect memory 0x{x} 128", .{(hit.address & ~@as(u64, 15)) -| 32}) catch return) catch {}; +} +fn executable(m: zt.store.Moment, address: u64) bool { + const map = (m.mapping(address, null, &.{}) catch null) orelse return false; + return map.prot & 4 != 0; +} +fn scrollLens(s: *State, index: usize, rows: f32) void { + const m = if (trace) |*t| t.moment(@min(s.moment, t.len -| 1)) catch return else return; + const lens = &s.lenses[index]; + if (lens.cycle) return; + const map = (m.mapping(lens.address, null, &.{}) catch null) orelse return; + const count: usize = @min(64, @as(usize, @intFromFloat(@ceil(@abs(rows))))); + for (0..count) |_| { + var buf: [1024]u8 = undefined; + const insn = if (executable(m, lens.address)) zt.telescope.instruction(m, lens.first, &buf) catch null else null; + const step: u64 = if (executable(m, lens.address)) (if (insn) |v| if (rows < 0) @max(1, v.back) else @max(1, v.len) else 1) else 16; + lens.first = std.math.clamp(if (rows < 0) lens.first -| step else lens.first +| step, map.addr, map.addr +| map.len -| 1); } } + fn lensViewport() Box { const y = @max(140, geometry.top + 12); return .{ .x = @max(24, geometry.w - 1132), .y = y, .w = @min(1108, geometry.w - 48), .h = @max(0, geometry.h - y - 40) }; @@ -452,6 +503,10 @@ fn pointer(s: *State, mouse_button: u16, x: f32, y: f32) void { }; return; } + if (addressAt(x, y)) |hit| { + s.selected_address = hit.address; + s.selected_box = hit.box; + } if (paneAt(x, y)) |pane| s.focus = pane; if (mouse_button == 4 or mouse_button == 5) { act(s, .{ .kind = if (mouse_button == 4) .back else .forward, .pane = s.focus }); @@ -547,7 +602,11 @@ pub fn update(s: *State, in: *const sk.Input) void { }, .wheel => { if (s.lens and lens_box != null and contains(lens_box.?, e.x, e.y)) { - s.lens_scroll = std.math.clamp(s.lens_scroll - e.wheel() * 48, 0, lensScroll(s.lens_count, false)); + var body: ?usize = null; + for (lens_boxes[0..drawn_lenses], 0..) |box, i| if (contains(box, e.x, e.y) and e.y >= box.y + 30) { + body = i; + }; + if (body != null and !in.held(sk.Key.left_shift) and !in.held(sk.Key.right_shift)) scrollLens(s, body.?, -e.wheel() * 3) else s.lens_scroll = std.math.clamp(s.lens_scroll - e.wheel() * 48, 0, lensScroll(s.lens_count, false)); } else if (contains(geometry.registers, e.x, e.y) and e.y >= geometry.registers.y + 30) { s.register_scroll = std.math.clamp(s.register_scroll - e.wheel() * 3, 0, @max(0, 29 - Geometry.visible(geometry.registers))); } else if (paneAt(e.x, e.y)) |pane| { @@ -750,7 +809,10 @@ fn button(u: ui.Ui, x: f32, y: f32, action: Action, label: []const u8, available const v = (if (available) u else u.faded(0.32)).moved(x, y); v.fill(.{ .x = 0, .y = 0, .w = 34, .h = 32 }, if (hover or active) ui.theme.color.rule else ui.theme.color.raised); if (hover or active) v.frame(.{ .x = 0, .y = 0, .w = 34, .h = 32 }, if (active) ui.theme.mark(.current).solid else ui.theme.color.text.dim, 1); - icon(v, action.kind, active); + if (action.kind == .unit) v.text(.mono_bold, 17, 5, 23, v.print("{d}", .{action.address * 8}), ui.theme.color.text.primary) else if (action.kind == .number_format) { + const labels = [_][]const u8{ "x", "u", "d", "f" }; + v.text(.mono_bold, 20, 10, 23, labels[@min(action.address, 3)], ui.theme.color.text.primary); + } else icon(v, action.kind, active); } fn paneButtons(u: ui.Ui, s: *const State, pane: Pane) void { const p = @backingInt(pane); @@ -896,6 +958,7 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { if (ss.capture_stop != s.execution) { ss.capture_stop = s.execution; ss.inspected = @splat(0); + ss.lens_inspected = @splat(0); } // Captures are bounded and only requested from the selected live stop. if (client != null and s.following and s.status == .stopped) for (0..3) |p| { @@ -916,14 +979,14 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { drawMemory(u.moved(panes[2].x, panes[2].y), s, ss, m, heat); ui.bound = null; u.unclip(); - ties(u, s, ss, m, travel); const place = if (t.len <= 1) 1 else @as(f32, @floatFromInt(m.index)) / @as(f32, @floatFromInt(t.len - 1)); u.fill(.{ .x = 24, .y = geometry.h - 34, .w = geometry.w - 48, .h = 2 }, ui.theme.color.rule); u.fill(.{ .x = 24, .y = geometry.h - 34, .w = (geometry.w - 48) * place, .h = 2 }, gold.solid); u.fill(.{ .x = 22 + (geometry.w - 48) * place, .y = geometry.h - 37, .w = 4, .h = 8 }, gold.solid); - if (geometry.w >= 1200 and geometry.content <= geometry.h + 1) u.text(.sans, 17, 24, geometry.h - 9, if (s.following) "Live stop · right-click an address to follow its meaning · click for a lens" else "Recorded state · inspecting and navigating leave the target unchanged", ink.dim); + if (geometry.w >= 1200 and geometry.content <= geometry.h + 1) u.text(.sans, 17, 24, geometry.h - 9, if (s.following) "Live stop · right-click: stack / memory · click for a lens" else "Recorded state · inspecting and navigating leave the target unchanged", ink.dim); if (geometry.content > geometry.h) u.text(.sans, 16, 24, geometry.h - 9, "PgUp/PgDn · scroll pane headers", ink.dim); overlays(u, s, ss, m); + ties(u, s, ss); } fn listing(ss: *Session, m: zt.store.Moment, base: u64) void { if (ss.listing_at == m.index and ss.listing_base == base) return; @@ -1204,7 +1267,7 @@ fn drawStack(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: memoryMini(u, ss, m, 1); } } -fn memoryRow(u: ui.Ui, m: zt.store.Moment, addr: u64, y: f32, room: f32, ascii: bool, touch: ?canim.Recording.Touch, heat: ui.Heat, before: ?zt.store.Moment) void { +fn memoryRow(u: ui.Ui, m: zt.store.Moment, addr: u64, y: f32, room: f32, ascii: bool, unit: u8, format: canim.rows.NumberFormat, touch: ?canim.Recording.Touch, heat: ui.Heat, before: ?zt.store.Moment) void { var values: [16]u8 = @splat(0); var known: [16]bool = @splat(false); m.read(addr, &values, &known) catch {}; @@ -1223,12 +1286,15 @@ fn memoryRow(u: ui.Ui, m: zt.store.Moment, addr: u64, y: f32, room: f32, ascii: run.* = .{ .first = @intCast(offset), .len = 8, .kind = if (canim.rows.regionOf(m, word) != .none) .pointer else .number, .read = read, .heat = if (changed != null) heat else .none, .changed = changed }; } const shift = canim.rows.addressRoom(addr); - canim.rows.bytesAt(u, y, addr, &values, &known, &runs, canim.rows.ink(canim.rows.regionOf(m, addr)), 0, false, m, shift); + const text_x: f32 = if (unit == 1 and format == .hex) blk: { + canim.rows.bytesAt(u, y, addr, &values, &known, &runs, canim.rows.ink(canim.rows.regionOf(m, addr)), 0, false, m, shift); + break :blk 640 + shift; + } else canim.rows.wordsAt(u, y, addr, &values, &known, unit, format, m); if (ascii) { var chars: [16]u8 = undefined; for (&chars, values, known) |*c, v, k| c.* = if (!k) '?' else if (v >= 32 and v < 127) v else '.'; - u.text(.mono, 20, 640 + shift, canim.rows.baseline(y), &chars, ui.theme.color.text.dim); - } else { + u.text(.mono, 20, text_x, canim.rows.baseline(y), &chars, ui.theme.color.text.dim); + } else if (unit == 1 and format == .hex) { const fields = [_]canim.hexdump.Field{ .{ .at = 0, .len = 8, .reads = if (runs[0].kind == .pointer) .pointer else .number }, .{ .at = 8, .len = 8, .reads = if (runs[1].kind == .pointer) .pointer else .number } }; _ = canim.hexdump.readingIn(u, y, shift, m, &values, &known, &fields, room); } @@ -1239,13 +1305,15 @@ fn memoryRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, first const before = if (m.index > 0) trace.?.moment(m.index - 1) catch null else null; for (start..@min(start + count, @as(usize, @intCast(ranges[2].len / 16)))) |i| { const y = (if (miniature) @as(f32, 0) else 32) + @as(f32, @floatCast((@as(f64, @floatFromInt(i)) - first) * 24)); - memoryRow(u, m, bases[2] +| i * 16, y, panes[2].w - if (s.maps[2]) @as(f32, 60) else 0, s.ascii, ss.touch, heat, if (miniature) null else before); + memoryRow(u, m, bases[2] +| i * 16, y, panes[2].w - if (s.maps[2]) @as(f32, 60) else 0, s.ascii, s.unit, s.number_format, ss.touch, heat, if (miniature) null else before); } } fn drawMemory(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, heat: ui.Heat) void { - _ = u.panel(panes[2].w, panes[2].h, if (panes[2].w < 600) "memory" else "memory / bytes", .{ .focus = s.focus == .memory }); - if (panes[2].w > 800) u.text(.sans, 17, 220, 19, if (s.ascii) "hex · ASCII" else "hex · pointer words", ui.theme.color.text.dim); + _ = 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); + button(u, 150, -3, .{ .kind = .number_format, .address = @backingInt(s.number_format) }, "Format: hex / unsigned / signed / float", true, false); + if (panes[2].w > 800) u.text(.sans, 16, 195, 19, u.print("{d}-bit {s}", .{ s.unit * 8, @tagName(s.number_format) }), ui.theme.color.text.dim); u.clip(.{ .x = 2, .y = 30, .w = panes[2].w - if (s.maps[2]) @as(f32, 60) else 4, .h = panes[2].h - 38 }); memoryRows(u.moved(-s.horizontal[2], 0), s, ss, m, ss.scroll[2], heat, false); u.unclip(); @@ -1278,7 +1346,7 @@ fn memoryMini(u: ui.Ui, ss: *Session, m: zt.store.Moment, p: usize) void { const y = @as(f32, @floatFromInt(row)) * 24; if (p == 1) { _ = canim.rows.slot(v, y, panes[p].w - 60, m, address, 0, &.{}, 0, .{ .most = 2 }, "", false, null); - } else memoryRow(v, m, address, y, panes[p].w - 60, true, null, .none, null); + } else memoryRow(v, m, address, y, panes[p].w - 60, true, 1, .hex, null, .none, null); } ui.strokes = false; u.unclip(); @@ -1307,27 +1375,43 @@ fn segmentMini(u: ui.Ui, p: usize, first: u64, len: u64, current: u64) void { u.line(.{ box.x, y }, .{ box.x + box.w, y }, ui.theme.mark(.current).solid, 2); } } -fn ties(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, travel: f32) void { - _ = m; +fn visibleHit(hit: Hit) bool { + if (hit.lens != null) return true; + const overlay = lens_box orelse return true; + const x = hit.box.x + hit.box.w / 2; + const y = hit.box.y + hit.box.h / 2; + if (contains(overlay, x, y)) for (lens_boxes[0..drawn_lenses]) |box| if (contains(box, x, y)) return false; + return true; +} +fn ties(u: ui.Ui, s: *const State, ss: *Session) void { + 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 (ss.touch) |touch| touch.addr else return; - var from: ?Box = if (hovered) |hit| hit.box else null; - for (hits[0..hit_count]) |hit| if (hit.address == address) { - if (from == null) { - from = hit.box; - continue; - } - const a = from.?; - const b = hit.box; - if (a.x == b.x and a.y == b.y) continue; - u.read(.{ .x = b.x, .y = b.y, .w = b.w, .h = b.h }, 1); - if (s.annotations) { - const lane = @min(geometry.w - 12, @max(a.x + a.w, b.x + b.w) + 12); - u.route(&.{ .{ a.x + a.w, a.y + a.h / 2 }, .{ lane, a.y + a.h / 2 }, .{ lane, b.y + b.h / 2 }, .{ b.x + b.w, b.y + b.h / 2 } }, ui.theme.mark(.read).solid, .{ .width = 1.5, .head = .{ 6, 6 }, .progress = if (hovered != null) 1 else travel }); - break; - } + 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; + var from: ?Box = if (hovered) |hit| hit.box else if (s.selected_address != 0) s.selected_box else null; + if (from == null) for (hits[0..hit_count]) |hit| if (hit.address == address) { + from = hit.box; + break; + }; + var first_visible: ?Box = null; + var origin_visible = false; + for (hits[0..hit_count]) |hit| if (hit.address == address and visibleHit(hit)) { + if (first_visible == null) first_visible = hit.box; + if (from != null and std.meta.eql(hit.box, from.?)) origin_visible = true; + }; + if (!origin_visible) from = first_visible; + const origin = from orelse return; + if (ss.match_address != address or !std.meta.eql(ss.match_box, origin)) { + ss.match_address = address; + ss.match_box = origin; + ss.match_at = u.f.in.now; + } + const seconds = @as(f32, @floatFromInt(u.f.in.now -| ss.match_at)) / 1e9; + var rank: usize = 1; + for (hits[0..hit_count]) |hit| if (hit.address == address and visibleHit(hit)) { + const first = std.meta.eql(origin, hit.box); + u.matchHighlight(.{ .x = hit.box.x, .y = hit.box.y, .w = hit.box.w, .h = hit.box.h }, seconds, if (first) 0 else rank, .{}); + if (!first) rank += 1; }; - if (hovered) |h| u.read(.{ .x = h.box.x, .y = h.box.y, .w = h.box.w, .h = h.box.h }, 1); } fn overlays(u: ui.Ui, s: *const State, ss: *Session, moment: ?zt.store.Moment) void { const ink = ui.theme.color.text; @@ -1348,23 +1432,60 @@ fn overlays(u: ui.Ui, s: *const State, ss: *Session, moment: ?zt.store.Moment) v const box: Box = .{ .x = overlay.x, .y = overlay.y + @as(f32, @floatFromInt(k)) * 204 - s.lens_scroll + (if (k + 1 == s.lens_count) 8 * (1 - amount) else 0), .w = overlay.w, .h = 188 }; lens_boxes[k] = box; drawn_lenses = k + 1; - current_lens = @intCast(k); const v = u.moved(box.x, box.y); - v.fill(.{ .x = 0, .y = 0, .w = box.w, .h = box.h }, ui.theme.color.lift); - _ = v.panel(box.w, box.h, v.print("lens {d}", .{k + 1}), .{}); + if (box.y + box.h <= overlay.y or box.y >= overlay.y + overlay.h) continue; + current_lens = @intCast(k); + const code = executable(moment.?, lens.address); + if (s.glass and u.f.host.gpu()) { + const uniforms = [4]f32{ box.w * display_scale, box.h * display_scale, display_scale, 0 }; + u.f.backdrop(Geometry.scaled(box, display_scale), @embedFile("glass"), std.mem.asBytes(&uniforms)); + v.faded(0.25).fill(.{ .x = 0, .y = 0, .w = box.w, .h = box.h }, ui.theme.color.lift); + } else v.fill(.{ .x = 0, .y = 0, .w = box.w, .h = box.h }, ui.theme.color.lift); + _ = v.faded(if (s.glass) 0.8 else 1).panel(box.w, box.h, v.print("lens {d}", .{k + 1}), .{}); + if (box.w > 520) v.text(.sans, 15, 320, 21, if (code) "disassembly · wheel browse · Shift-wheel chain" else "memory · wheel browse · Shift-wheel chain", ink.dim); + if (client != null and s.following and s.status == .stopped and !lens.cycle) { + const key = lens.first ^ (s.pc *% 0x9e3779b97f4a7c15); + if (ss.lens_inspected[k] != key) { + ss.lens_inspected[k] = key; + u.f.run(v.print("inspect {s} 0x{x} {d}", .{ if (code) "code" else "memory", lens.first, @as(u32, if (code) 32 else 128) })); + } + } _ = v.address(90, 21, lens.address, .{ .ink = ui.rgb(canim.rows.ink(canim.rows.regionOf(moment.?, lens.address))) }); button(v, box.w - 40, -2, .{ .kind = .close_lens, .address = k }, "Close lens and descendants", true, false); v.clip(.{ .x = 2, .y = 30, .w = box.w - 4, .h = box.h - 32 }); if (lens.cycle) { v.text(.sans_medium, 20, 16, 65, "Cycle · this address is already an ancestor", ui.theme.mark(.current).solid); } else { - const first = (lens.address & ~@as(u64, 15)) -| 32; + const first = lens.first; + const focus_start = if (code) lens.address else (lens.address & ~@as(u64, 15)) -| 32; var bytes: [80]u8 = undefined; var known: [80]bool = @splat(false); moment.?.read(first, &bytes, &known) catch {}; if (std.mem.indexOfScalar(bool, &known, true) == null) { v.text(.sans, 18, 16, 62, if (s.following and s.status == .stopped) "Unreadable pointer · no bytes captured" else "Uncaptured at this recorded stop", ink.dim); - } else for (0..5) |i| memoryRow(v, moment.?, first +| i * 16, 34 + @as(f32, @floatFromInt(i)) * 24, box.w - 12, false, null, .none, null); + } else if (code) { + var pc = first; + for (0..6) |i| { + var text: [1024]u8 = undefined; + const insn = (zt.telescope.instruction(moment.?, pc, &text) catch null) orelse { + v.text(.sans, 18, 16, 53 + @as(f32, @floatFromInt(i)) * 24, "Instructions not captured at this stop", ink.dim); + break; + }; + var encoded: [15]u8 = undefined; + var captured: [15]bool = @splat(false); + if (insn.len == 0 or insn.len > 15) break; + moment.?.read(pc, encoded[0..insn.len], captured[0..insn.len]) catch break; + if (std.mem.indexOfScalar(bool, captured[0..insn.len], false) != null) break; + const row: canim.disasm.Insn = .{ .addr = pc, .len = insn.len, .text = insn.text }; + const context = pc < focus_start or pc >= lens.focus_end; + canim.disasm.liveRow(v.faded(if (context) 0.4 else 1), row, 34 + @as(f32, @floatFromInt(i)) * 24, box.w - 12, moment.?, (moment.?.regs(s.tid) catch null) orelse .{}, .{ .compact = box.w < 520 }); + pc +|= insn.len; + } + } else for (0..6) |i| { + const address = first +| i * 16; + const context = address < focus_start or address >= lens.focus_end; + memoryRow(v.faded(if (context) 0.4 else 1), moment.?, address, 34 + @as(f32, @floatFromInt(i)) * 24, box.w - 12, false, s.unit, s.number_format, null, .none, null); + } } v.unclip(); current_lens = null; @@ -1413,7 +1534,7 @@ fn overlays(u: ui.Ui, s: *const State, ss: *Session, moment: ?zt.store.Moment) v v.fill(.{ .x = 0, .y = 0, .w = w, .h = @min(560, geometry.h - 160) }, ui.theme.color.lift); _ = v.panel(w, @min(560, geometry.h - 160), "Keys · Esc closes", .{ .focus = true }); v.clip(.{ .x = 0, .y = 32, .w = w, .h = @max(0, geometry.h - 192) }); - const lines = [_][]const u8{ "s instruction · n source · c run", "Esc / Ctrl-c pause · Shift-r restart", "Ctrl +/− font · Ctrl-0 reset", "j/k scroll · PgUp/PgDn page", "h/l source · Shift-h/l horizontal", "Ctrl-d/u half page · Tab focus", "Ctrl-o/i address history", "[ / ] stops · F live · f follow", "t graph · d unobserved opacity", "p segments · v source · m minimap", "click: lens · right-click: navigate", "z lens · : command · ? help", "Gold current · bright observed", "Branch target: prediction only", "Dim: unknown between live stops" }; + const lines = [_][]const u8{ "s instruction · n source · c run", "Esc / Ctrl-c pause · Shift-r restart", "Ctrl +/− font · Ctrl-0 reset", "j/k scroll · PgUp/PgDn page", "h/l source · Shift-h/l horizontal", "Ctrl-d/u half page · Tab focus", "Ctrl-o/i address history", "[ / ] stops · F live · f follow", "t graph · d unobserved opacity", "p segments · v source · m minimap", "click: lens · right-click: stack/memory", "Lens wheel: browse · Shift: chain", "z lens · : command · ? help", "Gold current · bright observed", "Branch target: prediction only", "Dim: unknown between live stops" }; for (lines, 0..) |line, i| v.text(.mono, 16, 12, 58 + @as(f32, @floatFromInt(i)) * 30, canim.rows.fitted(v, line, w - 24), ink.primary); v.unclip(); } diff --git a/gui/src/glass.frag b/gui/src/glass.frag new file mode 100644 index 0000000..6e6f2a7 --- /dev/null +++ b/gui/src/glass.frag @@ -0,0 +1,27 @@ +#version 450 +layout(location=0) in vec4 color; +layout(location=1) in vec2 uv; +layout(set=2, binding=0) uniform sampler2D backdrop; +layout(set=3, binding=0) uniform Glass { vec4 size; } glass; +layout(location=0) out vec4 out_color; +void main() { + vec2 px = uv * glass.size.xy; + vec2 half_size = glass.size.xy * .5; + float radius = min(18.0 * glass.size.z, half_size.y); + vec2 q = abs(px - half_size) - (half_size - radius); + float distance = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius; + float edge = 1.0 - smoothstep(0.0, 16.0 * glass.size.z, max(-distance, 0.0)); + vec2 normal = normalize((px - half_size) / max(half_size, vec2(1.0)) + vec2(.0001)); + vec2 offset = normal * (2.0 + 11.0 * edge) * glass.size.z / glass.size.xy; + vec2 refracted = clamp(uv - offset, vec2(.002), vec2(.998)); + vec2 split = normal * 1.2 * edge * glass.size.z / glass.size.xy; + vec3 scene = vec3(texture(backdrop, refracted + split).r, + texture(backdrop, refracted).g, + texture(backdrop, refracted - split).b); + vec3 tint = mix(vec3(.035, .05, .10), scene, .34 * edge); + float rim = exp(-abs(distance + 1.4 * glass.size.z) / (1.1 * glass.size.z)); + float light = .35 + .65 * max(dot(normal, normalize(vec2(-.4,-1.0))), 0.0); + tint += vec3(.23, .72, .85) * rim * light * .65; + tint += vec3(.025, .08, .1) * edge; + out_color = vec4(tint, 1.0 - smoothstep(-1.0, 1.0, distance)) * color; +} diff --git a/gui/test/basic.script b/gui/test/basic.script index be2034f..9aeb647 100644 --- a/gui/test/basic.script +++ b/gui/test/basic.script @@ -49,14 +49,14 @@ release left_ctrl expect nav[2].place.row 7 key f expect nav[2].place.follow true -# Rendered code addresses route to disassembly, including source-aligned rows. +# Right-click always opens bytes; only stack mappings use the stack pane. console mouse-button 3 650 204 -expect focus code -expect nav[0].place.follow false -console mouse-button 4 650 204 -expect nav[0].place.follow true -console mouse-button 5 650 204 -expect nav[0].place.follow false +expect focus memory +expect nav[2].place.follow false +console mouse-button 4 1500 1000 +expect nav[2].place.follow true +console mouse-button 5 1500 1000 +expect nav[2].place.follow false key f # Stack storage addresses route to telescope. console mouse-button 3 250 855 diff --git a/gui/test/lenses.py b/gui/test/lenses.py new file mode 100644 index 0000000..c78e250 --- /dev/null +++ b/gui/test/lenses.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +"""Executable/data lenses, scroll bounds, display formats and native glass rendering.""" +import argparse +from pathlib import Path +import re +import subprocess +import tempfile + +ROOT = Path(__file__).resolve().parents[2] +p = argparse.ArgumentParser(description=__doc__) +p.add_argument('--gui', type=Path, default=ROOT / 'gui/zig-out/bin/ztrace-gui') +p.add_argument('--native', action='store_true') +p.add_argument('--output', type=Path) +a = p.parse_args() +a.gui = a.gui.resolve() +with tempfile.TemporaryDirectory(prefix='ztrace-lenses-') as directory: + out = a.output.resolve() if a.output else Path(directory) + out.mkdir(parents=True, exist_ok=True) + target = out / 'segments' + subprocess.run(['cc', '-g', '-O0', '-no-pie', str(ROOT / 'gui/targets/segments.c'), '-o', str(target)], check=True) + symbols = {name: int(address, 16) for address, name in re.findall(r'^([0-9a-f]+) \w (\w+)$', subprocess.check_output(['nm', '-n', str(target)], text=True), re.M)} + head, code = symbols['head'], symbols['checkpoint'] + script = out / 'check.script' + commands = f'''console launch {target} +await stops 1 +console break checkpoint +console continue +await execution 1 +frames 40 +console lens {code} +expect lens_count 1 +expect lenses[0].first {code} +frames 40 +screenshot {out / 'code-glass.png'} +console set glass false +frames 20 +screenshot {out / 'code-opaque.png'} +expect-different-screenshot {out / 'code-glass.png'} {out / 'code-opaque.png'} 1120 175 1060 140 +console set glass true +wheel 1600 220 -1 +frames 40 +print lenses[0].first +expect execution 1 +# Right-clicking an executable lens address opens memory, not code. +console mouse-button 3 1230 161 +expect focus memory +expect nav[2].place.address {code} +key escape +# Data lens context is scrollable in both directions without altering its anchor. +console lens {head} +frames 40 +expect lenses[0].address {head} +expect lenses[0].first {(head & ~15) - 32} +wheel 1600 220 -2 +frames 40 +expect lenses[0].first {(head & ~15) + 64} +screenshot {out / 'memory-context.png'} +wheel 1600 220 2 +frames 40 +expect lenses[0].first {(head & ~15) - 32} +# Same-parent pointer recursion preserves ancestors and detects a cycle. +click 1230 161 +expect lens_count 2 +expect lenses[1].cycle true +frames 30 +click 2180 350 +expect lens_count 1 +key escape +console goto memory {head} +frames 40 +# Both controls are available directly on the memory pane. +click 1240 822 +expect unit 2 +click 1240 822 +expect unit 4 +click 1240 822 +expect unit 8 +click 1278 822 +expect number_format unsigned +click 1278 822 +expect number_format signed +click 1278 822 +expect number_format float +click 1278 822 +expect number_format hex +''' + for unit in (1, 2, 4, 8): + for fmt in ('hex', 'unsigned', 'signed') + (('float',) if unit >= 4 else ()): + commands += f'console memory-format {unit} {fmt}\nexpect unit {unit}\nexpect number_format {fmt}\nframes 2\n' + commands += f'''console memory-format 8 hex +frames 10 +screenshot {out / 'words.png'} +# Historical browsing never requests bytes from a live target. +key left_bracket +expect following false +print stops +console lens {head} +frames 30 +wheel 1600 220 -20 +frames 30 +print stops +expect execution 1 +key escape +expect-no-log CommandFailed +expect-no-log backdrop shader +''' + script.write_text(commands) + args = [str(a.gui), '--fresh', '--size', '2240x1260', '--state', str(out / 'session.state'), '--script', str(script)] + if not a.native: + args.append('--headless') + run = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + stdout, stderr = run.communicate(timeout=100) + (out / 'run.log').write_text(stdout + stderr) + assert run.returncode == 0, stderr + first = int(re.search(r'lenses\[0\].first = (\d+)', stderr)[1]) + assert first > code, (first, code) + 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'): + recording.unlink() + print(('Native' if a.native else 'Headless') + ': code/data lenses, context scrolling, pointer recursion, memory formats and historical isolation passed') diff --git a/gui/test/restart.py b/gui/test/restart.py index 166d8e3..a9447b5 100644 --- a/gui/test/restart.py +++ b/gui/test/restart.py @@ -59,6 +59,14 @@ expect stops 1 if zoom == 200: # Tiny overlays reveal the new lens's header and keep its close control reachable. commands += 'key z\nexpect lens_count 1\nframes 30\nclick 250 406\nexpect lens_count 2\nexpect lenses[1].cycle true\nframes 30\nclick 700 406\nexpect lens_count 1\nkey escape\n' + # Native glass shares the canvas: changing font size must not resize it. + commands += 'move 0 0\nkey z\nframes 10\n' + for cycle in range(3): + for zoom in (60, 200, 100): + shot = out / f'glass-{cycle}-{zoom}.png' + images.append(shot) + commands += f'console set zoom {zoom}\nframes 5\nscreenshot {shot}\n' + commands += 'key escape\n' commands += '''hold left_ctrl key minus release left_ctrl |
