OS Manuals

/usr/bin/bpftrace

High-level tracing language for Linux

From bpftrace 0.27.1-r0 (enterprise-packages), captured 2026-11-08 by running bpftrace --help (exit 0). permalink

bpftrace - a high-level tracing language for Linux powered by BPF

USAGE:
    bpftrace [options] filename
    bpftrace [options] - <stdin input>
    bpftrace [options] -e 'program'
    use -- after filename/-e 'program' for named script parameters

OPTIONS:
    -e 'program'   execute this program
    -l, --list [search|filename]
                   list kernel probes or probes in a program
    -v, --verbose  enable verbose messages; with -l, also show probe arguments
    -h, --help     show this help message
    -V, --version  bpftrace version
    --info         print information about kernel BPF support

    -p, --pid PID  filter actions and enable USDT probes on PID
    -c, --cmd CMD  run CMD and enable USDT probes on resulting process
    --dwarf-pid PID
                   add additional pids to the DWARF-unwinder
    --usdt-file-activation
                   activate usdt semaphores based on file path

    -o, --output FILE
                   redirect bpftrace output to FILE
    -f FORMAT      output format ('text', 'json')
    -B MODE        output buffering mode ('line', 'full', 'none')
    -q, --quiet    keep messages quiet
    -k, --warnings emit a warning when probe read helpers return an error
    --no-warnings  disable all warning messages

    -I DIR         add the directory to the include search path
    --include FILE add an #include file before preprocessing
    --debuginfo DIR[:DIR]
                   add directories to the debug info search path
    --traceable-functions FILE
                   load the list of traceable kernel functions from FILE

    --unsafe       allow unsafe/destructive functionality
    --no-feature FEATURE[,FEATURE]
                   disable use of detected features

DEVELOPER OPTIONS:
    --mode MODE    used for benchmarking and testing
                   ('codegen', 'compiler-bench', 'bench', 'test', 'format')
    --test         run all test: probes (same as --mode test)
    --bench        run all bench: probes (same as --mode bench)
    --probe-filter REGEX
                   only run probes whose name matches REGEX
    --fmt          format the input script and print it

TROUBLESHOOTING OPTIONS:
    --dry-run      terminate execution right after attaching all the probes
    --verify-llvm-ir
                   check that the generated LLVM IR is valid
    -d, --debug STAGE
                   debug info for various stages of bpftrace execution
                   ('all', 'ast', 'types', 'codegen', 'codegen-opt', 'libbpf', 'verifier')
                   ('parse', 'dis') - available on debug builds
    --emit-elf FILE
                   (dry run) generate ELF file with bpf programs and write to FILE
    --emit-llvm FILE
                   write LLVM IR to FILE.original.ll and FILE.optimized.ll

CONFIGURATION:
    bpftrace also supports environment variables and config options
    for tuning behavior. See 'man bpftrace' or the online documentation
    for the full list.

EXAMPLES:
    bpftrace -e 'kprobe:do_nanosleep { printf("PID %d sleeping...\n", pid); }'
        trace processes calling sleep
    bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); }'
        count syscalls by process name
    bpftrace -e 'tracepoint:syscalls:sys_enter_openat { printf("%s %s\n", comm, str(args.filename)); }'
        trace file opens with process name and path
    bpftrace -e 'profile:hz:99 { @[kstack] = count(); }'
        profile kernel stacks at 99 Hertz
    bpftrace -e 'tracepoint:block:block_rq_issue { @ = hist(args.bytes); }'
        histogram of block I/O request sizes
    bpftrace -p 1337 -e 'uprobe:/usr/lib/libc.so.6:malloc { @[ustack] = count(); }'
        count malloc calls by user stack for a specific process
    bpftrace -l '*sleep*'
        list probes containing "sleep"
    bpftrace -lv 'kprobe:do_nanosleep'
        show the arguments for the do_nanosleep kprobe

DOCUMENTATION:
    https://bpftrace.org
    https://github.com/bpftrace/bpftrace
Options (30)
OptionDescriptionSource
-e 'program'execute this programhelp
-l, --list search|filenamelist kernel probes or probes in a programhelp
-v, --verboseenable verbose messages;help
-h, --helpshow this help messagehelp
-V, --versionbpftrace versionhelp
--infoprint information about kernel BPF supporthelp
-p, --pid PIDfilter actions and enable USDT probes on PIDhelp
-c, --cmd CMDrun CMD and enable USDT probes on resulting processhelp
--dwarf-pid PIDadd additional pids to the DWARF-unwinderhelp
--usdt-file-activationactivate usdt semaphores based on file pathhelp
-o, --output FILEredirect bpftrace output to FILEhelp
-f FORMAToutput format ('text', 'json')help
-B MODEoutput buffering mode ('line', 'full', 'none')help
-q, --quietkeep messages quiethelp
--no-warningsdisable all warning messageshelp
-I DIRadd the directory to the include search pathhelp
--debuginfo DIR[:DIRadd directories to the debug info search pathhelp
--traceable-functions FILEload the list of traceable kernel functions from FILEhelp
--unsafeallow unsafe/destructive functionalityhelp
--no-feature FEATUREdisable use of detected featureshelp
--mode MODEused for benchmarking and testing ('codegen', 'compiler-bench', 'bench', 'test', 'format')help
--testrun all test: probes (same as --mode test)help
--benchrun all bench: probes (same as --mode bench)help
--probe-filter REGEXonly run probes whose name matches REGEXhelp
--fmtformat the input script and print ithelp
--dry-runterminate execution right after attaching all the probeshelp
--verify-llvm-ircheck that the generated LLVM IR is validhelp
-d, --debug STAGEdebug info for various stages of bpftrace execution ('all', 'ast', 'types', 'codegen', 'codegen-opt', 'libbpf', 'verifier') ('parse', 'dis') - available on debug buildshelp
--emit-elf FILE(dry run) generate ELF file with bpf programs and write to FILEhelp
--emit-llvm FILEwrite LLVM IR to FILE.original.ll and FILE.optimized.llhelp
Examples (4) from the manual page, untested

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.