The R Project SVN R

Rev

Rev 67112 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 67112 Rev 68697
1
 
1
 
2
/*
2
/*
3
   ----------------------------------------------------------------
3
   ----------------------------------------------------------------
4
 
4
 
5
   Notice that the following BSD-style license applies to this one
5
   Notice that the following BSD-style license applies to this one
6
   file (memcheck.h) only.  The rest of Valgrind is licensed under the
6
   file (memcheck.h) only.  The rest of Valgrind is licensed under the
7
   terms of the GNU General Public License, version 2, unless
7
   terms of the GNU General Public License, version 2, unless
8
   otherwise indicated.  See the COPYING file in the source
8
   otherwise indicated.  See the COPYING file in the source
9
   distribution for details.
9
   distribution for details.
10
 
10
 
11
   ----------------------------------------------------------------
11
   ----------------------------------------------------------------
12
 
12
 
13
   This file is part of MemCheck, a heavyweight Valgrind tool for
13
   This file is part of MemCheck, a heavyweight Valgrind tool for
14
   detecting memory errors.
14
   detecting memory errors.
15
 
15
 
16
   Copyright (C) 2000-2013 Julian Seward.  All rights reserved.
16
   Copyright (C) 2000-2013 Julian Seward.  All rights reserved.
17
 
17
 
18
   Redistribution and use in source and binary forms, with or without
18
   Redistribution and use in source and binary forms, with or without
19
   modification, are permitted provided that the following conditions
19
   modification, are permitted provided that the following conditions
20
   are met:
20
   are met:
21
 
21
 
22
   1. Redistributions of source code must retain the above copyright
22
   1. Redistributions of source code must retain the above copyright
23
      notice, this list of conditions and the following disclaimer.
23
      notice, this list of conditions and the following disclaimer.
24
 
24
 
25
   2. The origin of this software must not be misrepresented; you must 
25
   2. The origin of this software must not be misrepresented; you must 
26
      not claim that you wrote the original software.  If you use this 
26
      not claim that you wrote the original software.  If you use this 
27
      software in a product, an acknowledgment in the product 
27
      software in a product, an acknowledgment in the product 
28
      documentation would be appreciated but is not required.
28
      documentation would be appreciated but is not required.
29
 
29
 
30
   3. Altered source versions must be plainly marked as such, and must
30
   3. Altered source versions must be plainly marked as such, and must
31
      not be misrepresented as being the original software.
31
      not be misrepresented as being the original software.
32
 
32
 
33
   4. The name of the author may not be used to endorse or promote 
33
   4. The name of the author may not be used to endorse or promote 
34
      products derived from this software without specific prior written 
34
      products derived from this software without specific prior written 
35
      permission.
35
      permission.
36
 
36
 
37
   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
37
   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
38
   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38
   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
39
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40
   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
40
   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
41
   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41
   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42
   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
42
   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
43
   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43
   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44
   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44
   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45
   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45
   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
46
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48
 
48
 
49
   ----------------------------------------------------------------
49
   ----------------------------------------------------------------
50
 
50
 
51
   Notice that the above BSD-style license applies to this one file
51
   Notice that the above BSD-style license applies to this one file
52
   (memcheck.h) only.  The entire rest of Valgrind is licensed under
52
   (memcheck.h) only.  The entire rest of Valgrind is licensed under
53
   the terms of the GNU General Public License, version 2.  See the
53
   the terms of the GNU General Public License, version 2.  See the
54
   COPYING file in the source distribution for details.
54
   COPYING file in the source distribution for details.
55
 
55
 
56
   ---------------------------------------------------------------- 
56
   ---------------------------------------------------------------- 
57
*/
57
*/
58
 
58
 
59
 
59
 
60
#ifndef __MEMCHECK_H
60
#ifndef __MEMCHECK_H
61
#define __MEMCHECK_H
61
#define __MEMCHECK_H
62
 
62
 
63
 
63
 
64
/* This file is for inclusion into client (your!) code.
64
/* This file is for inclusion into client (your!) code.
65
 
65
 
66
   You can use these macros to manipulate and query memory permissions
66
   You can use these macros to manipulate and query memory permissions
67
   inside your own programs.
67
   inside your own programs.
68
 
68
 
69
   See comment near the top of valgrind.h on how to use them.
69
   See comment near the top of valgrind.h on how to use them.
70
*/
70
*/
71
 
71
 
-
 
72
/* R change to ensure that our copy of the header is used */
72
#include "vg/valgrind.h"
73
#include "vg/valgrind.h"
73
 
74
 
74
/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! 
75
/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! 
75
   This enum comprises an ABI exported by Valgrind to programs
76
   This enum comprises an ABI exported by Valgrind to programs
76
   which use client requests.  DO NOT CHANGE THE ORDER OF THESE
77
   which use client requests.  DO NOT CHANGE THE ORDER OF THESE
77
   ENTRIES, NOR DELETE ANY -- add new ones at the end. */
78
   ENTRIES, NOR DELETE ANY -- add new ones at the end. */
78
typedef
79
typedef
79
   enum { 
80
   enum { 
80
      VG_USERREQ__MAKE_MEM_NOACCESS = VG_USERREQ_TOOL_BASE('M','C'),
81
      VG_USERREQ__MAKE_MEM_NOACCESS = VG_USERREQ_TOOL_BASE('M','C'),
81
      VG_USERREQ__MAKE_MEM_UNDEFINED,
82
      VG_USERREQ__MAKE_MEM_UNDEFINED,
82
      VG_USERREQ__MAKE_MEM_DEFINED,
83
      VG_USERREQ__MAKE_MEM_DEFINED,
83
      VG_USERREQ__DISCARD,
84
      VG_USERREQ__DISCARD,
84
      VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,
85
      VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,
85
      VG_USERREQ__CHECK_MEM_IS_DEFINED,
86
      VG_USERREQ__CHECK_MEM_IS_DEFINED,
86
      VG_USERREQ__DO_LEAK_CHECK,
87
      VG_USERREQ__DO_LEAK_CHECK,
87
      VG_USERREQ__COUNT_LEAKS,
88
      VG_USERREQ__COUNT_LEAKS,
88
 
89
 
89
      VG_USERREQ__GET_VBITS,
90
      VG_USERREQ__GET_VBITS,
90
      VG_USERREQ__SET_VBITS,
91
      VG_USERREQ__SET_VBITS,
91
 
92
 
92
      VG_USERREQ__CREATE_BLOCK,
93
      VG_USERREQ__CREATE_BLOCK,
93
 
94
 
94
      VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE,
95
      VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE,
95
 
96
 
96
      /* Not next to VG_USERREQ__COUNT_LEAKS because it was added later. */
97
      /* Not next to VG_USERREQ__COUNT_LEAKS because it was added later. */
97
      VG_USERREQ__COUNT_LEAK_BLOCKS,
98
      VG_USERREQ__COUNT_LEAK_BLOCKS,
98
 
99
 
99
      VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE,
100
      VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE,
100
      VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE,
101
      VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE,
101
 
102
 
102
      /* This is just for memcheck's internal use - don't use it */
103
      /* This is just for memcheck's internal use - don't use it */
103
      _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR 
104
      _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR 
104
         = VG_USERREQ_TOOL_BASE('M','C') + 256
105
         = VG_USERREQ_TOOL_BASE('M','C') + 256
105
   } Vg_MemCheckClientRequest;
106
   } Vg_MemCheckClientRequest;
106
 
107
 
107
 
108
 
108
 
109
 
109
/* Client-code macros to manipulate the state of memory. */
110
/* Client-code macros to manipulate the state of memory. */
110
 
111
 
111
/* Mark memory at _qzz_addr as unaddressable for _qzz_len bytes. */
112
/* Mark memory at _qzz_addr as unaddressable for _qzz_len bytes. */
112
#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len)           \
113
#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len)           \
113
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
114
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
114
                            VG_USERREQ__MAKE_MEM_NOACCESS,       \
115
                            VG_USERREQ__MAKE_MEM_NOACCESS,       \
115
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
116
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
116
      
117
      
117
/* Similarly, mark memory at _qzz_addr as addressable but undefined
118
/* Similarly, mark memory at _qzz_addr as addressable but undefined
118
   for _qzz_len bytes. */
119
   for _qzz_len bytes. */
119
#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len)          \
120
#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len)          \
120
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
121
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
121
                            VG_USERREQ__MAKE_MEM_UNDEFINED,      \
122
                            VG_USERREQ__MAKE_MEM_UNDEFINED,      \
122
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
123
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
123
 
124
 
124
/* Similarly, mark memory at _qzz_addr as addressable and defined
125
/* Similarly, mark memory at _qzz_addr as addressable and defined
125
   for _qzz_len bytes. */
126
   for _qzz_len bytes. */
126
#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len)            \
127
#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len)            \
127
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
128
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
128
                            VG_USERREQ__MAKE_MEM_DEFINED,        \
129
                            VG_USERREQ__MAKE_MEM_DEFINED,        \
129
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
130
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
130
 
131
 
131
/* Similar to VALGRIND_MAKE_MEM_DEFINED except that addressability is
132
/* Similar to VALGRIND_MAKE_MEM_DEFINED except that addressability is
132
   not altered: bytes which are addressable are marked as defined,
133
   not altered: bytes which are addressable are marked as defined,
133
   but those which are not addressable are left unchanged. */
134
   but those which are not addressable are left unchanged. */
134
#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(_qzz_addr,_qzz_len)     \
135
#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(_qzz_addr,_qzz_len)     \
135
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,              \
136
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,              \
136
                            VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, \
137
                            VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, \
137
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
138
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
138
 
139
 
139
/* Create a block-description handle.  The description is an ascii
140
/* Create a block-description handle.  The description is an ascii
140
   string which is included in any messages pertaining to addresses
141
   string which is included in any messages pertaining to addresses
141
   within the specified memory range.  Has no other effect on the
142
   within the specified memory range.  Has no other effect on the
142
   properties of the memory range. */
143
   properties of the memory range. */
143
#define VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc)	   \
144
#define VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc)	   \
144
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,        \
145
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,        \
145
                            VG_USERREQ__CREATE_BLOCK,              \
146
                            VG_USERREQ__CREATE_BLOCK,              \
146
                            (_qzz_addr), (_qzz_len), (_qzz_desc),  \
147
                            (_qzz_addr), (_qzz_len), (_qzz_desc),  \
147
                            0, 0)
148
                            0, 0)
148
 
149
 
149
/* Discard a block-description-handle. Returns 1 for an
150
/* Discard a block-description-handle. Returns 1 for an
150
   invalid handle, 0 for a valid handle. */
151
   invalid handle, 0 for a valid handle. */
151
#define VALGRIND_DISCARD(_qzz_blkindex)                          \
152
#define VALGRIND_DISCARD(_qzz_blkindex)                          \
152
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
153
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,      \
153
                            VG_USERREQ__DISCARD,                 \
154
                            VG_USERREQ__DISCARD,                 \
154
                            0, (_qzz_blkindex), 0, 0, 0)
155
                            0, (_qzz_blkindex), 0, 0, 0)
155
 
156
 
156
 
157
 
157
/* Client-code macros to check the state of memory. */
158
/* Client-code macros to check the state of memory. */
158
 
159
 
159
/* Check that memory at _qzz_addr is addressable for _qzz_len bytes.
160
/* Check that memory at _qzz_addr is addressable for _qzz_len bytes.
160
   If suitable addressibility is not established, Valgrind prints an
161
   If suitable addressibility is not established, Valgrind prints an
161
   error message and returns the address of the first offending byte.
162
   error message and returns the address of the first offending byte.
162
   Otherwise it returns zero. */
163
   Otherwise it returns zero. */
163
#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len)      \
164
#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len)      \
164
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                             \
165
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                             \
165
                            VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,  \
166
                            VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,  \
166
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
167
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
167
 
168
 
168
/* Check that memory at _qzz_addr is addressable and defined for
169
/* Check that memory at _qzz_addr is addressable and defined for
169
   _qzz_len bytes.  If suitable addressibility and definedness are not
170
   _qzz_len bytes.  If suitable addressibility and definedness are not
170
   established, Valgrind prints an error message and returns the
171
   established, Valgrind prints an error message and returns the
171
   address of the first offending byte.  Otherwise it returns zero. */
172
   address of the first offending byte.  Otherwise it returns zero. */
172
#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len)        \
173
#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len)        \
173
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                           \
174
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                           \
174
                            VG_USERREQ__CHECK_MEM_IS_DEFINED,    \
175
                            VG_USERREQ__CHECK_MEM_IS_DEFINED,    \
175
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
176
                            (_qzz_addr), (_qzz_len), 0, 0, 0)
176
 
177
 
177
/* Use this macro to force the definedness and addressibility of an
178
/* Use this macro to force the definedness and addressibility of an
178
   lvalue to be checked.  If suitable addressibility and definedness
179
   lvalue to be checked.  If suitable addressibility and definedness
179
   are not established, Valgrind prints an error message and returns
180
   are not established, Valgrind prints an error message and returns
180
   the address of the first offending byte.  Otherwise it returns
181
   the address of the first offending byte.  Otherwise it returns
181
   zero. */
182
   zero. */
182
#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue)                \
183
#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue)                \
183
   VALGRIND_CHECK_MEM_IS_DEFINED(                                \
184
   VALGRIND_CHECK_MEM_IS_DEFINED(                                \
184
      (volatile unsigned char *)&(__lvalue),                     \
185
      (volatile unsigned char *)&(__lvalue),                     \
185
                      (unsigned long)(sizeof (__lvalue)))
186
                      (unsigned long)(sizeof (__lvalue)))
186
 
187
 
187
 
188
 
188
/* Do a full memory leak check (like --leak-check=full) mid-execution. */
189
/* Do a full memory leak check (like --leak-check=full) mid-execution. */
189
#define VALGRIND_DO_LEAK_CHECK                                   \
190
#define VALGRIND_DO_LEAK_CHECK                                   \
190
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,   \
191
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,   \
191
                                    0, 0, 0, 0, 0)
192
                                    0, 0, 0, 0, 0)
192
 
193
 
193
/* Same as VALGRIND_DO_LEAK_CHECK but only showing the entries for
194
/* Same as VALGRIND_DO_LEAK_CHECK but only showing the entries for
194
   which there was an increase in leaked bytes or leaked nr of blocks
195
   which there was an increase in leaked bytes or leaked nr of blocks
195
   since the previous leak search. */
196
   since the previous leak search. */
196
#define VALGRIND_DO_ADDED_LEAK_CHECK                            \
197
#define VALGRIND_DO_ADDED_LEAK_CHECK                            \
197
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,  \
198
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,  \
198
                                    0, 1, 0, 0, 0)
199
                                    0, 1, 0, 0, 0)
199
 
200
 
200
/* Same as VALGRIND_DO_ADDED_LEAK_CHECK but showing entries with
201
/* Same as VALGRIND_DO_ADDED_LEAK_CHECK but showing entries with
201
   increased or decreased leaked bytes/blocks since previous leak
202
   increased or decreased leaked bytes/blocks since previous leak
202
   search. */
203
   search. */
203
#define VALGRIND_DO_CHANGED_LEAK_CHECK                          \
204
#define VALGRIND_DO_CHANGED_LEAK_CHECK                          \
204
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,  \
205
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,  \
205
                                    0, 2, 0, 0, 0)
206
                                    0, 2, 0, 0, 0)
206
 
207
 
207
/* Do a summary memory leak check (like --leak-check=summary) mid-execution. */
208
/* Do a summary memory leak check (like --leak-check=summary) mid-execution. */
208
#define VALGRIND_DO_QUICK_LEAK_CHECK                             \
209
#define VALGRIND_DO_QUICK_LEAK_CHECK                             \
209
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,   \
210
    VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DO_LEAK_CHECK,   \
210
                                    1, 0, 0, 0, 0)
211
                                    1, 0, 0, 0, 0)
211
 
212
 
212
/* Return number of leaked, dubious, reachable and suppressed bytes found by
213
/* Return number of leaked, dubious, reachable and suppressed bytes found by
213
   all previous leak checks.  They must be lvalues.  */
214
   all previous leak checks.  They must be lvalues.  */
214
#define VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed)     \
215
#define VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed)     \
215
   /* For safety on 64-bit platforms we assign the results to private
216
   /* For safety on 64-bit platforms we assign the results to private
216
      unsigned long variables, then assign these to the lvalues the user
217
      unsigned long variables, then assign these to the lvalues the user
217
      specified, which works no matter what type 'leaked', 'dubious', etc
218
      specified, which works no matter what type 'leaked', 'dubious', etc
218
      are.  We also initialise '_qzz_leaked', etc because
219
      are.  We also initialise '_qzz_leaked', etc because
219
      VG_USERREQ__COUNT_LEAKS doesn't mark the values returned as
220
      VG_USERREQ__COUNT_LEAKS doesn't mark the values returned as
220
      defined. */                                                        \
221
      defined. */                                                        \
221
   {                                                                     \
222
   {                                                                     \
222
    unsigned long _qzz_leaked    = 0, _qzz_dubious    = 0;               \
223
    unsigned long _qzz_leaked    = 0, _qzz_dubious    = 0;               \
223
    unsigned long _qzz_reachable = 0, _qzz_suppressed = 0;               \
224
    unsigned long _qzz_reachable = 0, _qzz_suppressed = 0;               \
224
    VALGRIND_DO_CLIENT_REQUEST_STMT(                                     \
225
    VALGRIND_DO_CLIENT_REQUEST_STMT(                                     \
225
                               VG_USERREQ__COUNT_LEAKS,                  \
226
                               VG_USERREQ__COUNT_LEAKS,                  \
226
                               &_qzz_leaked, &_qzz_dubious,              \
227
                               &_qzz_leaked, &_qzz_dubious,              \
227
                               &_qzz_reachable, &_qzz_suppressed, 0);    \
228
                               &_qzz_reachable, &_qzz_suppressed, 0);    \
228
    leaked     = _qzz_leaked;                                            \
229
    leaked     = _qzz_leaked;                                            \
229
    dubious    = _qzz_dubious;                                           \
230
    dubious    = _qzz_dubious;                                           \
230
    reachable  = _qzz_reachable;                                         \
231
    reachable  = _qzz_reachable;                                         \
231
    suppressed = _qzz_suppressed;                                        \
232
    suppressed = _qzz_suppressed;                                        \
232
   }
233
   }
233
 
234
 
234
/* Return number of leaked, dubious, reachable and suppressed bytes found by
235
/* Return number of leaked, dubious, reachable and suppressed bytes found by
235
   all previous leak checks.  They must be lvalues.  */
236
   all previous leak checks.  They must be lvalues.  */
236
#define VALGRIND_COUNT_LEAK_BLOCKS(leaked, dubious, reachable, suppressed) \
237
#define VALGRIND_COUNT_LEAK_BLOCKS(leaked, dubious, reachable, suppressed) \
237
   /* For safety on 64-bit platforms we assign the results to private
238
   /* For safety on 64-bit platforms we assign the results to private
238
      unsigned long variables, then assign these to the lvalues the user
239
      unsigned long variables, then assign these to the lvalues the user
239
      specified, which works no matter what type 'leaked', 'dubious', etc
240
      specified, which works no matter what type 'leaked', 'dubious', etc
240
      are.  We also initialise '_qzz_leaked', etc because
241
      are.  We also initialise '_qzz_leaked', etc because
241
      VG_USERREQ__COUNT_LEAKS doesn't mark the values returned as
242
      VG_USERREQ__COUNT_LEAKS doesn't mark the values returned as
242
      defined. */                                                        \
243
      defined. */                                                        \
243
   {                                                                     \
244
   {                                                                     \
244
    unsigned long _qzz_leaked    = 0, _qzz_dubious    = 0;               \
245
    unsigned long _qzz_leaked    = 0, _qzz_dubious    = 0;               \
245
    unsigned long _qzz_reachable = 0, _qzz_suppressed = 0;               \
246
    unsigned long _qzz_reachable = 0, _qzz_suppressed = 0;               \
246
    VALGRIND_DO_CLIENT_REQUEST_STMT(                                     \
247
    VALGRIND_DO_CLIENT_REQUEST_STMT(                                     \
247
                               VG_USERREQ__COUNT_LEAK_BLOCKS,            \
248
                               VG_USERREQ__COUNT_LEAK_BLOCKS,            \
248
                               &_qzz_leaked, &_qzz_dubious,              \
249
                               &_qzz_leaked, &_qzz_dubious,              \
249
                               &_qzz_reachable, &_qzz_suppressed, 0);    \
250
                               &_qzz_reachable, &_qzz_suppressed, 0);    \
250
    leaked     = _qzz_leaked;                                            \
251
    leaked     = _qzz_leaked;                                            \
251
    dubious    = _qzz_dubious;                                           \
252
    dubious    = _qzz_dubious;                                           \
252
    reachable  = _qzz_reachable;                                         \
253
    reachable  = _qzz_reachable;                                         \
253
    suppressed = _qzz_suppressed;                                        \
254
    suppressed = _qzz_suppressed;                                        \
254
   }
255
   }
255
 
256
 
256
 
257
 
257
/* Get the validity data for addresses [zza..zza+zznbytes-1] and copy it
258
/* Get the validity data for addresses [zza..zza+zznbytes-1] and copy it
258
   into the provided zzvbits array.  Return values:
259
   into the provided zzvbits array.  Return values:
259
      0   if not running on valgrind
260
      0   if not running on valgrind
260
      1   success
261
      1   success
261
      2   [previously indicated unaligned arrays;  these are now allowed]
262
      2   [previously indicated unaligned arrays;  these are now allowed]
262
      3   if any parts of zzsrc/zzvbits are not addressable.
263
      3   if any parts of zzsrc/zzvbits are not addressable.
263
   The metadata is not copied in cases 0, 2 or 3 so it should be
264
   The metadata is not copied in cases 0, 2 or 3 so it should be
264
   impossible to segfault your system by using this call.
265
   impossible to segfault your system by using this call.
265
*/
266
*/
266
#define VALGRIND_GET_VBITS(zza,zzvbits,zznbytes)                \
267
#define VALGRIND_GET_VBITS(zza,zzvbits,zznbytes)                \
267
    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                \
268
    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                \
268
                                    VG_USERREQ__GET_VBITS,      \
269
                                    VG_USERREQ__GET_VBITS,      \
269
                                    (const char*)(zza),         \
270
                                    (const char*)(zza),         \
270
                                    (char*)(zzvbits),           \
271
                                    (char*)(zzvbits),           \
271
                                    (zznbytes), 0, 0)
272
                                    (zznbytes), 0, 0)
272
 
273
 
273
/* Set the validity data for addresses [zza..zza+zznbytes-1], copying it
274
/* Set the validity data for addresses [zza..zza+zznbytes-1], copying it
274
   from the provided zzvbits array.  Return values:
275
   from the provided zzvbits array.  Return values:
275
      0   if not running on valgrind
276
      0   if not running on valgrind
276
      1   success
277
      1   success
277
      2   [previously indicated unaligned arrays;  these are now allowed]
278
      2   [previously indicated unaligned arrays;  these are now allowed]
278
      3   if any parts of zza/zzvbits are not addressable.
279
      3   if any parts of zza/zzvbits are not addressable.
279
   The metadata is not copied in cases 0, 2 or 3 so it should be
280
   The metadata is not copied in cases 0, 2 or 3 so it should be
280
   impossible to segfault your system by using this call.
281
   impossible to segfault your system by using this call.
281
*/
282
*/
282
#define VALGRIND_SET_VBITS(zza,zzvbits,zznbytes)                \
283
#define VALGRIND_SET_VBITS(zza,zzvbits,zznbytes)                \
283
    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                \
284
    (unsigned)VALGRIND_DO_CLIENT_REQUEST_EXPR(0,                \
284
                                    VG_USERREQ__SET_VBITS,      \
285
                                    VG_USERREQ__SET_VBITS,      \
285
                                    (const char*)(zza),         \
286
                                    (const char*)(zza),         \
286
                                    (const char*)(zzvbits),     \
287
                                    (const char*)(zzvbits),     \
287
                                    (zznbytes), 0, 0 )
288
                                    (zznbytes), 0, 0 )
288
 
289
 
289
/* Disable and re-enable reporting of addressing errors in the
290
/* Disable and re-enable reporting of addressing errors in the
290
   specified address range. */
291
   specified address range. */
291
#define VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(_qzz_addr,_qzz_len) \
292
#define VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE(_qzz_addr,_qzz_len) \
292
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,    \
293
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,    \
293
       VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE,      \
294
       VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE,      \
294
       (_qzz_addr), (_qzz_len), 0, 0, 0)
295
       (_qzz_addr), (_qzz_len), 0, 0, 0)
295
 
296
 
296
#define VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(_qzz_addr,_qzz_len) \
297
#define VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(_qzz_addr,_qzz_len) \
297
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,    \
298
    VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */,    \
298
       VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE,       \
299
       VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE,       \
299
       (_qzz_addr), (_qzz_len), 0, 0, 0)
300
       (_qzz_addr), (_qzz_len), 0, 0, 0)
300
 
301
 
301
#endif
302
#endif
302
 
303