]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ddb/tr.h
xnu-517.3.7.tar.gz
[apple/xnu.git] / osfmk / ddb / tr.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
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
13 * file.
14 *
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 */
28/*
29 * HISTORY
30 *
31 * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
32 * Import of Mac OS X kernel (~semeria)
33 *
34 * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
35 * Import of OSF Mach kernel (~mburg)
36 *
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.
41 * [95/10/09 rwd]
42 * Added TR_INIT() macro.
43 * Change from NMK16.1 [93/09/22 paire]
44 * [94/02/04 paire]
45 * [97/02/25 barbou]
46 *
47 * Revision 1.1.6.1 1995/02/23 16:34:23 alanl
48 * Taken from DIPC2_SHARED. Change to !FREE Copyright.
49 * [95/01/05 rwd]
50 *
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]
57 *
58 * Revision 1.1.4.3 1994/08/08 17:59:35 rwd
59 * Include mach_tr.h
60 * [94/08/08 rwd]
61 *
62 * Revision 1.1.4.2 1994/08/05 19:36:08 mmp
63 * Added prototype for db_show_tr.
64 *
65 * Conditionalize on MACH_TR
66 * [94/07/20 rwd]
67 *
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]
71 *
72 * Revision 1.1.9.1 1994/03/07 16:55:24 paire
73 * Added ANSI prototypes.
74 * [94/02/15 paire]
75 *
76 * Added TR_INIT() macro.
77 * Change from NMK16.1 [93/09/22 paire]
78 * [94/02/04 paire]
79 *
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]
83 *
84 * Revision 1.1 1992/09/30 02:34:09 robert
85 * Initial revision
86 *
87 * $EndLog$
88 */
89
90/*
91 * File: ddb/tr.h
92 * Author: Alan Langerman, Jeffrey Heller
93 * Date: 1992
94 *
95 * Internal trace routines. Like old-style XPRs but
96 * less formatting.
97 */
98
99#include <mach_assert.h>
100#include <mach_tr.h>
101
102#include <kern/cpu_number.h>
103
104/*
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
109 * orthogonal.
110 */
111#define TRACE_BUFFER (MACH_TR)
112
113/*
114 * Log events in a circular trace buffer for future debugging.
115 * Events are unsigned integers. Each event has a descriptive
116 * message.
117 *
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
125 * is turned off.
126 */
127#ifndef _DDB_TR_H_
128#define _DDB_TR_H_
129
130#if TRACE_BUFFER
131
132#include <machine/db_machdep.h>
133
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
138#define tr1(msg) \
139 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
140 0,0,0,0)
141#define tr2(msg,tag1) \
142 tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \
143 __ui__(tag1),0,0,0)
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))
153
154/*
155 * Adjust tr log indentation based on function
156 * call graph.
157 */
158#if NCPUS == 1
159extern int tr_indent;
160#define tr_start() tr_indent++
161#define tr_stop() tr_indent--
162#else /* NCPUS == 1 */
163extern 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 */
167
168extern void tr_init(void);
169extern void tr(
170 char *funcname,
171 char *file,
172 unsigned int lineno,
173 char *fmt,
174 unsigned int tag1,
175 unsigned int tag2,
176 unsigned int tag3,
177 unsigned int tag4);
178
179extern void db_show_tr(
180 db_expr_t addr,
181 boolean_t have_addr,
182 db_expr_t count,
183 char * modif);
184
185#else /* TRACE_BUFFER */
186
187#define TR_INIT()
188#define TR_SHOW(a,b,c)
189#define TR_DECL(funcname)
190#define tr1(msg)
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)
195#define tr_start()
196#define tr_stop()
197
198#endif /* TRACE_BUFFER */
199
200#endif /* _DDB_TR_H_ */