|
NAMEktr —
kernel tracing facility
SYNOPSISoptions KTR
options ALQ
options KTR_ALQ
options KTR_COMPILE=(KTR_LOCK|KTR_INTR|KTR_PROC)
options KTR_CPUMASK=0x3
options KTR_ENTRIES=8192
options KTR_MASK=(KTR_INTR|KTR_PROC)
options KTR_VERBOSE
DESCRIPTIONThektr facility allows kernel events to be logged while
the kernel executes so that they can be examined later when debugging. The
only mandatory option to enable ktr is
“options KTR ”.
The Event MaskingEvent levels can be enabled or disabled to trim excessive and overly verbose logging. First, a mask of events is specified at compile time via theKTR_COMPILE option to limit which events are actually
compiled into the kernel. The default value for this option is for all events
to be enabled.
Secondly, the actual events logged while the kernel runs can be
further masked via the run time event mask. The
Furthermore, there is a CPU event mask whose default value can be
changed via the Verbose ModeBy default, events are only logged to the internal buffer for examination later, but if the verbose flag is set then they are dumped to the kernel console as well. This flag can also be set from the loader via the debug.ktr.verbose environment variable, or it can be examined and set after booting via the debug.ktr.verbose sysctl. If the flag is set to zero, which is the default, then verbose output is disabled. If the flag is set to one, then the contents of the log message and the CPU number are printed to the kernel console. If the flag is greater than one, then the filename and line number of the event are output to the console in addition to the log message and the CPU number. TheKTR_VERBOSE option sets the flag to one.
Examining the EventsThe KTR buffer can be examined from within ddb(4) via theshow ktr [/vV ] command.
This command displays the contents of the trace buffer one page at a time. At
the “--more-- ” prompt, the Enter key
displays one more entry and prompts again. The spacebar displays another page
of entries. Any other key quits. By default the timestamp, filename, and line
number are not displayed with each log entry. If the
/v modifier is specified, then they are displayed in
addition to the normal output. If the /V modifier is
specified, then just the timestamp is displayed in addition to the normal
output. Note that the events are displayed in reverse chronological order.
That is, the most recent events are displayed first.
Logging ktr to DiskTheKTR_ALQ option can be used to log
ktr entries to disk for post analysis using the
ktrdump(8)
utility. This option depends on the ALQ option. Due to
the potentially high volume of trace messages the trace mask should be
selected carefully. This feature is configured through a group of sysctls.
SEE ALSOktrdump(8), alq(9), ktr(9)HISTORYThe KTR kernel tracing facility first appeared in BSD/OS 3.0 and was imported into FreeBSD 5.0.
Visit the GSP FreeBSD Man Page Interface. |