KTR provides a circular buffer of events that can be logged in a
These events can then be dumped with
Events are created and logged in the kernel via the
The first parameter is a mask of event types
.In sys/ktr.h .
The event will be logged only if any of the event types specified in
are enabled in the global event mask stored in
argument is a
style format string used to build the text of the event log message.
string are zero to five arguments referenced by
Each event is logged with a file name and source line number of the
originating CTR call, and a timestamp in addition to the log message.
The event is stored in the circular buffer with supplied arguments as is,
and formatting is done at the dump time.
Do not use pointers to the objects with limited lifetime, for instance,
strings, because the pointer may become invalid when buffer is printed.
Note that the different macros differ only in the number of arguments each
one takes, as indicated by its name.
variable contains the number of entries in the
These variables are mostly useful for post-mortem crash dump tools to locate
the base of the circular trace buffer and its length.
variable contains the run time mask of events to log.
The CPU event mask is stored in the
variable stores the verbose flag that controls whether events are logged to
the console in addition to the event buffer.
This example demonstrates the use of tracepoints at the
* Pick a new current process and record its start time.
CTR3(KTR_PROC, "mi_switch: old proc %p (pid %d)", p, p->p_pid);
CTR3(KTR_PROC, "mi_switch: new proc %p (pid %d)", p, p->p_pid);