KTRACE(1) | General Commands Manual | KTRACE(1) |
ktrace
, ktruss
—
ktrace |
[-aCcdins ] [-f
trfile] [-g
pgrp] [-p
pid] [-t
trstr] |
ktrace |
[-adis ] [-f
trfile] [-t
trstr] command |
ktruss |
[-aCcdilnRT ] [-e
emulation] [-f
infile] [-g
pgrp] [-m
maxdata] [-o
outfile] [-p
pid] [-t
trstr] |
ktruss |
[-adinRT ] [-e
emulation] [-m
maxdata] [-o
outfile] [-t
trstr] [-v
vers] command |
ktrace
enables kernel trace logging for the specified
processes. Kernel trace data is logged to the file
ktrace.out. The kernel operations that are traced
include system calls, namei translations, signal processing, and I/O.
Once tracing is enabled on a process, trace data will be logged until either the process exits or the trace point is cleared. A traced process can generate enormous amounts of log data quickly; It is strongly suggested that users memorize how to disable tracing before attempting to trace a process. The following command is sufficient to disable tracing on all user owned processes, and, if executed by root, all processes:
$ ktrace -C
The trace file is not human readable; use kdump(1) to decode it.
ktruss
is functionally the same as
ktrace
except that trace output is printed on
standard output or to the file specified with the -o
option. ktruss
is useful to see the kernel
operations interleaved with the program output.
The options are as follows:
-a
-C
-c
-d
-f
trfile-f
infile-g
pgid-g
flag is permitted).-i
-l
-f
option.-m
maxdata-x
is specified when it will be
output in hex and ascii.-n
ktruss
and only affects
ktrace
when writing to
stdout
. If this flag is not set, then the traced
program will block until it can write more data to the trace file
descriptor.-o
outfilektruss
will print its output in a human readable
format to standard out.-p
pid-p
flag is permitted).-s
-R
-T
-R
option, but use absolute timestamps
instead.-t
trstrA
a
c
e
f
i
n
S
s
u
v
w
+
-
-e
emulation-v
versionThe -p
, -g
, and
command options are mutually exclusive. The
-R
and -T
options are also
mutually exclusive.
$ ktrace -p 34
# trace all kernel operations of processes in process group 15 and # pass the trace flags to all current and future children
$ ktrace -idg 15
# disable all tracing of process 65
$ ktrace -cp 65
# disable tracing signals on process 70 and all current children
$ ktrace -t s -cdp 70
# enable tracing of I/O on process 67
$ ktrace -ti -p 67
# run the command "w", tracing only system calls
$ ktrace -tc w
# disable all tracing to the file "tracedata"
$ ktrace -c -f tracedata
# disable tracing of all processes owned by the user
$ ktrace -C
# run the command "w", displaying to standard output
$ ktruss w
# trace process 42 and log the records to "ktruss.out"
$ ktruss -p 42 -o
ktruss.out
# poll ktruss.out for available records and print them
$ ktruss -lf ktruss.out
ktrace
command appears in
4.4BSD.
January 8, 2015 | NetBSD 9.4 |