]>
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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
28 * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
29 * Import of Mac OS X kernel (~semeria)
31 * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
32 * Import of OSF Mach kernel (~mburg)
34 * Revision 1.1.11.1 1997/03/27 18:47:01 barbou
35 * Merge smp_shared merges into mainline.
36 * [1996/09/19 13:55:17 addis]
37 * Make tr_indent NCPU safe.
39 * Added TR_INIT() macro.
40 * Change from NMK16.1 [93/09/22 paire]
44 * Revision 1.1.6.1 1995/02/23 16:34:23 alanl
45 * Taken from DIPC2_SHARED. Change to !FREE Copyright.
48 * Revision 1.1.4.4 1994/08/18 01:07:26 alanl
49 * + Allow tracing strictly based on MACH_TR;
50 * don't also require MACH_ASSERT (alanl).
51 * + ANSI-fication: cast tr arguments (alanl).
52 * + Added tr_indent and macros to use it (sjs).
53 * [1994/08/18 01:06:09 alanl]
55 * Revision 1.1.4.3 1994/08/08 17:59:35 rwd
59 * Revision 1.1.4.2 1994/08/05 19:36:08 mmp
60 * Added prototype for db_show_tr.
62 * Conditionalize on MACH_TR
65 * Revision 1.1.4.1 1994/08/04 01:43:04 mmp
66 * DIPC: moved from norma/ to ddb/. Updated includes.
67 * [1994/08/03 13:37:46 mmp]
69 * Revision 1.1.9.1 1994/03/07 16:55:24 paire
70 * Added ANSI prototypes.
73 * Added TR_INIT() macro.
74 * Change from NMK16.1 [93/09/22 paire]
77 * Revision 1.1.2.2 1993/06/02 23:57:10 jeffc
78 * Added to OSF/1 R1.3 from NMK15.0.
79 * [1993/06/02 21:22:08 jeffc]
81 * Revision 1.1 1992/09/30 02:34:09 robert
89 * Author: Alan Langerman, Jeffrey Heller
92 * Internal trace routines. Like old-style XPRs but
96 #include <mach_assert.h>
99 #include <kern/cpu_number.h>
102 * Originally, we only wanted tracing when
103 * MACH_TR and MACH_ASSERT were turned on
104 * together. Now, there's no reason why
105 * MACH_TR and MACH_ASSERT can't be completely
108 #define TRACE_BUFFER (MACH_TR)
111 * Log events in a circular trace buffer for future debugging.
112 * Events are unsigned integers. Each event has a descriptive
115 * TR_DECL must be used at the beginning of a routine using
116 * one of the tr calls. The macro should be passed the name
117 * of the function surrounded by quotation marks, e.g.,
118 * TR_DECL("netipc_recv_intr");
119 * and should be terminated with a semi-colon. The TR_DECL
120 * must be the *last* declaration in the variable declaration
121 * list, or syntax errors will be introduced when TRACE_BUFFER
129 #include <machine/db_machdep.h>
131 #define __ui__ (unsigned int)
132 #define TR_INIT() tr_init()
133 #define TR_SHOW(a,b,c) show_tr((a),(b),(c))
134 #define TR_DECL(funcname) char *__ntr_func_name__ = funcname
136 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
138 #define tr2(msg,tag1) \
139 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
141 #define tr3(msg,tag1,tag2) \
142 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
143 __ui__(tag1),__ui__(tag2),0,0)
144 #define tr4(msg,tag1,tag2,tag3) \
145 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
146 __ui__(tag1),__ui__(tag2),__ui__(tag3),0)
147 #define tr5(msg,tag1,tag2,tag3,tag4) \
148 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
149 __ui__(tag1),__ui__(tag2),__ui__(tag3),__ui__(tag4))
152 * Adjust tr log indentation based on function
156 extern int tr_indent
;
157 #define tr_start() tr_indent++
158 #define tr_stop() tr_indent--
159 #else /* NCPUS == 1 */
160 extern int tr_indent
[NCPUS
];
161 #define tr_start() tr_indent[cpu_number()]++
162 #define tr_stop() (--tr_indent[cpu_number()]<0?tr_indent[cpu_number()]=0:0);
163 #endif /* NCPUS == 1 */
165 extern void tr_init(void);
176 extern void db_show_tr(
182 #else /* TRACE_BUFFER */
185 #define TR_SHOW(a,b,c)
186 #define TR_DECL(funcname)
188 #define tr2(msg, tag1)
189 #define tr3(msg, tag1, tag2)
190 #define tr4(msg, tag1, tag2, tag3)
191 #define tr5(msg, tag1, tag2, tag3, tag4)
195 #endif /* TRACE_BUFFER */
197 #endif /* _DDB_TR_H_ */