kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

Debugger, Debug Info, and Profiling (planned work)

This roadmap consolidates the remaining work across the interactive JIT debugger (kit dbg), the DWARF producer/consumer, and the not-yet-built sampling profiler (kit prof). Designs live one level up: ../DBG.md covers the KitJitSession architecture, the KitDbgOs host vtable, software breakpoints, and displaced single-step; ../DWARF.md covers the producer pipeline and the kit_dwarf_* consumer surface. This document is forward-looking: it states the baseline only as a starting point, then enumerates the open gaps, their rationale, and the next steps. Shipped items are noted as "done (baseline)".

Baseline

What already works and is not re-planned here:

The sections below are the work that remains.

1. Bring x64 / rv64 debug sessions to full parity

The non-aarch64 lifters exist (per baseline) but test/dbg/run.sh self-skips on any host that is not aarch64. The remaining work is proving the non-aa64 sessions are real, not writing new lifters.

2. Displaced single-step: remaining instruction coverage

The lifters cover the common PC-relative families per arch. One known decline remains, plus general hardening:

3. Direct dbg unit + smoke tests

Much verification has gone through transcript tests; the low-level primitives still lack focused unit coverage. Following red-green TDD (see ../TESTING.md):

4. REPL polish and machine-readable mode

Shared REPL work that improves usability and unblocks tooling/IDE frontends:

5. Toy and C REPL frontends

The Toy frontend drives the debugger as the first REPL language; C support is the larger follow-on. Design detail lives in ../FRONTENDS.md.

Toy result formatting and structured values:

C as a REPL language (after the Toy experience is solid):

6. DWARF producer/consumer gaps

Producer and consumer are colocated under src/debug/ but share only the wire format (dwarf_defs.h); that boundary must hold for any new work. The remaining gaps:

Explicitly deferred until a client needs them (carried forward, not planned):

7. Sampling profiler — kit prof (not yet built)

A statistical CPU profiler that reuses the debugger's host signal infrastructure. Nothing exists yet: no prof subcommand in driver/main.c, no src/dbg/prof.c, no on_sample field on KitDbgSignalOps. Design intent: SIGPROF fires on the worker, the handler walks the frame-pointer chain into a pre-allocated ring buffer and returns without parking — the one property that keeps sampling cheap and guest timing undisturbed — and PCs are symbolicated after the guest exits.

Public API (include/kit.h):

Library (src/dbg/prof.c, freestanding C11):

Host adapter (driver/env/posix_dbg.c and windows.c):

Driver (driver/cmd/prof.c, wired into the multi-call dispatch in driver/main.c):

Tests: test/smoke/prof_hello (assert prof.folded is non-empty and main appears), test/dbg/fp_walk_* (canned frame chains per arch, assert the PC sequence and termination), and test/dbg/prof_buf_overflow (fill to capacity, assert dropped increments and count caps).

Profiler follow-ons (deferred): per-thread timers via timer_create(CLOCK_THREAD_CPUTIME_ID) + SIGEV_THREAD_ID for multi-thread guests; an ITIMER_REAL wall-clock mode for I/O-bound programs; allocation profiling via a conditional breakpoint on the allocator; SpeedScope / pprof output.

8. Bigger follow-ons (cross-cutting)