annotate usr/src/uts/common/sys/debug.h @ 13765:9410cf539b11

backout 3006: causes 3046 (panics after mounting root)
author Richard Lowe <richlowe@richlowe.net>
date Wed, 01 Aug 2012 16:40:39 -0400
parents 38b4aca480b3
children e3a9ae14a119
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
1 /*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
2 * CDDL HEADER START
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
3 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
8269
03a7e9050cfd 6674216 "zfs share" doesn't work, but "zfs set sharenfs=on" does
Mark J Musante <Mark.Musante@Sun.COM>
parents: 1110
diff changeset
5 * Common Development and Distribution License (the "License").
03a7e9050cfd 6674216 "zfs share" doesn't work, but "zfs set sharenfs=on" does
Mark J Musante <Mark.Musante@Sun.COM>
parents: 1110
diff changeset
6 * You may not use this file except in compliance with the License.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
7 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
10 * See the License for the specific language governing permissions
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
11 * and limitations under the License.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
12 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
18 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
19 * CDDL HEADER END
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
20 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
21 /*
11474
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
23 * Use is subject to license terms.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
24 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
25
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
27 /* All Rights Reserved */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
28
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
29 #ifndef _SYS_DEBUG_H
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
30 #define _SYS_DEBUG_H
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
31
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
32 #include <sys/isa_defs.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
33 #include <sys/types.h>
11173
87f3734e64df 6881015 ZFS write activity prevents other threads from running in a timely manner
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 8269
diff changeset
34 #include <sys/note.h>
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
35
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
36 #ifdef __cplusplus
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
37 extern "C" {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
38 #endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
39
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
40 /*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
41 * ASSERT(ex) causes a panic or debugger entry if expression ex is not
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
42 * true. ASSERT() is included only for debugging, and is a no-op in
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
43 * production kernels. VERIFY(ex), on the other hand, behaves like
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
44 * ASSERT and is evaluated on both debug and non-debug kernels.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
45 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
46
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
47 #if defined(__STDC__)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
48 extern int assfail(const char *, const char *, int);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
49 #define VERIFY(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__)))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
50 #if DEBUG
8269
03a7e9050cfd 6674216 "zfs share" doesn't work, but "zfs set sharenfs=on" does
Mark J Musante <Mark.Musante@Sun.COM>
parents: 1110
diff changeset
51 #define ASSERT(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__)))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
52 #else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
53 #define ASSERT(x) ((void)0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
54 #endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
55 #else /* defined(__STDC__) */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
56 extern int assfail();
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
57 #define VERIFY(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__)))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
58 #if DEBUG
8269
03a7e9050cfd 6674216 "zfs share" doesn't work, but "zfs set sharenfs=on" does
Mark J Musante <Mark.Musante@Sun.COM>
parents: 1110
diff changeset
59 #define ASSERT(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__)))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
60 #else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
61 #define ASSERT(x) ((void)0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
62 #endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
63 #endif /* defined(__STDC__) */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
64
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
65 /*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
66 * Assertion variants sensitive to the compilation data model
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
67 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
68 #if defined(_LP64)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
69 #define ASSERT64(x) ASSERT(x)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
70 #define ASSERT32(x)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
71 #else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
72 #define ASSERT64(x)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
73 #define ASSERT32(x) ASSERT(x)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
74 #endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
75
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
76 /*
11474
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
77 * IMPLY and EQUIV are assertions of the form:
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
78 *
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
79 * if (a) then (b)
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
80 * and
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
81 * if (a) then (b) *AND* if (b) then (a)
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
82 */
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
83 #if DEBUG
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
84 #define IMPLY(A, B) \
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
85 ((void)(((!(A)) || (B)) || \
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
86 assfail("(" #A ") implies (" #B ")", __FILE__, __LINE__)))
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
87 #define EQUIV(A, B) \
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
88 ((void)((!!(A) == !!(B)) || \
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
89 assfail("(" #A ") is equivalent to (" #B ")", __FILE__, __LINE__)))
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
90 #else
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
91 #define IMPLY(A, B) ((void)0)
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
92 #define EQUIV(A, B) ((void)0)
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
93 #endif
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
94
857f9db4ef05 4517853 debug.h should include macros to assert implication and equivalence
Jonathan Adams <Jonathan.Adams@Sun.COM>
parents: 11173
diff changeset
95 /*
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
96 * ASSERT3() behaves like ASSERT() except that it is an explicit conditional,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
97 * and prints out the values of the left and right hand expressions as part of
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
98 * the panic message to ease debugging. The three variants imply the type
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
99 * of their arguments. ASSERT3S() is for signed data types, ASSERT3U() is
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
100 * for unsigned, and ASSERT3P() is for pointers. The VERIFY3*() macros
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
101 * have the same relationship as above.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
102 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
103 extern void assfail3(const char *, uintmax_t, const char *, uintmax_t,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
104 const char *, int);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
105 #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
106 const TYPE __left = (TYPE)(LEFT); \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
107 const TYPE __right = (TYPE)(RIGHT); \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
108 if (!(__left OP __right)) \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
109 assfail3(#LEFT " " #OP " " #RIGHT, \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
110 (uintmax_t)__left, #OP, (uintmax_t)__right, \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
111 __FILE__, __LINE__); \
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
112 _NOTE(CONSTCOND) } while (0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
113
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
114 #define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
115 #define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
116 #define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
117 #if DEBUG
8269
03a7e9050cfd 6674216 "zfs share" doesn't work, but "zfs set sharenfs=on" does
Mark J Musante <Mark.Musante@Sun.COM>
parents: 1110
diff changeset
118 #define ASSERT3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t)
03a7e9050cfd 6674216 "zfs share" doesn't work, but "zfs set sharenfs=on" does
Mark J Musante <Mark.Musante@Sun.COM>
parents: 1110
diff changeset
119 #define ASSERT3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t)
03a7e9050cfd 6674216 "zfs share" doesn't work, but "zfs set sharenfs=on" does
Mark J Musante <Mark.Musante@Sun.COM>
parents: 1110
diff changeset
120 #define ASSERT3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
121 #else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
122 #define ASSERT3S(x, y, z) ((void)0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
123 #define ASSERT3U(x, y, z) ((void)0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
124 #define ASSERT3P(x, y, z) ((void)0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
125 #endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents: 0
diff changeset
126
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
127 #ifdef _KERNEL
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
128
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
129 extern void abort_sequence_enter(char *);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
130 extern void debug_enter(char *);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
131
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
132 #endif /* _KERNEL */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
133
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
134 #if defined(DEBUG) && !defined(__sun)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
135 /* CSTYLED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
136 #define STATIC
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
137 #else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
138 /* CSTYLED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
139 #define STATIC static
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
140 #endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
141
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
142 #ifdef __cplusplus
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
143 }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
144 #endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
145
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
146 #endif /* _SYS_DEBUG_H */