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.38.2.1 2004/06/24 14:04:11 he 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 ktr_buf */
   55         short   ktr_type;               /* trace record type */
   56         pid_t   ktr_pid;                /* process id */
   57         char    ktr_comm[MAXCOMLEN+1];  /* command name */
   58         struct  timeval ktr_time;       /* timestamp */
   59         const void *ktr_buf;
   60 };
   61 
   62 /*
   63  * Test for kernel trace point
   64  */
   65 #define KTRPOINT(p, type)       \
   66         (((p)->p_traceflag & ((1<<(type))|KTRFAC_ACTIVE)) == (1<<(type)))
   67 
   68 /*
   69  * ktrace record types
   70  */
   71 
   72 /*
   73  * KTR_SYSCALL - system call record
   74  */
   75 #define KTR_SYSCALL     1
   76 struct ktr_syscall {
   77         int     ktr_code;               /* syscall number */
   78         int     ktr_argsize;            /* size of arguments */
   79         /*
   80          * followed by ktr_argsize/sizeof(register_t) "register_t"s
   81          */
   82 };
   83 
   84 /*
   85  * KTR_SYSRET - return from system call record
   86  */
   87 #define KTR_SYSRET      2
   88 struct ktr_sysret {
   89         short   ktr_code;
   90         short   ktr_eosys;              /* XXX unused */
   91         int     ktr_error;
   92         register_t ktr_retval;
   93         register_t ktr_retval_1;
   94 };
   95 
   96 /*
   97  * KTR_NAMEI - namei record
   98  */
   99 #define KTR_NAMEI       3
  100         /* record contains pathname */
  101 
  102 /*
  103  * KTR_GENIO - trace generic process i/o
  104  */
  105 #define KTR_GENIO       4
  106 struct ktr_genio {
  107         int     ktr_fd;
  108         enum    uio_rw ktr_rw;
  109         /*
  110          * followed by data successfully read/written
  111          */
  112 };
  113 
  114 /*
  115  * KTR_PSIG - trace processed signal
  116  */
  117 #define KTR_PSIG        5
  118 struct ktr_psig {
  119         int     signo;
  120         sig_t   action;
  121         sigset_t mask;
  122         int     code;
  123         /*
  124          * followed by optional siginfo_t
  125          */
  126 };
  127 
  128 /*
  129  * KTR_CSW - trace context switches
  130  */
  131 #define KTR_CSW         6
  132 struct ktr_csw {
  133         int     out;    /* 1 if switch out, 0 if switch in */
  134         int     user;   /* 1 if usermode (ivcsw), 0 if kernel (vcsw) */
  135 };
  136 
  137 /*
  138  * KTR_EMUL - emulation change
  139  */
  140 #define KTR_EMUL        7
  141         /* record contains emulation name */
  142 
  143 /*
  144  * KTR_USER - user record
  145  */
  146 #define KTR_USER        8
  147 #define KTR_USER_MAXIDLEN       20
  148 #define KTR_USER_MAXLEN         2048    /* maximum length of passed data */
  149 struct ktr_user {
  150         char    ktr_id[KTR_USER_MAXIDLEN];      /* string id of caller */
  151         /*
  152          * Followed by ktr_len - sizeof(struct ktr_user) of user data.
  153          */
  154 };
  155 
  156 /*
  157  * KTR_MMSG - Mach message
  158  */
  159 #define KTR_MMSG                9
  160 struct ktr_mmsg { 
  161         /* 
  162          * This is a Mach message header
  163          */
  164         int     ktr_bits;
  165         int     ktr_size;
  166         int     ktr_remote_port;
  167         int     ktr_local_port;
  168         int     ktr_reserved;
  169         int     ktr_id;
  170         /* 
  171          * Followed by ktr_size - sizeof(mach_msg_header_t) of message payload
  172          */
  173 };
  174 
  175 /*
  176  * KTR_EXEC_ARG, KTR_EXEC_ENV - Arguments and environment from exec
  177  */
  178 #define KTR_EXEC_ARG            10
  179 #define KTR_EXEC_ENV            11
  180         /* record contains arg/env string */
  181 
  182 /*
  183  * KTR_MOOL - Mach Out Of Line data
  184  */
  185 #define KTR_MOOL                12
  186 struct ktr_mool {
  187         const void      *uaddr; /* User address */
  188         size_t          size;   /* Data len */
  189         /* Followed by size bytes of data */
  190 };
  191 
  192 /*
  193  * kernel trace points (in p_traceflag)
  194  */
  195 #define KTRFAC_MASK     0x00ffffff
  196 #define KTRFAC_SYSCALL  (1<<KTR_SYSCALL)
  197 #define KTRFAC_SYSRET   (1<<KTR_SYSRET)
  198 #define KTRFAC_NAMEI    (1<<KTR_NAMEI)
  199 #define KTRFAC_GENIO    (1<<KTR_GENIO)
  200 #define KTRFAC_PSIG     (1<<KTR_PSIG)
  201 #define KTRFAC_CSW      (1<<KTR_CSW)
  202 #define KTRFAC_EMUL     (1<<KTR_EMUL)
  203 #define KTRFAC_USER     (1<<KTR_USER)
  204 #define KTRFAC_MMSG     (1<<KTR_MMSG)
  205 #define KTRFAC_EXEC_ARG (1<<KTR_EXEC_ARG)
  206 #define KTRFAC_EXEC_ENV (1<<KTR_EXEC_ENV)
  207 #define KTRFAC_MOOL     (1<<KTR_MOOL)
  208 
  209 /*
  210  * trace flags (also in p_traceflags)
  211  */
  212 #define KTRFAC_ROOT     0x80000000      /* root set this trace */
  213 #define KTRFAC_INHERIT  0x40000000      /* pass trace flags to children */
  214 #define KTRFAC_ACTIVE   0x20000000      /* ktrace logging in progress, ignore */
  215 #define KTRFAC_TRC_EMUL 0x10000000      /* ktrace KTR_EMUL before next trace */
  216 
  217 #ifndef _KERNEL
  218 
  219 #include <sys/cdefs.h>
  220 
  221 __BEGIN_DECLS
  222 int     ktrace(const char *, int, int, pid_t);
  223 int     fktrace(int, int, int, pid_t);
  224 int     utrace(const char *, void *, size_t);
  225 __END_DECLS
  226 
  227 #else
  228 
  229 int ktrcsw(struct proc *, int, int);
  230 int ktremul(struct proc *);
  231 int ktrgenio(struct proc *, int, enum uio_rw, struct iovec *, int, int);
  232 int ktrnamei(struct proc *, char *);
  233 int ktrpsig(struct proc *, int, sig_t, const sigset_t *, const ksiginfo_t *);
  234 int ktrsyscall(struct proc *, register_t, register_t, 
  235     const struct sysent *, register_t []);
  236 int ktrsysret(struct proc *, register_t, int, register_t *);
  237 int ktruser(struct proc *, const char *, void *, size_t, int);
  238 int ktrmmsg(struct proc *, const void *, size_t);
  239 int ktrkmem(struct proc *, int, const void *, size_t);
  240 int ktrmool(struct proc *, const void *, size_t, const void *);
  241 
  242 void ktrderef(struct proc *);
  243 void ktradref(struct proc *);
  244 
  245 #endif  /* !_KERNEL */
  246 
  247 #endif /* _SYS_KTRACE_H_ */

Cache object: 2911475f55d0ccda3ab149cb81ce454d


[ 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.