~ubuntu-branches/ubuntu/raring/exim4/raring-proposed

« back to all changes in this revision

Viewing changes to src/memcheck.h

  • Committer: Bazaar Package Importer
  • Author(s): Stéphane Graber
  • Date: 2011-05-06 14:51:28 UTC
  • mfrom: (2.1.15 sid)
  • Revision ID: james.westby@ubuntu.com-20110506145128-9q87vglgh6lb0w5o
Tags: 4.75-2ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/control: Don't declare a Provides: default-mta; in Ubuntu,
    we want postfix to be the default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   This file is part of MemCheck, a heavyweight Valgrind tool for
14
14
   detecting memory errors.
15
15
 
16
 
   Copyright (C) 2000-2009 Julian Seward.  All rights reserved.
 
16
   Copyright (C) 2000-2010 Julian Seward.  All rights reserved.
17
17
 
18
18
   Redistribution and use in source and binary forms, with or without
19
19
   modification, are permitted provided that the following conditions
107
107
 
108
108
/* Mark memory at _qzz_addr as unaddressable for _qzz_len bytes. */
109
109
#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len)           \
110
 
   (__extension__({unsigned long _qzz_res;                       \
111
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
 
110
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
112
111
                            VG_USERREQ__MAKE_MEM_NOACCESS,       \
113
 
                            _qzz_addr, _qzz_len, 0, 0, 0);       \
114
 
    _qzz_res;                                                    \
115
 
   }))
 
112
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
116
113
      
117
114
/* Similarly, mark memory at _qzz_addr as addressable but undefined
118
115
   for _qzz_len bytes. */
119
116
#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len)          \
120
 
   (__extension__({unsigned long _qzz_res;                       \
121
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
 
117
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
122
118
                            VG_USERREQ__MAKE_MEM_UNDEFINED,      \
123
 
                            _qzz_addr, _qzz_len, 0, 0, 0);       \
124
 
    _qzz_res;                                                    \
125
 
   }))
 
119
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
126
120
 
127
121
/* Similarly, mark memory at _qzz_addr as addressable and defined
128
122
   for _qzz_len bytes. */
129
123
#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len)            \
130
 
   (__extension__({unsigned long _qzz_res;                       \
131
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
 
124
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
132
125
                            VG_USERREQ__MAKE_MEM_DEFINED,        \
133
 
                            _qzz_addr, _qzz_len, 0, 0, 0);       \
134
 
    _qzz_res;                                                    \
135
 
   }))
 
126
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
136
127
 
137
128
/* Similar to VALGRIND_MAKE_MEM_DEFINED except that addressability is
138
129
   not altered: bytes which are addressable are marked as defined,
139
130
   but those which are not addressable are left unchanged. */
140
 
#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(_qzz_addr,_qzz_len) \
141
 
   (__extension__({unsigned long _qzz_res;                       \
142
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
 
131
#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(_qzz_addr,_qzz_len)     \
 
132
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,              \
143
133
                            VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, \
144
 
                            _qzz_addr, _qzz_len, 0, 0, 0);       \
145
 
    _qzz_res;                                                    \
146
 
   }))
 
134
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
147
135
 
148
136
/* Create a block-description handle.  The description is an ascii
149
137
   string which is included in any messages pertaining to addresses
150
138
   within the specified memory range.  Has no other effect on the
151
139
   properties of the memory range. */
152
 
#define VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc)     \
153
 
        (__extension__({unsigned long _qzz_res;                  \
154
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
155
 
                            VG_USERREQ__CREATE_BLOCK,            \
156
 
                            _qzz_addr, _qzz_len, _qzz_desc,      \
157
 
                            0, 0);                               \
158
 
    _qzz_res;                                                    \
159
 
   }))
 
140
#define VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc)       \
 
141
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,        \
 
142
                            VG_USERREQ__CREATE_BLOCK,              \
 
143
                            (_qzz_addr), (_qzz_len), (_qzz_desc),  \
 
144
                            0, 0)
160
145
 
161
146
/* Discard a block-description-handle. Returns 1 for an
162
147
   invalid handle, 0 for a valid handle. */
163
148
#define VALGRIND_DISCARD(_qzz_blkindex)                          \
164
 
   (__extension__ ({unsigned long _qzz_res;                      \
165
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
 
149
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
166
150
                            VG_USERREQ__DISCARD,                 \
167
 
                            0, _qzz_blkindex, 0, 0, 0);          \
168
 
    _qzz_res;                                                    \
169
 
   }))
 
151
                            0, (_qzz_blkindex), 0, 0, 0)
170
152
 
171
153
 
172
154
/* Client-code macros to check the state of memory. */
175
157
   If suitable addressibility is not established, Valgrind prints an
176
158
   error message and returns the address of the first offending byte.
177
159
   Otherwise it returns zero. */
178
 
#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len)    \
179
 
   (__extension__({unsigned long _qzz_res;                       \
180
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                      \
181
 
                            VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,\
182
 
                            _qzz_addr, _qzz_len, 0, 0, 0);       \
183
 
    _qzz_res;                                                    \
184
 
   }))
 
160
#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len)      \
 
161
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                             \
 
162
                            VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,  \
 
163
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
185
164
 
186
165
/* Check that memory at _qzz_addr is addressable and defined for
187
166
   _qzz_len bytes.  If suitable addressibility and definedness are not
188
167
   established, Valgrind prints an error message and returns the
189
168
   address of the first offending byte.  Otherwise it returns zero. */
190
169
#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len)        \
191
 
   (__extension__({unsigned long _qzz_res;                       \
192
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                      \
 
170
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                           \
193
171
                            VG_USERREQ__CHECK_MEM_IS_DEFINED,    \
194
 
                            _qzz_addr, _qzz_len, 0, 0, 0);       \
195
 
    _qzz_res;                                                    \
196
 
   }))
 
172
                            (_qzz_addr), (_qzz_len), 0, 0, 0);
197
173
 
198
174
/* Use this macro to force the definedness and addressibility of an
199
175
   lvalue to be checked.  If suitable addressibility and definedness
276
252
   The metadata is not copied in cases 0, 2 or 3 so it should be
277
253
   impossible to segfault your system by using this call.
278
254
*/
279
 
#define VALGRIND_GET_VBITS(zza,zzvbits,zznbytes)                 \
280
 
   (__extension__({unsigned long _qzz_res;                       \
281
 
    char* czza     = (char*)zza;                                 \
282
 
    char* czzvbits = (char*)zzvbits;                             \
283
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                      \
284
 
                            VG_USERREQ__GET_VBITS,               \
285
 
                            czza, czzvbits, zznbytes, 0, 0 );    \
286
 
    _qzz_res;                                                    \
287
 
   }))
 
255
#define VALGRIND_GET_VBITS(zza,zzvbits,zznbytes)                     \
 
256
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                               \
 
257
                                    VG_USERREQ__GET_VBITS,           \
 
258
                                    (char*)(zza), (char*)(zzvbits),  \
 
259
                                    (zznbytes), 0, 0)
288
260
 
289
261
/* Set the validity data for addresses [zza..zza+zznbytes-1], copying it
290
262
   from the provided zzvbits array.  Return values:
295
267
   The metadata is not copied in cases 0, 2 or 3 so it should be
296
268
   impossible to segfault your system by using this call.
297
269
*/
298
 
#define VALGRIND_SET_VBITS(zza,zzvbits,zznbytes)                 \
299
 
   (__extension__({unsigned int _qzz_res;                        \
300
 
    char* czza     = (char*)zza;                                 \
301
 
    char* czzvbits = (char*)zzvbits;                             \
302
 
    VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0,                      \
303
 
                            VG_USERREQ__SET_VBITS,               \
304
 
                            czza, czzvbits, zznbytes, 0, 0 );    \
305
 
    _qzz_res;                                                    \
306
 
   }))
 
270
#define VALGRIND_SET_VBITS(zza,zzvbits,zznbytes)                     \
 
271
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                               \
 
272
                                    VG_USERREQ__SET_VBITS,           \
 
273
                                    (char*)(zza), (char*)(zzvbits),  \
 
274
                                    (zznbytes), 0, 0 )
307
275
 
308
276
#endif
309
277