summaryrefslogtreecommitdiff
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/Navigation.zig56
-rw-r--r--gui/src/Sources.zig34
-rw-r--r--gui/src/app.zig977
3 files changed, 936 insertions, 131 deletions
diff --git a/gui/src/Navigation.zig b/gui/src/Navigation.zig
new file mode 100644
index 0000000..f9ae34a
--- /dev/null
+++ b/gui/src/Navigation.zig
@@ -0,0 +1,56 @@
+//! 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 };
+place: Location = .{},
+history: [32]Location = @splat(.{}),
+len: u8 = 0,
+cursor: u8 = 0,
+
+pub fn visit(n: *Navigation, address: u64) void {
+ if (n.place.address == address and !n.place.follow) return;
+ if (n.len == 0) {
+ n.history[0] = n.place;
+ n.len = 1;
+ }
+ n.history[n.cursor] = n.place;
+ n.len = n.cursor + 1;
+ if (n.len == n.history.len) {
+ std.mem.copyForwards(Location, n.history[0..31], n.history[1..]);
+ n.len -= 1;
+ }
+ n.cursor = n.len;
+ n.place = .{ .address = address, .follow = false };
+ n.history[n.len] = n.place;
+ n.len += 1;
+}
+
+pub fn back(n: *Navigation) void {
+ if (n.len == 0 or n.cursor == 0) return;
+ n.history[n.cursor] = n.place;
+ n.cursor -= 1;
+ n.place = n.history[n.cursor];
+}
+
+pub fn forward(n: *Navigation) void {
+ if (n.cursor + 1 >= n.len) return;
+ n.history[n.cursor] = n.place;
+ n.cursor += 1;
+ n.place = n.history[n.cursor];
+}
+
+test "pane jumps retain scroll and discard the abandoned forward branch" {
+ var n: Navigation = .{};
+ n.visit(0x1000);
+ n.place.row = 3;
+ n.visit(0x2000);
+ n.back();
+ try std.testing.expectEqual(@as(f32, 3), n.place.row);
+ n.visit(0x3000);
+ n.forward();
+ try std.testing.expectEqual(@as(u64, 0x3000), n.place.address);
+ for (0..40) |i| n.visit(0x4000 + i);
+ try std.testing.expectEqual(@as(u8, 32), n.len);
+ for (0..40) |_| n.back();
+ try std.testing.expectEqual(@as(u64, 0x4008), n.place.address);
+}
diff --git a/gui/src/Sources.zig b/gui/src/Sources.zig
new file mode 100644
index 0000000..33268c5
--- /dev/null
+++ b/gui/src/Sources.zig
@@ -0,0 +1,34 @@
+//! Owned, bounded source cache. No animation-global cache can outlive these bytes.
+const std = @import("std");
+const canim = @import("canim");
+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,
+
+pub fn close(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.* = .{};
+}
+
+pub fn get(s: *Sources, gpa: std.mem.Allocator, io: std.Io, m: zt.store.Moment, id: u64) ?*const File {
+ for (s.files.items) |*file| if (file.id == id) return file;
+ 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 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 {
+ if (text) |t| t.deinit();
+ gpa.free(path);
+ gpa.free(bytes);
+ return null;
+ };
+ return &s.files.items[s.files.items.len - 1];
+}
diff --git a/gui/src/app.zig b/gui/src/app.zig
index 220fc28..dfa0d0a 100644
--- a/gui/src/app.zig
+++ b/gui/src/app.zig
@@ -4,9 +4,12 @@ const canim = @import("canim");
const zt = @import("ztrace");
const ui = canim.ui;
const Client = @import("Client.zig");
+const Navigation = @import("Navigation.zig");
+const Sources = @import("Sources.zig");
+var sources: Sources = .{};
pub const name = "ztrace debugger";
-pub const width = 1920;
-pub const height = 1080;
+pub const width = 2240;
+pub const height = 1260;
pub var io: std.Io = undefined;
pub var gpa: std.mem.Allocator = undefined;
var trace: ?zt.Trace = null;
@@ -21,9 +24,47 @@ pub const State = struct {
stops: u64 = 0,
pc: u64 = 0,
action: sk.Request(Action) = .{},
+ nav: [3]Navigation = @splat(.{}),
+ focus: Pane = .code,
+ maps: [3]bool = @splat(true),
+ source: bool = true,
+ source_column: u16 = 0,
+ annotations: bool = true,
+ depth: u8 = 4,
+ ascii: bool = true,
+ lens: bool = false,
+ lens_address: u64 = 0,
+ lens_origin: Box = .{},
+ help: bool = false,
+ prefix: u8 = 0,
+ command_open: bool = false,
+ command_text: [512]u8 = @splat(0),
+ command_len: u16 = 0,
+ drag_map: ?Pane = null,
};
pub const Session = struct {
action: sk.Handled = .{},
+ scroll: [3]f32 = @splat(0),
+ base: [3]u64 = @splat(0),
+ mini: [3]ui.Collected = @splat(.{}),
+ mini_key: [3]u64 = @splat(0),
+ listing_at: ?u64 = null,
+ listing_base: u64 = 0,
+ code: [256]canim.disasm.Insn = undefined,
+ code_text: [256][1024]u8 = undefined,
+ code_lines: [256]?zt.store.Line = undefined,
+ code_count: usize = 0,
+ aligned: [512]canim.aligned.LiveRow = undefined,
+ aligned_count: usize = 0,
+ marker_key: u64 = 0,
+ marker_base: u64 = 0,
+ marker_from: f32 = 0,
+ marker_to: f32 = 0,
+ marker_shown: f32 = 0,
+ marker_at: u64 = 0,
+ lens_at: u64 = 0,
+ lens_previous: u64 = 0,
+
shown: ?u64 = null,
tid: u32 = 0,
changed_at: u64 = 0,
@@ -31,16 +72,34 @@ pub const Session = struct {
changed_stack: u16 = 0,
changed_flags: u64 = 0,
code_start: u64 = 0,
- mark_from: f32 = 0,
- mark_to: f32 = 0,
trail: [3]u64 = @splat(0),
result_at: ?u64 = null,
touch: ?canim.Recording.Touch = null,
branch: ?canim.Recording.Branch = null,
};
-const Action = enum { cont, pause, stepi, step };
+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 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 };
+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 button_count: usize = 0;
+var extents: [3]f32 = @splat(0);
+var bases: [3]u64 = @splat(0);
+var tooltip: ?Button = null;
+var lens_box: ?Box = null;
+var lens_hits: usize = 0;
pub fn close() void {
+ sources.close(gpa);
if (trace) |*t| t.close();
trace = null;
if (client) |c| c.close();
@@ -77,11 +136,31 @@ 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, "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, "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")) {
+ 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);
+ s.focus = pane;
+ if (client != null and s.status == .stopped and s.following) {
+ var buf: [96]u8 = undefined;
+ try client.?.send(try std.fmt.bufPrint(&buf, "inspect {s} 0x{x} {d}", .{ if (pane == .code) "code" else "memory", address, @as(u32, if (pane == .code) 128 else 2048) }));
+ }
+ return true;
+ }
+ if (std.mem.eql(u8, cmd, "mouse-button")) {
+ // The headless host has no non-left click syntax; exercise the actual handler.
+ const code = try std.fmt.parseInt(u16, words.next() orelse return error.MissingButton, 10);
+ const x = try std.fmt.parseFloat(f32, words.next() orelse return error.MissingX);
+ const y = try std.fmt.parseFloat(f32, words.next() orelse return error.MissingY);
+ pointer(s, code, x, y);
+ return true;
+ }
if (!std.mem.eql(u8, cmd, "open")) return false;
if (client != null) return error.TargetActive;
const path = words.next() orelse return error.MissingPath;
@@ -91,6 +170,7 @@ pub fn command(s: *State, c: *sk.Console, line: []const u8) !bool {
var events = try (try next.moment(next.len - 1)).events(gpa);
defer events.deinit(gpa);
if (trace) |*t| t.close();
+ sources.close(gpa);
trace = next;
s.moment = next.len -| 1;
s.stops = next.len;
@@ -102,37 +182,378 @@ pub fn command(s: *State, c: *sk.Console, line: []const u8) !bool {
return true;
}
-pub fn update(s: *State, in: *const sk.Input) void {
- if (in.pressed(sk.Key.left)) {
- s.following = false;
- s.moment -|= 1;
+fn contains(r: Box, x: f32, y: f32) bool {
+ return x >= r.x and y >= r.y and x < r.x + r.w and y < r.y + r.h;
+}
+fn paneAt(x: f32, y: f32) ?Pane {
+ for (panes, 0..) |box, i| if (contains(box, x, y)) return @fromBackingInt(@intCast(i));
+ return null;
+}
+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;
+ while (i > floor) {
+ i -= 1;
+ if (contains(hits[i].box, x, y)) return hits[i];
}
- if (in.pressed(sk.Key.right)) {
- s.following = false;
- s.moment = @min(s.moment +| 1, s.stops -| 1);
+ return null;
+}
+fn collectAddress(_: *anyopaque, address: u64, box: Box) void {
+ if (hit_count == hits.len) return;
+ hits[hit_count] = .{ .address = address, .box = box };
+ hit_count += 1;
+}
+fn scroll(s: *State, pane: Pane, delta: f32) void {
+ const p = @backingInt(pane);
+ const n = &s.nav[p];
+ if (n.place.follow) {
+ n.place.address = bases[p];
+ n.place.follow = false;
}
- if (in.pressed(sk.Key.end)) {
- s.following = true;
- s.moment = s.stops -| 1;
+ n.place.row = std.math.clamp(n.place.row + delta, 0, extents[p]);
+}
+fn act(s: *State, a: Action) void {
+ const p = @backingInt(a.pane);
+ switch (a.kind) {
+ .previous => {
+ s.following = false;
+ s.moment -|= 1;
+ },
+ .next => {
+ s.following = false;
+ s.moment = @min(s.moment +| 1, s.stops -| 1);
+ },
+ .live => {
+ s.following = true;
+ s.moment = s.stops -| 1;
+ },
+ .follow => {
+ s.nav[p].place = .{};
+ },
+ .back => s.nav[p].back(),
+ .forward => s.nav[p].forward(),
+ .source => s.source = !s.source,
+ .map => s.maps[p] = !s.maps[p],
+ .annotate => s.annotations = !s.annotations,
+ .shallower => s.depth = @max(1, s.depth -| 1),
+ .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;
+ };
+ }
+ },
+ .close_lens => s.lens = false,
+ .help => s.help = !s.help,
+ .command => {
+ s.command_open = true;
+ s.command_len = 0;
+ },
+ else => s.action.send(a),
}
- if (client == null or s.status == .exited) return;
- if (in.pressed(sk.Key.f5)) s.action.send(if (s.status == .running) .pause else .cont);
- if (in.pressed(sk.Key.f10) and s.status != .running) s.action.send(.stepi);
- if (in.pressed(sk.Key.f11) and s.status != .running) s.action.send(.step);
- if (in.mousePressed(.left)) |e| if (e.y >= 38 and e.y < 64) {
- if (e.x >= 24 and e.x < 190) s.action.send(if (s.status == .running) .pause else .cont);
- if (e.x >= 204 and e.x < 370 and s.status != .running) s.action.send(.stepi);
- if (e.x >= 384 and e.x < 550 and s.status != .running) s.action.send(.step);
+}
+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;
+ },
};
+ s.lens_address = address;
+ s.focus = pane;
+ s.action.send(.{ .kind = .go, .pane = pane, .address = address });
+}
+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);
+}
+fn enabled(s: *const State, a: Action) bool {
+ return switch (a.kind) {
+ .cont, .stepi, .step, .breakpoint => client != null and s.status == .stopped,
+ .pause => client != null and s.status == .running,
+ .back => s.nav[@backingInt(a.pane)].cursor > 0,
+ .forward => s.nav[@backingInt(a.pane)].cursor + 1 < s.nav[@backingInt(a.pane)].len,
+ else => true,
+ };
+}
+fn pointer(s: *State, mouse_button: u16, x: f32, y: f32) void {
+ if (s.help) 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 });
+ return;
+ }
+ if (mouse_button == 3) {
+ if (addressAt(x, y)) |hit| semantic(s, hit.address);
+ return;
+ }
+ if (mouse_button != 1) return;
+ var b = button_count;
+ while (b > 0) {
+ b -= 1;
+ if (contains(buttons[b].box, x, y)) {
+ if (enabled(s, buttons[b].action)) act(s, buttons[b].action);
+ 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;
+ }
+ 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;
+ mapDrag(s, pane, y);
+ return;
+ }
+ }
+ if (addressAt(x, y)) |hit| {
+ s.lens_address = hit.address;
+ s.lens_origin = hit.box;
+ s.lens = true;
+ }
+}
+
+pub fn update(s: *State, in: *const sk.Input) void {
+ if (in.console) return;
+ for (in.events) |e| {
+ 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 != ':') {
+ s.command_text[s.command_len] = @intCast(e.value);
+ s.command_len += 1;
+ }
+ }
+ if (e.kind == .key_down) switch (@as(sk.Key, @fromBackingInt(@intCast(@as(u8, @intCast(e.code)))))) {
+ .escape => s.command_open = false,
+ .backspace => s.command_len -|= 1,
+ .@"return" => {
+ s.command_open = false;
+ s.action.send(.{ .kind = .submit });
+ },
+ else => {},
+ };
+ continue;
+ }
+ switch (e.kind) {
+ .text => switch (e.value) {
+ ':' => act(s, .{ .kind = .command }),
+ '?' => act(s, .{ .kind = .help }),
+ else => {},
+ },
+ .mouse_down => pointer(s, e.code, e.x, e.y),
+ .mouse_up, .cancel => s.drag_map = null,
+ .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);
+ },
+ .key_down => {
+ const key: sk.Key = @fromBackingInt(@intCast(@as(u8, @intCast(e.code))));
+ const ctrl = e.value & sk.Key.Mod.ctrl != 0 or in.held(sk.Key.left_ctrl) or in.held(sk.Key.right_ctrl);
+ 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),
+ .o => act(s, .{ .kind = .back, .pane = s.focus }),
+ .i => act(s, .{ .kind = .forward, .pane = s.focus }),
+ .w => s.prefix = 'w',
+ .c => if (s.status == .running) {
+ act(s, .{ .kind = .pause });
+ },
+ else => {},
+ }
+ continue;
+ }
+ if (s.prefix == 'w') {
+ s.focus = switch (key) {
+ .h => .stack,
+ .l => .memory,
+ .k => .code,
+ .j => .stack,
+ else => s.focus,
+ };
+ s.prefix = 0;
+ continue;
+ }
+ 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),
+ .j => scroll(s, s.focus, 1),
+ .k => scroll(s, s.focus, -1),
+ .g => if (shift) {
+ scroll(s, s.focus, extents[@backingInt(s.focus)]);
+ } else if (was_g) {
+ scroll(s, s.focus, -extents[@backingInt(s.focus)]);
+ } else {
+ s.prefix = 'g';
+ },
+ .s => if (s.status == .stopped) {
+ act(s, .{ .kind = .stepi });
+ },
+ .n => if (s.status == .stopped) {
+ act(s, .{ .kind = .step });
+ },
+ .c => if (s.status == .stopped) {
+ act(s, .{ .kind = .cont });
+ },
+ .escape => if (s.lens or s.help) {
+ s.lens = false;
+ s.help = false;
+ } else if (s.status == .running) {
+ act(s, .{ .kind = .pause });
+ },
+ .left_bracket => act(s, .{ .kind = .previous }),
+ .right_bracket => act(s, .{ .kind = .next }),
+ .f => if (shift) {
+ act(s, .{ .kind = .live });
+ } else {
+ act(s, .{ .kind = .follow, .pane = s.focus });
+ },
+ .b => act(s, .{ .kind = .breakpoint, .address = s.pc }),
+ .m => act(s, .{ .kind = .map, .pane = s.focus }),
+ .v => act(s, .{ .kind = .source }),
+ .a => act(s, .{ .kind = .annotate }),
+ .z => act(s, .{ .kind = .lens, .address = if (addressAt(in.mouse_x, in.mouse_y)) |h| h.address else s.pc }),
+ .tab => s.focus = @fromBackingInt(@intCast((@backingInt(s.focus) + 1) % 3)),
+ else => {},
+ }
+ },
+ else => {},
+ }
+ }
+}
+
+fn icon(u: ui.Ui, kind: Kind, active: bool) void {
+ const c = if (active) ui.theme.mark(.current).solid else ui.theme.color.text.primary;
+ const v = u.moved(6, 5);
+ switch (kind) {
+ .cont => sk.draw.polygon(u.f, &.{ .{ 3, 2 }, .{ 3, 20 }, .{ 18, 11 } }, v.at.pen(.{ .fill = ui.rgb(c) })),
+ .pause => {
+ v.fill(.{ .x = 4, .y = 3, .w = 4, .h = 16 }, c);
+ v.fill(.{ .x = 13, .y = 3, .w = 4, .h = 16 }, c);
+ },
+ .stepi, .step => {
+ v.route(&.{ .{ 2, 11 }, .{ 18, 11 } }, c, .{ .width = 2, .head = .{ 6, 6 } });
+ v.line(.{ 20, 3 }, .{ 20, 19 }, c, 2);
+ if (kind == .step) {
+ v.line(.{ 2, 2 }, .{ 12, 2 }, c, 2);
+ v.line(.{ 2, 20 }, .{ 12, 20 }, c, 2);
+ }
+ },
+ .previous, .back, .next, .forward => {
+ const left = kind == .previous or kind == .back;
+ v.route(&.{ .{ if (left) 19 else 3, 11 }, .{ if (left) 3 else 19, 11 } }, c, .{ .width = 2, .head = .{ 6, 7 } });
+ if (kind == .previous or kind == .next) v.disc(.{ if (left) 21 else 1, 11 }, 2, ui.rgb(c), null, 0);
+ },
+ .live, .follow => {
+ v.disc(.{ 11, 11 }, 7, null, ui.rgb(c), 2);
+ v.disc(.{ 11, 11 }, 2, ui.rgb(c), null, 0);
+ v.line(.{ 11, 0 }, .{ 11, 5 }, c, 1);
+ v.line(.{ 11, 17 }, .{ 11, 22 }, c, 1);
+ },
+ .breakpoint => v.disc(.{ 11, 11 }, 7, ui.rgb(ui.theme.mark(.write).solid), null, 0),
+ .source => {
+ v.line(.{ 10, 3 }, .{ 4, 11 }, c, 2);
+ v.line(.{ 4, 11 }, .{ 10, 19 }, c, 2);
+ v.line(.{ 14, 3 }, .{ 20, 11 }, c, 2);
+ v.line(.{ 20, 11 }, .{ 14, 19 }, c, 2);
+ },
+ .map => {
+ v.frame(.{ .x = 1, .y = 1, .w = 20, .h = 20 }, c, 1);
+ for (0..5) |i| {
+ const y = 4 + @as(f32, @floatFromInt(i)) * 3;
+ v.line(.{ 4, y }, .{ if (i % 2 == 0) 18 else 13, y }, c, 1);
+ }
+ v.frame(.{ .x = 2, .y = 8, .w = 18, .h = 7 }, c, 1);
+ },
+ .lens => {
+ v.disc(.{ 9, 9 }, 7, null, ui.rgb(c), 2);
+ v.line(.{ 14, 14 }, .{ 21, 21 }, c, 3);
+ },
+ .shallower, .deeper => {
+ v.line(.{ 3, 11 }, .{ 19, 11 }, c, 2);
+ if (kind == .deeper) v.line(.{ 11, 3 }, .{ 11, 19 }, c, 2);
+ },
+ .annotate => {
+ v.route(&.{ .{ 2, 18 }, .{ 2, 5 }, .{ 20, 5 } }, c, .{ .width = 2, .head = .{ 6, 6 } });
+ v.line(.{ 8, 14 }, .{ 20, 14 }, c, 2);
+ v.line(.{ 8, 19 }, .{ 17, 19 }, c, 2);
+ },
+ .ascii => v.text(.mono_bold, 20, 1, 19, "Aa", c),
+ .close_lens => {
+ v.line(.{ 3, 3 }, .{ 19, 19 }, c, 2);
+ v.line(.{ 19, 3 }, .{ 3, 19 }, c, 2);
+ },
+ .help => v.text(.mono_bold, 22, 5, 19, "?", c),
+ .command => {
+ v.route(&.{ .{ 2, 4 }, .{ 10, 11 }, .{ 2, 18 } }, c, .{ .width = 2, .head = null });
+ v.line(.{ 12, 18 }, .{ 21, 18 }, c, 2);
+ },
+ else => {},
+ }
+}
+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 };
+ const b: Button = .{ .action = action, .box = box, .label = label, .enabled = available };
+ if (button_count < buttons.len) {
+ buttons[button_count] = b;
+ button_count += 1;
+ }
+ const hover = !u.f.in.console and contains(box, u.f.in.mouse_x, u.f.in.mouse_y);
+ if (hover) tooltip = b;
+ 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);
+}
+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;
+ 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 - 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);
}
pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void {
- if (ss.action.take(s.action)) |action| f.run(switch (action) {
- .cont => "continue",
- .pause => "interrupt",
- .stepi => "stepi",
- .step => "nextline",
- });
+ if (ss.action.take(s.action)) |action| switch (action.kind) {
+ .cont => f.run("continue"),
+ .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 })),
+ .breakpoint => f.run(ui.Ui.init(f).print("break *0x{x}", .{action.address})),
+ .submit => f.run(s.command_text[0..s.command_len]),
+ else => {},
+ };
if (client) |c| if (c.poll()) |update_| if (update_.generation != latest.generation) {
latest = update_;
if (latest.status != .running and latest.moments > loaded) {
@@ -149,30 +570,42 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void {
const u = ui.Ui.init(f);
const ink = ui.theme.color.text;
const gold = ui.theme.mark(.current);
+ hit_count = 0;
+ button_count = 0;
+ tooltip = null;
+ lens_box = null;
+ ui.address_hit = .{ .ctx = ss, .emit = collectAddress };
+ defer ui.address_hit = null;
u.text(.sans_medium, 24, 24, 28, "ztrace / debugger", ink.primary);
- const status_ink = if (s.status == .failed) ui.theme.mark(.write).solid else gold.solid;
const status = if (client == null) (if (trace == null) "READY" else "RECORDING") else @tagName(s.status);
- u.fill(.{ .x = 332, .y = 9, .w = 118, .h = 24 }, ui.theme.color.raised);
- u.text(.mono_bold, 17, 344, 27, status, status_ink);
- u.text(.sans, 18, 468, 27, latest.reason(), ink.dim);
- if (client != null) u.text(.mono, 17, 1610, 27, u.print("last command {d:.3} ms", .{@as(f64, @floatFromInt(latest.elapsed_ns)) / 1e6}), ink.dim);
- for ([_][]const u8{ if (s.status == .running) "F5 Pause" else "F5 Continue", "F10 Instruction", "F11 Source line" }, 0..) |label, i| {
- const x = 24 + @as(f32, @floatFromInt(i)) * 180;
- const enabled = client != null and s.status != .exited and (i == 0 or s.status != .running);
- const hover = enabled and !f.in.console and f.in.mouse_x >= x and f.in.mouse_x < x + 166 and f.in.mouse_y >= 38 and f.in.mouse_y < 64;
- const v = if (enabled) u else u.faded(0.45);
- v.fill(.{ .x = x, .y = 38, .w = 166, .h = 26 }, if (hover) ui.theme.color.rule else ui.theme.color.raised);
- v.frame(.{ .x = x, .y = 38, .w = 166, .h = 26 }, if (hover) gold.solid else ui.theme.color.rule, 1);
- v.text(.sans_medium, 17, x + 8, 57, label, ink.primary);
+ 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 · ?" };
+ 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) {
+ .source => s.source,
+ .map => s.maps[@backingInt(s.focus)],
+ .annotate => s.annotations,
+ .lens => s.lens,
+ .live => s.following,
+ else => false,
+ });
}
- u.text(.sans, 18, 584, 57, "← / → history End live ` commands", ink.dim);
+ u.text(.sans, 17, 600, 63, "j k scroll s instruction n source c run : command ? help", ink.dim);
const t = if (trace) |*t| t else {
- _ = u.moved(24, 88).panel(1872, 948, "session", .{ .focus = true });
+ _ = u.moved(24, 88).panel(2192, 1124, "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 the command line with backtick, then set a breakpoint and continue.", ink.dim);
+ u.text(.sans, 22, 72, 268, "Open commands with : or backtick, then set a breakpoint and continue.", ink.dim);
u.text(.mono, 20, 72, 328, "break FUNCTION break *ADDRESS clear ID", ink.primary);
- u.text(.sans, 22, 72, 396, "Or inspect a recording with open PATH.", ink.dim);
+ overlays(u, s, ss, null);
return;
};
const m = t.moment(@min(s.moment, t.len -| 1)) catch return;
@@ -181,106 +614,394 @@ pub fn draw(s: *const State, ss: *Session, f: *sk.Frame) void {
if (ss.shown != m.index or ss.tid != s.tid) selected(ss, t, m, regs, s.tid, low, f.in.now);
const seconds = @as(f32, @floatFromInt(f.in.now -| ss.changed_at)) / 1e9;
const heat = changedHeat(seconds);
- const travel = ui.theme.ease(.standard, std.math.clamp(seconds / ui.theme.time.step, 0, 1));
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, 1360, 57, mode, gold.solid);
- u.text(.mono, 18, 1492, 57, u.print("moment {d}/{d} · tid {d}", .{ m.index, t.len -| 1, s.tid }), ink.dim);
-
- const d = u.moved(24, 88);
- var symbol_buf: [256]u8 = undefined;
- const symbol = (m.string(regs.rip, &symbol_buf) catch null) orelse "source unavailable";
- _ = d.panel(1180, 620, "disassembly", .{ .focus = true, .note = canim.rows.fitted(d, symbol, 820) });
- d.clip(.{ .x = 2, .y = 26, .w = 1176, .h = 590 });
- const marker = 32 + std.math.lerp(ss.mark_from, ss.mark_to, travel) * 24;
- d.current(.{ .x = 2, .y = marker, .w = 1176, .h = 24 }, ui.theme.metric.plaque.pc, fire);
- sk.draw.polygon(f, &.{ .{ 20, marker + 12 }, .{ 10, marker + 6 }, .{ 10, marker + 18 } }, d.at.pen(.{ .fill = ui.rgb(gold.on_solid) }));
- var pc = ss.code_start;
- var target_y: ?f32 = null;
- for (0..24) |i| {
- var buf: [1024]u8 = undefined;
- const insn = (zt.telescope.instruction(m, pc, &buf) catch null) orelse break;
- const y = 32 + @as(f32, @floatFromInt(i)) * 24;
- for (ss.trail, 0..) |old, k| if (old == pc and pc != regs.rip) {
+ 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);
+ 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;
+ 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;
+ 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;
+ }
+ 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);
+ 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);
+ overlays(u, s, ss, m);
+}
+fn listing(ss: *Session, m: zt.store.Moment, base: u64) void {
+ if (ss.listing_at == m.index and ss.listing_base == base) return;
+ ss.listing_at = m.index;
+ ss.listing_base = base;
+ ss.code_count = 0;
+ 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;
+ 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;
+}
+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);
+ return;
+ };
+ if (line.line == 0 or line.line > text.lines.len) return;
+ const range = text.lines[line.line - 1];
+ 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 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;
+ var current_group: ?usize = null;
+ var group_start: usize = 0;
+ for (ss.aligned[0..ss.aligned_count], 0..) |row, i| {
+ if (row.source != null) group_start = i;
+ if (row.instruction) |j| if (ss.code[j].addr == regs.rip) {
+ current_group = group_start;
+ };
+ }
+ 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 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 current = row.addr == regs.rip;
+ if (current) {
+ const marker_y = if (miniature) y else 32 + (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) }));
+ }
+ for (ss.trail, 0..) |old, k| if (old == row.addr and !current) {
d.trail(2, y, k);
break;
};
- const current = pc == regs.rip;
- const row: canim.disasm.Insn = .{ .addr = pc, .len = insn.len, .text = insn.text, .line = if (insn.line) |line| line.line else null, .params = insn.params };
- canim.disasm.liveRow(d, row, y, 1180, m, regs, .{
- .current = current,
- .executed = ss.result_at == pc,
- .heat = heat,
- .lead = ui.shared(&.{ ss.code_start, ss.code_start + 256 }),
- .touch = if (current) ss.touch else null,
- .branch = if (current) ss.branch else null,
- });
- if (ss.branch) |branch| if (branch.to == pc) {
- target_y = y;
+ 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 });
+ if (ss.branch) |branch| if (branch.to == row.addr) {
+ branch_row = y;
};
- pc += insn.len;
}
- if (ss.branch) |branch| if (target_y) |to| if (branch.kind == .jump and to != marker) {
- d.route(&.{ .{ 38, marker + 12 }, .{ 31, marker + 12 }, .{ 31, to + 12 }, .{ 39, to + 12 } }, if (branch.taken) gold.solid else ink.faint, .{ .width = 2, .head = .{ 7, 8 }, .radius = 4, .dashed = !branch.taken, .progress = travel });
+ 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 (@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) {
+ u.route(&.{ .{ seam + 37, pc_row.? + 12 }, .{ seam + 28, pc_row.? + 12 }, .{ seam + 28, branch_row.? + 12 }, .{ seam + 38, branch_row.? + 12 } }, if (branch.taken) ui.theme.mark(.current).solid else ui.theme.color.text.faint, .{ .width = 2, .head = .{ 7, 8 }, .radius = 4, .dashed = !branch.taken, .progress = travel });
};
- d.unclip();
-
- const r = u.moved(1228, 88);
- _ = r.panel(668, 620, "registers", .{ .note = u.print("{d} changed", .{@popCount(ss.changed_regs)}) });
+}
+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));
+ if (ss.marker_key != marker_key) {
+ 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) {
+ ss.marker_to = @floatFromInt(i);
+ ss.marker_from = if (ss.marker_base == bases[0]) ss.marker_shown else ss.marker_to;
+ };
+ }
+ ss.marker_key = marker_key;
+ ss.marker_base = bases[0];
+ ss.marker_at = u.f.in.now;
+ }
+ 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 });
+ 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);
+ 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")) {
+ 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);
+ 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);
+ 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);
+ }
+}
+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 });
for (zt.Regs.names[0..16], 0..) |reg, i| {
const changed = ss.changed_regs & (@as(u32, 1) << @intCast(i)) != 0;
- _ = canim.rows.reg(r, 34 + @as(f32, @floatFromInt(i)) * 24, 668, reg, m, regs.named(reg).?, .{ .first = if (changed) heat else .none, .extend = if (changed) seconds else null });
+ _ = 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.rip(r, 430, 668, m, regs.rip, regs.eflags, ss.changed_flags, heat.corner, fire, if (ss.branch != null) flagsReadAt(m, regs.rip) else 0, 1, null);
- r.text(.sans, 17, 14, 492, "Pointers keep the ink of the memory they reach", ink.dim);
- for ([_][]const u8{ "stack", "heap", "code", "data" }, [_]u24{ ui.theme.color.region.stack, ui.theme.color.region.heap, ui.theme.color.region.code_, ui.theme.color.region.data }, 0..) |label, color, i| {
- r.text(.mono, 18, 14 + @as(f32, @floatFromInt(i)) * 132, 524, label, color);
+ 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);
+ var frame_buf: [10]zt.Debugger.Frame = undefined;
+ const frames = zt.telescope.frames(m, &regs, &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_) });
+ 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);
}
- r.corner(14, 548, 8, 1);
- r.text(.sans, 17, 32, 562, "changed since previous stop", ink.dim);
- r.frame(.{ .x = 14, .y = 578, .w = 12, .h = 14 }, ui.theme.mark(.read).solid, 2);
- r.text(.sans, 17, 32, 592, "read by the current instruction", ink.dim);
-
- const stack = u.moved(24, 724);
- _ = stack.panel(1280, 312, "stack / telescope", .{ .note = "addresses · pointers · values · frame roles" });
- var slots: [11]zt.telescope.Slot = undefined;
- _ = zt.telescope.slots(m, &regs, low, &slots) catch {
+ 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 {
+ const start: usize = if (miniature) 0 else @intFromFloat(@floor(@max(0, first)));
+ const count: usize = if (miniature) 128 else 17;
+ const base = bases[1] & ~@as(u64, 7);
+ var slots: [128]zt.telescope.Slot = undefined;
+ _ = zt.telescope.slots(m, &regs, base +| start * 8, slots[0..@min(count, 128 - start)]) catch {
@memset(&slots, .{});
};
- for (&slots, 0..) |*slot, i| {
- const addr = low + i * 8;
- const y = 32 + @as(f32, @floatFromInt(i)) * 24;
- const changed = ss.changed_stack & (@as(u16, 1) << @intCast(i)) != 0;
- const touched = if (ss.touch) |touch| touch.how & 1 != 0 and addr < touch.addr + touch.len and addr + 8 > touch.addr else false;
+ for (start..@min(start + count, 128)) |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 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, slot.*, (canim.Recording.word(m, addr, 8) catch null) orelse 0);
- _ = canim.rows.slot(stack, y, 1280, 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(&.{ low, low + 80 }), .extend = if (changed) seconds else null }, role.name, role.local, null);
+ 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);
}
+}
+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);
+ 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);
var frame_buf: [10]zt.Debugger.Frame = undefined;
const frames = zt.telescope.frames(m, &regs, &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 + slots.len * 8);
+ const to = @min(frame.high, low + 15 * 8);
if (from >= to) continue;
- canim.rows.span(stack, 1280, 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 + slots.len * 8);
+ 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);
}
- const back = u.moved(1328, 724);
- _ = back.panel(568, 312, "call stack", .{ .note = "observed frames" });
- for (frames[0..@min(frames.len, 5)], 0..) |frame, i| {
- const y = 32 + @as(f32, @floatFromInt(i)) * 52;
- if (i == 0) canim.rows.callCurrent(back, y, 568);
- back.text(.mono, 20, 12, canim.rows.baseline(y), u.print("{d}", .{i}), if (i == 0) gold.on_solid else ink.dim);
- _ = back.address(60, canim.rows.baseline(y), frame.pc, .{ .ink = ui.rgb(ui.theme.color.region.code_) });
- var buf: [256]u8 = undefined;
- const frame_name = (m.string(frame.pc, &buf) catch null) orelse "anonymous code";
- back.text(.mono, 18, 60, y + 44, canim.rows.fitted(back, ui.symbol(u, frame_name), 470), ink.dim);
+ 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);
+ }
+}
+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 {
+ var values: [16]u8 = @splat(0);
+ var known: [16]bool = @splat(false);
+ m.read(addr, &values, &known) catch {};
+ var previous: [16]u8 = @splat(0);
+ var was_known: [16]bool = @splat(false);
+ if (before) |b| b.read(addr, &previous, &was_known) catch {};
+ var runs: [2]canim.rows.Run = undefined;
+ for (&runs, 0..) |*run, i| {
+ const offset = i * 8;
+ const word = std.mem.readInt(u64, values[offset..][0..8], .little);
+ var changed: ?[2]u8 = null;
+ for (offset..offset + 8) |j| if (known[j] and was_known[j] and values[j] != previous[j]) {
+ if (changed == null) changed = .{ @intCast(j - offset), @intCast(j - offset) } else changed.?[1] = @intCast(j - offset);
+ };
+ const read: f32 = if (touch) |t| if (t.addr < addr +| offset +| 8 and t.addr +| t.len > addr +| offset) 1 else 0 else 0;
+ 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);
+ 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 {
+ 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);
+ }
+}
+fn memoryRows(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, first: f32, 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 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);
+ }
+}
+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);
+ 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.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;
+ }
+ 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);
+ }
+}
+fn ties(u: ui.Ui, s: *const State, ss: *Session, m: zt.store.Moment, travel: f32) void {
+ _ = m;
+ const hovered = addressAt(u.f.in.mouse_x, u.f.in.mouse_y);
+ 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 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 });
+ break;
+ }
+ };
+ 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;
+ 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) {
+ ss.lens_at = u.f.in.now;
+ ss.lens_previous = 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 });
+ } 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 });
+ }
+ break;
+ };
+ }
+ 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);
+ }
+ 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);
+ }
+ 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);
}
- const place = if (t.len <= 1) 1 else @as(f32, @floatFromInt(m.index)) / @as(f32, @floatFromInt(t.len - 1));
- u.fill(.{ .x = 24, .y = 1050, .w = 1872, .h = 2 }, ui.theme.color.rule);
- u.fill(.{ .x = 24, .y = 1050, .w = 1872 * place, .h = 2 }, gold.solid);
- u.fill(.{ .x = 22 + 1872 * place, .y = 1047, .w = 4, .h = 8 }, gold.solid);
- u.text(.sans, 17, 24, 1075, if (s.following) "Inspecting the live stop" else "Inspecting recorded state · target is unchanged", ink.dim);
- u.text(.sans, 17, 1400, 1075, "gold: execution vermilion: changed", ink.dim);
}
fn changedHeat(seconds: f32) ui.Heat {
@@ -308,11 +1029,7 @@ fn rowOf(m: zt.store.Moment, start: u64, address: u64) ?usize {
}
fn selected(ss: *Session, t: *zt.Trace, m: zt.store.Moment, regs: zt.Regs, tid: u32, low: u64, now: u64) void {
- const seconds = @as(f32, @floatFromInt(now -| ss.changed_at)) / 1e9;
- ss.mark_from = std.math.lerp(ss.mark_from, ss.mark_to, ui.theme.ease(.standard, std.math.clamp(seconds / ui.theme.time.step, 0, 1)));
- if (rowOf(m, ss.code_start, regs.rip)) |row| {
- ss.mark_to = @floatFromInt(row);
- } else {
+ if (rowOf(m, ss.code_start, regs.rip) == null) {
ss.code_start = regs.rip;
for (0..6) |_| {
var buf: [1024]u8 = undefined;
@@ -320,8 +1037,6 @@ fn selected(ss: *Session, t: *zt.Trace, m: zt.store.Moment, regs: zt.Regs, tid:
if (insn.back == 0) break;
ss.code_start -|= insn.back;
}
- ss.mark_to = @floatFromInt(rowOf(m, ss.code_start, regs.rip) orelse 0);
- ss.mark_from = ss.mark_to;
}
ss.shown = m.index;
ss.tid = tid;