]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ddb/tr.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
31 * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
32 * Import of Mac OS X kernel (~semeria)
34 * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
35 * Import of OSF Mach kernel (~mburg)
37 * Revision 1.1.11.1 1997/03/27 18:47:01 barbou
38 * Merge smp_shared merges into mainline.
39 * [1996/09/19 13:55:17 addis]
40 * Make tr_indent NCPU safe.
42 * Added TR_INIT() macro.
43 * Change from NMK16.1 [93/09/22 paire]
47 * Revision 1.1.6.1 1995/02/23 16:34:23 alanl
48 * Taken from DIPC2_SHARED. Change to !FREE Copyright.
51 * Revision 1.1.4.4 1994/08/18 01:07:26 alanl
52 * + Allow tracing strictly based on MACH_TR;
53 * don't also require MACH_ASSERT (alanl).
54 * + ANSI-fication: cast tr arguments (alanl).
55 * + Added tr_indent and macros to use it (sjs).
56 * [1994/08/18 01:06:09 alanl]
58 * Revision 1.1.4.3 1994/08/08 17:59:35 rwd
62 * Revision 1.1.4.2 1994/08/05 19:36:08 mmp
63 * Added prototype for db_show_tr.
65 * Conditionalize on MACH_TR
68 * Revision 1.1.4.1 1994/08/04 01:43:04 mmp
69 * DIPC: moved from norma/ to ddb/. Updated includes.
70 * [1994/08/03 13:37:46 mmp]
72 * Revision 1.1.9.1 1994/03/07 16:55:24 paire
73 * Added ANSI prototypes.
76 * Added TR_INIT() macro.
77 * Change from NMK16.1 [93/09/22 paire]
80 * Revision 1.1.2.2 1993/06/02 23:57:10 jeffc
81 * Added to OSF/1 R1.3 from NMK15.0.
82 * [1993/06/02 21:22:08 jeffc]
84 * Revision 1.1 1992/09/30 02:34:09 robert
92 * Author: Alan Langerman, Jeffrey Heller
95 * Internal trace routines. Like old-style XPRs but
99 #include <mach_assert.h>
102 #include <kern/cpu_number.h>
105 * Originally, we only wanted tracing when
106 * MACH_TR and MACH_ASSERT were turned on
107 * together. Now, there's no reason why
108 * MACH_TR and MACH_ASSERT can't be completely
111 #define TRACE_BUFFER (MACH_TR)
114 * Log events in a circular trace buffer for future debugging.
115 * Events are unsigned integers. Each event has a descriptive
118 * TR_DECL must be used at the beginning of a routine using
119 * one of the tr calls. The macro should be passed the name
120 * of the function surrounded by quotation marks, e.g.,
121 * TR_DECL("netipc_recv_intr");
122 * and should be terminated with a semi-colon. The TR_DECL
123 * must be the *last* declaration in the variable declaration
124 * list, or syntax errors will be introduced when TRACE_BUFFER
132 #include <machine/db_machdep.h>
134 #define __ui__ (unsigned int)
135 #define TR_INIT() tr_init()
136 #define TR_SHOW(a,b,c) show_tr((a),(b),(c))
137 #define TR_DECL(funcname) char *__ntr_func_name__ = funcname
139 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
141 #define tr2(msg,tag1) \
142 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
144 #define tr3(msg,tag1,tag2) \
145 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
146 __ui__(tag1),__ui__(tag2),0,0)
147 #define tr4(msg,tag1,tag2,tag3) \
148 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
149 __ui__(tag1),__ui__(tag2),__ui__(tag3),0)
150 #define tr5(msg,tag1,tag2,tag3,tag4) \
151 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
152 __ui__(tag1),__ui__(tag2),__ui__(tag3),__ui__(tag4))
155 * Adjust tr log indentation based on function
159 extern int tr_indent
;
160 #define tr_start() tr_indent++
161 #define tr_stop() tr_indent--
162 #else /* NCPUS == 1 */
163 extern int tr_indent
[NCPUS
];
164 #define tr_start() tr_indent[cpu_number()]++
165 #define tr_stop() (--tr_indent[cpu_number()]<0?tr_indent[cpu_number()]=0:0);
166 #endif /* NCPUS == 1 */
168 extern void tr_init(void);
179 extern void db_show_tr(
185 #else /* TRACE_BUFFER */
188 #define TR_SHOW(a,b,c)
189 #define TR_DECL(funcname)
191 #define tr2(msg, tag1)
192 #define tr3(msg, tag1, tag2)
193 #define tr4(msg, tag1, tag2, tag3)
194 #define tr5(msg, tag1, tag2, tag3, tag4)
198 #endif /* TRACE_BUFFER */
200 #endif /* _DDB_TR_H_ */