Expand description
SnapshotBridge is the request/reply channel between the
scenario executor and the host capture pipeline. Implements
callbacks (CaptureCallback, WatchRegisterCallback), the
per-thread bridge installation guard (BridgeGuard), the
diagnostic event log (SnapshotBridgeEvent), and the
storage caps (MAX_STORED_SNAPSHOTS, MAX_STORED_EVENTS,
MAX_WATCH_SNAPSHOTS).
Modules§
- accessor_
worker_ state - State codes for the accessor-init worker, written to the
SnapshotBridge::accessor_worker_stateatomic. Two-bit encoding leaves the high bits open for future sub-states (e.g. “shutting down”).
Structs§
- Bridge
Guard - RAII guard returned by
SnapshotBridge::set_thread_local. Restores the prior thread-local bridge on drop so a nested scenario inside an outer one cannot leak its bridge into the outer scope. - Cgroup
Procs Snapshot - A single
cgroup.procssnapshot captured byOp::CaptureCgroupProcs. - Snapshot
Bridge - Host-side capture pipeline that the freeze coordinator routes
Op::CaptureSnapshotandOp::WatchSnapshotrequests through.
Enums§
- Snapshot
Bridge Event - A structured event surfaced by the
SnapshotBridgeduring its own operation (capture, storage, drain). Promotes the previoustracing::warn!-only diagnostic channel into an operator- drainable structured row so tests can assert on bridge-side conditions (eviction, missing capture, invariant violations) instead of grepping stderr.
Constants§
- MAX_
STORED_ EVENTS - Maximum number of
SnapshotBridgeEvententries the bridge retains betweenSnapshotBridge::drain_eventscalls. A scenario that triggers many cap-eviction events (a Loop step that captures a unique tag every 30ms for 10 minutes produces ~20 000 events, each ~100 bytes) would otherwise grow the events log without bound. The bridge enforces FIFO eviction at this cap — when push would exceed it, the oldest event is dropped, the dropped count is tracked onSnapshotStore::events_dropped, and the nextSnapshotBridge::drain_eventscall appends a syntheticSnapshotBridgeEvent::EventLogTruncatedentry at the tail so the operator never silently loses events. The cap is loose enough (1024 events × ~100 bytes ≈ 100 KiB) that legitimate scenarios never hit it; only runaway capture frequency does. - MAX_
STORED_ SNAPSHOTS - Maximum number of
FailureDumpReports the bridge keeps. Captures driven by a Loop step with a unique tag per iteration would otherwise grow the storage map without bound — every report renders a full BTF tree (potentially hundreds of KB), so an uncapped bridge under hostile/runaway capture frequency drains host memory. The bridge enforces FIFO eviction at this cap so the most recent captures stay reachable; eviction logs atracing::warn!naming the dropped tag so the operator sees the truncation. - MAX_
WATCH_ SNAPSHOTS - Shared state owning the capture closure plus the captured-report map.
Functions§
- with_
active_ bridge - Run
fwith the active bridge if one is installed. When no bridge is installed, returnsNonewithout invokingf— the caller’s responsibility to fall through to its own no-bridge path.
Type Aliases§
- Capture
Callback - Closure type the bridge invokes to capture a snapshot.
- Kernel
OpCallback - Closure type the bridge invokes for a host-side kernel-memory
write or read (
Op::WriteKernel{Hot,Cold}/Op::ReadKernel{Hot,Cold}). - Watch
Register Callback - Closure type the bridge invokes to register a hardware-watchpoint snapshot.