debug.h

Go to the documentation of this file.
00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1998, 1999, 2000
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: debug_8h-source.html,v 1.1 2008/06/08 10:18:34 sebdiaz Exp $
00008  */
00009 
00010 #if defined(__cplusplus)
00011 extern "C" {
00012 #endif
00013 
00014 /*
00015  * When running with #DIAGNOSTIC defined, we smash memory and do memory
00016  * guarding with a special byte value.
00017  */
00018 #define CLEAR_BYTE      0xdb
00019 #define GUARD_BYTE      0xdc
00020 
00021 /*
00022  * DB assertions.
00023  */
00024 #if defined(DIAGNOSTIC) && defined(__STDC__)
00025 #define DB_ASSERT(e)    ((e) ? (void)0 : __db_assert(#e, __FILE__, __LINE__))
00026 #else
00027 #define DB_ASSERT(e)    ((void)0)
00028 #endif
00029 
00030 /*
00031  * Purify and similar run-time tools complain about unitialized reads/writes
00032  * for structure fields whose only purpose is padding.
00033  */
00034 #define UMRW(v)         (v) = 0
00035 
00036 /*
00037  * Debugging macro to log operations.
00038  *      If DEBUG_WOP is defined, log operations that modify the database.
00039  *      If DEBUG_ROP is defined, log operations that read the database.
00040  *
00041  * D dbp
00042  * T txn
00043  * O operation (string)
00044  * K key
00045  * A data
00046  * F flags
00047  */
00048 #define LOG_OP(C, T, O, K, A, F) {                                      \
00049         DB_LSN __lsn;                                                   \
00050         DBT __op;                                                       \
00051         if (DB_LOGGING((C))) {                                          \
00052                 memset(&__op, 0, sizeof(__op));                         \
00053                 __op.data = O;                                          \
00054                 __op.size = strlen(O) + 1;                              \
00055                 (void)CDB___db_debug_log((C)->dbp->dbenv,                       \
00056                     T, &__lsn, 0, &__op, (C)->dbp->log_fileid, K, A, F);\
00057         }                                                               \
00058 }
00059 #ifdef  DEBUG_ROP
00060 #define DEBUG_LREAD(C, T, O, K, A, F)   LOG_OP(C, T, O, K, A, F)
00061 #else
00062 #define DEBUG_LREAD(C, T, O, K, A, F)
00063 #endif
00064 #ifdef  DEBUG_WOP
00065 #define DEBUG_LWRITE(C, T, O, K, A, F)  LOG_OP(C, T, O, K, A, F)
00066 #else
00067 #define DEBUG_LWRITE(C, T, O, K, A, F)
00068 #endif
00069 
00070 /*
00071  * Hook for testing recovery at various places in the create/delete paths.
00072  */
00073 #if CONFIG_TEST
00074 #define DB_TEST_RECOVERY(dbp, val, ret, name)                           \
00075 do {                                                                    \
00076         int __ret;                                                      \
00077         PANIC_CHECK((dbp)->dbenv);                                      \
00078         if ((dbp)->dbenv->test_copy == (val)) {                         \
00079                 /* COPY the FILE */                                     \
00080                 if (F_ISSET((dbp), DB_OPEN_CALLED) && (dbp)->mpf != NULL) \
00081                         (void)(dbp)->sync((dbp), 0);                    \
00082                 if ((__ret = __db_testcopy((dbp), (name))) != 0)        \
00083                         (ret) = CDB___db_panic((dbp)->dbenv, __ret);    \
00084         }                                                               \
00085         if ((dbp)->dbenv->test_abort == (val)) {                        \
00086                 /* ABORT the TXN */                                     \
00087                 (ret) = EINVAL;                                         \
00088                 goto db_tr_err;                                         \
00089         }                                                               \
00090 } while (0)
00091 #define DB_TEST_RECOVERY_LABEL  db_tr_err:
00092 #else
00093 #define DB_TEST_RECOVERY(dbp, val, ret, name)
00094 #define DB_TEST_RECOVERY_LABEL
00095 #endif
00096 
00097 #if defined(__cplusplus)
00098 }
00099 #endif

Generated on Sun Jun 8 10:56:37 2008 for GNUmifluz by  doxygen 1.5.5