Reference

Reference

Every subcommand, every build-integration variable, every environment variable, and the limitations worth knowing before you rely on a number.

CLI

CommandPurpose
callsight init <dir>Adopt callsight into a project: copy the runtime and build wiring, write a starter config, print the wiring snippet
callsight scan <dir>Preview which sources a config selects, without building
callsight select <dir>Explore a function's call subtree; emit the matching config lines
callsight flagsPrint the compiler flags (what the build integrations call)
callsight analyze [traces/]Hotspot report, JSON, or folded stacks
callsight uiLocal web UI (needs the ui extra)
callsight serveTCP server for remote streams (needs the stream extra)
callsight provisionDownload the bundled static ctags used by the UI config builder
callsight --versionInstalled version

init

callsight init <dir> [--build make|cmake] [--stream]
--buildForce the build system. Default: auto-detect (CMakeLists.txt → cmake, else make)
--streamAlso copy the on-device streaming client (trace_stream.c + vendored zstd)

An existing trace.config is never overwritten.

scan

callsight scan <dir> [--config trace.config]

Prints how many sources would be instrumented versus excluded, lists the excluded ones, and — for an include-func config — the subtree size and any substring-collision warnings.

select

callsight select <dir> --function NAME [--depth N] [--threads GLOB] [--list]
--function, -fSeed function; repeatable
--depth, -dLimit subtree expansion (0 = just the seed, 1 = direct callees). Default: full subtree
--threads, -tAlso print a TRACE_THREADS runtime hint
--list, -lList every function callsight can see, with the files defining it

flags

callsight flags --config CONFIG [--scan DIR] [--format make|raw]
                [--compiler auto|gcc|clang] [--compiler-cmd CC] [--print] -- srcs...
--configConfig path (required)
--scan DIRCollect sources recursively under DIR instead of listing them
--formatmake (default) prints a CFLAGS_INSTRUMENT = … assignment for $(eval $(shell …)); raw prints only the flags
--compilerTarget toolchain. auto (default) detects it by running --compiler-cmd
--compiler-cmdCompiler command used for detection. Default: $CC, else cc
--printHuman-readable selection summary on stderr

A selective config under a detected Clang exits with an explanation rather than emitting GCC-only flags. A failed detection is treated as GCC, so detection can never break a build that would otherwise work.

analyze

callsight analyze [tracedir] [--exe BIN] [--top N] [--format text|json|folded]
tracedirDirectory of trace.*.bin files. Default traces
--exeInstrumented binary for addr2line. Default: the single *.instr under ./bin or .
--topRows per table (default 20). With --format json, 0 means every row
--formattext tables (default), json for tooling, or folded collapsed stacks for flamegraph.pl and speedscope

serve · ui · provision

callsight serve [--host 0.0.0.0] [--port 9001] [--out traces]
callsight ui    [--host 127.0.0.1] [--port 8321]
callsight provision [--force]

provision reports where ctags comes from and installs the bundled static copy into $CALLSIGHT_HOME/bin (default ~/.callsight/bin), verifying its checksum. --force installs it even when a system ctags is present.

Build integrations

Both do the same three things: generate the flags from your config and source list, compile the runtime without instrumentation so hooks cannot recurse, and link with -no-pie.

GNU Make

CALLSIGHT_DIR ?= callsight
include $(CALLSIGHT_DIR)/Makefile.callsight

Expects SRCS, BUILDDIR, BINDIR, TARGET, CC, CFLAGS_SYMBOLS and LDFLAGS. Defines:

VariableDefaultMeaning
CALLSIGHT_DIRcallsightWhere trace.c/trace.h live
CALLSIGHT_CONFIGtrace.configSelection config
CALLSIGHTcallsightCommand that prints the flags — point it at python3 …/cli.py to run from a source checkout

When make instrument is requested and no flags could be generated, the build stops with an explanation instead of silently producing an uninstrumented binary. A normal make still succeeds even if callsight isn't installed.

CMake

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/callsight")
include(CallSight)
callsight_instrument(<target>)
Cache variableDefaultMeaning
CALLSIGHT_INSTRUMENTOFFApply hooks to callsight_instrument() targets
CALLSIGHT_CONFIG<src>/trace.configSelection config
CALLSIGHT_COMMANDcallsightFlag generator; a ;-list works, e.g. -D"CALLSIGHT_COMMAND=python3;/path/cli.py"
CALLSIGHT_COMMAND is a cache variable — pass it with -D. A plain set() before include(CallSight) gets shadowed by the cache definition under CMP0126.

Environment variables

VariableDefaultMeaning
TRACE_ENABLEoff1 enables collection; hooks are inert otherwise
TRACE_DIR./tracesOutput directory (file mode)
TRACE_MAX0 (unlimited)Global event cap
TRACE_THREADSunset (all)Comma-separated globs matched against thread names
TRACE_SHMunsetStreaming mode: POSIX shm ring name
TRACE_SHM_SIZE16 MiBRing capacity in bytes
CCccRead by callsight flags for compiler detection
CALLSIGHT_HOME~/.callsightWhere the bundled ctags is installed

File formats

Trace files

trace.<pid>.<tid>.bin (file mode) or trace.stream.<id>.bin (streamed). A 16-byte header — MLTRACE magic, u32 version, u32 event size — followed by fixed 32-byte little-endian event records. The architecture page documents the record; a file with a bad magic, unknown version or mismatched event size is skipped with a warning, and a truncated final record is tolerated.

Folded stacks

main;handle_request;parse_headers 148230
main;handle_request 92117

One line per distinct call path: semicolon-separated frames, then self time in nanoseconds. Read directly by flamegraph.pl and speedscope.

JSON report

Summary counters (events, threads, functions, span_ms, unmatched_exits, unclosed_enters), a rows array sorted by self time, a per_thread array, plus tool and version. See the analysis page for a full example.

Known limitations