386BSD 0.1 development
[unix-history] / usr / src / sys.386bsd / sys / trace.h
CommitLineData
b688fc87
WJ
1/*-
2 * Copyright (c) 1982, 1986 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)trace.h 7.6 (Berkeley) 5/5/91
34 */
35
36/*
37 * File system buffer tracing points; all trace <pack(dev, size), bn>
38 */
39#define TR_BREADHIT 0 /* buffer read found in cache */
40#define TR_BREADMISS 1 /* buffer read not in cache */
41#define TR_BWRITE 2 /* buffer written */
42#define TR_BREADHITRA 3 /* buffer read-ahead found in cache */
43#define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */
44#define TR_XFODMISS 5 /* exe fod read */
45#define TR_XFODHIT 6 /* exe fod read */
46#define TR_BRELSE 7 /* brelse */
47#define TR_BREALLOC 8 /* expand/contract a buffer */
48
49/*
50 * Memory allocator trace points; all trace the amount of memory involved
51 */
52#define TR_MALL 10 /* memory allocated */
53
54/*
55 * Paging trace points: all are <vaddr, pid>
56 */
57#define TR_INTRANS 20 /* page intransit block */
58#define TR_EINTRANS 21 /* page intransit wait done */
59#define TR_FRECLAIM 22 /* reclaim from free list */
60#define TR_RECLAIM 23 /* reclaim from loop */
61#define TR_XSFREC 24 /* reclaim from free list instead of drum */
62#define TR_XIFREC 25 /* reclaim from free list instead of fsys */
63#define TR_WAITMEM 26 /* wait for memory in pagein */
64#define TR_EWAITMEM 27 /* end memory wait in pagein */
65#define TR_ZFOD 28 /* zfod page fault */
66#define TR_EXFOD 29 /* exec fod page fault */
67#define TR_VRFOD 30 /* vread fod page fault */
68#define TR_CACHEFOD 31 /* fod in file system cache */
69#define TR_SWAPIN 32 /* drum page fault */
70#define TR_PGINDONE 33 /* page in done */
71#define TR_SWAPIO 34 /* swap i/o request arrives */
72
73/*
74 * System call trace points.
75 */
76#define TR_VADVISE 40 /* vadvise occurred with <arg, pid> */
77
78/*
79 * Miscellaneous
80 */
81#define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */
82
83/*
84 * This defines the size of the trace flags array.
85 */
86#define TR_NFLAGS 100 /* generous */
87
88#define TRCSIZ 4096
89
90/*
91 * Specifications of the vtrace() system call, which takes one argument.
92 */
93#define VTRACE 64+51
94
95#define VTR_DISABLE 0 /* set a trace flag to 0 */
96#define VTR_ENABLE 1 /* set a trace flag to 1 */
97#define VTR_VALUE 2 /* return value of a trace flag */
98#define VTR_UALARM 3 /* set alarm to go off (sig 16) */
99 /* in specified number of hz */
100#define VTR_STAMP 4 /* user specified stamp */
101
102#ifdef KERNEL
103#ifdef TRACE
104char traceflags[TR_NFLAGS];
105struct proc *traceproc;
106int tracebuf[TRCSIZ];
107unsigned tracex;
108int tracewhich;
109#define pack(v,b) (((v)->v_mount->mnt_stat.f_fsid.val[0])<<16)|(b)
110#define trace(a,b,c) if (traceflags[a]) trace1(a,b,c)
111#else
112#define trace(a,b,c) ;
113#endif
114#endif