summaryrefslogtreecommitdiff
path: root/anim/src/syscalls.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/syscalls.zig')
-rw-r--r--anim/src/syscalls.zig72
1 files changed, 53 insertions, 19 deletions
diff --git a/anim/src/syscalls.zig b/anim/src/syscalls.zig
index ca98920..b568612 100644
--- a/anim/src/syscalls.zig
+++ b/anim/src/syscalls.zig
@@ -128,7 +128,9 @@ pub fn step(c: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void {
while (call < made.enter and !(if (rec.insn_branches[call]) |b| b.kind == .call else false)) call += 1;
if (call >= made.enter) call = from;
// 1, the instructions before the call: a cascade, the plaque onto the
- // call's row 12 f after the last strike, no rest (the line stays current).
+ // call's row 12 f after the last strike, no rest (the line stays current):
+ // what it struck cools on into the crossing.
+ var cooling: f32 = 0;
if (call > from) {
var before = c.reading(from, call);
const regs_before: f32 = @floatFromInt(@popCount(rec.registersChanged(from, call) & ~cursors.quiet));
@@ -139,12 +141,14 @@ pub fn step(c: cursors.Cursor, s: *anim.Frame, by: Recording.Stop) void {
before.advance = last + 12.0 / 60.0;
before.travel = time.step;
before.total = before.advance + before.travel;
+ cooling = time.strike.cool - before.travel;
c.step(s, call, before, before.total);
}
// 2, the crossing from the call row (its chart's frame 18 first); 3, the stores after.
const p = if (call > from) Plan.of(made).shifted(-time.cascade) else Plan.of(made);
var plan = p.step();
plan.fires = call == from;
+ plan.cooling = cooling;
// The store after the call: 18 f after rax, and after the registers the call left (6 f apart).
const regs: f32 = @floatFromInt(@popCount(rec.registersChanged(call, to) & ~cursors.quiet));
const last_register = p.struck + @min(@max(regs - 1, 0), 3) * cursors.write_apart;
@@ -263,35 +267,56 @@ pub const Crossing = struct {
var first: usize = 0;
while (first < rec.syscalls.len and rec.syscalls[first].enter < c.cursor.first) first += 1;
var newest = latest(rec, now.stops[0]);
- // A crossing's own row comes in once it is back (rax struck), 12 f.
+ // A crossing's own row comes in once it is back (rax struck): the
+ // rows make room for it, a full log scrolling a row (24 f, `glide`),
+ // as it fades in (12 f), and the count above crossfades with them.
var arrives: f32 = 1;
if (newest) |n| if (inStep(now) != null and now.walking()) {
const p = Plan.in(now, rec.syscalls[n]);
- arrives = std.math.clamp((now.time - p.struck - 6.0 / 60.0) / theme.time.quick, 0, 1);
+ arrives = std.math.clamp((now.time - p.struck - 6.0 / 60.0) / theme.time.move, 0, 1);
};
if (newest) |n| if (n < first) {
newest = null;
};
const count = if (newest) |n| n + 1 - first else 0;
- const body = u.panel(box.w, box.h, "system calls", .{ .focus = c.focus, .note = if (count > room) u.print("as strace writes them \u{00b7} newest at the bottom \u{00b7} {d} more above", .{count - room}) else "as strace writes them \u{00b7} newest at the bottom" });
+ const above = [2]usize{ (count -| 1) -| room, count -| room };
+ const notes = [2][]const u8{ logNote(u, above[0]), logNote(u, above[1]) };
+ const scroll = cursors.glide(arrives);
+ const renote = above[0] != above[1] and arrives < 1;
+ const body = u.panel(box.w, box.h, "system calls", .{ .focus = c.focus, .note = if (renote) "" else notes[1] });
+ if (renote) {
+ u.faded(1 - scroll).tagNote(box.w, notes[0]);
+ u.faded(scroll).tagNote(box.w, notes[1]);
+ }
context.clipBody(u, box);
defer u.unclip();
const n = newest orelse return;
const top = body.y + theme.metric.context.pad;
const shown = @min(count, room);
- for (0..shown) |j| {
- const i = n + 1 - shown + j;
- const v = if (i == n) u.faded(arrives) else u;
- const y = top + @as(f32, @floatFromInt(j)) * row_h;
+ // A full log's oldest row shown goes up and out as the new one comes.
+ const scrolls = arrives < 1 and count > room;
+ const from = n + 1 - shown - @intFromBool(scrolls);
+ for (from..n + 1) |i| {
+ const fresh = std.math.clamp(arrives * theme.time.move / theme.time.quick - 1, 0, 1);
+ const v = if (i == n) u.faded(fresh) else u;
+ const row: f32 = @as(f32, @floatFromInt(i - from)) - if (scrolls) scroll else 0;
+ const y = top + row * row_h;
logRow(v, rec, rec.syscalls[i], y, box.w - theme.metric.context.side);
// The newest's turned corner; the one before keeps it until the new row is in.
if (i == n) v.corner(theme.metric.context.side, y + 2, theme.metric.context.corner, 1);
- if (i + 1 == n and arrives < 1) u.faded(1 - arrives).corner(theme.metric.context.side, y + 2, theme.metric.context.corner, 1);
+ if (i + 1 == n and fresh < 1) u.faded(1 - fresh).corner(theme.metric.context.side, y + 2, theme.metric.context.corner, 1);
}
}
+ fn logNote(u: ui.Ui, above: usize) []const u8 {
+ return if (above > 0) u.print("as strace writes them \u{00b7} newest at the bottom \u{00b7} {d} more above", .{above}) else "as strace writes them \u{00b7} newest at the bottom";
+ }
+
/// A call as strace writes it, its arguments by name: `read fd 3
- /// "note" buf 7fffffffecd0 count 32 = 15`, cut at `room` with `…`.
+ /// "note" buf 7fffffffecd0 count 32 = 15`, a path by its string (as the
+ /// kernel took it, where the stop did not read it). Out of room the
+ /// faint names go first, then the arguments from the right (`…`); what
+ /// it returned stays.
fn logRow(u: ui.Ui, rec: *const Recording, made: Recording.Syscall, y: f32, room: f32) void {
const base = theme.baseline(y, row_h, size);
const adv = ui.advance(size);
@@ -301,16 +326,18 @@ pub const Crossing = struct {
x += u.width(.mono_bold, size, name) + adv;
const names = zt.syscalls.names(made.nr);
const n = @min(zt.syscalls.signature(made.nr).len, 6);
- const Part = struct { text: []const u8, ink: u24 };
+ const Part = struct { text: []const u8, ink: u24, name: bool = false };
var parts: [32]Part = undefined;
var np: usize = 0;
for (0..n) |j| {
const what = if (j < names.len) names[j] else "";
if (what.len > 0) {
- parts[np] = .{ .text = what, .ink = theme.color.text.dim };
+ parts[np] = .{ .text = what, .ink = theme.color.text.dim, .name = true };
np += 1;
}
- parts[np] = .{ .text = @import("disasm.zig").argument(u, rec, made.enter, what, made.args[j]), .ink = theme.color.text.primary };
+ var said = @import("disasm.zig").argument(u, rec, made.enter, what, made.args[j]);
+ if (std.mem.eql(u8, what, "path") and said[0] != '"' and made.text.len > 0) said = u.print("\"{s}\"", .{made.text[0 .. std.mem.indexOfScalar(u8, made.text, 0) orelse made.text.len]});
+ parts[np] = .{ .text = said, .ink = theme.color.text.primary };
np += 1;
if (std.mem.endsWith(u8, what, "fd")) {
const on = rec.openOn(u.f.scratch, made.args[j], made.enter);
@@ -320,19 +347,25 @@ pub const Crossing = struct {
}
}
}
- parts[np] = .{ .text = "=", .ink = theme.color.text.faint };
- np += 1;
- parts[np] = .{ .text = if (made.exit != null) result(u, made) else "?", .ink = theme.color.text.primary };
- np += 1;
+ const answer = u.print("= {s}", .{if (made.exit != null) result(u, made) else "?"});
+ const answer_w = u.width(.mono, size, answer);
+ var total: f32 = 0;
+ for (parts[0..np]) |part| total += u.width(.mono, size, part.text) + adv;
+ // The faint names first, where all of it does not fit.
+ const named = x + total + answer_w <= room;
for (parts[0..np]) |part| {
+ if (part.name and !named) continue;
const w = u.width(.mono, size, part.text);
- if (x + w > room) {
+ if (x + w + adv + answer_w > room) {
u.text(.mono, size, x, base, "\u{2026}", theme.color.text.faint);
- return;
+ x += 2 * adv;
+ break;
}
u.text(.mono, size, x, base, part.text, part.ink);
x += w + adv;
}
+ u.text(.mono, size, x, base, "=", theme.color.text.faint);
+ u.text(.mono, size, x + 2 * adv, base, answer[2..], theme.color.text.primary);
}
/// Its view: the bytes the call crossing in this step is given or
@@ -390,6 +423,7 @@ pub const Crossing = struct {
.region = context.ink(context.regionOf(now.moment(), sp.addr)),
.given = .{ .addr = sp.addr, .bytes = text, .shows = 1, .since = if (fills(given) != null) tm - p.fills else null },
.read = if (bufferRead(given) != null) now.held(p.work) else 0,
+ .pins = true,
});
v.veil(now);
}