diff options
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/Geometry.zig | 57 | ||||
| -rw-r--r-- | gui/src/Navigation.zig | 14 | ||||
| -rw-r--r-- | gui/src/Sources.zig | 17 | ||||
| -rw-r--r-- | gui/src/app.zig | 830 |
4 files changed, 686 insertions, 232 deletions
diff --git a/gui/src/Geometry.zig b/gui/src/Geometry.zig new file mode 100644 index 0000000..3ebdf4e --- /dev/null +++ b/gui/src/Geometry.zig @@ -0,0 +1,57 @@ +//! All pane and minimap geometry is in font-sized canvas units. +const std = @import("std"); +const Rect = @import("sketch").Rect; +const Geometry = @This(); +w: f32, +h: f32, +content: f32, +top: f32, +columns: usize, +panes: [3]Rect, +registers: Rect, + +pub fn init(w: f32, h: f32, scroll: f32) Geometry { + const margin: f32 = 24; + const gap: f32 = 16; + const room = @max(240, w - 2 * margin); + const columns: usize = @intFromFloat(@max(1, @floor((w - 48) / 42))); + const top: f32 = 78 + @as(f32, @floatFromInt((16 + columns - 1) / columns)) * 34; + const tall = @max(320, (h - top - 64) * 0.64); + const bottom = @max(240, h - top - tall - gap - 48); + var code: Rect = .{ .x = margin, .y = top, .w = room, .h = tall }; + var regs: Rect = .{ .x = margin, .y = top + tall + gap, .w = room, .h = 320 }; + if (w >= 1500) { + regs = .{ .x = margin + room * 0.72 + gap, .y = top, .w = room * 0.28 - gap, .h = tall }; + code.w = room * 0.72; + } + const y = @max(code.y + code.h, regs.y + regs.h) + gap; + var stack: Rect = .{ .x = margin, .y = y, .w = room, .h = bottom }; + var mem: Rect = .{ .x = margin, .y = y + bottom + gap, .w = room, .h = bottom }; + if (w >= 1500) { + stack.w = (room - gap) / 2; + mem = .{ .x = margin + stack.w + gap, .y = y, .w = stack.w, .h = bottom }; + } + const content = mem.y + mem.h + 48; + for ([_]*Rect{ &code, ®s, &stack, &mem }) |r| r.y -= std.math.clamp(scroll, 0, @max(0, content - h)); + return .{ .w = w, .h = h, .content = content, .top = top, .columns = columns, .panes = .{ code, stack, mem }, .registers = regs }; +} +pub fn visible(r: Rect) f32 { + return @max(1, @floor((r.h - 40) / 24)); +} +pub fn mini(r: Rect) Rect { + return .{ .x = r.w - 52, .y = 32, .w = 46, .h = r.h - 40 }; +} +pub fn seam(r: Rect) f32 { + return @min(536, r.w * 0.34); +} + +test "wide panes sit beside each other; narrow panes stack without overlap at every font scale" { + for ([_][2]f32{ .{ 2240, 1260 }, .{ 1440, 900 }, .{ 800, 700 } }) |size| { + for ([_]f32{ 0.6, 1, 2 }) |scale| { + const g = init(size[0] / scale, size[1] / scale, 0); + for (g.panes) |p| try std.testing.expect(p.w > 0 and p.h > 0 and p.x + p.w <= g.w); + try std.testing.expect(g.registers.x >= g.panes[0].x + g.panes[0].w or g.registers.y >= g.panes[0].y + g.panes[0].h); + try std.testing.expect(g.panes[2].x >= g.panes[1].x + g.panes[1].w or g.panes[2].y >= g.panes[1].y + g.panes[1].h); + } + } +} diff --git a/gui/src/Navigation.zig b/gui/src/Navigation.zig index f9ae34a..7edd4d9 100644 --- a/gui/src/Navigation.zig +++ b/gui/src/Navigation.zig @@ -1,7 +1,7 @@ //! Bounded per-pane jump history. Scrolling changes the current location, not the target. const std = @import("std"); const Navigation = @This(); -pub const Location = struct { address: u64 = 0, row: f32 = 0, follow: bool = true }; +pub const Location = struct { address: u64 = 0, row: f64 = 0, follow: bool = true, manual: bool = false }; place: Location = .{}, history: [32]Location = @splat(.{}), len: u8 = 0, @@ -45,7 +45,7 @@ test "pane jumps retain scroll and discard the abandoned forward branch" { n.place.row = 3; n.visit(0x2000); n.back(); - try std.testing.expectEqual(@as(f32, 3), n.place.row); + try std.testing.expectEqual(@as(f64, 3), n.place.row); n.visit(0x3000); n.forward(); try std.testing.expectEqual(@as(u64, 0x3000), n.place.address); @@ -54,3 +54,13 @@ test "pane jumps retain scroll and discard the abandoned forward branch" { for (0..40) |_| n.back(); try std.testing.expectEqual(@as(u64, 0x4008), n.place.address); } + +test "large mapping row history keeps individual words reachable" { + var n: Navigation = .{}; + n.visit(0x100000000); + n.place.row = 268435455; + n.place.row -= 1; + n.visit(0x200000000); + n.back(); + try std.testing.expectEqual(@as(f64, 268435454), n.place.row); +} diff --git a/gui/src/Sources.zig b/gui/src/Sources.zig index 33268c5..3bd4cbf 100644 --- a/gui/src/Sources.zig +++ b/gui/src/Sources.zig @@ -5,15 +5,28 @@ const zt = @import("ztrace"); const Sources = @This(); const File = struct { id: u64, path: []const u8, bytes: []const u8, text: ?canim.source.Text }; files: std.ArrayList(File) = .empty, +paths: ?zt.Symbols = null, pub fn close(s: *Sources, gpa: std.mem.Allocator) void { + s.clear(gpa); + if (s.paths) |*paths| paths.deinit(); + s.* = .{}; +} + +pub fn map(s: *Sources, gpa: std.mem.Allocator, io: std.Io, from: []const u8, to: []const u8) !void { + if (s.paths == null) s.paths = .{ .gpa = gpa, .io = io }; + try s.paths.?.mapSource(from, to); + s.clear(gpa); +} + +fn clear(s: *Sources, gpa: std.mem.Allocator) void { for (s.files.items) |file| { if (file.text) |t| t.deinit(); gpa.free(file.path); gpa.free(file.bytes); } s.files.deinit(gpa); - s.* = .{}; + s.files = .empty; } pub fn get(s: *Sources, gpa: std.mem.Allocator, io: std.Io, m: zt.store.Moment, id: u64) ?*const File { @@ -21,7 +34,7 @@ pub fn get(s: *Sources, gpa: std.mem.Allocator, io: std.Io, m: zt.store.Moment, if (s.files.items.len == 32) return null; var buffer: [4096]u8 = undefined; const name = (m.string(id, &buffer) catch null) orelse return null; - const path = gpa.dupe(u8, name) catch return null; + const path = (if (s.paths) |*paths| paths.sourcePath(.{ .key = 0, .dir = "", .name = name, .line = 0, .column = 0 }) else gpa.dupe(u8, name)) catch return null; const bytes = std.Io.Dir.cwd().readFileAlloc(io, path, gpa, .limited(8 * 1024 * 1024)) catch &.{}; const text = if (bytes.len > 0) canim.source.prepare(bytes, path) catch null else null; s.files.append(gpa, .{ .id = id, .path = path, .bytes = bytes, .text = text }) catch { diff --git a/gui/src/app.zig b/gui/src/app.zig index dfa0d0a..e334b0b 100644 --- a/gui/src/app.zig +++ b/gui/src/app.zig @@ -5,6 +5,7 @@ const zt = @import("ztrace"); const ui = canim.ui; const Client = @import("Client.zig"); const Navigation = @import("Navigation.zig"); +const Geometry = @import("Geometry.zig"); const Sources = @import("Sources.zig"); var sources: Sources = .{}; pub const name = "ztrace debugger"; @@ -22,6 +23,7 @@ pub const State = struct { following: bool = true, status: zt.control.Status = .stopped, stops: u64 = 0, + execution: u64 = 0, pc: u64 = 0, action: sk.Request(Action) = .{}, nav: [3]Navigation = @splat(.{}), @@ -32,6 +34,20 @@ pub const State = struct { annotations: bool = true, depth: u8 = 4, ascii: bool = true, + zoom: u16 = 100, + page_scroll: f32 = 0, + register_scroll: f32 = 0, + horizontal: [3]f32 = @splat(0), + graph: bool = false, + dim: u8 = 75, + segments: bool = false, + segment_query: [128]u8 = @splat(0), + segment_len: u8 = 0, + segment_row: u32 = 0, + origin: u64 = 0, + lenses: [32]Lens = @splat(.{}), + lens_count: u8 = 0, + lens_scroll: f32 = 0, lens: bool = false, lens_address: u64 = 0, lens_origin: Box = .{}, @@ -41,10 +57,12 @@ pub const State = struct { command_text: [512]u8 = @splat(0), command_len: u16 = 0, drag_map: ?Pane = null, + drag_content: bool = false, }; pub const Session = struct { action: sk.Handled = .{}, - scroll: [3]f32 = @splat(0), + graph: bool = false, + scroll: [3]f64 = @splat(0), base: [3]u64 = @splat(0), mini: [3]ui.Collected = @splat(.{}), mini_key: [3]u64 = @splat(0), @@ -62,6 +80,9 @@ pub const Session = struct { marker_to: f32 = 0, marker_shown: f32 = 0, marker_at: u64 = 0, + inspected: [3]u64 = @splat(0), + capture_stop: u64 = 0, + origin_line: ?zt.store.Line = null, lens_at: u64 = 0, lens_previous: u64 = 0, @@ -78,25 +99,39 @@ pub const Session = struct { branch: ?canim.Recording.Branch = null, }; const Pane = enum { code, stack, memory }; -const Kind = enum { 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 }; +const Lens = struct { address: u64 = 0, origin: Box = .{}, cycle: bool = false }; +const Kind = enum { 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; -const panes = [3]Box{ - .{ .x = 24, .y = 88, .w = 1580, .h = 708 }, - .{ .x = 24, .y = 812, .w = 1072, .h = 400 }, - .{ .x = 1120, .y = 812, .w = 1096, .h = 400 }, -}; -const Hit = struct { address: u64, box: Box }; +var geometry = Geometry.init(width, height, 0); +var panes = Geometry.init(width, height, 0).panes; +var ranges: [3]zt.store.Mapping = @splat(.{ .addr = 0, .len = 2048, .prot = 0, .offset = 0 }); +var code_after: u64 = 0; +var code_before: u64 = 0; +var code_top: f32 = 32; +var origin_height: f32 = 72; +var source_height: f32 = 48; +var compact_rows: [256]usize = undefined; +var compact_count: usize = 0; +var compact_addresses: [3][128]u64 = undefined; +var compact_counts: [3]usize = @splat(0); +var current_lens: ?u8 = null; +var lens_boxes: [32]Box = undefined; +var segment_hits: [64]struct { box: Box, address: u64 } = undefined; +var segment_hit_count: usize = 0; +var segment_total: u32 = 0; +const Hit = struct { address: u64, box: Box, lens: ?u8 }; const Button = struct { action: Action, box: Box, label: []const u8, enabled: bool }; var hits: [2048]Hit = undefined; var hit_count: usize = 0; -var buttons: [64]Button = undefined; +var buttons: [128]Button = undefined; var button_count: usize = 0; -var extents: [3]f32 = @splat(0); +var extents: [3]f64 = @splat(0); var bases: [3]u64 = @splat(0); +var shown_scroll: [3]f64 = @splat(0); var tooltip: ?Button = null; var lens_box: ?Box = null; -var lens_hits: usize = 0; +var drawn_lenses: usize = 0; pub fn close() void { sources.close(gpa); @@ -122,6 +157,13 @@ pub fn command(s: *State, c: *sk.Console, line: []const u8) !bool { return true; } if (std.mem.eql(u8, cmd, "observed")) { + if (latest.moments != s.stops and (std.mem.eql(u8, latest.reason(), "step") or std.mem.startsWith(u8, latest.reason(), "signal ") or (std.mem.startsWith(u8, latest.reason(), "breakpoint ") and !std.mem.endsWith(u8, latest.reason(), " set")))) { + s.execution += 1; + if (s.nav[0].place.follow) s.page_scroll = 0; + for (&s.nav) |*n| if (n.place.follow) { + n.place.manual = false; + }; + } s.status = latest.status; s.stops = latest.moments; s.pc = latest.pc; @@ -136,16 +178,32 @@ pub fn command(s: *State, c: *sk.Console, line: []const u8) !bool { s.moment = latest.moments -| 1; return true; } - if (std.mem.eql(u8, cmd, "symbols") or std.mem.eql(u8, cmd, "break") or std.mem.eql(u8, cmd, "clear") or std.mem.eql(u8, cmd, "signal") or std.mem.eql(u8, cmd, "continue") or std.mem.eql(u8, cmd, "interrupt") or std.mem.eql(u8, cmd, "stepi") or std.mem.eql(u8, cmd, "nextline")) { + if (std.mem.eql(u8, cmd, "source-map")) { + const from = words.next() orelse return error.MissingPrefix; + const to = words.next() orelse return error.MissingPath; + if (words.next() != null) return error.InvalidSourceMap; + try sources.map(gpa, io, from, to); + if (client) |target| try target.send(line); + return true; + } + if (std.mem.eql(u8, cmd, "inspect") or std.mem.eql(u8, cmd, "symbols") or std.mem.eql(u8, cmd, "break") or std.mem.eql(u8, cmd, "clear") or std.mem.eql(u8, cmd, "signal") or std.mem.eql(u8, cmd, "continue") or std.mem.eql(u8, cmd, "interrupt") or std.mem.eql(u8, cmd, "stepi") or std.mem.eql(u8, cmd, "nextline")) { try (client orelse return error.NoTarget).send(if (std.mem.eql(u8, cmd, "interrupt")) "pause" else if (std.mem.eql(u8, cmd, "nextline")) "step" else line); 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, "goto")) { + if (std.mem.eql(u8, cmd, "origin")) { + s.origin = try std.fmt.parseInt(u64, words.next() orelse return error.MissingAddress, 0); + return true; + } + if (std.mem.eql(u8, cmd, "goto") or std.mem.eql(u8, cmd, "browse")) { const which = words.next() orelse return error.MissingPane; const pane = std.meta.stringToEnum(Pane, which) orelse return error.InvalidPane; const address = try std.fmt.parseInt(u64, words.next() orelse return error.MissingAddress, 0); - s.nav[@backingInt(pane)].visit(address); + if (std.mem.eql(u8, cmd, "goto")) s.nav[@backingInt(pane)].visit(address) else { + s.nav[@backingInt(pane)].place.address = address; + s.nav[@backingInt(pane)].place.row = 0; + s.nav[@backingInt(pane)].place.manual = true; + } s.focus = pane; if (client != null and s.status == .stopped and s.following) { var buf: [96]u8 = undefined; @@ -191,30 +249,58 @@ fn paneAt(x: f32, y: f32) ?Pane { } fn addressAt(x: f32, y: f32) ?Hit { var i = hit_count; - const floor = if (lens_box) |box| if (contains(box, x, y)) lens_hits else 0 else 0; + var owner: ?u8 = null; + for (lens_boxes[0..drawn_lenses], 0..) |box, k| if (lens_box != null and contains(lens_box.?, x, y) and contains(box, x, y)) { + owner = @intCast(k); + }; + const floor: usize = 0; while (i > floor) { i -= 1; - if (contains(hits[i].box, x, y)) return hits[i]; + if (hits[i].lens == owner and contains(hits[i].box, x, y)) return hits[i]; } return null; } fn collectAddress(_: *anyopaque, address: u64, box: Box) void { if (hit_count == hits.len) return; - hits[hit_count] = .{ .address = address, .box = box }; + hits[hit_count] = .{ .address = address, .box = box, .lens = current_lens }; hit_count += 1; } -fn scroll(s: *State, pane: Pane, delta: f32) void { +fn scroll(s: *State, pane: Pane, delta: f64) void { const p = @backingInt(pane); const n = &s.nav[p]; - if (n.place.follow) { - n.place.address = bases[p]; - n.place.follow = false; + if (!n.place.manual) n.place.row = shown_scroll[p]; + n.place.manual = true; + const next = n.place.row + delta; + if (pane == .code and !s.graph and (next < 0 or next > extents[0])) { + const address = if (next < 0) code_before else code_after; + if (address >= ranges[0].addr and address < ranges[0].addr +| ranges[0].len) { + n.place.address = address; + n.place.row = 0; + s.action.send(.{ .kind = .go, .pane = .code, .address = address, .manual = true }); + return; + } } - n.place.row = std.math.clamp(n.place.row + delta, 0, extents[p]); + n.place.row = std.math.clamp(next, 0, extents[p]); } fn act(s: *State, a: Action) void { const p = @backingInt(a.pane); switch (a.kind) { + .graph => { + s.graph = !s.graph; + s.nav[0].place.row = 0; + s.nav[0].place.manual = s.graph; + s.horizontal[0] = 0; + }, + .dim => s.dim = if (s.dim >= 100) 25 else s.dim + 25 - s.dim % 25, + .segments => { + s.segments = !s.segments; + s.segment_len = 0; + s.segment_row = 0; + }, + .select_segment => { + s.segments = false; + s.action.send(.{ .kind = .go, .pane = a.pane, .address = a.address }); + }, .previous => { s.following = false; s.moment -|= 1; @@ -239,16 +325,16 @@ fn act(s: *State, a: Action) void { .deeper => s.depth = @min(6, s.depth + 1), .ascii => s.ascii = !s.ascii, .lens => { - s.lens = !s.lens; - if (a.address != 0) { - s.lens_address = a.address; - for (hits[0..hit_count]) |hit| if (hit.address == a.address) { - s.lens_origin = hit.box; - break; - }; - } + if (s.lens) { + s.lens = false; + s.lens_count = 0; + } else openLens(s, .{ .address = a.address, .box = .{}, .lens = null }); + }, + .close_lens => { + s.lens_count = @intCast(@min(a.address, s.lens_count)); + s.lens = s.lens_count > 0; + s.lens_scroll = @min(s.lens_scroll, @max(0, @as(f32, @floatFromInt(s.lens_count)) * 204 - (geometry.h - 180))); }, - .close_lens => s.lens = false, .help => s.help = !s.help, .command => { s.command_open = true; @@ -276,9 +362,39 @@ fn semantic(s: *State, address: u64) void { fn mapDrag(s: *State, pane: Pane, y: f32) void { const p = @backingInt(pane); const box = panes[p]; - const visible = (box.h - 40) / 24; - const row = std.math.clamp((y - box.y - 32) / (box.h - 40), 0, 1) * (extents[p] + visible) - visible / 2; - scroll(s, pane, row - s.nav[p].place.row); + const ratio = std.math.clamp((y - box.y - 32) / (box.h - 40), 0, 1); + if (pane == .code and s.drag_content and compact_count > 0) { + const index: usize = @min(compact_count - 1, @as(usize, @intFromFloat(ratio * @as(f32, @floatFromInt(compact_count))))); + s.nav[0].place.manual = true; + s.nav[0].place.row = @min(extents[0], @as(f64, @floatFromInt(compact_rows[index]))); + } else if (pane != .code and s.drag_content and compact_counts[p] > 0) { + const index: usize = @min(compact_counts[p] - 1, @as(usize, @intFromFloat(ratio * @as(f32, @floatFromInt(compact_counts[p]))))); + s.nav[p].place.manual = true; + s.nav[p].place.row = @floatFromInt((compact_addresses[p][index] - ranges[p].addr) / (if (p == 1) @as(u64, 8) else 16)); + } else if (pane == .code) { + const address = ranges[p].addr + @as(u64, @intFromFloat(ratio * @as(f64, @floatFromInt(ranges[p].len -| 1)))); + s.action.send(.{ .kind = .go, .pane = pane, .address = address, .manual = true }); + } else { + s.nav[p].place.manual = true; + s.nav[p].place.row = ratio * extents[p]; + } +} +fn openLens(s: *State, hit: Hit) void { + const at: u8 = if (hit.lens) |i| i + 1 else 0; + if (at == s.lenses.len) return; + var cycle = false; + for (s.lenses[0..at]) |lens| if (lens.address == hit.address) { + cycle = true; + }; + s.lenses[at] = .{ .address = hit.address, .origin = hit.box, .cycle = cycle }; + s.lens_count = at + 1; + s.lens = true; + s.lens_address = hit.address; + s.lens_scroll = @max(0, @as(f32, @floatFromInt(s.lens_count)) * 204 - (geometry.h - 160)); + 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 enabled(s: *const State, a: Action) bool { return switch (a.kind) { @@ -291,6 +407,13 @@ fn enabled(s: *const State, a: Action) bool { } fn pointer(s: *State, mouse_button: u16, x: f32, y: f32) void { if (s.help) return; + if (s.segments) { + if (mouse_button == 1) for (segment_hits[0..segment_hit_count]) |hit| if (contains(hit.box, x, y)) { + act(s, .{ .kind = .select_segment, .pane = s.focus, .address = hit.address }); + return; + }; + return; + } 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 }); @@ -309,32 +432,49 @@ fn pointer(s: *State, mouse_button: u16, x: f32, y: f32) void { return; } } - if (lens_box) |box| if (contains(box, x, y)) { - if (addressAt(x, y)) |hit| { - s.lens_address = hit.address; - s.lens_origin = hit.box; - s.lens = true; - } + for (lens_boxes[0..drawn_lenses]) |box| if (lens_box != null and contains(lens_box.?, x, y) and contains(box, x, y)) { + if (addressAt(x, y)) |hit| openLens(s, hit); return; }; if (paneAt(x, y)) |pane| { const p = @backingInt(pane); if (s.maps[p] and x >= panes[p].x + panes[p].w - 54 and y >= panes[p].y + 32) { s.drag_map = pane; + s.drag_content = (pane != .code or !s.graph) and x < panes[p].x + panes[p].w - 18; mapDrag(s, pane, y); return; } } - if (addressAt(x, y)) |hit| { - s.lens_address = hit.address; - s.lens_origin = hit.box; - s.lens = true; - } + if (addressAt(x, y)) |hit| openLens(s, hit); } pub fn update(s: *State, in: *const sk.Input) void { if (in.console) return; + s.page_scroll = std.math.clamp(s.page_scroll, 0, @max(0, geometry.content - geometry.h)); for (in.events) |e| { + if (s.segments) { + if (e.kind == .text and e.value >= 32 and e.value < 127 and s.segment_len < s.segment_query.len) { + s.segment_query[s.segment_len] = @intCast(e.value); + s.segment_len += 1; + s.segment_row = 0; + } + if (e.kind == .wheel) s.segment_row = @intFromFloat(std.math.clamp(@as(f32, @floatFromInt(s.segment_row)) - e.wheel() * 3, 0, @as(f32, @floatFromInt(segment_total -| 1)))); + if (e.kind == .mouse_down) pointer(s, e.code, e.x, e.y); + if (e.kind == .key_down) switch (@as(sk.Key, @fromBackingInt(@intCast(e.code)))) { + .escape => s.segments = false, + .backspace => { + s.segment_len -|= 1; + s.segment_row = 0; + }, + .down => s.segment_row = @min(s.segment_row + 1, segment_total -| 1), + .up => s.segment_row -|= 1, + .@"return" => if (segment_hit_count > 0) { + act(s, .{ .kind = .select_segment, .pane = s.focus, .address = segment_hits[0].address }); + }, + else => {}, + }; + continue; + } if (s.command_open) { if (e.kind == .text and e.value >= 32 and e.value < 127 and s.command_len < s.command_text.len) { if (s.command_len != 0 or e.value != ':') { @@ -364,9 +504,15 @@ pub fn update(s: *State, in: *const sk.Input) void { .mouse_move => if (s.drag_map) |pane| { mapDrag(s, pane, e.y); }, - .wheel => if (paneAt(e.x, e.y)) |pane| { - s.focus = pane; - scroll(s, pane, -e.wheel() * 3); + .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, @max(0, @as(f32, @floatFromInt(s.lens_count)) * 204 - (geometry.h - 160))); + } 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| { + s.focus = pane; + if (e.y < panes[@backingInt(pane)].y + 30) s.page_scroll = std.math.clamp(s.page_scroll - e.wheel() * 80, 0, @max(0, geometry.content - geometry.h)) else scroll(s, pane, -e.wheel() * 3); + } else s.page_scroll = std.math.clamp(s.page_scroll - e.wheel() * 80, 0, @max(0, geometry.content - geometry.h)); }, .key_down => { const key: sk.Key = @fromBackingInt(@intCast(@as(u8, @intCast(e.code)))); @@ -374,8 +520,11 @@ pub fn update(s: *State, in: *const sk.Input) void { const shift = e.value & sk.Key.Mod.shift != 0 or in.held(sk.Key.left_shift) or in.held(sk.Key.right_shift); if (ctrl) { switch (key) { - .d => scroll(s, s.focus, (panes[@backingInt(s.focus)].h - 40) / 48), - .u => scroll(s, s.focus, -(panes[@backingInt(s.focus)].h - 40) / 48), + .equals => s.zoom = @min(200, s.zoom + 10), + .minus => s.zoom = @max(60, s.zoom -| 10), + .@"0" => s.zoom = 100, + .d => scroll(s, s.focus, Geometry.visible(panes[@backingInt(s.focus)]) / 2), + .u => scroll(s, s.focus, -Geometry.visible(panes[@backingInt(s.focus)]) / 2), .o => act(s, .{ .kind = .back, .pane = s.focus }), .i => act(s, .{ .kind = .forward, .pane = s.focus }), .w => s.prefix = 'w', @@ -400,8 +549,21 @@ pub fn update(s: *State, in: *const sk.Input) void { const was_g = s.prefix == 'g'; s.prefix = 0; switch (key) { - .h => s.source_column -|= 4, - .l => s.source_column = @min(s.source_column +| 4, 4096), + .h => if (s.focus == .code and s.source and !s.graph and !shift) { + s.source_column -|= 4; + } else { + s.horizontal[@backingInt(s.focus)] = @max(0, s.horizontal[@backingInt(s.focus)] - 48); + }, + .l => if (s.focus == .code and s.source and !s.graph and !shift) { + s.source_column = @min(s.source_column +| 4, 4096); + } else { + s.horizontal[@backingInt(s.focus)] = @min(1600, s.horizontal[@backingInt(s.focus)] + 48); + }, + .page_down => s.page_scroll = @min(@max(0, geometry.content - geometry.h), s.page_scroll + geometry.h * 0.7), + .page_up => s.page_scroll = @max(0, s.page_scroll - geometry.h * 0.7), + .p => act(s, .{ .kind = .segments, .pane = s.focus }), + .t => act(s, .{ .kind = .graph }), + .d => act(s, .{ .kind = .dim }), .j => scroll(s, s.focus, 1), .k => scroll(s, s.focus, -1), .g => if (shift) { @@ -422,6 +584,7 @@ pub fn update(s: *State, in: *const sk.Input) void { }, .escape => if (s.lens or s.help) { s.lens = false; + s.lens_count = 0; s.help = false; } else if (s.status == .running) { act(s, .{ .kind = .pause }); @@ -503,6 +666,13 @@ fn icon(u: ui.Ui, kind: Kind, active: bool) void { v.line(.{ 8, 14 }, .{ 20, 14 }, c, 2); v.line(.{ 8, 19 }, .{ 17, 19 }, c, 2); }, + .segments => v.text(.mono_bold, 20, 1, 19, "≡", c), + .graph => { + v.frame(.{ .x = 1, .y = 1, .w = 8, .h = 7 }, c, 1); + v.frame(.{ .x = 13, .y = 14, .w = 8, .h = 7 }, c, 1); + v.line(.{ 5, 8 }, .{ 17, 14 }, c, 1); + }, + .dim => v.text(.mono_bold, 19, 1, 19, "◐", c), .ascii => v.text(.mono_bold, 20, 1, 19, "Aa", c), .close_lens => { v.line(.{ 3, 3 }, .{ 19, 19 }, c, 2); @@ -518,9 +688,14 @@ fn icon(u: ui.Ui, kind: Kind, active: bool) void { } fn button(u: ui.Ui, x: f32, y: f32, action: Action, label: []const u8, available: bool, active: bool) void { const a = u.at.xf.apply(.{ x, y }); - const box: Box = .{ .x = a[0], .y = a[1], .w = 34, .h = 32 }; + var box: Box = .{ .x = a[0], .y = a[1], .w = 34, .h = 32 }; + if (ui.bound) |clip| { + const x0 = @max(box.x, clip.x); + const y0 = @max(box.y, clip.y); + box = .{ .x = x0, .y = y0, .w = @max(0, @min(box.x + box.w, clip.x + clip.w) - x0), .h = @max(0, @min(box.y + box.h, clip.y + clip.h) - y0) }; + } const b: Button = .{ .action = action, .box = box, .label = label, .enabled = available }; - if (button_count < buttons.len) { + if (box.w > 0 and box.h > 0 and button_count < buttons.len) { buttons[button_count] = b; button_count += 1; } @@ -535,10 +710,15 @@ fn paneButtons(u: ui.Ui, s: *const State, pane: Pane) void { const p = @backingInt(pane); const n = s.nav[p]; const w = panes[p].w; + if (w < 600) { + button(u, w - 78, -3, .{ .kind = .follow, .pane = pane }, "Follow live address · f", true, n.place.follow); + button(u, w - 40, -3, .{ .kind = .map, .pane = pane }, "Minimap · right rail spans whole segment · m", true, s.maps[p]); + return; + } button(u, w - 230, -3, .{ .kind = .back, .pane = pane }, "Back · Ctrl-o / Mouse4", n.cursor > 0, false); button(u, w - 192, -3, .{ .kind = .forward, .pane = pane }, "Forward · Ctrl-i / Mouse5", n.cursor + 1 < n.len, false); button(u, w - 154, -3, .{ .kind = .follow, .pane = pane }, "Follow live address · f", true, n.place.follow); - button(u, w - 116, -3, .{ .kind = .map, .pane = pane }, "Toggle content minimap · m", true, s.maps[p]); + button(u, w - 116, -3, .{ .kind = .map, .pane = pane }, "Minimap · right rail spans whole segment · m", true, s.maps[p]); button(u, w - 78, -3, .{ .kind = if (pane == .code) .source else if (pane == .stack) .shallower else .ascii, .pane = pane }, if (pane == .code) "Aligned source · v" else if (pane == .stack) "Fewer pointer hops" else "ASCII / pointer words", true, if (pane == .code) s.source else if (pane == .memory) s.ascii else false); button(u, w - 40, -3, .{ .kind = if (pane == .stack) .deeper else .annotate, .pane = pane }, if (pane == .stack) "More pointer hops" else "Read / result annotations · a", true, if (pane == .stack) false else s.annotations); } @@ -549,7 +729,7 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { .pause => f.run("interrupt"), .stepi => f.run("stepi"), .step => f.run("nextline"), - .go => f.run(ui.Ui.init(f).print("goto {s} 0x{x}", .{ @tagName(action.pane), action.address })), + .go => f.run(ui.Ui.init(f).print("{s} {s} 0x{x}", .{ if (action.manual) "browse" else "goto", @tagName(action.pane), action.address })), .breakpoint => f.run(ui.Ui.init(f).print("break *0x{x}", .{action.address})), .submit => f.run(s.command_text[0..s.command_len]), else => {}, @@ -565,7 +745,18 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { } f.run("observed"); }; - f.canvas(width, height); + const scale = @as(f32, @floatFromInt(s.zoom)) / 100; + const w = @max(1, @round(f.in.window_width / scale)); + const h = @max(1, @round(f.in.window_height / scale)); + f.canvas(@intFromFloat(w), @intFromFloat(h)); + const next_geometry = Geometry.init(w, h, s.page_scroll); + if (geometry.w != w or geometry.h != h) { + ss.mini_key = @splat(0); + ss.marker_key = 0; + ss.marker_base = 0; + } + geometry = next_geometry; + panes = geometry.panes; f.clear(ui.theme.color.page); const u = ui.Ui.init(f); const ink = ui.theme.color.text; @@ -574,22 +765,24 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { button_count = 0; tooltip = null; lens_box = null; + drawn_lenses = 0; + current_lens = null; ui.address_hit = .{ .ctx = ss, .emit = collectAddress }; defer ui.address_hit = null; - u.text(.sans_medium, 24, 24, 28, "ztrace / debugger", ink.primary); + u.text(.sans_medium, 24, 24, 28, if (geometry.w < 700) "ztrace" else "ztrace / debugger", ink.primary); const status = if (client == null) (if (trace == null) "READY" else "RECORDING") else @tagName(s.status); - u.fill(.{ .x = 300, .y = 9, .w = 118, .h = 24 }, ui.theme.color.raised); - u.text(.mono_bold, 17, 312, 27, status, if (s.status == .failed) ui.theme.mark(.write).solid else gold.solid); - u.text(.sans, 18, 434, 27, latest.reason(), ink.dim); - if (client != null) u.text(.mono, 17, 1904, 27, u.print("command {d:.3} ms", .{@as(f64, @floatFromInt(latest.elapsed_ns)) / 1e6}), ink.dim); - const kinds = [_]Kind{ if (s.status == .running) .pause else .cont, .stepi, .step, .breakpoint, .previous, .next, .live, .source, .map, .annotate, .lens, .command, .help }; - const labels = [_][]const u8{ if (s.status == .running) "Pause · Esc / Ctrl-c" else "Continue · c", "Single instruction · s", "Next source line (enters calls) · n", "Breakpoint at PC · b", "Previous recorded stop · [", "Next recorded stop · ]", "Live stop · F (Shift-f)", "Aligned source · v", "Focused pane minimap · m", "Operand annotations · a", "Address lens · z", "Command line · :", "Keyboard help · ?" }; + u.fill(.{ .x = if (geometry.w < 700) 150 else 300, .y = 9, .w = 118, .h = 24 }, ui.theme.color.raised); + u.text(.mono_bold, 17, if (geometry.w < 700) 162 else 312, 27, status, if (s.status == .failed) ui.theme.mark(.write).solid else gold.solid); + if (geometry.w > 850) u.text(.sans, 18, 434, 27, canim.rows.fitted(u, latest.reason(), geometry.w - 740), ink.dim); + if (client != null and geometry.w > 1200) u.text(.mono, 17, geometry.w - 310, 27, u.print("command {d:.3} ms", .{@as(f64, @floatFromInt(latest.elapsed_ns)) / 1e6}), ink.dim); + const kinds = [_]Kind{ if (s.status == .running) .pause else .cont, .stepi, .step, .breakpoint, .previous, .next, .live, .source, .map, .annotate, .lens, .segments, .graph, .dim, .command, .help }; + const labels = [_][]const u8{ if (s.status == .running) "Pause · Esc / Ctrl-c" else "Continue · c", "Single instruction · s", "Next source line (enters calls) · n", "Breakpoint at PC · b", "Previous recorded stop · [", "Next recorded stop · ]", "Live stop · F (Shift-f)", "Aligned source · v", "Focused pane minimap · m", "Operand annotations · a", "Address lens · z", "Memory segments · p (active pane)", "Control-flow graph · t", "Unobserved instruction opacity · d", "Command line · :", "Keyboard help · ?" }; for (kinds, labels, 0..) |kind, label, i| { const available = switch (kind) { .cont, .pause, .stepi, .step, .breakpoint => client != null and s.status != .exited and (kind == .pause or s.status == .stopped), else => true, }; - button(u, 24 + @as(f32, @floatFromInt(i)) * 42, 42, .{ .kind = kind, .pane = s.focus, .address = s.pc }, label, available, switch (kind) { + button(u, 24 + @as(f32, @floatFromInt(i % geometry.columns)) * 42, 42 + @as(f32, @floatFromInt(i / geometry.columns)) * 34, .{ .kind = kind, .pane = s.focus, .address = s.pc }, label, available, switch (kind) { .source => s.source, .map => s.maps[@backingInt(s.focus)], .annotate => s.annotations, @@ -598,9 +791,9 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { else => false, }); } - u.text(.sans, 17, 600, 63, "j k scroll s instruction n source c run : command ? help", ink.dim); + if (geometry.w > 1500) u.text(.sans, 17, 740, 63, u.print("t graph · d unobserved {d}% · p segments · Ctrl +/− {d}%", .{ s.dim, s.zoom }), ink.dim); const t = if (trace) |*t| t else { - _ = u.moved(24, 88).panel(2192, 1124, "session", .{ .focus = true }); + _ = u.moved(24, 112).panel(geometry.w - 48, geometry.h - 160, "session", .{ .focus = true }); u.text(.sans_medium, 34, 72, 174, "Start with a real process.", ink.primary); u.text(.mono, 22, 72, 226, "launch PROGRAM [ARGS]", gold.solid); u.text(.sans, 22, 72, 268, "Open commands with : or backtick, then set a breakpoint and continue.", ink.dim); @@ -612,37 +805,69 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void { const regs = (m.regs(s.tid) catch null) orelse return; const low = (regs.rsp -| 24) & ~@as(u64, 7); if (ss.shown != m.index or ss.tid != s.tid) selected(ss, t, m, regs, s.tid, low, f.in.now); + if (ss.graph != s.graph) { + ss.graph = s.graph; + ss.scroll[0] = 0; + } const seconds = @as(f32, @floatFromInt(f.in.now -| ss.changed_at)) / 1e9; const heat = changedHeat(seconds); const fire = if (seconds < ui.theme.time.fire) ui.theme.pulse(seconds / ui.theme.time.fire) else 0; const travel = ui.theme.ease(.standard, std.math.clamp(seconds / ui.theme.time.step, 0, 1)); const mode = if (!s.following) "HISTORY" else if (s.status == .running) "LAST STOP" else "LIVE"; - u.text(.mono_bold, 18, 1650, 63, mode, gold.solid); - u.text(.mono, 18, 1770, 63, u.print("moment {d}/{d} · tid {d}", .{ m.index, t.len -| 1, s.tid }), ink.dim); + u.text(.mono_bold, 17, 24, geometry.top - 12, mode, gold.solid); + u.text(.mono, 17, 150, geometry.top - 12, canim.rows.fitted(u, u.print("moment {d}/{d} · tid {d}", .{ m.index, t.len -| 1, s.tid }), geometry.w - 174), ink.dim); const live_bases = [3]u64{ ss.code_start, low, (ss.touch orelse canim.Recording.Touch{ .addr = regs.rsp, .len = 8, .how = 1 }).addr & ~@as(u64, 15) }; for (0..3) |p| { - bases[p] = if (s.nav[p].place.follow) live_bases[p] else s.nav[p].place.address; + const nav = s.nav[p].place; + const address = if (nav.follow and !nav.manual) live_bases[p] else if (nav.address != 0) nav.address else live_bases[p]; + ranges[p] = (m.mapping(address, null, &.{}) catch null) orelse .{ .addr = address, .len = 2048, .prot = 0, .offset = 0 }; + bases[p] = if (p == 0) address else ranges[p].addr; if (ss.base[p] != bases[p]) { ss.scroll[p] = 0; ss.base[p] = bases[p]; } - const target = if (s.nav[p].place.follow) 0 else s.nav[p].place.row; + 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; - ss.scroll[p] = std.math.lerp(ss.scroll[p], target, 1 - @exp(-dt * 18)); - if (@abs(ss.scroll[p] - target) < 0.001) ss.scroll[p] = target; + // 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)); + shown_scroll[p] = ss.scroll[p]; } listing(ss, m, bases[0]); - drawCode(u.moved(24, 88), s, ss, m, regs, heat, fire, travel); - drawRegisters(u.moved(1628, 88), s, ss, m, regs, heat, seconds, fire); - drawStack(u.moved(24, 812), s, ss, m, regs, heat, seconds); - drawMemory(u.moved(1120, 812), s, ss, m, heat); + if (s.origin != 0) { + var buf: [1024]u8 = undefined; + if ((zt.telescope.instruction(m, s.origin, &buf) catch null)) |insn| ss.origin_line = insn.line; + } + if (ss.capture_stop != s.execution) { + ss.capture_stop = s.execution; + ss.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| { + const address = bases[p] +| (if (p == 0) @as(u64, 0) else @as(u64, @intFromFloat(@floor(if (s.nav[p].place.manual) s.nav[p].place.row else ss.scroll[p]))) * (if (p == 1) @as(u64, 8) else 16)); + const key = address ^ (s.pc *% 0x9e3779b97f4a7c15); + if (ss.inspected[p] != key and (s.nav[p].place.manual or !s.nav[p].place.follow) and (p != 0 or ss.code_count == 0)) { + ss.inspected[p] = key; + f.run(u.print("inspect {s} 0x{x} {d}", .{ if (p == 0) "code" else "memory", address, @as(u32, if (p == 0) 128 else 2048) })); + break; + } + }; + ui.bound = .{ .x = 0, .y = geometry.top, .w = geometry.w, .h = @max(0, geometry.h - geometry.top - 40) }; + u.clip(.{ .x = ui.bound.?.x, .y = ui.bound.?.y, .w = ui.bound.?.w, .h = ui.bound.?.h }); + drawCode(u.moved(panes[0].x, panes[0].y), s, ss, m, regs, heat, fire, travel); + drawRegisters(u.moved(geometry.registers.x, geometry.registers.y), s, ss, m, regs, heat, seconds, fire); + drawStack(u.moved(panes[1].x, panes[1].y), s, ss, m, regs, heat, seconds); + 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 = 1226, .w = 2192, .h = 2 }, ui.theme.color.rule); - u.fill(.{ .x = 24, .y = 1226, .w = 2192 * place, .h = 2 }, gold.solid); - u.fill(.{ .x = 22 + 2192 * place, .y = 1223, .w = 4, .h = 8 }, gold.solid); - u.text(.sans, 17, 24, 1251, 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); - u.text(.sans, 17, 1730, 1251, "gold: execution vermilion: changed", ink.dim); + 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.content > geometry.h) u.text(.sans, 16, 24, geometry.h - 9, "PgUp/PgDn · scroll pane headers", ink.dim); overlays(u, s, ss, m); } fn listing(ss: *Session, m: zt.store.Moment, base: u64) void { @@ -653,17 +878,35 @@ fn listing(ss: *Session, m: zt.store.Moment, base: u64) void { var pc = base; for (&ss.code, &ss.code_text, &ss.code_lines) |*row, *buf, *line| { const insn = (zt.telescope.instruction(m, pc, buf) catch null) orelse break; + var bytes: [15]u8 = undefined; + var known: [15]bool = @splat(false); + if (insn.len == 0 or insn.len > bytes.len) break; + m.read(pc, bytes[0..insn.len], known[0..insn.len]) catch break; + if (std.mem.indexOfScalar(bool, known[0..insn.len], false) != null) break; row.* = .{ .addr = pc, .len = insn.len, .text = insn.text, .line = if (insn.line) |l| l.line else null, .params = insn.params }; line.* = insn.line; ss.code_count += 1; pc +|= insn.len; } - ss.aligned_count = canim.aligned.livePlan(ss.code_lines[0..ss.code_count], &ss.aligned).len; + code_after = if (pc > base) pc else base +| 128; + code_before = base -| 128; + if (ss.code_count > 0) { + var previous: [1024]u8 = undefined; + if ((zt.telescope.instruction(m, base, &previous) catch null)) |insn| if (insn.back > 0) { + code_before = base -| insn.back; + }; + } + var prefix: usize = 0; + if (ss.code_count > 0) if (ss.code_lines[0]) |first| { + prefix = @min(2, first.line -| 1); + for (0..prefix) |i| ss.aligned[i] = .{ .instruction = null, .source = .{ .file = first.file, .line = first.line - @as(u32, @intCast(prefix - i)) } }; + }; + ss.aligned_count = prefix + canim.aligned.livePlan(ss.code_lines[0..ss.code_count], ss.aligned[prefix..]).len; } fn sourceLine(u: ui.Ui, column: usize, m: zt.store.Moment, line: zt.store.Line, y: f32, w: f32, current: bool, fire: f32, again: bool) void { const file = sources.get(gpa, io, m, line.file) orelse return; const text = file.text orelse { - u.text(.mono, 18, 64, y + 18, "source file unavailable", ui.theme.color.text.faint); + u.text(.mono, 18, 64, y + 18, canim.rows.fitted(u, "source file unavailable", @max(0, w - 64)), ui.theme.color.text.faint); return; }; if (line.line == 0 or line.line > text.lines.len) return; @@ -671,10 +914,16 @@ fn sourceLine(u: ui.Ui, column: usize, m: zt.store.Moment, line: zt.store.Line, canim.rows.line(u, y, w, line.line, canim.rows.numberRoom(@intCast(text.lines.len)), text.bytes[@min(range[0] + column, range[1])..range[1]], text.styles[@min(range[0] + column, range[1])..range[1]], if (current) .{ .current = fire } else .plain); if (again) u.text(.mono, 18, 3, y + 19, "↻", ui.theme.color.text.dim); } +fn codeVisible() f32 { + return @max(1, @floor((@min(panes[0].y + panes[0].h, geometry.h - 40) - @max(panes[0].y + code_top, geometry.top)) / 24)); +} +fn columns(s: *const State) bool { + return s.source and panes[0].w >= 900; +} fn codeRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, first: f32, heat: ui.Heat, fire: f32, travel: f32, miniature: bool) void { - const seam: f32 = if (s.source) 536 else 0; - const room: f32 = 1580 - seam - if (s.maps[0]) @as(f32, 58) else 6; - const count = if (s.source) ss.aligned_count else ss.code_count; + const seam: f32 = if (columns(s)) Geometry.seam(panes[0]) else 0; + const room: f32 = panes[0].w - seam - if (s.maps[0]) @as(f32, 58) else 6; + const count = if (columns(s)) ss.aligned_count else ss.code_count; var current_group: ?usize = null; var group_start: usize = 0; for (ss.aligned[0..ss.aligned_count], 0..) |row, i| { @@ -686,20 +935,22 @@ fn codeRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z var pc_row: ?f32 = null; var branch_row: ?f32 = null; for (0..count) |i| { - const r: canim.aligned.LiveRow = if (s.source) ss.aligned[i] else .{ .instruction = i }; - const y = (if (miniature) @as(f32, 0) else 32) + (@as(f32, @floatFromInt(i)) - first) * 24; - if (!miniature and (y < 8 or y >= 706)) continue; - if (s.source) if (r.source) |line| { + const r: canim.aligned.LiveRow = if (columns(s)) ss.aligned[i] else .{ .instruction = i }; + const y = (if (miniature) @as(f32, 0) else code_top) + @as(f32, @floatCast((@as(f64, @floatFromInt(i)) - first) * 24)); + if (!miniature and (y < code_top - 24 or y >= panes[0].h - 2)) continue; + if (columns(s)) if (r.source) |line| { const current = current_group == i; sourceLine(if (r.instruction == null) u.faded(0.45) else u, if (miniature) 0 else s.source_column, m, line, y, seam - 32, current, fire, r.again); if (r.instruction != null) u.route(&.{ .{ seam - 30, y + 12 }, .{ seam - 8, y + 12 }, .{ seam + 2, y + 12 } }, if (current) ui.theme.mark(.current).solid else ui.theme.color.rule, .{ .width = 1.5, .head = .{ 5, 6 }, .progress = if (current) travel else 1 }); }; const index = r.instruction orelse continue; const row = ss.code[index]; - const d = u.moved(seam, 0); + const observed = std.mem.indexOfScalar(u64, &ss.trail, row.addr) != null; + const predicted = if (ss.branch) |branch| (branch.kind == .jump and branch.taken and branch.to == row.addr) else false; + const d = u.moved(seam, 0).faded(if (row.addr == regs.rip or observed or predicted) 1 else @max(0.15, @as(f32, @floatFromInt(s.dim)) / 100)); const current = row.addr == regs.rip; if (current) { - const marker_y = if (miniature) y else 32 + (ss.marker_shown - first) * 24; + const marker_y = if (miniature) y else code_top + (ss.marker_shown - first) * 24; pc_row = marker_y; d.current(.{ .x = 2, .y = marker_y, .w = room - 4, .h = 24 }, ui.theme.metric.plaque.pc, fire); sk.draw.polygon(u.f, &.{ .{ 20, marker_y + 12 }, .{ 10, marker_y + 6 }, .{ 10, marker_y + 18 } }, d.at.pen(.{ .fill = ui.rgb(ui.theme.mark(.current).on_solid) })); @@ -708,13 +959,13 @@ fn codeRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z d.trail(2, y, k); break; }; - canim.disasm.liveRow(d, row, y, room, m, regs, .{ .current = current and s.annotations, .executed = ss.result_at == row.addr and s.annotations, .heat = heat, .lead = ui.shared(&.{ bases[0], bases[0] +| 512 }), .touch = if (current and s.annotations) ss.touch else null, .branch = if (current and s.annotations) ss.branch else null }); + canim.disasm.liveRow(d, row, y, room, m, regs, .{ .compact = room < 520, .current = current and s.annotations, .executed = ss.result_at == row.addr and s.annotations, .heat = heat, .lead = ui.shared(&.{ bases[0], bases[0] +| 512 }), .touch = if (current and s.annotations) ss.touch else null, .branch = if (current and s.annotations) ss.branch else null }); if (ss.branch) |branch| if (branch.to == row.addr) { branch_row = y; }; } - if (!miniature and s.source and pc_row != null and current_group != null) { - const from = 32 + (@as(f32, @floatFromInt(current_group.?)) - first) * 24 + 12; + if (!miniature and columns(s) and pc_row != null and current_group != null) { + const from = code_top + (@as(f32, @floatFromInt(current_group.?)) - first) * 24 + 12; if (@abs(from - pc_row.? - 12) > 1) u.route(&.{ .{ seam - 30, from }, .{ seam - 12, from }, .{ seam - 12, pc_row.? + 12 }, .{ seam + 2, pc_row.? + 12 } }, ui.theme.mark(.current).solid, .{ .width = 2, .head = .{ 6, 7 }, .progress = travel }); } if (!miniature and pc_row != null and branch_row != null) if (ss.branch) |branch| if (branch.kind == .jump) { @@ -722,11 +973,20 @@ 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 count = if (s.source) ss.aligned_count else ss.code_count; - const marker_key = (m.index + 1) *% 0x9e3779b97f4a7c15 ^ bases[0] ^ @as(u64, @intFromBool(s.source)); + 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; + source_height = if (actual_height < 250) 24 else 48; + const native_line = m.line(s.tid) catch null; + if (!s.graph) if (ss.origin_line) |origin| if (native_line == null or native_line.?.file != origin.file) { + code_top += origin_height; + }; + if (!columns(s) and s.source and !s.graph) code_top += source_height; + const count = if (columns(s)) ss.aligned_count else ss.code_count; + const marker_key = (m.index + 1) *% 0x9e3779b97f4a7c15 ^ bases[0] ^ @as(u64, @intFromBool(columns(s))); if (ss.marker_key != marker_key) { for (0..count) |i| { - const index = if (s.source) ss.aligned[i].instruction else i; + const index = if (columns(s)) ss.aligned[i].instruction else i; if (index) |j| if (ss.code[j].addr == regs.rip) { ss.marker_to = @floatFromInt(i); ss.marker_from = if (ss.marker_base == bases[0]) ss.marker_shown else ss.marker_to; @@ -736,124 +996,157 @@ fn drawCode(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: z ss.marker_base = bases[0]; ss.marker_at = u.f.in.now; } + if (!s.graph and s.nav[0].place.follow and !s.nav[0].place.manual) { + var start: f32 = ss.marker_to; + if (columns(s)) { + var group: usize = 0; + for (ss.aligned[0..ss.aligned_count], 0..) |r, k| { + if (r.source != null) group = k; + if (r.instruction) |j| if (ss.code[j].addr == regs.rip) { + start = @floatFromInt(group); + break; + }; + } + } + 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)); + shown_scroll[0] = ss.scroll[0]; + } const marker_time = @as(f32, @floatFromInt(u.f.in.now -| ss.marker_at)) / 1e9; ss.marker_shown = std.math.lerp(ss.marker_from, ss.marker_to, ui.theme.ease(.standard, std.math.clamp(marker_time / ui.theme.time.step, 0, 1))); - extents[0] = @max(0, @as(f32, @floatFromInt(count)) - 27); - _ = u.panel(1580, 708, if (s.source) "source / disassembly" else "disassembly", .{ .focus = s.focus == .code }); + extents[0] = @max(0, @as(f32, @floatFromInt(count)) - codeVisible()); + _ = u.panel(panes[0].w, panes[0].h, if (s.graph) "control flow" else if (panes[0].w < 600) "code" else if (s.source) "source / disassembly" else "disassembly", .{ .focus = s.focus == .code }); var file_name: []const u8 = "no recorded source mapping"; for (ss.code_lines[0..ss.code_count]) |line| if (line) |l| { if (sources.get(gpa, io, m, l.file)) |file| file_name = file.path; break; }; - u.text(.sans, 17, 250, 19, canim.rows.fitted(u, file_name, 1050), ui.theme.color.text.dim); + u.text(.sans, 17, 250, 19, canim.rows.fitted(u, file_name, @max(0, panes[0].w - 500)), ui.theme.color.text.dim); paneButtons(u, s, .code); - u.clip(.{ .x = 2, .y = 30, .w = 1576 - if (s.maps[0]) @as(f32, 56) else 0, .h = 676 }); - if (s.source) u.line(.{ 530, 30 }, .{ 530, 706 }, ui.theme.color.rule, 1); - codeRows(u, s, ss, m, regs, ss.scroll[0], heat, fire, travel, false); - if (ss.code_count == 0) u.text(.sans, 20, if (s.source) 550 else 24, 64, "Code not captured · use goto code ADDRESS at a live stop", ui.theme.color.text.dim); - if (s.source and std.mem.eql(u8, file_name, "no recorded source mapping")) { + if (!s.graph and code_top >= 32 + origin_height) if (ss.origin_line) |origin| { + if (sources.get(gpa, io, m, origin.file)) |file| { + u.text(.sans, 17, 12, 50, canim.rows.fitted(u, u.print("Originating JS · {s}:{d}", .{ std.fs.path.basename(file.path), origin.line }), panes[0].w - 30), ui.theme.mark(.current).solid); + sourceLine(u, 0, m, origin, if (origin_height < 72) 52 else 58, panes[0].w - 64, false, 0, false); + u.line(.{ 8, 32 + origin_height - 4 }, .{ panes[0].w - 60, 32 + origin_height - 4 }, ui.theme.color.rule, 1); + } + }; + if (!columns(s) and s.source and !s.graph) { + const line = if (s.nav[0].place.follow and !s.nav[0].place.manual) native_line else if (ss.code_count > 0) ss.code_lines[0] else null; + if (line) |l| sourceLine(u, s.source_column, m, l, code_top - source_height, panes[0].w - 64, true, 0, false); + } + u.clip(.{ .x = 2, .y = code_top, .w = panes[0].w - 4 - if (s.maps[0]) @as(f32, 56) else 0, .h = panes[0].h - code_top - 2 }); + if (columns(s) and !s.graph) u.line(.{ Geometry.seam(panes[0]) - 6, 30 }, .{ Geometry.seam(panes[0]) - 6, panes[0].h - 2 }, ui.theme.color.rule, 1); + if (s.graph) { + const size = canim.graph.live(u.moved(-s.horizontal[0], 32 - @as(f32, @floatCast(ss.scroll[0] * 24))), m, regs.rip, ss.trail, @as(f32, @floatFromInt(s.dim)) / 100); + extents[0] = @max(0, (size - panes[0].h + 40) / 24); + } else codeRows(u.moved(-s.horizontal[0], 0), s, ss, m, regs, @floatCast(ss.scroll[0]), heat, fire, travel, false); + if (!s.graph and ss.code_count == 0) u.text(.sans, 20, if (columns(s)) Geometry.seam(panes[0]) + 14 else 24, 64, "Code not captured · use goto code ADDRESS at a live stop", ui.theme.color.text.dim); + if (!s.graph and columns(s) and std.mem.eql(u8, file_name, "no recorded source mapping")) { u.text(.sans_medium, 22, 28, 72, "Source mapping unavailable", ui.theme.color.text.dim); u.text(.sans, 18, 28, 106, "This code has no recorded file / line table.", ui.theme.color.text.faint); u.text(.sans, 18, 28, 136, "Machine instructions remain fully inspectable.", ui.theme.color.text.faint); } u.unclip(); if (s.maps[0]) { - const key = (m.index + 1) *% 0x9e3779b97f4a7c15 ^ bases[0] ^ (@as(u64, s.depth) << 32) ^ (@as(u64, @intFromBool(s.source)) << 40) ^ (@as(u64, @intFromBool(s.ascii)) << 41); + segmentMini(u, 0, bases[0], @max(1, code_after -| bases[0]), regs.rip); + compact_count = ss.code_count; + for (ss.code[0..ss.code_count], 0..) |_, j| { + compact_rows[j] = j; + if (columns(s)) for (ss.aligned[0..ss.aligned_count], 0..) |r, k| if (r.instruction == j) { + compact_rows[j] = k; + break; + }; + } + const key = (m.index + 1) *% 0x9e3779b97f4a7c15 ^ bases[0]; if (ss.mini_key[0] != key) { ui.collected.reset(); ui.strokes = true; u.clip(.{ .x = 0, .y = 0, .w = 0, .h = 0 }); - // Identity coordinates keep the collected miniature local to its pane. - codeRows(ui.Ui.init(u.f), s, ss, m, regs, 0, .none, 0, 1, true); + const v = ui.Ui.init(u.f); + for (ss.code[0..ss.code_count], 0..) |row, i| { + v.text(.mono, 20, 0, @as(f32, @floatFromInt(i)) * 24 + 20, row.text, ui.theme.color.text.dim); + } ui.strokes = false; u.unclip(); ss.mini[0] = ui.collected; ss.mini_key[0] = key; } - var current: ?f32 = null; - for (0..count) |i| { - const index = if (s.source) ss.aligned[i].instruction else i; - if (index) |j| if (ss.code[j].addr == regs.rip) { - current = @floatFromInt(i); - }; - } - canim.minimap.liveStrip(u, ss.mini[0].runs[0..ss.mini[0].n_runs], .{ .x = 1528, .y = 32, .w = 46, .h = 668 }, 1520, count, ss.scroll[0], 27, current); + var mini = Geometry.mini(panes[0]); + mini.w -= 16; + var first: f32 = 0; + for (compact_rows[0..compact_count], 0..) |row, i| if (@as(f64, @floatFromInt(row)) <= ss.scroll[0]) { + first = @floatFromInt(i); + }; + const shown = ui.Rect{ .x = mini.x, .y = mini.y, .w = mini.w, .h = mini.h }; + canim.minimap.liveStrip(u, ss.mini[0].runs[0..ss.mini[0].n_runs], shown, 900, ss.code_count, first, Geometry.visible(panes[0]), null); } } 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 { - _ = u.panel(588, 708, "registers / call stack", .{ .note = u.print("{d} changed", .{@popCount(ss.changed_regs)}) }); - u.clip(.{ .x = 2, .y = 30, .w = 584, .h = 674 }); + _ = 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); for (zt.Regs.names[0..16], 0..) |reg, i| { const changed = ss.changed_regs & (@as(u32, 1) << @intCast(i)) != 0; - _ = canim.rows.reg(u, 34 + @as(f32, @floatFromInt(i)) * 24, 588, reg, m, regs.named(reg).?, .{ .first = if (changed) heat else .none, .extend = if (changed) seconds else null, .most = s.depth }); + _ = canim.rows.reg(v, 34 + @as(f32, @floatFromInt(i)) * 24, geometry.registers.w, reg, m, regs.named(reg).?, .{ .first = if (changed) heat else .none, .extend = if (changed) seconds else null, .most = s.depth }); } - u.current(.{ .x = 1, .y = 430, .w = 586, .h = 24 }, ui.theme.metric.plaque.rip, fire); - u.text(.mono_bold, 20, 14, canim.rows.baseline(430), "rip", ui.theme.mark(.current).on_solid); - _ = canim.rows.chain(u, 74, 430, m, regs.rip, 576, .{}); - canim.rows.ripFlags(u, 224, 458, regs.eflags, ss.changed_flags, heat.corner, if (ss.branch != null) flagsReadAt(m, regs.rip) else 0, 1, .{ .moment = m, .pc = regs.rip, .eflags = regs.eflags }); - u.line(.{ 12, 484 }, .{ 576, 484 }, ui.theme.color.rule, 1); - u.text(.sans_medium, 18, 14, 510, "call stack", ui.theme.color.text.primary); + v.current(.{ .x = 1, .y = 430, .w = geometry.registers.w - 2, .h = 24 }, ui.theme.metric.plaque.rip, fire); + v.text(.mono_bold, 20, 14, canim.rows.baseline(430), "rip", ui.theme.mark(.current).on_solid); + _ = canim.rows.chain(v, 74, 430, m, regs.rip, geometry.registers.w - 12, .{}); + canim.rows.ripFlags(v, 224, 458, regs.eflags, ss.changed_flags, heat.corner, if (ss.branch != null) flagsReadAt(m, regs.rip) else 0, 1, .{ .moment = m, .pc = regs.rip, .eflags = regs.eflags }); + v.line(.{ 12, 484 }, .{ geometry.registers.w - 12, 484 }, ui.theme.color.rule, 1); + v.text(.sans_medium, 18, 14, 510, "call stack", ui.theme.color.text.primary); var frame_buf: [10]zt.Debugger.Frame = undefined; const frames = zt.telescope.frames(m, ®s, &frame_buf) catch &.{}; for (frames[0..@min(frames.len, 3)], 0..) |frame, i| { const y = 522 + @as(f32, @floatFromInt(i)) * 52; - if (i == 0) canim.rows.callCurrent(u, y, 588); - u.text(.mono, 20, 12, canim.rows.baseline(y), u.print("{d}", .{i}), if (i == 0) ui.theme.mark(.current).on_solid else ui.theme.color.text.dim); - _ = u.address(60, canim.rows.baseline(y), frame.pc, .{ .ink = ui.rgb(ui.theme.color.region.code_) }); + if (i == 0) canim.rows.callCurrent(v, y, geometry.registers.w); + v.text(.mono, 20, 12, canim.rows.baseline(y), v.print("{d}", .{i}), if (i == 0) ui.theme.mark(.current).on_solid else ui.theme.color.text.dim); + _ = v.address(60, canim.rows.baseline(y), frame.pc, .{ .ink = ui.rgb(ui.theme.color.region.code_) }); var buf: [256]u8 = undefined; const name_ = (m.string(frame.pc, &buf) catch null) orelse "anonymous code"; - u.text(.mono, 18, 60, y + 44, canim.rows.fitted(u, ui.symbol(u, name_), 510), ui.theme.color.text.dim); + v.text(.mono, 18, 60, y + 44, canim.rows.fitted(v, ui.symbol(v, name_), geometry.registers.w - 72), ui.theme.color.text.dim); } u.unclip(); } -fn stackRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, first: f32, heat: ui.Heat, seconds: f32, miniature: bool) void { +fn stackRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, first: f64, heat: ui.Heat, seconds: f32, miniature: bool) void { const start: usize = if (miniature) 0 else @intFromFloat(@floor(@max(0, first))); - const count: usize = if (miniature) 128 else 17; + const count: usize = if (miniature) 128 else @intFromFloat(Geometry.visible(panes[1]) + 2); const base = bases[1] & ~@as(u64, 7); var slots: [128]zt.telescope.Slot = undefined; - _ = zt.telescope.slots(m, ®s, base +| start * 8, slots[0..@min(count, 128 - start)]) catch { + _ = zt.telescope.slots(m, ®s, base +| start * 8, slots[0..@min(count, 128)]) catch { @memset(&slots, .{}); }; - for (start..@min(start + count, 128)) |i| { + for (start..@min(start + @min(count, 128), @as(usize, @intCast(ranges[1].len / 8)))) |i| { const addr = base +| i * 8; - const y = (if (miniature) @as(f32, 0) else 32) + (@as(f32, @floatFromInt(i)) - first) * 24; - const changed = addr >= regs.rsp -| 24 and i < 11 and base == ((regs.rsp -| 24) & ~@as(u64, 7)) and ss.changed_stack & (@as(u16, 1) << @as(u4, @intCast(i))) != 0; + const y = (if (miniature) @as(f32, 0) else 32) + @as(f32, @floatCast((@as(f64, @floatFromInt(i)) - first) * 24)); + const changed = addr >= regs.rsp -| 24 and addr < (regs.rsp -| 24) + 88 and ss.changed_stack & (@as(u16, 1) << @as(u4, @intCast((addr - (regs.rsp -| 24)) / 8))) != 0; const touched = if (ss.touch) |touch| touch.how & 1 != 0 and addr < touch.addr +| touch.len and addr +| 8 > touch.addr else false; const pins: []const []const u8 = if (addr == regs.rsp and addr == regs.rbp) &.{ "rsp", "rbp" } else if (addr == regs.rsp) &.{"rsp"} else if (addr == regs.rbp) &.{"rbp"} else &.{}; const role = canim.Stack.slotName(u, slots[i - start], (canim.Recording.word(m, addr, 8) catch null) orelse 0); - _ = canim.rows.slot(u, y, if (s.maps[1]) 1012 else 1072, m, addr, @bitCast(addr -% regs.rsp), pins, 1, .{ .first = if (changed) heat else .none, .read = if (touched) 1 else null, .read_shows = 1, .lead = ui.shared(&.{ base, base +| 1024 }), .extend = if (changed) seconds else null, .most = s.depth }, role.name, role.local, null); + _ = canim.rows.slot(u, y, panes[1].w - if (s.maps[1]) @as(f32, 60) else 0, m, addr, @bitCast(addr -% regs.rsp), pins, 1, .{ .first = if (changed) heat else .none, .read = if (touched) 1 else null, .read_shows = 1, .lead = ui.shared(&.{ base, base +| 1024 }), .extend = if (changed) seconds else null, .most = s.depth }, role.name, role.local, null); } } fn drawStack(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, regs: zt.Regs, heat: ui.Heat, seconds: f32) void { - extents[1] = 113; - _ = u.panel(1072, 400, "stack / telescope", .{ .focus = s.focus == .stack }); - u.text(.sans, 17, 235, 19, u.print("{d} pointer hops", .{s.depth}), ui.theme.color.text.dim); + _ = 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); - u.clip(.{ .x = 2, .y = 30, .w = if (s.maps[1]) 1012 else 1068, .h = 362 }); - stackRows(u, s, ss, m, regs, ss.scroll[1], heat, seconds, false); + u.clip(.{ .x = 2, .y = 30, .w = panes[1].w - if (s.maps[1]) @as(f32, 60) else 4, .h = panes[1].h - 38 }); + stackRows(u.moved(-s.horizontal[1], 0), s, ss, m, regs, ss.scroll[1], heat, seconds, false); var frame_buf: [10]zt.Debugger.Frame = undefined; const frames = zt.telescope.frames(m, ®s, &frame_buf) catch &.{}; const low = (bases[1] & ~@as(u64, 7)) + @as(u64, @intFromFloat(ss.scroll[1])) * 8; for (frames, 0..) |frame, k| { const from = @max(frame.low, low); - const to = @min(frame.high, low + 15 * 8); + const to = @min(frame.high, low + @as(u64, @intFromFloat(Geometry.visible(panes[1]))) * 8); if (from >= to) continue; - canim.rows.span(u, if (s.maps[1]) 1012 else 1072, 32 + @as(f32, @floatFromInt((from - low) / 8)) * 24, 32 + @as(f32, @floatFromInt((to - low) / 8)) * 24, u.print("#{d}", .{k}), k == 0, frame.high > low + 15 * 8); + canim.rows.span(u, panes[1].w - if (s.maps[1]) @as(f32, 60) else 0, 32 + @as(f32, @floatFromInt((from - low) / 8)) * 24, 32 + @as(f32, @floatFromInt((to - low) / 8)) * 24, u.print("#{d}", .{k}), k == 0, frame.high > low + @as(u64, @intFromFloat(Geometry.visible(panes[1]))) * 8); } u.unclip(); if (s.maps[1]) { - const key = (m.index + 1) *% 0x9e3779b97f4a7c15 ^ bases[1] ^ (@as(u64, s.depth) << 32) ^ (@as(u64, @intFromBool(s.source)) << 40) ^ (@as(u64, @intFromBool(s.ascii)) << 41); - if (ss.mini_key[1] != key) { - ui.collected.reset(); - ui.strokes = true; - u.clip(.{ .x = 0, .y = 0, .w = 0, .h = 0 }); - stackRows(ui.Ui.init(u.f), s, ss, m, regs, 0, .none, seconds, true); - ui.strokes = false; - u.unclip(); - ss.mini[1] = ui.collected; - ss.mini_key[1] = key; - } - canim.minimap.liveStrip(u, ss.mini[1].runs[0..ss.mini[1].n_runs], .{ .x = 1020, .y = 32, .w = 46, .h = 360 }, 1012, 128, ss.scroll[1], 15, if (regs.rsp >= bases[1] and regs.rsp < bases[1] +| 1024) @as(f32, @floatFromInt((regs.rsp - bases[1]) / 8)) else null); + segmentMini(u, 1, bases[1] + @as(u64, @intFromFloat(ss.scroll[1])) * 8, @as(u64, @intFromFloat(Geometry.visible(panes[1]))) * 8, regs.rsp); + 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 { @@ -885,36 +1178,78 @@ fn memoryRow(u: ui.Ui, m: zt.store.Moment, addr: u64, y: f32, room: f32, ascii: _ = canim.hexdump.readingIn(u, y, shift, m, &values, &known, &fields, room); } } -fn memoryRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, first: f32, heat: ui.Heat, miniature: bool) void { +fn memoryRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, first: f64, heat: ui.Heat, miniature: bool) void { const start: usize = if (miniature) 0 else @intFromFloat(@floor(@max(0, first))); - const count: usize = if (miniature) 128 else 17; + const count: usize = if (miniature) 128 else @intFromFloat(Geometry.visible(panes[2]) + 2); const before = if (m.index > 0) trace.?.moment(m.index - 1) catch null else null; - for (start..@min(start + count, 128)) |i| { - const y = (if (miniature) @as(f32, 0) else 32) + (@as(f32, @floatFromInt(i)) - first) * 24; - memoryRow(u, m, bases[2] +| i * 16, y, if (s.maps[2]) 1036 else 1096, s.ascii, ss.touch, heat, if (miniature) null else before); + 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); } } fn drawMemory(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, heat: ui.Heat) void { - extents[2] = 113; - _ = u.panel(1096, 400, "memory / bytes", .{ .focus = s.focus == .memory }); - 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, 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); paneButtons(u, s, .memory); - u.clip(.{ .x = 2, .y = 30, .w = if (s.maps[2]) 1036 else 1092, .h = 362 }); - memoryRows(u, s, ss, m, ss.scroll[2], heat, false); + 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(); if (s.maps[2]) { - const key = (m.index + 1) *% 0x9e3779b97f4a7c15 ^ bases[2] ^ (@as(u64, s.depth) << 32) ^ (@as(u64, @intFromBool(s.source)) << 40) ^ (@as(u64, @intFromBool(s.ascii)) << 41); - if (ss.mini_key[2] != key) { - ui.collected.reset(); - ui.strokes = true; - u.clip(.{ .x = 0, .y = 0, .w = 0, .h = 0 }); - memoryRows(ui.Ui.init(u.f), s, ss, m, 0, .none, true); - ui.strokes = false; - u.unclip(); - ss.mini[2] = ui.collected; - ss.mini_key[2] = key; + segmentMini(u, 2, bases[2] + @as(u64, @intFromFloat(ss.scroll[2])) * 16, @as(u64, @intFromFloat(Geometry.visible(panes[2]))) * 16, if (ss.touch) |t| t.addr else bases[2]); + memoryMini(u, ss, m, 2); + } +} +fn memoryMini(u: ui.Ui, ss: *Session, m: zt.store.Moment, p: usize) void { + 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); + const key = (m.index + 1) *% 0x9e3779b97f4a7c15 ^ first; + if (ss.mini_key[p] != key) { + compact_counts[p] = 0; + ui.collected.reset(); + ui.strokes = true; + u.clip(.{ .x = 0, .y = 0, .w = 0, .h = 0 }); + const v = ui.Ui.init(u.f); + for (0..128) |i| { + const address = first +| i * stride; + if (address >= ranges[p].addr +| ranges[p].len) break; + var bytes: [16]u8 = undefined; + var known: [16]bool = @splat(false); + m.read(address, bytes[0..stride], known[0..stride]) catch continue; + if (std.mem.indexOfScalar(bool, known[0..stride], true) == null) continue; + const row = compact_counts[p]; + compact_addresses[p][row] = address; + compact_counts[p] += 1; + 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); } - canim.minimap.liveStrip(u, ss.mini[2].runs[0..ss.mini[2].n_runs], .{ .x = 1044, .y = 32, .w = 46, .h = 360 }, 1036, 128, ss.scroll[2], 15, if (ss.touch) |t| if (t.addr >= bases[2] and t.addr < bases[2] +| 2048) @as(f32, @floatFromInt((t.addr - bases[2]) / 16)) else null else null); + ui.strokes = false; + u.unclip(); + ss.mini[p] = ui.collected; + ss.mini_key[p] = key; + } + var mini = Geometry.mini(panes[p]); + mini.w -= 16; + var first_row: f32 = 0; + for (compact_addresses[p][0..compact_counts[p]], 0..) |addr, i| if (addr <= current) { + first_row = @floatFromInt(i); + }; + canim.minimap.liveStrip(u, ss.mini[p].runs[0..ss.mini[p].n_runs], .{ .x = mini.x, .y = mini.y, .w = mini.w, .h = mini.h }, panes[p].w - 60, compact_counts[p], first_row, Geometry.visible(panes[p]), null); +} +fn segmentMini(u: ui.Ui, p: usize, first: u64, len: u64, current: u64) void { + var box = Geometry.mini(panes[p]); + box.x += 34; + box.w -= 34; + u.fill(.{ .x = box.x, .y = box.y, .w = box.w, .h = box.h }, ui.theme.color.raised); + const total: f64 = @floatFromInt(@max(1, ranges[p].len)); + const at: f32 = @floatCast(@as(f64, @floatFromInt(first -| ranges[p].addr)) / total); + const size: f32 = @floatCast(@as(f64, @floatFromInt(len)) / total); + u.frame(.{ .x = box.x, .y = box.y + at * (box.h - 3), .w = box.w, .h = @max(3, @min(box.h, size * box.h)) }, ui.theme.color.text.dim, 1); + if (current >= ranges[p].addr and current - ranges[p].addr < ranges[p].len) { + const y = box.y + @as(f32, @floatCast(@as(f64, @floatFromInt(current - ranges[p].addr)) / total)) * (box.h - 2); + 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 { @@ -931,9 +1266,9 @@ fn ties(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, travel: f32 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 and a.y < 796 and b.y > 812) { - const lane: f32 = 804; - u.route(&.{ .{ a.x + a.w, a.y + a.h / 2 }, .{ 1616, a.y + a.h / 2 }, .{ 1616, lane }, .{ if (b.x < 1100) 16 else 1112, lane }, .{ if (b.x < 1100) 16 else 1112, b.y + b.h / 2 }, .{ if (b.x < 1100) 26 else 1122, b.y + b.h / 2 } }, ui.theme.mark(.read).solid, .{ .width = 1.5, .head = .{ 6, 6 }, .progress = if (hovered != null) 1 else travel }); + 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; } }; @@ -943,64 +1278,97 @@ fn overlays(u: ui.Ui, s: *const State, ss: *Session, moment: ?zt.store.Moment) v const ink = ui.theme.color.text; if (!s.lens) ss.lens_previous = 0; if (s.lens and moment != null) { - const address = if (s.lens_address != 0) s.lens_address else s.pc; - if (ss.lens_previous != address) { + const overlay: Box = .{ .x = @max(24, geometry.w - 1132), .y = 140, .w = @min(1108, geometry.w - 48), .h = @max(0, geometry.h - 180) }; + lens_box = overlay; + const previous_bound = ui.bound; + ui.bound = overlay; + u.clip(.{ .x = overlay.x, .y = overlay.y, .w = overlay.w, .h = overlay.h }); + if (ss.lens_previous != s.lens_address) { ss.lens_at = u.f.in.now; - ss.lens_previous = address; + ss.lens_previous = s.lens_address; } const seconds = @as(f32, @floatFromInt(u.f.in.now -| ss.lens_at)) / 1e9; const amount = ui.theme.ease(.standard, std.math.clamp(seconds / 0.2, 0, 1)); - const resting_y: f32 = if (s.lens_origin.y >= 592 and s.lens_origin.y < 780 and s.lens_origin.x + s.lens_origin.w > 1090) 300 else 592; - const box: Box = .{ .x = 1090, .y = resting_y + 8 * (1 - amount), .w = 1108, .h = 188 }; - lens_box = box; - lens_hits = hit_count; - const v = u.moved(box.x, box.y).faded(amount); - v.fill(.{ .x = 14 * amount, .y = 18 * amount, .w = box.w, .h = box.h }, ui.mix(ui.theme.color.page, 0x000000, 0.2)); - v.fill(.{ .x = 0, .y = 0, .w = box.w, .h = box.h }, ui.theme.color.lift); - v.fill(.{ .x = 0, .y = 0, .w = box.w, .h = 28 }, ui.theme.color.lift_tag); - v.frame(.{ .x = 0, .y = 0, .w = box.w, .h = box.h }, ui.theme.color.rule, 1); - v.text(.sans_medium, 18, 14, 21, "address lens", ink.primary); - _ = v.address(158, 21, address, .{ .ink = ui.rgb(canim.rows.ink(canim.rows.regionOf(moment.?, address))) }); - const first = (address & ~@as(u64, 15)) -| 32; - var bytes: [80]u8 = undefined; - var known: [80]bool = @splat(false); - moment.?.read(first, &bytes, &known) catch {}; - v.text(.sans, 17, 370, 21, if (std.mem.indexOfScalar(bool, &known, true) == null) "Bytes were not captured at this stop · Esc closes" else "click a pointer to follow · right-click to navigate · Esc closes", ink.dim); - button(v, box.w - 40, -2, .{ .kind = .close_lens }, "Close address lens · Esc / z", true, true); - v.clip(.{ .x = 2, .y = 30, .w = box.w - 4, .h = box.h - 32 }); - for (0..5) |i| memoryRow(v, moment.?, first +| i * 16, 34 + @as(f32, @floatFromInt(i)) * 24, box.w - 12, false, null, .none, null); - const row_y = 34 + @as(f32, @floatFromInt((address - first) / 16)) * 24; - const shift = canim.rows.addressRoom(address); - v.read(.{ .x = canim.rows.byteX(@intCast(address % 16)) + shift - 3, .y = row_y, .w = 28, .h = 24 }, amount); - v.unclip(); - for (hits[0..hit_count]) |hit| if (hit.address == address and !contains(box, hit.box.x, hit.box.y)) { - u.read(.{ .x = hit.box.x, .y = hit.box.y, .w = hit.box.w, .h = hit.box.h }, amount); - if (hit.box.y > box.y + box.h and hit.box.y < 796) { - u.route(&.{ .{ hit.box.x, hit.box.y + hit.box.h }, .{ 1616, hit.box.y + hit.box.h }, .{ 1616, box.y + box.h } }, ui.theme.mark(.read).solid, .{ .width = 2, .head = null, .progress = amount }); - } else if (hit.box.y > box.y + box.h) { - const lane: f32 = if (hit.box.x < 1100) 16 else 1112; - u.route(&.{ .{ hit.box.x, hit.box.y + hit.box.h }, .{ lane, hit.box.y + hit.box.h }, .{ lane, 804 }, .{ box.x + 176, 804 }, .{ box.x + 176, box.y + box.h } }, ui.theme.mark(.read).solid, .{ .width = 2, .head = null, .progress = amount }); + for (s.lenses[0..s.lens_count], 0..) |lens, k| { + 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}), .{}); + _ = 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 lane: f32 = if (hit.box.x >= 1628) 2228 else 1616; - u.route(&.{ .{ hit.box.x + hit.box.w, hit.box.y + hit.box.h }, .{ lane, hit.box.y + hit.box.h }, .{ lane, box.y - 8 }, .{ box.x + box.w - 24, box.y - 8 }, .{ box.x + box.w - 24, box.y } }, ui.theme.mark(.read).solid, .{ .width = 2, .head = null, .progress = amount }); + const first = (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); } - break; - }; + v.unclip(); + current_lens = null; + const from = if (k > 0) lens_boxes[k - 1] else lens.origin; + const lane = overlay.x + 8; + u.route(&.{ .{ from.x + @min(from.w, 40), from.y + from.h }, .{ lane, from.y + from.h + 8 }, .{ lane, box.y - 8 }, .{ box.x + 40, box.y } }, ui.theme.mark(.read).solid, .{ .width = 2, .head = .{ 6, 6 }, .progress = amount }); + } + ui.bound = previous_bound; + u.unclip(); + } + if (s.segments and moment != null) { + const box: Box = .{ .x = 24, .y = 112, .w = geometry.w - 48, .h = geometry.h - 160 }; + 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("segments → {s}", .{@tagName(s.focus)}), .{ .focus = true }); + v.text(.mono, 19, 12, 53, v.print("/ {s}▏", .{s.segment_query[0..s.segment_len]}), ink.primary); + v.text(.sans, 15, 12, 76, "Enter opens · Esc closes · type to search", ink.dim); + segment_hit_count = 0; + segment_total = 0; + const maps = moment.?.mappings(u.f.scratch) catch &.{}; + v.clip(.{ .x = 2, .y = 64, .w = box.w - 4, .h = box.h - 66 }); + for (maps) |map| { + var buf: [4096]u8 = undefined; + var path: []const u8 = ""; + _ = moment.?.mapping(map.addr, &path, &buf) catch null; + const title = v.print("{s} 0x{x}–0x{x} {d} KiB {c}{c}{c}", .{ if (path.len == 0) "[anonymous]" else path, map.addr, map.addr +| map.len, map.len / 1024, @as(u8, if (map.prot & 1 != 0) 'r' else '-'), @as(u8, if (map.prot & 2 != 0) 'w' else '-'), @as(u8, if (map.prot & 4 != 0) 'x' else '-') }); + if (std.ascii.findIgnoreCase(title, s.segment_query[0..s.segment_len]) == null) continue; + const row = segment_total; + segment_total += 1; + if (row < s.segment_row) continue; + const y = 90 + @as(f32, @floatFromInt(row - s.segment_row)) * 78; + if (y + 74 > box.h or segment_hit_count == segment_hits.len) continue; + if (row == s.segment_row) v.fill(.{ .x = 2, .y = y, .w = box.w - 4, .h = 76 }, ui.theme.color.raised); + v.text(.mono, 15, 12, y + 18, v.print("{x}–{x}", .{ map.addr, map.addr +| map.len }), ink.primary); + v.text(.mono, 15, 12, y + 40, v.print("{c}{c}{c} · {d} KiB", .{ @as(u8, if (map.prot & 1 != 0) 'r' else '-'), @as(u8, if (map.prot & 2 != 0) 'w' else '-'), @as(u8, if (map.prot & 4 != 0) 'x' else '-'), map.len / 1024 }), ink.primary); + v.text(.sans, 15, 12, y + 62, canim.rows.fitted(v, if (path.len == 0) "[anonymous]" else path, box.w - 24), ink.dim); + segment_hits[segment_hit_count] = .{ .box = .{ .x = box.x, .y = box.y + y, .w = box.w, .h = 76 }, .address = map.addr }; + segment_hit_count += 1; + } + if (segment_total == 0) v.text(.sans, 20, 12, 90, "No matching mappings", ink.dim); + v.unclip(); } if (s.help) { - const v = u.moved(690, 190); - v.fill(.{ .x = 0, .y = 0, .w = 860, .h = 480 }, ui.theme.color.lift); - _ = v.panel(860, 480, "Vim keys / debugger", .{ .focus = true }); - const lines = [_][]const u8{ "s single machine instruction n next source line", "c continue Esc / Ctrl-c pause", "j / k scroll h / l source columns gg / G ends", "Ctrl-d / u half page Ctrl-w h/j/k/l focus pane", "Ctrl-o / i address history Mouse4 / 5 back / forward", "[ / ] recorded stops Shift-f live stop f follow pane", "v source columns m minimap a operand annotations", "b breakpoint at PC z address lens Esc close lens", "Click address: lens Right-click: code / telescope / hex", ": commands goto code|stack|memory ADDRESS", "break FUNCTION break *ADDRESS clear ID signal 0" }; - for (lines, 0..) |line, i| v.text(.mono, 18, 22, 64 + @as(f32, @floatFromInt(i)) * 36, line, ink.primary); + const w = @min(860, geometry.w - 48); + const v = u.moved((geometry.w - w) / 2, 112); + 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", "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" }; + 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(); } if (s.command_open) { - u.fill(.{ .x = 24, .y = 1218, .w = 2192, .h = 40 }, ui.theme.color.lift); - u.text(.mono, 22, 36, 1247, u.print(":{s}▏", .{s.command_text[0..s.command_len]}), ink.primary); + u.fill(.{ .x = 24, .y = geometry.h - 42, .w = geometry.w - 48, .h = 40 }, ui.theme.color.lift); + u.text(.mono, 22, 36, geometry.h - 11, u.print(":{s}▏", .{s.command_text[0..s.command_len]}), ink.primary); } if (tooltip) |b| { - u.fill(.{ .x = 596, .y = 42, .w = 1020, .h = 32 }, ui.theme.color.page); - u.text(.sans_medium, 18, 608, 64, u.print("{s}{s}", .{ b.label, if (b.enabled) "" else " · unavailable in this state" }), if (b.enabled) ink.primary else ink.dim); + u.fill(.{ .x = 24, .y = geometry.h - 40, .w = geometry.w - 48, .h = 32 }, ui.theme.color.page); + u.text(.sans_medium, 18, 36, geometry.h - 17, u.print("{s}{s}", .{ b.label, if (b.enabled) "" else " · unavailable in this state" }), if (b.enabled) ink.primary else ink.dim); } } @@ -1038,6 +1406,12 @@ fn selected(ss: *Session, t: *zt.Trace, m: zt.store.Moment, regs: zt.Regs, tid: ss.code_start -|= insn.back; } } + if (ss.shown) |old| if (old != m.index) { + const prior = t.moment(old) catch m; + if ((prior.line(ss.tid) catch null)) |line| if (sources.get(gpa, io, prior, line.file)) |file| { + if (std.mem.endsWith(u8, file.path, ".js")) ss.origin_line = line; + }; + }; ss.shown = m.index; ss.tid = tid; ss.changed_at = now; |
