summaryrefslogtreecommitdiff
path: root/src/trace
Commit message (Collapse)AuthorAge
* kernel: smaller BPF records, syscall tracepoints sorted out in place, the READMEGabriel Schneider7 days
| | | | | | | | | | | Syscall entries and kprobes send the event alone (a kernel function's registers are not the thread's; a syscall's are its arguments), a probe's event is not inherited (it failed the target's clone). The per-syscall tracepoints are told entry from exit on the events themselves, not on a second set. The VM has two CPUs and a time limit. README: the kernel's view, with what each mode costs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* ztrace probe: BPF on syscalls, scheduling, kprobes, uprobes and USDTGabriel Schneider7 days
| | | | | | | | | | | | | | | | Programs built as instruction arrays for one process (no compiler, no libbpf), writing Events into a BPF ring buffer; a drop counter in a map; task_struct offsets from the kernel's BTF; a USDT probe's arguments read in the kernel at the probe. Without CAP_BPF and CAP_PERFMON it says so; --dry-run builds and lists everything. Tested offline by running the programs in a small BPF machine, and for real by test-kernel-vm, which boots this kernel in QEMU where we are root. ztrace perf: moments are no longer cut per event unless --cut; --max-size, and a full recording stops the target and says so. perf.Sorted merges two backends' events by time. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* ztrace perf: the kernel's view of a program, unprivilegedGabriel Schneider7 days
| | | | | | | | | | | | | perf_event_open on a held child: counters, a sampling profile, every page fault with its registers, maps, threads, context switches, every syscall (the per-syscall tracepoints, the only ones open to a user), and the debug registers as watchpoints and breakpoints that do not stop the target. One time-ordered stream of Events into a Sink; --threads follows with a ring per CPU. usdt.zig: the notes of <sys/sdt.h> and their arguments from a Regs and a memory reader, independent of BPF. test-kernel runs all of it on targets/kernel_*. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* the backends together: a ring under the debugger, strings that do not collideGabriel Schneider7 days
| | | | | | | | | | | | ztrace record and dbg take --ring, --preload and --alloc: the target gets the ring ztrace run gives it, and the debugger drains it while the target runs (polling for the stop, so a full ring cannot hold both) and before it reports a stop. A program compiled by ztrace cc, with the agent preloaded, stopped at breakpoints, is one recording in order; test-together checks it. Recording such a program showed the debugger's file names and the pass's strings both counted from 1: event.stringId (a hash, top bit set) is now what every producer without a table of its own uses.
* ring: a producer waiting for room is woken at half empty, not at every recordGabriel Schneider7 days
| | | | | | | | 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]>
* client: a thread's id asked once, the environment read by nameGabriel Schneider7 days
| | | | | | | | 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]>
* ring: each side reads the other's counter only when its own view is used upGabriel Schneider7 days
| | | | | | 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.
* event: what instrumentation puts in call, ret, line, variable, mem_writeGabriel Schneider7 days
| | | | | | | | | 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]>
* host: a stop mask set before the target startsGabriel Schneider7 days
| | | | | | | | 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]>
* targets, test-debugger, bench-debuggerGabriel Schneider7 days
| | | | | | | | | | | 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]>
* debugger: steps by instruction and line, breakpoints, hooks, watches, ↵Gabriel Schneider7 days
| | | | | | | | | | | | | | | | | | | 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]>
* recorder: a moment is its events, state is at keyframesGabriel Schneider7 days
| | | | | | | | | | | | | | | | | | 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.
* ring: a record larger than the ring is dropped and counted, not asserted onGabriel Schneider7 days
|
* recorder: moments in batches, and the heap, the stack, variables, lines and ↵Gabriel Schneider7 days
| | | | | | | | | | | | | | | 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.
* ztrace: the event, the ring, the recording, a ptrace loopGabriel Schneider7 days
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.