ktracer.1m (2010 09)
k
ktracer(1M) ktracer(1M)
The above command actually prints a brief
ktracedump usage message to /dev/null.
This command is convenient to defer the overhead of
ktracedump processing until later (for
example, when the system has less of a load).
LIMITATIONS
Traces are only collected at function entry, not at function exit or elsewhere. Therefore, the "Elapsed
Times" are from function entry to function entry. You will not see when a function exited or what value it
returned. If you need to trace function exit, make a function call in the source code, such as
kt_dbg(retval, errno, 0, 0)
. Then look for kt_dbg in the trace output, and the
arg0 column
shows the return value, and the
arg1 column shows
errno. Most, but not all, kernel functions are
traceable.
To produce a list of all traceable functions in a given system, run:
# ktracer -R -h; ktracedump -DNF > traceable_functions
If a C source file is compiled with the option
+O3 or +Oinline, the optimizer inlines functions to reduce
function call overhead. When a function call is inlined, the function call is no longer made. Then
ktracer no longer traces it, causing the absence of expected function call traces in the
ktracedump
output. Function inlining also causes caller to callee relationships to differ from the source code
definition. For example, suppose that in the file
pm_swtch.c, the function real_sleep() calls
_swtch(), and the function _swtch() calls swtch_to_thread()
. If the optimizer inlines the
_swtch() function, then real_sleep() will call swtch_to_thread()
directly, and the calls to
_swtch() will not be traced.
RETURN VALUE
The
ktracer command returns 0 upon success, and returns a positive error number upon failure.
ERRORS
If
ktracer fails, it returns one of the following errors:
[EPERM] Must be superuser or have DEVOPS privilege. See privileges (5).
[ENOMEM] Not enough kernel memory.
[ENOSYS] Attempted operation is not supported.
[EINVAL] Invalid parameter(s).
DIAGNOSTICS
Most kernel functions are traceable, but not all. When a function is not traceable,
ktracer will display
a diagnostics message resembling the following:
# ktracer -a whereami
WARNING: Unrecognized Symbol: whereami, not adding!
No kernel function named "whereami" exists. Not found.
# ktracer -a $cold_idle
ERROR: $cold_idle: Func name has non-C chars [$#.]
Certain compiler generated labels are not traceable, because they do not follow the procedure-
calling conventions.
# ktracer -a 0xe000000001fedcb0 (the address of read+0xb0)
ERROR: 0xe000000001fedcb0: Func addr not at unwind start
Only the entry points of functions can be traced. It cannot trace offsets into the middle of functions.
# ktracer -a _etext_f
ERROR: _etext_f: Func has no unwind info
Data addresses, branch stubs, and some assembly labels lack the information that is needed to qual-
ify them as a function entry point.
# ktracer -a m_wsio_slot
ERROR: m_wsio_slot: Func starts with an untraceable instruction
Certain instructions, such as relative branches, cannot be replaced with branches to tracing code.
# ktracer -a Xicode
ERROR: Xicode: Func name is on exclude list
10 Hewlett-Packard Company − 10 − HP-UX 11i Version 3: September 2010