summaryrefslogtreecommitdiff
path: root/src/trace/Debugger.zig
Commit message (Collapse)AuthorAge
* symbols: a library's separate debug info, when it is of the same buildGabriel Schneider6 days
| | | | | | | | | | | | | | | The system glibc stays dynamically linked and is symbolized from the debug file in the debuginfod client's cache or under /usr/lib/debug, used only when its own build id equals the mapped library's; nothing is downloaded. Static functions get names (the loader's resolver is _dl_runtime_resolve_xsavec; main_arena is found by symbol), libc's frames their file and line as the build saw them, and locals, blocks and parameter counts follow. A recording says of each module its build id and where its names came from; ztrace show prints it. Read only when an address in the module needs a name: 44 ms and 25 MB at the first one. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
* trace: a function's basic blocks; ASan's shadow memoryGabriel Schneider6 days
| | | | | | | | | | | | | | | | | For a graph of a function's blocks: at the first stop inside it a function's blocks are recorded once (bounds, how each ends, where its edges go), with every instruction's text up to 2048 of them; telescope.blocks reads them, and a branch event ties a run to the edge it took. Stripped libraries get blocks from their unwind bounds. For a plain build seen against an ASan one: record --asan keeps the shadow of every region it records, the offset found from the process; telescope.shadow gives an address's shadow byte. The report functions are named and the chain holds from inside the report to main. Tested on an overflowing target built plain, with gcc's ASan and with clang's. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
* canim: nothing changes in one frame; the map's space is used; the heap scene ↵Gabriel Schneider6 days
| | | | | | | | | | | | | | | | | | | | at its storyboard's length The motion check counts a third of the one-frame changes it did: the minimap's changes fade, and a register's value, a flag, a role, a pin's names, a tag's note, a backtrace row, a call tree's node and a dump row crossfade where they changed at once. What still fires is named in the README; an encoder's keyframe and the gallery's cuts are exempt by name. No caption stands over twelve seconds or under its reading time. The heap scene is 78 s: what the storyboard does not narrate runs, and each free's line cascades onto its call row (line stepping stops at a breakpoint for that). On the map, leftover space holds the stack continued, dumps round what the registers and the stack point at, open loupes and the key: between 1% and 13% of a map is page, where it was 14% to 42%. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
* trace: names for PLT stubs and GOT slots; a call followed down; the vDSO is ↵Gabriel Schneider6 days
| | | | | | | | | | | | | | | | | | | | run through For a disassembly that follows a call into libc. A stub is open@plt and a slot open@got, from the relocations (libc's own, IFUNC and nameless, by the function they resolve to); telescope.got says what a slot holds and whether it is still lazy. A library function's entry is named even when its mapping was not known yet, by the alias the program imports. The chain holds through the stub's jump, the callee's first instruction, the syscall and the loader's resolver: ld.so's unwind section lacks the entry that ends it, which lost every frame there. A syscall is tied to its instruction's moment, and each frame's call is recorded with the row before it. Stepped by instruction, a call into the vDSO is one moment and its return the next: its clock loop, single-stepped, made three million moments of three reads. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
* trace: glibc's heap, read from a recording at any momentGabriel Schneider6 days
| | | | | | | | | | | | | | | | | record --heap keeps the arena, the tcache and, of every chunk, its size word and the links of those on a list: free chunks stay readable, which --alloc dropped at the free. zt.heap.glibc gives the chunks in address order, the tcache's and the bins' chains (safe-linking as the stored value and the pointer it protects), the top; each with the address of the word it was read from, each chain saying how it ended. ztrace show prints it. Layouts for glibc 2.44 (no fastbins; a tcache made at the first free, counting the slots left) and 2.40; the arena found by symbol or by the struct whose next points at itself. Against pwndbg on 2.40: the same at every stop. Three bytes a moment and a sixth slower on the list by instruction. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
* trace: the call chain by the unwind tables; what each word of the stack isGabriel Schneider6 days
| | | | | | | | | | | | | | | | | | | backtrace and frames follow .debug_frame or .eh_frame where there is one (PLT entries expanded into exact rows) and the frame pointer where there is none: the caller is no longer lost in a prologue, in a function that keeps no frame, in a PLT entry or inside libc's syscall wrappers. Against gdb: the same chains on fib and on SQLite, where the old walk lost __sbrk and unixSync. A recording holds, once a function, its unwind rows and its locals on the stack (DW_OP_fbreg, with the block each lives in), and the process's first stack pointer. telescope.slots says of each word what it is: a saved register and which, a return address, a local by name, argc, argv, envp, auxv. Four bytes a moment on the list by instruction, and no slower. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
* debugger: the red zone, and the region round what an instruction touchesGabriel Schneider6 days
| | | | | | | | | The 128 bytes under the stack pointer are recorded with the stack; what an instruction reads or writes is recorded with --around bytes each side of it, as what a pointer leads to is: a viewer's memory panel shows the neighbourhood, not the word. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* record: how much of the context a stop keeps is asked forGabriel Schneider6 days
| | | | | | | | | --around BYTES of memory each side of what a pointer leads to, for a viewer that shows the region and not the word; --disasm ROWS above and below the pc; and every word of the --stack bytes is followed as a pointer, not the first sixteen. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* backtrace: an outer frame is on its call's lineGabriel Schneider6 days
| | | | | | | | The debugger records the call each frame returns from, as an instruction with its line; canim reads it. main is at list.c:41 while reverse() runs, not at 42, and the rows of a stop deep in SQLite have their lines. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* debugger: what a write gives the kernel is memory too; --from passes other stopsGabriel Schneider6 days
| | | | | | | | | | A write's buffer was recorded as the syscall's payload only: a reader of the moment's memory found there what an earlier stop had seen of it (zeros, in SQLite's page). And record --from with --by syscall took the loader's first syscall for the place and gave up its breakpoint. Both found by the first animation of a real program. Co-Authored-By: Claude Fable 5.2 <[email protected]>
* trace: what the context draws is in the recording; SQLite on the ladderGabriel Schneider6 days
| | | | | | | | | | | | | | | | 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]>
* debugger: a variable the target declares is watched; the runtime has no ↵Gabriel Schneider6 days
| | | | | | | | | | | debug info Events from the target's ring pass a tap on their way to the sink: a variable declared there (the pass's --instr vars, the agent's ztrace_watch) joins the regions recorded at every stop. With nothing else instrumented that is names and types from the compiler, values and everything else from the debugger. The instrumentation runtime is built stripped, so stepping by line runs through its calls.
* context: eight instructions above the pc and eight below; where a branch goesGabriel Schneider6 days
| | | | | | | | A function is decoded once from its start, so the instructions before the pc are known: each instruction's string now says the length of the one before it, and ztrace show prints eight above and eight below, as pwndbg does. A call, a jump or a return at the pc is a branch event with its target (named) and, for a conditional jump, whether the flags take it.
* context: what an instruction is about to touch, and the call chainGabriel Schneider6 days
| | | | | | | | | | | At a stop the instruction at the pc is decoded against the registers it will run with (capstone's operands): a touch event for each memory operand (address, size, read or write), what is there recorded with it, and what a write left there read back at the next stop. An instruction-level recording so has every memory write of the stepped thread, nothing watched. The frames of the call chain are recorded and their return addresses named; telescope.backtrace walks them from the recording and ztrace show prints them. Process.read no longer panics on address 0.
* context: disassembly, telescopes and names in every stop; strings as one tableGabriel Schneider6 days
| | | | | | | | | | | | | | | For a viewer to show what pwndbg's context shows, the debugger records it while the memory is there: each register and the top of the stack followed as pointers three deep (--telescope), every code address met named, eight instructions from the pc disassembled by capstone (built from source for x86, into the command only; pinned as in 03-codenomicom). zt.telescope reads a chain back with the kind of memory each link points into, and ztrace show prints the context, coloured on a terminal as pwndbg colours. The thirty thousand strings of a small run showed that a string map in each keyframe costs 700 bytes of tree a string: strings are now one table for the recording, appended a batch and read whole at open. fib(12) by instruction with everything on: 9 MB, 71 000 moments/s.
* syscalls: what writev's buffers hold is captured, by the debugger and the agentGabriel Schneider7 days
| | | | | | musl's printf and Zig programs write through writev: pardes drawing an image showed nothing of the kitty graphics commands it sends until this. The README says what Lua and pardes were run with and what they showed.
* static probes from the debugger: -b usdt:PROVIDER:NAME, no rootGabriel Schneider7 days
| | | | | | | | | Debugger.usdt arms the USDT probes of every mapped module as breakpoints whose hook records a probe event with its arguments and lets the program run on, raising a probe's semaphore first; record and dbg take usdt:PROVIDER:NAME (* for any), running the loader through when the probe is a library's. glibc's own 78 probes are there for the asking: memory_sbrk_more shows malloc growing the heap.
* 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.
* 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]>