|
NAMEktrace —
process tracing
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <sys/param.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/ktrace.h>
int
DESCRIPTIONThektrace () system call enables or disables tracing of
one or more processes. Users may only trace their own processes. Only the
super-user can trace setuid or setgid programs.
The tracefile argument gives the pathname of the file to be used for tracing. The file must exist and be a regular file writable by the calling process. All trace records are always appended to the file, so the file must be truncated to zero length to discard previous trace data. If tracing points are being disabled (see KTROP_CLEAR below), tracefile may be NULL. The ops argument specifies the requested ktrace operation. The defined operations are:
The trpoints argument specifies the trace points of interest. The defined trace points are:
Each tracing event outputs a record composed of a generic header followed by a trace point specific structure. The generic header is: struct ktr_header { int ktr_len; /* length of buf */ short ktr_type; /* trace record type */ pid_t ktr_pid; /* process id */ char ktr_comm[MAXCOMLEN+1]; /* command name */ struct timeval ktr_time; /* timestamp */ intptr_t ktr_tid; /* was ktr_buffer */ }; The ktr_len field specifies the length of the ktr_type data that follows this header. The ktr_pid and ktr_comm fields specify the process and command generating the record. The ktr_time field gives the time (with microsecond resolution) that the record was generated. The ktr_tid field holds a thread id. The generic header is followed by ktr_len
bytes of a ktr_type record. The type specific records
are defined in the
SYSCTL TUNABLESThe following sysctl(8) tunables influence the behaviour ofktrace ():
Sysctl tunables that control process debuggability (as determined
by
p_candebug(9))
also affect the operation of RETURN VALUESThektrace () function returns the value 0 if
successful; otherwise the value -1 is returned and the global variable
errno is set to indicate the error.
ERRORSThektrace () system call will fail if:
A thread may be unable to log one or more tracing events due to a
temporary shortage of resources. This condition is remembered by the kernel,
and the next tracing request that succeeds will have the flag
SEE ALSOkdump(1), ktrace(1), utrace(2), sysctl(8), p_candebug(9)HISTORYThektrace () system call first appeared in
4.4BSD.
Visit the GSP FreeBSD Man Page Interface. |