diff options
Diffstat (limited to 'anim/src/descent.zig')
| -rw-r--r-- | anim/src/descent.zig | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/anim/src/descent.zig b/anim/src/descent.zig index 5dd156c..ff478df 100644 --- a/anim/src/descent.zig +++ b/anim/src/descent.zig @@ -59,15 +59,32 @@ pub fn step(cur: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void { const b = rec.insn_branches[from] orelse return cur.walk(s, by, to); var name_buf: [256]u8 = undefined; const here = (rec.moment(from).string(rec.register(from, "rip"), &name_buf) catch null) orelse ""; + // `tied`: the push or the read first, as any call's or return's (the touch, the word, rsp's pin, the + // window following: the stack's own timetable), then the windows, 42 f (a call) or 48 f (a return) later. + const tied = cur.levels.annotation == .tied; const plan: cursors.Plan = switch (b.kind) { - .call => .{ .at = .{ f(24), f(60), f(60) }, .advance = f(138), .travel = f(12), .total = f(174) }, - .ret => .{ .at = .{ f(36), f(18), f(36) }, .advance = f(114), .travel = f(12), .total = f(150) }, + .call => if (tied) stacked(cur, from, to, f(180), f(216)) else .{ .at = .{ f(24), f(60), f(60) }, .advance = f(138), .travel = f(12), .total = f(174) }, + .ret => if (tied) stacked(cur, from, to, f(162), f(198)) else .{ .at = .{ f(36), f(18), f(36) }, .advance = f(114), .travel = f(12), .total = f(150) }, .jump => if (std.mem.indexOf(u8, here, "@plt") != null) .{ .at = .{ f(18), f(24), f(24) }, .advance = f(96), .travel = f(12), .total = f(132) } else return cur.walk(s, by, to), .none => return cur.walk(s, by, to), }; cur.step(s, to, plan, plan.total); } +/// The key of the head row over function `name`'s window (a `ties.Place.row`). +pub fn headKey(name: []const u8) u64 { + return std.hash.Wyhash.hash(0, name) | 1 << 63; +} + +/// The stack's own timetable for the step (`Cursor.planned`), its advance and its end the descent's. +fn stacked(cur: cursors.Cursor, from: u64, to: u64, advance: f32, total: f32) cursors.Plan { + var plan = cur.planned(from, to, false); + plan.advance = advance; + plan.travel = f(12); + plan.total = total; + return plan; +} + /// A row of the panel. const Item = struct { key: u64, @@ -110,9 +127,15 @@ pub const Descent = struct { const after = layout(u, rec, now.stops[0], room, d.root); // On the map its box is as long as the rows it has wanted: not 69 for a function of 30. if (ui.mapping) map.measure(.disasm, @max(before.items.len, after.items.len)); - const tm = now.time; const going = now.advancing(); const kind: enum { same, down, through, up } = if (now.resting() or now.stops[0] == now.stops[1]) .same else if (after.windows > before.windows) (if (before.in_stub) .through else .down) else if (after.windows < before.windows) .up else .same; + // `tied` (a plan with the stack's own moves, `stacked`): the windows move once the stack has, 42 f later down, 48 f up. + const shift: f32 = if (now.plan.follow < 0) 0 else switch (kind) { + .down => f(42), + .up => f(48), + .same, .through => 0, + }; + const tm = now.time - shift; const shown = if (going >= 0.5) after else before; // A tag that changes with the advance crossfades over it. const retag = !std.mem.eql(u8, before.tag, after.tag); @@ -268,6 +291,7 @@ pub const Descent = struct { last_window = p.item.window; switch (p.item.what) { .head => |h| { + ties.anchor(u, .{ .row = p.item.key }, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); v.fill(.{ .x = theme.stroke.rule, .y = y, .w = box.w - 2 * theme.stroke.rule, .h = theme.stroke.rule }, theme.color.rule); v.text(.sans_medium, theme.size.sans.micro, c.address, y + 18, h.name, t.primary); v.text(.sans, theme.size.sans.micro, map.content(box.w) - m.side - v.width(.sans, theme.size.sans.micro, h.note), y + 18, h.note, t.faint); @@ -319,6 +343,7 @@ pub const Descent = struct { covered = if (p.twin) @max(covered, hangs) else @max(covered -| 1, hangs); last_line = line; map.row(.disasm, row.addr, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); + if (!p.twin) ties.anchor(u, .{ .row = row.addr }, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); }, } } @@ -348,7 +373,9 @@ pub const Descent = struct { // Its strip is the deepest window's function's column, that window framed on it. map.window(.disasm, deepest(after), deepest(before), cursors.glide(going)); if (pc_y[1] orelse pc_y[0]) |y| ties.anchor(u, .pc, .{ .x = 0, .y = y, .w = theme.metric.plaque.pc, .h = m.row }); - kernel(u, now, box, under orelse top + @as(f32, @floatFromInt(room -| 3)) * m.row, pc_y[0] orelse pc_y[1]); + const floor = under orelse top + @as(f32, @floatFromInt(room -| 3)) * m.row; + if (shown.kernel) ties.anchor(u, .floor, .{ .x = 0, .y = floor, .w = box.w, .h = m.row }); + kernel(u, now, box, floor, pc_y[0] orelse pc_y[1]); context.veiled(u, box, now.veil); // Going down or up, the strip is another function's column: it fades through as the mark lands (24 f). map.strip(.disasm, if (kind == .same) u else u.faded(map.through(now, now.plan.travel + f(12))), box); @@ -513,7 +540,7 @@ fn layout(u: ui.Ui, rec: *const Recording, i: u64, room: usize, root: []const u8 row += 1; } if (li > 0) { - items.append(a, .{ .key = std.hash.Wyhash.hash(0, l.name) | 1 << 63, .row = row, .window = window, .what = .{ .head = .{ .name = l.name, .note = headNote(u, rec, i, l) } } }) catch {}; + items.append(a, .{ .key = headKey(l.name), .row = row, .window = window, .what = .{ .head = .{ .name = l.name, .note = headNote(u, rec, i, l) } } }) catch {}; row += 1; } const nearest = li + 2 == kept.len and l.kind == .caller; |
