~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/dbinc/debug.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-
2
 
 * See the file LICENSE for redistribution information.
3
 
 *
4
 
 * Copyright (c) 1998-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 *
7
 
 * $Id$
8
 
 */
9
 
 
10
 
#ifndef _DB_DEBUG_H_
11
 
#define _DB_DEBUG_H_
12
 
 
13
 
#if defined(__cplusplus)
14
 
extern "C" {
15
 
#endif
16
 
 
17
 
/*
18
 
 * When running with #DIAGNOSTIC defined, we smash memory and do memory
19
 
 * guarding with a special byte value.
20
 
 */
21
 
#define CLEAR_BYTE      0xdb
22
 
#define GUARD_BYTE      0xdc
23
 
 
24
 
/*
25
 
 * DB assertions.
26
 
 */
27
 
#if defined(DIAGNOSTIC) && defined(__STDC__)
28
 
#define DB_ASSERT(e)    ((e) ? (void)0 : __db_assert(#e, __FILE__, __LINE__))
29
 
#else
30
 
#define DB_ASSERT(e)
31
 
#endif
32
 
 
33
 
/*
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.
37
 
 */
38
 
#ifdef  UMRW
39
 
#define UMRW_SET(v)     (v) = 0
40
 
#else
41
 
#define UMRW_SET(v)
42
 
#endif
43
 
 
44
 
/*
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.
49
 
 */
50
 
#if defined(__STDC__) || defined(__cplusplus)
51
 
#define DB_REAL_ERR(env, error, error_set, stderr_default, fmt) {       \
52
 
        va_list ap;                                                     \
53
 
                                                                        \
54
 
        /* Call the user's callback function, if specified. */          \
55
 
        va_start(ap, fmt);                                              \
56
 
        if ((env) != NULL && (env)->db_errcall != NULL)                 \
57
 
                __db_errcall(env, error, error_set, fmt, ap);           \
58
 
        va_end(ap);                                                     \
59
 
                                                                        \
60
 
        /* Write to the user's file descriptor, if specified. */        \
61
 
        va_start(ap, fmt);                                              \
62
 
        if ((env) != NULL && (env)->db_errfile != NULL)                 \
63
 
                __db_errfile(env, error, error_set, fmt, ap);           \
64
 
        va_end(ap);                                                     \
65
 
                                                                        \
66
 
        /*                                                              \
67
 
         * If we have a default and we didn't do either of the above,   \
68
 
         * write to the default.                                        \
69
 
         */                                                             \
70
 
        va_start(ap, fmt);                                              \
71
 
        if ((stderr_default) && ((env) == NULL ||                       \
72
 
            ((env)->db_errcall == NULL && (env)->db_errfile == NULL)))  \
73
 
                __db_errfile(env, error, error_set, fmt, ap);           \
74
 
        va_end(ap);                                                     \
75
 
}
76
 
#else
77
 
#define DB_REAL_ERR(env, error, error_set, stderr_default, fmt) {       \
78
 
        va_list ap;                                                     \
79
 
                                                                        \
80
 
        /* Call the user's callback function, if specified. */          \
81
 
        va_start(ap);                                                   \
82
 
        if ((env) != NULL && (env)->db_errcall != NULL)                 \
83
 
                __db_errcall(env, error, error_set, fmt, ap);           \
84
 
        va_end(ap);                                                     \
85
 
                                                                        \
86
 
        /* Write to the user's file descriptor, if specified. */        \
87
 
        va_start(ap);                                                   \
88
 
        if ((env) != NULL && (env)->db_errfile != NULL)                 \
89
 
                __db_errfile(env, error, error_set, fmt, ap);           \
90
 
        va_end(ap);                                                     \
91
 
                                                                        \
92
 
        /*                                                              \
93
 
         * If we have a default and we didn't do either of the above,   \
94
 
         * write to the default.                                        \
95
 
         */                                                             \
96
 
        va_start(ap);                                                   \
97
 
        if ((stderr_default) && ((env) == NULL ||                       \
98
 
            ((env)->db_errcall == NULL && (env)->db_errfile == NULL)))  \
99
 
                __db_errfile(env, error, error_set, fmt, ap);           \
100
 
        va_end(ap);                                                     \
101
 
}
102
 
#endif
103
 
 
104
 
/*
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.
108
 
 *
109
 
 * D dbp
110
 
 * T txn
111
 
 * O operation (string)
112
 
 * K key
113
 
 * A data
114
 
 * F flags
115
 
 */
116
 
#define LOG_OP(C, T, O, K, A, F) {                                      \
117
 
        DB_LSN __lsn;                                                   \
118
 
        DBT __op;                                                       \
119
 
        if (DBC_LOGGING((C))) {                                         \
120
 
                memset(&__op, 0, sizeof(__op));                         \
121
 
                __op.data = O;                                          \
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);        \
125
 
        }                                                               \
126
 
}
127
 
#ifdef  DEBUG_ROP
128
 
#define DEBUG_LREAD(C, T, O, K, A, F)   LOG_OP(C, T, O, K, A, F)
129
 
#else
130
 
#define DEBUG_LREAD(C, T, O, K, A, F)
131
 
#endif
132
 
#ifdef  DEBUG_WOP
133
 
#define DEBUG_LWRITE(C, T, O, K, A, F)  LOG_OP(C, T, O, K, A, F)
134
 
#else
135
 
#define DEBUG_LWRITE(C, T, O, K, A, F)
136
 
#endif
137
 
 
138
 
/*
139
 
 * Hook for testing recovery at various places in the create/delete paths.
140
 
 * Hook for testing subdb locks.
141
 
 */
142
 
#if CONFIG_TEST
143
 
#define DB_TEST_SUBLOCKS(env, flags)                                    \
144
 
do {                                                                    \
145
 
        if ((env)->test_abort == DB_TEST_SUBDB_LOCKS)                   \
146
 
                (flags) |= DB_LOCK_NOWAIT;                              \
147
 
} while (0)
148
 
 
149
 
#define DB_ENV_TEST_RECOVERY(env, val, ret, name)                       \
150
 
do {                                                                    \
151
 
        int __ret;                                                      \
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);               \
157
 
        }                                                               \
158
 
        if ((env)->test_abort == (val)) {                               \
159
 
                /* ABORT the TXN */                                     \
160
 
                (env)->test_abort = 0;                                  \
161
 
                (ret) = EINVAL;                                         \
162
 
                goto db_tr_err;                                         \
163
 
        }                                                               \
164
 
} while (0)
165
 
 
166
 
#define DB_TEST_RECOVERY(dbp, val, ret, name)                           \
167
 
do {                                                                    \
168
 
        int __ret;                                                      \
169
 
        PANIC_CHECK((dbp)->dbenv);                                      \
170
 
        if ((dbp)->dbenv->test_copy == (val)) {                         \
171
 
                /* Copy the file. */                                    \
172
 
                if (F_ISSET((dbp),                                      \
173
 
                    DB_AM_OPEN_CALLED) && (dbp)->mpf != NULL)           \
174
 
                        (void)(dbp)->sync((dbp), 0);                    \
175
 
                if ((__ret =                                            \
176
 
                    __db_testcopy((dbp)->dbenv, (dbp), (name))) != 0)   \
177
 
                        (ret) = __db_panic((dbp)->dbenv, __ret);        \
178
 
        }                                                               \
179
 
        if ((dbp)->dbenv->test_abort == (val)) {                        \
180
 
                /* Abort the transaction. */                            \
181
 
                (dbp)->dbenv->test_abort = 0;                           \
182
 
                (ret) = EINVAL;                                         \
183
 
                goto db_tr_err;                                         \
184
 
        }                                                               \
185
 
} while (0)
186
 
 
187
 
#define DB_TEST_RECOVERY_LABEL  db_tr_err:
188
 
#else
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
193
 
#endif
194
 
 
195
 
#if defined(__cplusplus)
196
 
}
197
 
#endif
198
 
#endif /* !_DB_DEBUG_H_ */