diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 16:03:43 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 16:05:20 -0300 |
| commit | 66a2a7cf733f6abc1f79561c52d901ce67019fb1 (patch) | |
| tree | b261d533887b37fb5287ad384d4f845348b35d81 /src/trace/together_test.zig | |
| parent | e0c4bfcc0395a561804e33942028c519f4e267f7 (diff) | |
| download | computeranim-66a2a7cf733f6abc1f79561c52d901ce67019fb1.tar.gz computeranim-66a2a7cf733f6abc1f79561c52d901ce67019fb1.zip | |
trace: what the context draws is in the recording; SQLite on the ladder
An instruction's string carries its source line and, for a direct call,
how many parameters the callee takes (DWARF); telescope.frames gives each
frame's extent on the stack; with --alloc the debugger watches each live
allocation and the allocator's header before it, changes only, 256 KiB a
stop at most. C++ names are shown and found as the source has them (the
command links the C++ runtime for its demangler).
SQLite 3.50.4 through every backend, measured (README, bench/sqlite.sh).
It found two faults: a file compiled by its full path was recorded under
a path joined onto the compile directory, and ztrace run noticed a
target's exit up to 10 ms late.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'src/trace/together_test.zig')
| -rw-r--r-- | src/trace/together_test.zig | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/trace/together_test.zig b/src/trace/together_test.zig new file mode 100644 index 0000000..09abb7b --- /dev/null +++ b/src/trace/together_test.zig @@ -0,0 +1,36 @@ +//! The recording `test-together` makes (a list built by `ztrace cc`, its +//! allocations told by the agent, stopped at breakpoints by the debugger), +//! read back: found through the `recording` options. +const std = @import("std"); +const zt = @import("ztrace"); +const recording = @import("recording"); + +test "at every stop each live allocation is there to read, with glibc's header before it" { + const gpa = std.testing.allocator; + var trace = try zt.Trace.open(gpa, std.testing.io, recording.together); + defer trace.close(); + var checked: usize = 0; + for (0..trace.len) |i| { + const m = try trace.moment(i); + var events = try m.events(gpa); + defer events.deinit(gpa); + const stop = while (events.next()) |item| { + if (item.ev.kind == .breakpoint) break true; + } else false; + if (!stop) continue; + const heap = try m.heap(gpa); + defer gpa.free(heap); + for (heap) |a| { + var bytes: [16 + 16]u8 = undefined; + var known: [16 + 16]bool = undefined; + try std.testing.expectEqual(@as(u64, 16), a.size); + try m.read(a.ptr - 16, &bytes, &known); + try std.testing.expect(std.mem.allEqual(bool, &known, true)); + // A chunk of 32 bytes: the 16 asked for, 8 of header, rounded to 16. + try std.testing.expectEqual(@as(u64, 32), std.mem.readInt(u64, bytes[8..16], .little) & ~@as(u64, 7)); + checked += 1; + } + } + // Five nodes, at the stops after each was made. + try std.testing.expect(checked >= 5); +} |
