]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/trace.h
0fe681b734bbc1a19dbb7dfb0d904517d2dc9d6e
[apple/xnu.git] / bsd / sys / trace.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
31 /*-
32 * Copyright (c) 1982, 1986, 1993
33 * The Regents of the University of California. All rights reserved.
34 *
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 * SUCH DAMAGE.
62 *
63 * @(#)trace.h 8.1 (Berkeley) 6/2/93
64 */
65
66 #ifndef _SYS_TRACE_H_
67 #define _SYS_TRACE_H_
68
69 #include <sys/appleapiopts.h>
70
71 #ifdef __APPLE_API_OBSOLETE
72 /*
73 * File system buffer tracing points; all trace <pack(dev, size), bn>
74 */
75 #define TR_BREADHIT 0 /* buffer read found in cache */
76 #define TR_BREADMISS 1 /* buffer read not in cache */
77 #define TR_BWRITE 2 /* buffer written */
78 #define TR_BREADHITRA 3 /* buffer read-ahead found in cache */
79 #define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */
80 #define TR_XFODMISS 5 /* exe fod read */
81 #define TR_XFODHIT 6 /* exe fod read */
82 #define TR_BRELSE 7 /* brelse */
83 #define TR_BREALLOC 8 /* expand/contract a buffer */
84
85 /*
86 * Memory allocator trace points; all trace the amount of memory involved
87 */
88 #define TR_MALL 10 /* memory allocated */
89
90 /*
91 * Paging trace points: all are <vaddr, pid>
92 */
93 #define TR_INTRANS 20 /* page intransit block */
94 #define TR_EINTRANS 21 /* page intransit wait done */
95 #define TR_FRECLAIM 22 /* reclaim from free list */
96 #define TR_RECLAIM 23 /* reclaim from loop */
97 #define TR_XSFREC 24 /* reclaim from free list instead of drum */
98 #define TR_XIFREC 25 /* reclaim from free list instead of fsys */
99 #define TR_WAITMEM 26 /* wait for memory in pagein */
100 #define TR_EWAITMEM 27 /* end memory wait in pagein */
101 #define TR_ZFOD 28 /* zfod page fault */
102 #define TR_EXFOD 29 /* exec fod page fault */
103 #define TR_VRFOD 30 /* vread fod page fault */
104 #define TR_CACHEFOD 31 /* fod in file system cache */
105 #define TR_SWAPIN 32 /* drum page fault */
106 #define TR_PGINDONE 33 /* page in done */
107 #define TR_SWAPIO 34 /* swap i/o request arrives */
108
109 /*
110 * System call trace points.
111 */
112 #define TR_VADVISE 40 /* vadvise occurred with <arg, pid> */
113
114 /*
115 * Miscellaneous
116 */
117 #define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */
118
119 /*
120 * This defines the size of the trace flags array.
121 */
122 #define TR_NFLAGS 100 /* generous */
123
124 #define TRCSIZ 4096
125
126 /*
127 * Specifications of the vtrace() system call, which takes one argument.
128 */
129 #define VTRACE 64+51
130
131 #define VTR_DISABLE 0 /* set a trace flag to 0 */
132 #define VTR_ENABLE 1 /* set a trace flag to 1 */
133 #define VTR_VALUE 2 /* return value of a trace flag */
134 #define VTR_UALARM 3 /* set alarm to go off (sig 16) */
135 /* in specified number of hz */
136 #define VTR_STAMP 4 /* user specified stamp */
137
138 #ifdef KERNEL
139 #if TRACE
140 extern struct proc *traceproc;
141 extern int tracewhich, tracebuf[TRCSIZ];
142 extern u_int tracex;
143 extern char traceflags[TR_NFLAGS];
144 #define pack(v,b) (((v)->v_mount->mnt_vfsstat.f_fsid.val[0])<<16)|(b)
145 #define trace(a,b,c) { \
146 if (traceflags[a]) \
147 trace1(a,b,c); \
148 }
149 #else
150 #define trace(a,b,c)
151 #endif
152 #endif /* KERNEL */
153
154 #endif /* __APPLE_API_OBSOLETE */
155
156 #endif /* !_SYS_TRACE_H_ */
157