OpenBSD manual page server

Manual Page Search Parameters

BT(5) File Formats Manual BT(5)

BTBug Tracing language

probe / filter / { action }

The BT language, also known as BPFtrace syntax, describes how to format and display information gathered from specified probe events.

Events are generated by the dynamic tracer dt(4) when an enabled probe is triggered. They are periodically collected by btrace(8), which formats them using the corresponding action. If a recorded event doesn't match the optional filter, it will be silently ignored.

A valid BT source file contains at least one probe clause associated with an action statement.

The list of available probes may vary from system to system and can be queried with btrace(8).

The special probes BEGIN and END may be used to manipulate states before the first event is recorded and after the last. They cannot be combined with any filter.

Define under which condition an event should be recorded when its related probe is executed. An empty filter means record all events.

Variable names available in filters:

Process ID of the current thread.
Thread ID of the current thread.

An action is a sequence of statements that are evaluated for each event recorded by the associated probe.

Variable names with special meaning:

Command line argument N after the script name.
Argument N of the corresponding probe.
Command name of the current process.
ID of the processor that recorded the event.
Kernel stack of the current thread.
Timestamp of the event in nanoseconds.
Process ID of the current thread.
Full name of the probe.
Return value of the traced syscall.
Thread ID of the current thread.
Userland stack of the current thread.


Delete all (key, value) pairs from @map.
Delete the pair indexed by key from @map.
Terminate execution with exit code 0. The END probe, if any, is executed and the contents of all non-empty maps are printed.
Increment the bucket corresponding to value in a power-of-two histogram.
(value, min, max, step)
Increment the bucket corresponding to value in the linear histogram spawning between the positive value min and max with buckets of step size.
Print all pairs from @map.
print(@map, n)
Print only the first n entries in @map.
(fmt, ...)
Print formatted string fmt.
($N, [index])
Return the string from argument $N, truncated to index characters (up to 64, the default) including a guaranteed NUL-terminator.
Print timestamps using strftime(3).
Set all values from @map to 0.

The following functions only work on a specific map entry.

@map[key] = ()
Increase the stored value for key by one.
@map[key] = (value)
Store the maximum recorded value for key.
@map[key] = (value)
Store the minimum recorded value for key.
@map[key] = (value)
Store the sum of all recorded values for key.

awk(1), dt(4), btrace(8)

BPFtrace reference guide,

The dialect of the BT language described in this manual and supported by btrace(8) is compatible with BPFtrace. The syntax is similar to awk(1) and dtrace.

October 22, 2023 OpenBSD-current