]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ddb/tr.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / osfmk / ddb / tr.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
A
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@
1c79356b
A
29 */
30/*
31 * @OSF_COPYRIGHT@
32 */
33/*
34 * HISTORY
35 *
36 * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
37 * Import of Mac OS X kernel (~semeria)
38 *
39 * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
40 * Import of OSF Mach kernel (~mburg)
41 *
42 * Revision 1.1.11.1 1997/03/27 18:47:01 barbou
43 * Merge smp_shared merges into mainline.
44 * [1996/09/19 13:55:17 addis]
45 * Make tr_indent NCPU safe.
46 * [95/10/09 rwd]
47 * Added TR_INIT() macro.
48 * Change from NMK16.1 [93/09/22 paire]
49 * [94/02/04 paire]
50 * [97/02/25 barbou]
51 *
52 * Revision 1.1.6.1 1995/02/23 16:34:23 alanl
53 * Taken from DIPC2_SHARED. Change to !FREE Copyright.
54 * [95/01/05 rwd]
55 *
56 * Revision 1.1.4.4 1994/08/18 01:07:26 alanl
57 * + Allow tracing strictly based on MACH_TR;
58 * don't also require MACH_ASSERT (alanl).
59 * + ANSI-fication: cast tr arguments (alanl).
60 * + Added tr_indent and macros to use it (sjs).
61 * [1994/08/18 01:06:09 alanl]
62 *
63 * Revision 1.1.4.3 1994/08/08 17:59:35 rwd
64 * Include mach_tr.h
65 * [94/08/08 rwd]
66 *
67 * Revision 1.1.4.2 1994/08/05 19:36:08 mmp
68 * Added prototype for db_show_tr.
69 *
70 * Conditionalize on MACH_TR
71 * [94/07/20 rwd]
72 *
73 * Revision 1.1.4.1 1994/08/04 01:43:04 mmp
74 * DIPC: moved from norma/ to ddb/. Updated includes.
75 * [1994/08/03 13:37:46 mmp]
76 *
77 * Revision 1.1.9.1 1994/03/07 16:55:24 paire
78 * Added ANSI prototypes.
79 * [94/02/15 paire]
80 *
81 * Added TR_INIT() macro.
82 * Change from NMK16.1 [93/09/22 paire]
83 * [94/02/04 paire]
84 *
85 * Revision 1.1.2.2 1993/06/02 23:57:10 jeffc
86 * Added to OSF/1 R1.3 from NMK15.0.
87 * [1993/06/02 21:22:08 jeffc]
88 *
89 * Revision 1.1 1992/09/30 02:34:09 robert
90 * Initial revision
91 *
92 * $EndLog$
93 */
94
95/*
96 * File: ddb/tr.h
97 * Author: Alan Langerman, Jeffrey Heller
98 * Date: 1992
99 *
100 * Internal trace routines. Like old-style XPRs but
101 * less formatting.
102 */
103
104#include <mach_assert.h>
105#include <mach_tr.h>
106
107#include <kern/cpu_number.h>
108
109/*
110 * Originally, we only wanted tracing when
111 * MACH_TR and MACH_ASSERT were turned on
112 * together. Now, there's no reason why
113 * MACH_TR and MACH_ASSERT can't be completely
114 * orthogonal.
115 */
116#define TRACE_BUFFER (MACH_TR)
117
118/*
119 * Log events in a circular trace buffer for future debugging.
120 * Events are unsigned integers. Each event has a descriptive
121 * message.
122 *
123 * TR_DECL must be used at the beginning of a routine using
124 * one of the tr calls. The macro should be passed the name
125 * of the function surrounded by quotation marks, e.g.,
126 * TR_DECL("netipc_recv_intr");
127 * and should be terminated with a semi-colon. The TR_DECL
128 * must be the *last* declaration in the variable declaration
129 * list, or syntax errors will be introduced when TRACE_BUFFER
130 * is turned off.
131 */
132#ifndef _DDB_TR_H_
133#define _DDB_TR_H_
134
135#if TRACE_BUFFER
136
137#include <machine/db_machdep.h>
138
139#define __ui__ (unsigned int)
140#define TR_INIT() tr_init()
141#define TR_SHOW(a,b,c) show_tr((a),(b),(c))
142#define TR_DECL(funcname) char *__ntr_func_name__ = funcname
143#define tr1(msg) \
144 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
145 0,0,0,0)
146#define tr2(msg,tag1) \
147 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
148 __ui__(tag1),0,0,0)
149#define tr3(msg,tag1,tag2) \
150 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
151 __ui__(tag1),__ui__(tag2),0,0)
152#define tr4(msg,tag1,tag2,tag3) \
153 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
154 __ui__(tag1),__ui__(tag2),__ui__(tag3),0)
155#define tr5(msg,tag1,tag2,tag3,tag4) \
156 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
157 __ui__(tag1),__ui__(tag2),__ui__(tag3),__ui__(tag4))
158
159/*
160 * Adjust tr log indentation based on function
161 * call graph.
162 */
163#if NCPUS == 1
164extern int tr_indent;
165#define tr_start() tr_indent++
166#define tr_stop() tr_indent--
167#else /* NCPUS == 1 */
168extern int tr_indent[NCPUS];
169#define tr_start() tr_indent[cpu_number()]++
170#define tr_stop() (--tr_indent[cpu_number()]<0?tr_indent[cpu_number()]=0:0);
171#endif /* NCPUS == 1 */
172
173extern void tr_init(void);
174extern void tr(
175 char *funcname,
176 char *file,
177 unsigned int lineno,
178 char *fmt,
179 unsigned int tag1,
180 unsigned int tag2,
181 unsigned int tag3,
182 unsigned int tag4);
183
184extern void db_show_tr(
185 db_expr_t addr,
186 boolean_t have_addr,
187 db_expr_t count,
188 char * modif);
189
190#else /* TRACE_BUFFER */
191
192#define TR_INIT()
193#define TR_SHOW(a,b,c)
194#define TR_DECL(funcname)
195#define tr1(msg)
196#define tr2(msg, tag1)
197#define tr3(msg, tag1, tag2)
198#define tr4(msg, tag1, tag2, tag3)
199#define tr5(msg, tag1, tag2, tag3, tag4)
200#define tr_start()
201#define tr_stop()
202
203#endif /* TRACE_BUFFER */
204
205#endif /* _DDB_TR_H_ */