The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/ktrace.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ktrace.h,v 1.45.2.1 2008/04/11 06:35:02 jdc Exp $      */
    2 
    3 /*
    4  * Copyright (c) 1988, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      @(#)ktrace.h    8.2 (Berkeley) 2/19/95
   32  */
   33 
   34 #ifndef _SYS_KTRACE_H_
   35 #define _SYS_KTRACE_H_
   36 
   37 /*
   38  * operations to ktrace system call  (KTROP(op))
   39  */
   40 #define KTROP_SET               0       /* set trace points */
   41 #define KTROP_CLEAR             1       /* clear trace points */
   42 #define KTROP_CLEARFILE         2       /* stop all tracing to file */
   43 #define KTROP_MASK              0x3
   44 #define KTROP(o)                ((o)&KTROP_MASK) /* macro to extract operation */
   45 /*
   46  * flags (ORed in with operation)
   47  */
   48 #define KTRFLAG_DESCEND         4       /* perform op on all children too */
   49 
   50 /*
   51  * ktrace record header
   52  */
   53 struct ktr_header {
   54         int     ktr_len;                /* length of record minus length of old header */
   55 #if BYTE_ORDER == LITTLE_ENDIAN
   56         short   ktr_type;               /* trace record type */
   57         short   ktr_version;            /* trace record version */
   58 #else
   59         short   ktr_version;            /* trace record version */
   60         short   ktr_type;               /* trace record type */
   61 #endif
   62         pid_t   ktr_pid;                /* process id */
   63         char    ktr_comm[MAXCOMLEN+1];  /* command name */
   64         union {
   65                 struct timeval _tv;     /* v0 timestamp */
   66                 struct timespec _ts;    /* v1 timespec */
   67         } _ktr_time;
   68         union {
   69                 const void *_buf;       /* v0 unused */
   70                 lwpid_t _lid;           /* v1 lwp id */
   71         } _ktr_id;
   72 };
   73 
   74 #define ktr_lid _ktr_id._lid
   75 #define ktr_time _ktr_time._ts
   76 #define ktr_tv _ktr_time._tv
   77 #define ktr_ts _ktr_time._ts
   78 #define ktr_unused _ktr_id._buf
   79 
   80 #define KTR_SHIMLEN     offsetof(struct ktr_header, ktr_pid)
   81 
   82 /*
   83  * Test for kernel trace point
   84  */
   85 #define KTRPOINT(p, type)       \
   86         (((p)->p_traceflag & ((1<<(type))|KTRFAC_ACTIVE)) == (1<<(type)))
   87 
   88 /*
   89  * ktrace record types
   90  */
   91 
   92 /*
   93  * KTR_SYSCALL - system call record
   94  */
   95 #define KTR_SYSCALL     1
   96 struct ktr_syscall {
   97         int     ktr_code;               /* syscall number */
   98         int     ktr_argsize;            /* size of arguments */
   99         /*
  100          * followed by ktr_argsize/sizeof(register_t) "register_t"s
  101          */
  102 };
  103 
  104 /*
  105  * KTR_SYSRET - return from system call record
  106  */
  107 #define KTR_SYSRET      2
  108 struct ktr_sysret {
  109         short   ktr_code;
  110         short   ktr_eosys;              /* XXX unused */
  111         int     ktr_error;
  112         register_t ktr_retval;
  113         register_t ktr_retval_1;
  114 };
  115 
  116 /*
  117  * KTR_NAMEI - namei record
  118  */
  119 #define KTR_NAMEI       3
  120         /* record contains pathname */
  121 
  122 /*
  123  * KTR_GENIO - trace generic process i/o
  124  */
  125 #define KTR_GENIO       4
  126 struct ktr_genio {
  127         int     ktr_fd;
  128         enum    uio_rw ktr_rw;
  129         /*
  130          * followed by data successfully read/written
  131          */
  132 };
  133 
  134 /*
  135  * KTR_PSIG - trace processed signal
  136  */
  137 #define KTR_PSIG        5
  138 struct ktr_psig {
  139         int     signo;
  140         sig_t   action;
  141         sigset_t mask;
  142         int     code;
  143         /*
  144          * followed by optional siginfo_t
  145          */
  146 };
  147 
  148 /*
  149  * KTR_CSW - trace context switches
  150  */
  151 #define KTR_CSW         6
  152 struct ktr_csw {
  153         int     out;    /* 1 if switch out, 0 if switch in */
  154         int     user;   /* 1 if usermode (ivcsw), 0 if kernel (vcsw) */
  155 };
  156 
  157 /*
  158  * KTR_EMUL - emulation change
  159  */
  160 #define KTR_EMUL        7
  161         /* record contains emulation name */
  162 
  163 /*
  164  * KTR_USER - user record
  165  */
  166 #define KTR_USER        8
  167 #define KTR_USER_MAXIDLEN       20
  168 #define KTR_USER_MAXLEN         2048    /* maximum length of passed data */
  169 struct ktr_user {
  170         char    ktr_id[KTR_USER_MAXIDLEN];      /* string id of caller */
  171         /*
  172          * Followed by ktr_len - sizeof(struct ktr_user) of user data.
  173          */
  174 };
  175 
  176 /*
  177  * KTR_MMSG - Mach message
  178  */
  179 #define KTR_MMSG                9
  180 struct ktr_mmsg {
  181         /*
  182          * This is a Mach message header
  183          */
  184         int     ktr_bits;
  185         int     ktr_size;
  186         int     ktr_remote_port;
  187         int     ktr_local_port;
  188         int     ktr_reserved;
  189         int     ktr_id;
  190         /*
  191          * Followed by ktr_size - sizeof(mach_msg_header_t) of message payload
  192          */
  193 };
  194 
  195 /*
  196  * KTR_EXEC_ARG, KTR_EXEC_ENV - Arguments and environment from exec
  197  */
  198 #define KTR_EXEC_ARG            10
  199 #define KTR_EXEC_ENV            11
  200         /* record contains arg/env string */
  201 
  202 /*
  203  * KTR_MOOL - Mach Out Of Line data
  204  */
  205 #define KTR_MOOL                12
  206 struct ktr_mool {
  207         const void      *uaddr; /* User address */
  208         size_t          size;   /* Data len */
  209         /* Followed by size bytes of data */
  210 };
  211 
  212 /*
  213  * KTR_SAUPCALL - scheduler activated upcall.
  214  */
  215 #define KTR_SAUPCALL    13
  216 struct ktr_saupcall {
  217         int ktr_type;
  218         int ktr_nevent;
  219         int ktr_nint;
  220         void *ktr_sas;
  221         void *ktr_ap;
  222         /*
  223          * followed by nevent sa_t's from sas[]
  224          */
  225 };
  226 
  227 /*
  228  * KTR_MIB - MIB name and data
  229  */
  230 #define KTR_MIB         14
  231         /* Record contains MIB name */
  232 
  233 
  234 /*
  235  * kernel trace points (in p_traceflag)
  236  */
  237 #define KTRFAC_MASK     0x00ffffff
  238 #define KTRFAC_SYSCALL  (1<<KTR_SYSCALL)
  239 #define KTRFAC_SYSRET   (1<<KTR_SYSRET)
  240 #define KTRFAC_NAMEI    (1<<KTR_NAMEI)
  241 #define KTRFAC_GENIO    (1<<KTR_GENIO)
  242 #define KTRFAC_PSIG     (1<<KTR_PSIG)
  243 #define KTRFAC_CSW      (1<<KTR_CSW)
  244 #define KTRFAC_EMUL     (1<<KTR_EMUL)
  245 #define KTRFAC_USER     (1<<KTR_USER)
  246 #define KTRFAC_MMSG     (1<<KTR_MMSG)
  247 #define KTRFAC_EXEC_ARG (1<<KTR_EXEC_ARG)
  248 #define KTRFAC_EXEC_ENV (1<<KTR_EXEC_ENV)
  249 #define KTRFAC_MOOL     (1<<KTR_MOOL)
  250 #define KTRFAC_SAUPCALL (1<<KTR_SAUPCALL)
  251 #define KTRFAC_MIB      (1<<KTR_MIB)
  252 /*
  253  * trace flags (also in p_traceflags)
  254  */
  255 #define KTRFAC_ROOT     0x80000000      /* root set this trace */
  256 #define KTRFAC_INHERIT  0x40000000      /* pass trace flags to children */
  257 #define KTRFAC_ACTIVE   0x20000000      /* ktrace logging in progress, ignore */
  258 #define KTRFAC_TRC_EMUL 0x10000000      /* ktrace KTR_EMUL before next trace */
  259 #define KTRFAC_VER_MASK 0x0f000000      /* record version mask */
  260 #define KTRFAC_VER_SHIFT        24      /* record version shift */
  261 
  262 #define KTRFAC_VERSION(tf)      (((tf) & KTRFAC_VER_MASK) >> KTRFAC_VER_SHIFT)
  263 
  264 #define KTRFACv0        (0 << KTRFAC_VER_SHIFT)
  265 #define KTRFACv1        (1 << KTRFAC_VER_SHIFT)
  266 
  267 #ifndef _KERNEL
  268 
  269 #include <sys/cdefs.h>
  270 
  271 __BEGIN_DECLS
  272 int     ktrace(const char *, int, int, pid_t);
  273 int     fktrace(int, int, int, pid_t);
  274 int     utrace(const char *, void *, size_t);
  275 __END_DECLS
  276 
  277 #else
  278 
  279 void ktrcsw(struct lwp *, int, int);
  280 void ktremul(struct lwp *);
  281 void ktrgenio(struct lwp *, int, enum uio_rw, struct iovec *, int, int);
  282 void ktrnamei(struct lwp *, char *);
  283 void ktrpsig(struct lwp *, int, sig_t, const sigset_t *, const ksiginfo_t *);
  284 void ktrsyscall(struct lwp *, register_t, register_t,
  285     const struct sysent *, register_t []);
  286 void ktrsysret(struct lwp *, register_t, int, register_t *);
  287 int ktruser(struct lwp *, const char *, void *, size_t, int);
  288 void ktrmmsg(struct lwp *, const void *, size_t);
  289 void ktrkmem(struct lwp *, int, const void *, size_t);
  290 void ktrmib(struct lwp *, const int *, u_int);
  291 void ktrmool(struct lwp *, const void *, size_t, const void *);
  292 void ktrsaupcall(struct lwp *, int, int, int, void *, void *, void *);
  293 
  294 void ktrderef(struct proc *);
  295 void ktradref(struct proc *);
  296 
  297 #endif  /* !_KERNEL */
  298 
  299 #endif /* _SYS_KTRACE_H_ */

Cache object: 105080b8ef0acaecacb8f1ed2d0b47f3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.