summaryrefslogtreecommitdiff
path: root/anim/src/context.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/context.zig')
-rw-r--r--anim/src/context.zig69
1 files changed, 49 insertions, 20 deletions
diff --git a/anim/src/context.zig b/anim/src/context.zig
index 37a95a6..9829fa7 100644
--- a/anim/src/context.zig
+++ b/anim/src/context.zig
@@ -46,6 +46,8 @@ pub const legend = blk: {
/// window on the map and its place; its tags, rules and lanes how much shown.
pub const Zoom = struct { box: Rect, to: Rect, chrome: f32 };
pub var zoomed: [8]?Zoom = @splat(null);
+/// How much the thread shows: it fades in (12 f) once a dive has landed, never in a frame.
+pub var thread_shows: f32 = 1;
/// A panel's `Ui`, moved to where the stage has its box now (or, in a
/// dive, scaled into the rect it is on its way through).
@@ -161,6 +163,7 @@ pub const Registers = struct {
var marks: rows.Marks = .{};
var landed = now.landed(.cpu, 0);
var note: []const u8 = "";
+ var note_shows: f32 = 1;
const crossing: ?Recording.Syscall = if (r.syscalls) syscalls.inStep(now) else null;
// A register is framed as carrying the call only while it holds the
// argument in the moment shown: the stop before the call, until the
@@ -176,6 +179,8 @@ pub const Registers = struct {
// A descriptor says what it is open on: the `value` class `fd`.
const names = zt.syscalls.names(made.nr);
if (k <= names.len and std.mem.endsWith(u8, names[k - 1], "fd")) note = rec.openOn(u.f.scratch, value_was, made.enter);
+ // In with its framing, over 12 f, and out with it: never in a frame.
+ note_shows = @min(std.math.clamp(framed / time.quick, 0, 1), now.reading(.cpu, 0));
};
if (if (std.mem.eql(u8, name, "rax")) crossing else null) |made| {
// rax: what was there, then the result, once the kernel's rows
@@ -210,8 +215,15 @@ pub const Registers = struct {
// At a run a value changes in place under an 8 f crossfade, unmarked, never in a frame.
const ran = runFade(now, .cpu);
if (ran < 1 and value_was != value_now) _ = rows.reg(u.faded(1 - ran), y, w, name, was.moment, value_was, marks);
- const hops = rows.reg(if (ran < 1 and value_was != value_now) u.faded(ran) else u, y, w, name, if (landed or ran < 1) is.moment else was.moment, if (landed or ran < 1) value_now else value_was, marks);
- fdNote(u, hops, y, note);
+ // Its chain reads memory as the panels show it: what the step writes
+ // there is followed again (`extend`) once the bytes have landed, never before.
+ var memory = if (landed or ran < 1) is.moment else was.moment;
+ if (ran >= 1 and landed and !r.quiet) {
+ memory, const again, marks.hops = now.following(value_now);
+ if (again) |ago| marks.extend = @min(marks.extend orelse ago, ago);
+ }
+ const hops = rows.reg(if (ran < 1 and value_was != value_now) u.faded(ran) else u, y, w, name, memory, if (landed or ran < 1) value_now else value_was, marks);
+ fdNote(u.faded(note_shows), hops, y, note);
anchor(u, i, hops, y);
}
@@ -349,12 +361,16 @@ pub const Stack = struct {
// stop deeper or shallower than a call is) does not scroll: the old
// rows fade out before memory strikes and the new ones in after,
// each with the memory of its own stop.
- const landed = now.landed(.memory, 0);
const jumped = far(window[0], window[1], slots);
+ // Out over 12 f to memory's landing and in over 12 f (at a run, half
+ // its step each, the turn no sooner than that): never in a frame.
+ const fade = @min(time.quick, now.plan.total / 2.0);
+ const turn = @max(now.plan.at[1] + time.strike.in / 2.0, fade);
+ const landed = if (jumped and !now.resting()) now.time >= turn else now.landed(.memory, 0);
// On the minimap the window glides there, whether it scrolls or fades here.
const ways = window;
const since_memory = now.since(.memory, 0);
- const jump_shows: f32 = if (!jumped or now.resting()) 1 else if (!landed) 1 - std.math.clamp((since_memory + time.quick) / time.quick, 0, 1) else std.math.clamp((since_memory - time.strike.in / 2.0) / time.quick, 0, 1);
+ const jump_shows: f32 = if (!jumped or now.resting()) 1 else if (!landed) 1 - std.math.clamp((now.time - turn + fade) / fade, 0, 1) else std.math.clamp((now.time - turn) / fade, 0, 1);
if (jumped) window = if (landed) .{ window[0], window[0] } else .{ window[1], window[1] };
const v = u.faded(jump_shows);
// Going to the hold and coming from it, the rows scroll: the
@@ -476,16 +492,19 @@ pub const Stack = struct {
const rsp_shown = if (landed) is.rsp else was.rsp;
// What each word is, where the recording says (`zt.telescope.slots`):
// a register saved for the caller, a local, the process's first stack.
- const roles_from = window[0] -% 16;
+ // Of the rows of both windows: those sliding out keep theirs as they go.
+ const roles_from = @min(window[0], window[1]) -% 16;
+ const roles_n = slots + 4 + @abs(@as(i64, @bitCast(window[0] -% window[1]))) / 8;
// Before the step and after it: a role that changes crossfades as memory strikes (12 f).
var roles_buf: [2][80]zt.telescope.Slot = undefined;
const roles = [2][]zt.telescope.Slot{
- zt.telescope.slots(now.before(), &was, roles_from, roles_buf[0][0..@min(slots + 4, roles_buf[0].len)]) catch roles_buf[0][0..0],
- zt.telescope.slots(now.moment(), &is, roles_from, roles_buf[1][0..@min(slots + 4, roles_buf[1].len)]) catch roles_buf[1][0..0],
+ zt.telescope.slots(now.before(), &was, roles_from, roles_buf[0][0..@min(roles_n, roles_buf[0].len)]) catch roles_buf[0][0..0],
+ zt.telescope.slots(now.moment(), &is, roles_from, roles_buf[1][0..@min(roles_n, roles_buf[1].len)]) catch roles_buf[1][0..0],
};
// The words that point at other words of the window: `arc`s.
var at_rows: std.ArrayList(hexdump.RowAt) = .empty;
- var pointers: std.ArrayList(struct { hexdump.RowAt, bool }) = .empty;
+ // Each with whether it is a saved rbp before the step and after it.
+ var pointers: std.ArrayList(struct { hexdump.RowAt, [2]bool }) = .empty;
var n: i64 = @as(i64, @intFromFloat(@floor(-slide))) - 1;
while (n <= @as(i64, @intCast(slots)) - @as(i64, @intFromFloat(@floor(slide)))) : (n += 1) {
const y = top + (@as(f32, @floatFromInt(n)) + slide) * m.row;
@@ -501,10 +520,13 @@ pub const Stack = struct {
const below_rsp: i64 = @bitCast(addr -% if (held) rsp_shown else is.rsp);
map.row(.stack, addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row });
// `free`: above rsp, not yet reached: its address at 60%, its word faint.
- if (held and addr < rsp_shown) {
- rows.free(v, y, memory, addr, below_rsp, lead);
- continue;
- }
+ // A free word rsp reaches (a push, `sub rsp`) becomes a slot as memory strikes (12 f), never in a frame.
+ const free_was = held and addr < was.rsp;
+ const free_is = held and addr < is.rsp;
+ const slot_shows: f32 = if (free_was == free_is or now.resting()) @as(f32, if (free_is) 0 else 1) else if (free_is) 1 - recast else recast;
+ if (slot_shows < 1) rows.free(v.faded(1 - slot_shows), y, memory, addr, below_rsp, lead);
+ if (slot_shows <= 0) continue;
+ const vs = v.faded(slot_shows);
// A frame's name beside this row: the chain ends a character before it.
var room_w = box.w;
for (spans[0..n_spans]) |sp| {
@@ -518,7 +540,7 @@ pub const Stack = struct {
gap = share * (u.width(.mono, size, name) + ui.advance(size));
}
const gapped = gap > 0 and names.names.len > 0 and names.shows > 0;
- if (gapped) pinGap(v.faded(names.shows), y, names.names, lone.?, gap);
+ if (gapped) pinGap(vs.faded(names.shows), y, names.names, lone.?, gap);
const k_role = (addr -% roles_from) / 8;
var role_at: [2]@TypeOf(roleName(u, .none, 0)) = undefined;
for (&role_at, roles, [2]Recording.Moment{ now.before(), now.moment() }) |*r, of, mem| {
@@ -533,10 +555,12 @@ pub const Stack = struct {
const word_was = Recording.word(now.before(), addr, 8) catch null;
const word_is = Recording.word(now.moment(), addr, 8) catch null;
const fades = ran < 1 and !std.meta.eql(word_was, word_is);
- if (fades) _ = rows.slot(v.faded(1 - ran), y, room_w, now.before(), addr, below_rsp, &.{}, 0, marks, role.name, role.local, role_was);
- const hops = rows.slot(if (fades) v.faded(ran) else v, y, room_w, if (fades) now.moment() else now.shownAt(addr), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local, role_was);
- at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {};
- pointers.append(u.f.scratch, .{ .{ .addr = addr, .y = y }, what == .saved and std.mem.eql(u8, what.saved, "rbp") }) catch {};
+ if (fades) _ = rows.slot(vs.faded(1 - ran), y, room_w, now.before(), addr, below_rsp, &.{}, 0, marks, role.name, role.local, role_was);
+ const hops = rows.slot(if (fades) vs.faded(ran) else vs, y, room_w, if (fades) now.moment() else now.shownAt(addr, 8), addr, below_rsp, if (gapped) &.{} else names.names, names.shows, marks, role.name, role.local, role_was);
+ // An arc's ends are rows on show (the row above the window, there for a slide, is not).
+ if (y + m.row > top + 1 and y < box.h - m.pad - 1) at_rows.append(u.f.scratch, .{ .addr = addr, .y = y }) catch {};
+ const what_was: zt.telescope.Role = if (k_role < roles[0].len) roles[0][k_role].role else .none;
+ if (y + m.row > top + 1 and y < box.h - m.pad - 1) pointers.append(u.f.scratch, .{ .{ .addr = addr, .y = y }, .{ what_was == .saved and std.mem.eql(u8, what_was.saved, "rbp"), what == .saved and std.mem.eql(u8, what.saved, "rbp") } }) catch {};
// Only a row on show is a place a tie can land.
if (y >= top - 1 and y + m.row <= box.h - m.pad + 1) {
ties.anchor(u, .{ .word = addr }, .{ .x = theme.metric.slot.address, .y = y, .w = if (hops.n > 0) hops.x[0] + hops.w[0] - theme.metric.slot.address else 120, .h = m.row });
@@ -547,12 +571,17 @@ pub const Stack = struct {
// A frame's saved rbp is drawn by its span: its arc only in a step that touches it.
var arcs: rows.Arcs = .{};
for (pointers.items) |p_| {
- const word, const saved = p_;
- if (saved and !(now.writeAge(word.addr, 8) == 0 or now.wasRead(word.addr, 8))) continue;
+ const word, const saved_was = p_;
+ const saved = saved_was[1];
+ const touched = now.writeAge(word.addr, 8) == 0 or now.wasRead(word.addr, 8);
+ if (saved and saved_was[0] and !touched) continue;
const before = arcs.n;
hexdump.pointerArcs(&arcs, now, word.addr, word.y, at_rows.items, 8, .{ top - m.pad, box.h - m.pad }, false, false);
+ if (arcs.n == before) continue;
// Its step's alone: it goes with the advance (18 f), not in the next step's first frame.
- if (saved and arcs.n > before) arcs.items[before].shows *= 1 - std.math.clamp((now.time - now.plan.advance) / time.read.out, 0, 1);
+ if (saved and touched) arcs.items[before].shows *= 1 - std.math.clamp((now.time - now.plan.advance) / time.read.out, 0, 1);
+ // A word becoming a saved rbp, or no longer one, with the step: its arc goes or comes as its role does (12 f).
+ if (!touched and saved != saved_was[0]) arcs.items[before].shows *= if (saved) 1 - recast else recast;
}
arcs.draw(v, theme.metric.arc.stack_lanes);
// Where the window is, for a link to a word outside it.