| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
|
|
| |
zig build bench-agent runs each capability against its native loop and
prints what it costs and writes; README has the table. ztrace run looks
at the ring a little longer before sleeping (a target that finds the
tracer asleep pays a futex wake an event). A hooked function's name is
defined as the string of its address, so the recorder's call stack reads
fib. A static link without libc's malloc says which -u to add. The
archive carries no stack probes, so cc links it in debug builds too.
Tests for --wrap (musl, zig cc) and for a recording that fills.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
| |
A full ring made consumer and producer trade a futex wake for every
record: 2.8 M events/s through ztrace run where the recorder alone does
12 M. One comparison in advance.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
what a recording may hold
Syscall User Dispatch now runs its handler on an alternate stack a thread
(a thread's own stack may not hold a signal frame; node makes such
threads), and makes clone, clone3 and vfork itself: the child leaves
through the gate with the target's registers instead of being stepped
into with the trap flag. Paths and written buffers are cut at 256 bytes
(--capture), a watch or snapshot above 1 MiB is refused, and ztrace run
ends a recording that is full (--max-size) with the target killed and the
file closed.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
libztrace-agent.so (preloaded) and libztrace-agent.a (linked in), one
source: map and thread_start at startup; alloc/free from the interposed
allocator; syscall_enter/exit through Syscall User Dispatch; call/ret
from int3 hooks; mem_write from watched regions diffed in-process; the
target-side API (include/ztrace.h, and the ztrace-agent module for Zig).
ztrace run turns each on (--alloc --syscalls --hook --watch), chooses the
moments (--cut), and stops the target at event kinds without ptrace
(--stop-at, --read, -i). test-agent records real targets and checks the
recordings.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
| |
The gettid per event is gone (a thread-local cache; a forked child resets
it), and environ/getenv are public: the agent reads its ZTRACE_* options
the way the ring's fd was read.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
| |
The consumer cached nothing and re-read head for every record, the
producers tail: the two cache lines bounced on each event. From the LLVM
runtime's profile: an event through the ring 65 ns to 29 ns.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
llvm/pass.cpp is an LLVM pass plugin: lines, stores, loads, calls and
variables, each call into the runtime carrying names and type descriptions,
selected by globs (-ztrace-only, -ztrace-mem), before the optimizer by
default. src/instr/rt.zig is the runtime (libztrace-rt.a), which also
answers clang's own coverage and -finstrument-functions hooks;
src/instr/types.zig the grammar of the type descriptions and its parser.
ztrace cc adds all of it to a compiler command.
test-llvm compiles fib, two sorts, a linked list and a BFS through ztrace
cc and asserts on their recordings; bench-llvm measures what each selection
costs.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
|
| |
Comments only: call's callee is a name's string id when the backend has
names, a3 its type; ret's aux is the size of the value; a variable's aux
its parameter number; a pc may be 0; a mem_write may hold the first bytes
of a large write.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
| |
Session.spawn stores Options.stop_mask in the ring before it forks, so a
tracer that steps a target by its events is not racing the target's first
one.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
| |
A linked list, a graph search in Zig, the same C under glibc and musl, two
threads. The tests drive the debugger over them: breakpoint counts, the
lines a step walks (as gdb), a list snapshotted by a hook, a watch's
words, the syscalls that tell glibc from musl, threads, attach, and
scripted dbg and record sessions. The bench measures steps, stops and
memory access from bare ptrace up to a recording.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
threads; ztrace dbg
ptrace.zig follows the threads a target makes, attaches, tells a step from
a breakpoint, and writes memory in one call (through /proc/pid/mem where
the page is read-only). Debugger.zig is the layer above: cont, stepi, step
(a source line, through std.debug's DWARF), breakpoints with hooks, syscall
stops and hooks with the path or buffer captured, watched regions sent as
the words that changed, and every stop an event. Symbols.zig is modules,
ELF symbols and line tables; syscalls.zig their names and shapes.
ztrace dbg is a small REPL on it that records as it goes and looks back
into the recording; ztrace record stops by instruction, line, syscall or
breakpoint, prints syscalls as strace does, and ends cleanly when the
recording is full.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Folding every event into persistent state at every moment cost 750 bytes a
step and 2 KB a scattered 8-byte write: the tree's path copied each time.
Now a moment stores its events alone, in a compact code (a flags byte,
varints, time as a difference, registers as the ones that changed), and the
state (threads, memory, heap, variables, mappings, strings) is written at a
keyframe a batch, sharing with the one before. A reader replays at most a
batch over a keyframe, and keeps four positions replayed, so playing
forward reads one moment a step.
Of a memory write the recorder keeps the spans that differ from what it
holds, so a region read again costs what changed in it. It stops at
max_bytes (1 GiB).
A step with registers: 749 bytes to 57. fib(12) by instruction, 142 000
moments: 111 MB to 8 MB, 197 000 moments/s. bench-store measures the rest.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
mappings in each
A transaction a moment cost 10 µs and 1 KB before the moment's own data:
the list's path copied each time. Moments now gather 256 to a transaction,
each frozen by its own cursor so the list grows in place, and a thread's
fields sit in the moment's map instead of two maps down: a small moment is
284 bytes and 1 µs, an instruction step with registers 780 bytes.
A moment also folds alloc/free into the live heap, call/ret into each
thread's stack, variable into the live variables (a local leaves with its
call), line, and map/unmap, so a viewer reads any of them at any moment
without replaying.
|
|
|
One 64-byte Event for every backend; a shared-memory ring from target to
tracer with stop/resume; a Recorder that folds events into xitdb moments
(registers, memory in 64-byte chunks with known-byte masks, strings) and a
Trace that reads any moment back; a minimal ptrace Process; ztrace record,
run and dump. Per-area build files so the areas grow apart.
|