00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _DB_DEBUG_H_
00011 #define _DB_DEBUG_H_
00012
00013 #if defined(__cplusplus)
00014 extern "C" {
00015 #endif
00016
00017
00018
00019
00020 #if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
00021 #define __attribute__(s)
00022 #endif
00023
00024
00025
00026
00027
00028 #define CLEAR_BYTE 0xdb
00029 #define GUARD_BYTE 0xdc
00030
00031
00032
00033
00034
00035
00036 #if defined(__STDC__) && defined(DIAGNOSTIC)
00037 #define DB_ASSERT(e) ((e) ? (void)0 : __db_assert(#e, __FILE__, __LINE__))
00038 #else
00039 #define DB_ASSERT(e)
00040 #endif
00041
00042
00043
00044
00045
00046
00047
00048 #define COMPQUIET(n, v) \
00049 (n) = (v); \
00050 (n) = (n)
00051
00052
00053
00054
00055
00056
00057 #ifdef UMRW
00058 #define UMRW_SET(v) (v) = 0
00059 #else
00060 #define UMRW_SET(v)
00061 #endif
00062
00063
00064
00065
00066
00067
00068
00069 #if defined(STDC_HEADERS) || defined(__cplusplus)
00070 #define DB_REAL_ERR(env, error, error_set, default_stream, fmt) { \
00071 va_list ap; \
00072 \
00073 \
00074 va_start(ap, fmt); \
00075 if ((env) != NULL && (env)->db_errcall != NULL) \
00076 __db_errcall(env, error, error_set, fmt, ap); \
00077 va_end(ap); \
00078 \
00079 \
00080 va_start(ap, fmt); \
00081 if ((env) != NULL && (env)->db_errfile != NULL) \
00082 __db_errfile(env, error, error_set, fmt, ap); \
00083 va_end(ap); \
00084 \
00085
00086
00087
00088 \
00089 va_start(ap, fmt); \
00090 if ((default_stream) && ((env) == NULL || \
00091 ((env)->db_errcall == NULL && (env)->db_errfile == NULL))) \
00092 __db_errfile(env, error, error_set, fmt, ap); \
00093 va_end(ap); \
00094 }
00095 #else
00096 #define DB_REAL_ERR(env, error, error_set, default_stream, fmt) { \
00097 va_list ap; \
00098 \
00099 \
00100 va_start(ap); \
00101 if ((env) != NULL && (env)->db_errcall != NULL) \
00102 __db_errcall(env, error, error_set, fmt, ap); \
00103 va_end(ap); \
00104 \
00105 \
00106 va_start(ap); \
00107 if ((env) != NULL && (env)->db_errfile != NULL) \
00108 __db_errfile(env, error, error_set, fmt, ap); \
00109 va_end(ap); \
00110 \
00111
00112
00113
00114 \
00115 va_start(ap); \
00116 if ((default_stream) && ((env) == NULL || \
00117 ((env)->db_errcall == NULL && (env)->db_errfile == NULL))) \
00118 __db_errfile(env, error, error_set, fmt, ap); \
00119 va_end(ap); \
00120 }
00121 #endif
00122 #if defined(STDC_HEADERS) || defined(__cplusplus)
00123 #define DB_REAL_MSG(env, fmt) { \
00124 va_list ap; \
00125 \
00126 \
00127 va_start(ap, fmt); \
00128 if ((env) != NULL && (env)->db_msgcall != NULL) \
00129 __db_msgcall(env, fmt, ap); \
00130 va_end(ap); \
00131 \
00132
00133
00134
00135
00136 \
00137 va_start(ap, fmt); \
00138 if ((env) == NULL || \
00139 (env)->db_msgfile != NULL || (env)->db_msgcall == NULL) { \
00140 __db_msgfile(env, fmt, ap); \
00141 } \
00142 va_end(ap); \
00143 }
00144 #else
00145 #define DB_REAL_MSG(env, fmt) { \
00146 va_list ap; \
00147 \
00148 \
00149 va_start(ap); \
00150 if ((env) != NULL && (env)->db_msgcall != NULL) \
00151 __db_msgcall(env, fmt, ap); \
00152 va_end(ap); \
00153 \
00154
00155
00156
00157
00158 \
00159 va_start(ap); \
00160 if ((env) == NULL || \
00161 (env)->db_msgfile != NULL || (env)->db_msgcall == NULL) { \
00162 __db_msgfile(env, fmt, ap); \
00163 } \
00164 va_end(ap); \
00165 }
00166 #endif
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 #define LOG_OP(C, T, O, K, A, F) { \
00181 DB_LSN __lsn; \
00182 DBT __op; \
00183 if (DBC_LOGGING((C))) { \
00184 memset(&__op, 0, sizeof(__op)); \
00185 __op.data = O; \
00186 __op.size = strlen(O) + 1; \
00187 (void)__db_debug_log((C)->dbp->dbenv, T, &__lsn, 0, \
00188 &__op, (C)->dbp->log_filename->id, K, A, F); \
00189 } \
00190 }
00191 #ifdef DEBUG_ROP
00192 #define DEBUG_LREAD(C, T, O, K, A, F) LOG_OP(C, T, O, K, A, F)
00193 #else
00194 #define DEBUG_LREAD(C, T, O, K, A, F)
00195 #endif
00196 #ifdef DEBUG_WOP
00197 #define DEBUG_LWRITE(C, T, O, K, A, F) LOG_OP(C, T, O, K, A, F)
00198 #else
00199 #define DEBUG_LWRITE(C, T, O, K, A, F)
00200 #endif
00201
00202
00203
00204
00205
00206 #if CONFIG_TEST
00207 #define DB_TEST_SUBLOCKS(env, flags) do { \
00208 if ((env)->test_abort == DB_TEST_SUBDB_LOCKS) \
00209 (flags) |= DB_LOCK_NOWAIT; \
00210 } while (0)
00211
00212 #define DB_ENV_TEST_RECOVERY(env, val, ret, name) do { \
00213 int __ret; \
00214 PANIC_CHECK((env)); \
00215 if ((env)->test_copy == (val)) { \
00216 \
00217 if ((__ret = __db_testcopy((env), NULL, (name))) != 0) \
00218 (ret) = __db_panic((env), __ret); \
00219 } \
00220 if ((env)->test_abort == (val)) { \
00221 \
00222 (env)->test_abort = 0; \
00223 (ret) = EINVAL; \
00224 goto db_tr_err; \
00225 } \
00226 } while (0)
00227
00228 #define DB_TEST_RECOVERY(dbp, val, ret, name) do { \
00229 int __ret; \
00230 PANIC_CHECK((dbp)->dbenv); \
00231 if ((dbp)->dbenv->test_copy == (val)) { \
00232 \
00233 if (F_ISSET((dbp), \
00234 DB_AM_OPEN_CALLED) && (dbp)->mpf != NULL) \
00235 (void)__db_sync(dbp); \
00236 if ((__ret = \
00237 __db_testcopy((dbp)->dbenv, (dbp), (name))) != 0) \
00238 (ret) = __db_panic((dbp)->dbenv, __ret); \
00239 } \
00240 if ((dbp)->dbenv->test_abort == (val)) { \
00241 \
00242 (dbp)->dbenv->test_abort = 0; \
00243 (ret) = EINVAL; \
00244 goto db_tr_err; \
00245 } \
00246 } while (0)
00247
00248 #define DB_TEST_RECOVERY_LABEL db_tr_err:
00249
00250 #define DB_TEST_WAIT(env, val) \
00251 if ((val) != 0) \
00252 __os_sleep((env), (u_long)(val), 0)
00253 #else
00254 #define DB_TEST_SUBLOCKS(env, flags)
00255 #define DB_ENV_TEST_RECOVERY(env, val, ret, name)
00256 #define DB_TEST_RECOVERY(dbp, val, ret, name)
00257 #define DB_TEST_RECOVERY_LABEL
00258 #define DB_TEST_WAIT(env, val)
00259 #endif
00260
00261 #if defined(__cplusplus)
00262 }
00263 #endif
00264 #endif