2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1998-2002
5
* Sleepycat Software. All rights reserved.
13
#if defined(__cplusplus)
18
* When running with #DIAGNOSTIC defined, we smash memory and do memory
19
* guarding with a special byte value.
21
#define CLEAR_BYTE 0xdb
22
#define GUARD_BYTE 0xdc
27
#if defined(DIAGNOSTIC) && defined(__STDC__)
28
#define DB_ASSERT(e) ((e) ? (void)0 : __db_assert(#e, __FILE__, __LINE__))
34
* Purify and other run-time tools complain about uninitialized reads/writes
35
* of structure fields whose only purpose is padding, as well as when heap
36
* memory that was never initialized is written to disk.
39
#define UMRW_SET(v) (v) = 0
45
* Error message handling. Use a macro instead of a function because va_list
46
* references to variadic arguments cannot be reset to the beginning of the
47
* variadic argument list (and then rescanned), by functions other than the
48
* original routine that took the variadic list of arguments.
50
#if defined(__STDC__) || defined(__cplusplus)
51
#define DB_REAL_ERR(env, error, error_set, stderr_default, fmt) { \
54
/* Call the user's callback function, if specified. */ \
56
if ((env) != NULL && (env)->db_errcall != NULL) \
57
__db_errcall(env, error, error_set, fmt, ap); \
60
/* Write to the user's file descriptor, if specified. */ \
62
if ((env) != NULL && (env)->db_errfile != NULL) \
63
__db_errfile(env, error, error_set, fmt, ap); \
67
* If we have a default and we didn't do either of the above, \
68
* write to the default. \
71
if ((stderr_default) && ((env) == NULL || \
72
((env)->db_errcall == NULL && (env)->db_errfile == NULL))) \
73
__db_errfile(env, error, error_set, fmt, ap); \
77
#define DB_REAL_ERR(env, error, error_set, stderr_default, fmt) { \
80
/* Call the user's callback function, if specified. */ \
82
if ((env) != NULL && (env)->db_errcall != NULL) \
83
__db_errcall(env, error, error_set, fmt, ap); \
86
/* Write to the user's file descriptor, if specified. */ \
88
if ((env) != NULL && (env)->db_errfile != NULL) \
89
__db_errfile(env, error, error_set, fmt, ap); \
93
* If we have a default and we didn't do either of the above, \
94
* write to the default. \
97
if ((stderr_default) && ((env) == NULL || \
98
((env)->db_errcall == NULL && (env)->db_errfile == NULL))) \
99
__db_errfile(env, error, error_set, fmt, ap); \
105
* Debugging macro to log operations.
106
* If DEBUG_WOP is defined, log operations that modify the database.
107
* If DEBUG_ROP is defined, log operations that read the database.
111
* O operation (string)
116
#define LOG_OP(C, T, O, K, A, F) { \
119
if (DBC_LOGGING((C))) { \
120
memset(&__op, 0, sizeof(__op)); \
122
__op.size = strlen(O) + 1; \
123
(void)__db_debug_log((C)->dbp->dbenv, T, &__lsn, 0, \
124
&__op, (C)->dbp->log_filename->id, K, A, F); \
128
#define DEBUG_LREAD(C, T, O, K, A, F) LOG_OP(C, T, O, K, A, F)
130
#define DEBUG_LREAD(C, T, O, K, A, F)
133
#define DEBUG_LWRITE(C, T, O, K, A, F) LOG_OP(C, T, O, K, A, F)
135
#define DEBUG_LWRITE(C, T, O, K, A, F)
139
* Hook for testing recovery at various places in the create/delete paths.
140
* Hook for testing subdb locks.
143
#define DB_TEST_SUBLOCKS(env, flags) \
145
if ((env)->test_abort == DB_TEST_SUBDB_LOCKS) \
146
(flags) |= DB_LOCK_NOWAIT; \
149
#define DB_ENV_TEST_RECOVERY(env, val, ret, name) \
152
PANIC_CHECK((env)); \
153
if ((env)->test_copy == (val)) { \
154
/* COPY the FILE */ \
155
if ((__ret = __db_testcopy((env), NULL, (name))) != 0) \
156
(ret) = __db_panic((env), __ret); \
158
if ((env)->test_abort == (val)) { \
159
/* ABORT the TXN */ \
160
(env)->test_abort = 0; \
166
#define DB_TEST_RECOVERY(dbp, val, ret, name) \
169
PANIC_CHECK((dbp)->dbenv); \
170
if ((dbp)->dbenv->test_copy == (val)) { \
171
/* Copy the file. */ \
173
DB_AM_OPEN_CALLED) && (dbp)->mpf != NULL) \
174
(void)(dbp)->sync((dbp), 0); \
176
__db_testcopy((dbp)->dbenv, (dbp), (name))) != 0) \
177
(ret) = __db_panic((dbp)->dbenv, __ret); \
179
if ((dbp)->dbenv->test_abort == (val)) { \
180
/* Abort the transaction. */ \
181
(dbp)->dbenv->test_abort = 0; \
187
#define DB_TEST_RECOVERY_LABEL db_tr_err:
189
#define DB_TEST_SUBLOCKS(env, flags)
190
#define DB_ENV_TEST_RECOVERY(env, val, ret, name)
191
#define DB_TEST_RECOVERY(dbp, val, ret, name)
192
#define DB_TEST_RECOVERY_LABEL
195
#if defined(__cplusplus)
198
#endif /* !_DB_DEBUG_H_ */