| 1 |
/* -*- c -*-
|
1 |
/* -*- c -*-
|
| 2 |
----------------------------------------------------------------
|
2 |
----------------------------------------------------------------
|
| 3 |
|
3 |
|
| 4 |
Notice that the following BSD-style license applies to this one
|
4 |
Notice that the following BSD-style license applies to this one
|
| 5 |
file (valgrind.h) only. The entire rest of Valgrind is licensed
|
5 |
file (valgrind.h) only. The entire rest of Valgrind is licensed
|
| 6 |
under the terms of the GNU General Public License, version 2. See
|
6 |
under the terms of the GNU General Public License, version 2. See
|
| 7 |
the COPYING file in the source distribution for details.
|
7 |
the COPYING file in the source distribution for details.
|
| 8 |
|
8 |
|
| 9 |
----------------------------------------------------------------
|
9 |
----------------------------------------------------------------
|
| 10 |
|
10 |
|
| 11 |
This file is part of Valgrind, a dynamic binary instrumentation
|
11 |
This file is part of Valgrind, a dynamic binary instrumentation
|
| 12 |
framework.
|
12 |
framework.
|
| 13 |
|
13 |
|
| 14 |
Copyright (C) 2000-2005 Julian Seward. All rights reserved.
|
14 |
Copyright (C) 2000-2005 Julian Seward. All rights reserved.
|
| 15 |
|
15 |
|
| 16 |
Redistribution and use in source and binary forms, with or without
|
16 |
Redistribution and use in source and binary forms, with or without
|
| 17 |
modification, are permitted provided that the following conditions
|
17 |
modification, are permitted provided that the following conditions
|
| 18 |
are met:
|
18 |
are met:
|
| 19 |
|
19 |
|
| 20 |
1. Redistributions of source code must retain the above copyright
|
20 |
1. Redistributions of source code must retain the above copyright
|
| 21 |
notice, this list of conditions and the following disclaimer.
|
21 |
notice, this list of conditions and the following disclaimer.
|
| 22 |
|
22 |
|
| 23 |
2. The origin of this software must not be misrepresented; you must
|
23 |
2. The origin of this software must not be misrepresented; you must
|
| 24 |
not claim that you wrote the original software. If you use this
|
24 |
not claim that you wrote the original software. If you use this
|
| 25 |
software in a product, an acknowledgment in the product
|
25 |
software in a product, an acknowledgment in the product
|
| 26 |
documentation would be appreciated but is not required.
|
26 |
documentation would be appreciated but is not required.
|
| 27 |
|
27 |
|
| 28 |
3. Altered source versions must be plainly marked as such, and must
|
28 |
3. Altered source versions must be plainly marked as such, and must
|
| 29 |
not be misrepresented as being the original software.
|
29 |
not be misrepresented as being the original software.
|
| 30 |
|
30 |
|
| 31 |
4. The name of the author may not be used to endorse or promote
|
31 |
4. The name of the author may not be used to endorse or promote
|
| 32 |
products derived from this software without specific prior written
|
32 |
products derived from this software without specific prior written
|
| 33 |
permission.
|
33 |
permission.
|
| 34 |
|
34 |
|
| 35 |
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
35 |
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
| 36 |
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
36 |
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 37 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
37 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 38 |
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
38 |
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
| 39 |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
39 |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 40 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
40 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
| 41 |
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
41 |
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
| 42 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
42 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
| 43 |
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
43 |
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
| 44 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
44 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
| 45 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
45 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 46 |
|
46 |
|
| 47 |
----------------------------------------------------------------
|
47 |
----------------------------------------------------------------
|
| 48 |
|
48 |
|
| 49 |
Notice that the above BSD-style license applies to this one file
|
49 |
Notice that the above BSD-style license applies to this one file
|
| 50 |
(valgrind.h) only. The entire rest of Valgrind is licensed under
|
50 |
(valgrind.h) only. The entire rest of Valgrind is licensed under
|
| 51 |
the terms of the GNU General Public License, version 2. See the
|
51 |
the terms of the GNU General Public License, version 2. See the
|
| 52 |
COPYING file in the source distribution for details.
|
52 |
COPYING file in the source distribution for details.
|
| 53 |
|
53 |
|
| 54 |
----------------------------------------------------------------
|
54 |
----------------------------------------------------------------
|
| 55 |
*/
|
55 |
*/
|
| 56 |
|
56 |
|
| 57 |
|
57 |
|
| 58 |
/* This file is for inclusion into client (your!) code.
|
58 |
/* This file is for inclusion into client (your!) code.
|
| 59 |
|
59 |
|
| 60 |
You can use these macros to manipulate and query Valgrind's
|
60 |
You can use these macros to manipulate and query Valgrind's
|
| 61 |
execution inside your own programs.
|
61 |
execution inside your own programs.
|
| 62 |
|
62 |
|
| 63 |
The resulting executables will still run without Valgrind, just a
|
63 |
The resulting executables will still run without Valgrind, just a
|
| 64 |
little bit more slowly than they otherwise would, but otherwise
|
64 |
little bit more slowly than they otherwise would, but otherwise
|
| 65 |
unchanged. When not running on valgrind, each client request
|
65 |
unchanged. When not running on valgrind, each client request
|
| 66 |
consumes very few (eg. < 10) instructions, so the resulting performance
|
66 |
consumes very few (eg. < 10) instructions, so the resulting performance
|
| 67 |
loss is negligible unless you plan to execute client requests
|
67 |
loss is negligible unless you plan to execute client requests
|
| 68 |
millions of times per second. Nevertheless, if that is still a
|
68 |
millions of times per second. Nevertheless, if that is still a
|
| 69 |
problem, you can compile with the NVALGRIND symbol defined (gcc
|
69 |
problem, you can compile with the NVALGRIND symbol defined (gcc
|
| 70 |
-DNVALGRIND) so that client requests are not even compiled in. */
|
70 |
-DNVALGRIND) so that client requests are not even compiled in. */
|
| 71 |
|
71 |
|
| 72 |
#ifndef __VALGRIND_H
|
72 |
#ifndef __VALGRIND_H
|
| 73 |
#define __VALGRIND_H
|
73 |
#define __VALGRIND_H
|
| 74 |
|
74 |
|
| 75 |
#include <stdarg.h>
|
75 |
#include <stdarg.h>
|
| 76 |
|
76 |
|
| 77 |
/* Nb: this file might be included in a file compiled with -ansi. So
|
77 |
/* Nb: this file might be included in a file compiled with -ansi. So
|
| 78 |
we can't use C++ style "//" comments nor the "asm" keyword (instead
|
78 |
we can't use C++ style "//" comments nor the "asm" keyword (instead
|
| 79 |
use "__asm__"). */
|
79 |
use "__asm__"). */
|
| 80 |
|
80 |
|
| 81 |
/* If we're not compiling for our target architecture, don't generate
|
81 |
/* If we're not compiling for our target architecture, don't generate
|
| 82 |
any inline asms. Note that in this file we're using the compiler's
|
82 |
any inline asms. Note that in this file we're using the compiler's
|
| 83 |
CPP symbols for identifying architectures, which are different to
|
83 |
CPP symbols for identifying architectures, which are different to
|
| 84 |
the ones we use within the rest of Valgrind. */
|
84 |
the ones we use within the rest of Valgrind. */
|
| 85 |
#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__)
|
85 |
#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__)
|
| 86 |
# ifndef NVALGRIND
|
86 |
# ifndef NVALGRIND
|
| 87 |
# define NVALGRIND 1
|
87 |
# define NVALGRIND 1
|
| 88 |
# endif /* NVALGRIND */
|
88 |
# endif /* NVALGRIND */
|
| 89 |
#endif
|
89 |
#endif
|
| 90 |
|
90 |
|
| 91 |
/* ------------------------------------------------------------------ */
|
91 |
/* ------------------------------------------------------------------ */
|
| 92 |
/* The architecture-specific part */
|
92 |
/* The architecture-specific part */
|
| 93 |
/* ------------------------------------------------------------------ */
|
93 |
/* ------------------------------------------------------------------ */
|
| 94 |
|
94 |
|
| 95 |
#ifdef NVALGRIND
|
95 |
#ifdef NVALGRIND
|
| 96 |
|
96 |
|
| 97 |
/* Define NVALGRIND to completely remove the Valgrind magic sequence
|
97 |
/* Define NVALGRIND to completely remove the Valgrind magic sequence
|
| 98 |
from the compiled code (analogous to NDEBUG's effects on assert()) */
|
98 |
from the compiled code (analogous to NDEBUG's effects on assert()) */
|
| 99 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
99 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
| 100 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
100 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
| 101 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
101 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
| 102 |
{ \
|
102 |
{ \
|
| 103 |
(_zzq_rlval) = (_zzq_default); \
|
103 |
(_zzq_rlval) = (_zzq_default); \
|
| 104 |
}
|
104 |
}
|
| 105 |
|
105 |
|
| 106 |
#else /* NVALGRIND */
|
106 |
#else /* NVALGRIND */
|
| 107 |
|
107 |
|
| 108 |
/* The following defines the magic code sequences which the JITter spots and
|
108 |
/* The following defines the magic code sequences which the JITter spots and
|
| 109 |
handles magically. Don't look too closely at them; they will rot
|
109 |
handles magically. Don't look too closely at them; they will rot
|
| 110 |
your brain. We must ensure that the default value gets put in the return
|
110 |
your brain. We must ensure that the default value gets put in the return
|
| 111 |
slot, so that everything works when this is executed not under Valgrind.
|
111 |
slot, so that everything works when this is executed not under Valgrind.
|
| 112 |
Args are passed in a memory block, and so there's no intrinsic limit to
|
112 |
Args are passed in a memory block, and so there's no intrinsic limit to
|
| 113 |
the number that could be passed, but it's currently four.
|
113 |
the number that could be passed, but it's currently four.
|
| 114 |
|
114 |
|
| 115 |
The macro args are:
|
115 |
The macro args are:
|
| 116 |
_zzq_rlval result lvalue
|
116 |
_zzq_rlval result lvalue
|
| 117 |
_zzq_default default value (result returned when running on real CPU)
|
117 |
_zzq_default default value (result returned when running on real CPU)
|
| 118 |
_zzq_request request code
|
118 |
_zzq_request request code
|
| 119 |
_zzq_arg1..4 request params
|
119 |
_zzq_arg1..4 request params
|
| 120 |
|
120 |
|
| 121 |
Nb: we put the assembly code sequences for all architectures in this one
|
121 |
Nb: we put the assembly code sequences for all architectures in this one
|
| 122 |
file. This is because this file must be stand-alone, and we don't want
|
122 |
file. This is because this file must be stand-alone, and we don't want
|
| 123 |
to have multiple files.
|
123 |
to have multiple files.
|
| 124 |
*/
|
124 |
*/
|
| 125 |
|
125 |
|
| 126 |
#ifdef __x86_64__
|
126 |
#ifdef __x86_64__
|
| 127 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
127 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
| 128 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
128 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
| 129 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
129 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
| 130 |
\
|
130 |
\
|
| 131 |
{ volatile unsigned long long _zzq_args[5]; \
|
131 |
{ volatile unsigned long long _zzq_args[5]; \
|
| 132 |
_zzq_args[0] = (volatile unsigned long long)(_zzq_request); \
|
132 |
_zzq_args[0] = (volatile unsigned long long)(_zzq_request); \
|
| 133 |
_zzq_args[1] = (volatile unsigned long long)(_zzq_arg1); \
|
133 |
_zzq_args[1] = (volatile unsigned long long)(_zzq_arg1); \
|
| 134 |
_zzq_args[2] = (volatile unsigned long long)(_zzq_arg2); \
|
134 |
_zzq_args[2] = (volatile unsigned long long)(_zzq_arg2); \
|
| 135 |
_zzq_args[3] = (volatile unsigned long long)(_zzq_arg3); \
|
135 |
_zzq_args[3] = (volatile unsigned long long)(_zzq_arg3); \
|
| 136 |
_zzq_args[4] = (volatile unsigned long long)(_zzq_arg4); \
|
136 |
_zzq_args[4] = (volatile unsigned long long)(_zzq_arg4); \
|
| 137 |
__asm__ volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
|
137 |
__asm__ volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
|
| 138 |
"rorl $27, %%eax ; rorl $5, %%eax\n\t" \
|
138 |
"rorl $27, %%eax ; rorl $5, %%eax\n\t" \
|
| 139 |
"roll $13, %%eax ; roll $19, %%eax" \
|
139 |
"roll $13, %%eax ; roll $19, %%eax" \
|
| 140 |
: "=d" (_zzq_rlval) \
|
140 |
: "=d" (_zzq_rlval) \
|
| 141 |
: "a" (&_zzq_args[0]), "0" (_zzq_default) \
|
141 |
: "a" (&_zzq_args[0]), "0" (_zzq_default) \
|
| 142 |
: "cc", "memory" \
|
142 |
: "cc", "memory" \
|
| 143 |
); \
|
143 |
); \
|
| 144 |
}
|
144 |
}
|
| 145 |
#endif /* __x86_64__ */
|
145 |
#endif /* __x86_64__ */
|
| 146 |
|
146 |
|
| 147 |
#ifdef __i386__
|
147 |
#ifdef __i386__
|
| 148 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
148 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
| 149 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
149 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
| 150 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
150 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
| 151 |
\
|
151 |
\
|
| 152 |
{ unsigned int _zzq_args[5]; \
|
152 |
{ unsigned int _zzq_args[5]; \
|
| 153 |
_zzq_args[0] = (unsigned int)(_zzq_request); \
|
153 |
_zzq_args[0] = (unsigned int)(_zzq_request); \
|
| 154 |
_zzq_args[1] = (unsigned int)(_zzq_arg1); \
|
154 |
_zzq_args[1] = (unsigned int)(_zzq_arg1); \
|
| 155 |
_zzq_args[2] = (unsigned int)(_zzq_arg2); \
|
155 |
_zzq_args[2] = (unsigned int)(_zzq_arg2); \
|
| 156 |
_zzq_args[3] = (unsigned int)(_zzq_arg3); \
|
156 |
_zzq_args[3] = (unsigned int)(_zzq_arg3); \
|
| 157 |
_zzq_args[4] = (unsigned int)(_zzq_arg4); \
|
157 |
_zzq_args[4] = (unsigned int)(_zzq_arg4); \
|
| 158 |
__asm__ volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
|
158 |
__asm__ volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
|
| 159 |
"rorl $27, %%eax ; rorl $5, %%eax\n\t" \
|
159 |
"rorl $27, %%eax ; rorl $5, %%eax\n\t" \
|
| 160 |
"roll $13, %%eax ; roll $19, %%eax" \
|
160 |
"roll $13, %%eax ; roll $19, %%eax" \
|
| 161 |
: "=d" (_zzq_rlval) \
|
161 |
: "=d" (_zzq_rlval) \
|
| 162 |
: "a" (&_zzq_args[0]), "0" (_zzq_default) \
|
162 |
: "a" (&_zzq_args[0]), "0" (_zzq_default) \
|
| 163 |
: "cc", "memory" \
|
163 |
: "cc", "memory" \
|
| 164 |
); \
|
164 |
); \
|
| 165 |
}
|
165 |
}
|
| 166 |
#endif /* __i386__ */
|
166 |
#endif /* __i386__ */
|
| 167 |
|
167 |
|
| 168 |
#ifdef __powerpc__
|
168 |
#ifdef __powerpc__
|
| 169 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
169 |
#define VALGRIND_MAGIC_SEQUENCE( \
|
| 170 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
170 |
_zzq_rlval, _zzq_default, _zzq_request, \
|
| 171 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
171 |
_zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4) \
|
| 172 |
\
|
172 |
\
|
| 173 |
{ volatile unsigned int _zzq_args[5]; \
|
173 |
{ volatile unsigned int _zzq_args[5]; \
|
| 174 |
register unsigned int _zzq_tmp __asm__("r3"); \
|
174 |
register unsigned int _zzq_tmp __asm__("r3"); \
|
| 175 |
register volatile unsigned int *_zzq_ptr __asm__("r4"); \
|
175 |
register volatile unsigned int *_zzq_ptr __asm__("r4"); \
|
| 176 |
_zzq_args[0] = (volatile unsigned int)(_zzq_request); \
|
176 |
_zzq_args[0] = (volatile unsigned int)(_zzq_request); \
|
| 177 |
_zzq_args[1] = (volatile unsigned int)(_zzq_arg1); \
|
177 |
_zzq_args[1] = (volatile unsigned int)(_zzq_arg1); \
|
| 178 |
_zzq_args[2] = (volatile unsigned int)(_zzq_arg2); \
|
178 |
_zzq_args[2] = (volatile unsigned int)(_zzq_arg2); \
|
| 179 |
_zzq_args[3] = (volatile unsigned int)(_zzq_arg3); \
|
179 |
_zzq_args[3] = (volatile unsigned int)(_zzq_arg3); \
|
| 180 |
_zzq_args[4] = (volatile unsigned int)(_zzq_arg4); \
|
180 |
_zzq_args[4] = (volatile unsigned int)(_zzq_arg4); \
|
| 181 |
_zzq_ptr = _zzq_args; \
|
181 |
_zzq_ptr = _zzq_args; \
|
| 182 |
__asm__ volatile("tw 0,3,27\n\t" \
|
182 |
__asm__ volatile("tw 0,3,27\n\t" \
|
| 183 |
"rlwinm 0,0,29,0,0\n\t" \
|
183 |
"rlwinm 0,0,29,0,0\n\t" \
|
| 184 |
"rlwinm 0,0,3,0,0\n\t" \
|
184 |
"rlwinm 0,0,3,0,0\n\t" \
|
| 185 |
"rlwinm 0,0,13,0,0\n\t" \
|
185 |
"rlwinm 0,0,13,0,0\n\t" \
|
| 186 |
"rlwinm 0,0,19,0,0\n\t" \
|
186 |
"rlwinm 0,0,19,0,0\n\t" \
|
| 187 |
"nop\n\t" \
|
187 |
"nop\n\t" \
|
| 188 |
: "=r" (_zzq_tmp) \
|
188 |
: "=r" (_zzq_tmp) \
|
| 189 |
: "0" (_zzq_default), "r" (_zzq_ptr) \
|
189 |
: "0" (_zzq_default), "r" (_zzq_ptr) \
|
| 190 |
: "memory"); \
|
190 |
: "memory"); \
|
| 191 |
_zzq_rlval = (__typeof__(_zzq_rlval)) _zzq_tmp; \
|
191 |
_zzq_rlval = (__typeof__(_zzq_rlval)) _zzq_tmp; \
|
| 192 |
}
|
192 |
}
|
| 193 |
#endif /* __powerpc__ */
|
193 |
#endif /* __powerpc__ */
|
| 194 |
|
194 |
|
| 195 |
/* Insert assembly code for other architectures here... */
|
195 |
/* Insert assembly code for other architectures here... */
|
| 196 |
|
196 |
|
| 197 |
#endif /* NVALGRIND */
|
197 |
#endif /* NVALGRIND */
|
| 198 |
|
198 |
|
| 199 |
|
199 |
|
| 200 |
/* ------------------------------------------------------------------ */
|
200 |
/* ------------------------------------------------------------------ */
|
| 201 |
/* The architecture-independent part */
|
201 |
/* The architecture-independent part */
|
| 202 |
/* ------------------------------------------------------------------ */
|
202 |
/* ------------------------------------------------------------------ */
|
| 203 |
|
203 |
|
| 204 |
/* Some request codes. There are many more of these, but most are not
|
204 |
/* Some request codes. There are many more of these, but most are not
|
| 205 |
exposed to end-user view. These are the public ones, all of the
|
205 |
exposed to end-user view. These are the public ones, all of the
|
| 206 |
form 0x1000 + small_number.
|
206 |
form 0x1000 + small_number.
|
| 207 |
|
207 |
|
| 208 |
Core ones are in the range 0x00000000--0x0000ffff. The non-public ones
|
208 |
Core ones are in the range 0x00000000--0x0000ffff. The non-public ones
|
| 209 |
start at 0x2000.
|
209 |
start at 0x2000.
|
| 210 |
*/
|
210 |
*/
|
| 211 |
|
211 |
|
| 212 |
/* These macros are used by tools -- they must be public, but don't embed them
|
212 |
/* These macros are used by tools -- they must be public, but don't embed them
|
| 213 |
* into other programs. */
|
213 |
* into other programs. */
|
| 214 |
#define VG_USERREQ_TOOL_BASE(a,b) \
|
214 |
#define VG_USERREQ_TOOL_BASE(a,b) \
|
| 215 |
((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
|
215 |
((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
|
| 216 |
#define VG_IS_TOOL_USERREQ(a, b, v) \
|
216 |
#define VG_IS_TOOL_USERREQ(a, b, v) \
|
| 217 |
(VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000))
|
217 |
(VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000))
|
| 218 |
|
218 |
|
| 219 |
typedef
|
219 |
typedef
|
| 220 |
enum { VG_USERREQ__RUNNING_ON_VALGRIND = 0x1001,
|
220 |
enum { VG_USERREQ__RUNNING_ON_VALGRIND = 0x1001,
|
| 221 |
VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002,
|
221 |
VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002,
|
| 222 |
|
222 |
|
| 223 |
/* These allow any function to be called from the
|
223 |
/* These allow any function to be called from the
|
| 224 |
simulated CPU but run on the real CPU.
|
224 |
simulated CPU but run on the real CPU.
|
| 225 |
Nb: the first arg passed to the function is always the ThreadId of
|
225 |
Nb: the first arg passed to the function is always the ThreadId of
|
| 226 |
the running thread! So CLIENT_CALL0 actually requires a 1 arg
|
226 |
the running thread! So CLIENT_CALL0 actually requires a 1 arg
|
| 227 |
function, etc. */
|
227 |
function, etc. */
|
| 228 |
VG_USERREQ__CLIENT_CALL0 = 0x1101,
|
228 |
VG_USERREQ__CLIENT_CALL0 = 0x1101,
|
| 229 |
VG_USERREQ__CLIENT_CALL1 = 0x1102,
|
229 |
VG_USERREQ__CLIENT_CALL1 = 0x1102,
|
| 230 |
VG_USERREQ__CLIENT_CALL2 = 0x1103,
|
230 |
VG_USERREQ__CLIENT_CALL2 = 0x1103,
|
| 231 |
VG_USERREQ__CLIENT_CALL3 = 0x1104,
|
231 |
VG_USERREQ__CLIENT_CALL3 = 0x1104,
|
| 232 |
|
232 |
|
| 233 |
/* Can be useful in regression testing suites -- eg. can send
|
233 |
/* Can be useful in regression testing suites -- eg. can send
|
| 234 |
Valgrind's output to /dev/null and still count errors. */
|
234 |
Valgrind's output to /dev/null and still count errors. */
|
| 235 |
VG_USERREQ__COUNT_ERRORS = 0x1201,
|
235 |
VG_USERREQ__COUNT_ERRORS = 0x1201,
|
| 236 |
|
236 |
|
| 237 |
/* These are useful and can be interpreted by any tool that tracks
|
237 |
/* These are useful and can be interpreted by any tool that tracks
|
| 238 |
malloc() et al, by using vg_replace_malloc.c. */
|
238 |
malloc() et al, by using vg_replace_malloc.c. */
|
| 239 |
VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
|
239 |
VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
|
| 240 |
VG_USERREQ__FREELIKE_BLOCK = 0x1302,
|
240 |
VG_USERREQ__FREELIKE_BLOCK = 0x1302,
|
| 241 |
/* Memory pool support. */
|
241 |
/* Memory pool support. */
|
| 242 |
VG_USERREQ__CREATE_MEMPOOL = 0x1303,
|
242 |
VG_USERREQ__CREATE_MEMPOOL = 0x1303,
|
| 243 |
VG_USERREQ__DESTROY_MEMPOOL = 0x1304,
|
243 |
VG_USERREQ__DESTROY_MEMPOOL = 0x1304,
|
| 244 |
VG_USERREQ__MEMPOOL_ALLOC = 0x1305,
|
244 |
VG_USERREQ__MEMPOOL_ALLOC = 0x1305,
|
| 245 |
VG_USERREQ__MEMPOOL_FREE = 0x1306,
|
245 |
VG_USERREQ__MEMPOOL_FREE = 0x1306,
|
| 246 |
|
246 |
|
| 247 |
/* Allow printfs to valgrind log. */
|
247 |
/* Allow printfs to valgrind log. */
|
| 248 |
VG_USERREQ__PRINTF = 0x1401,
|
248 |
VG_USERREQ__PRINTF = 0x1401,
|
| 249 |
VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
|
249 |
VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
|
| 250 |
|
250 |
|
| 251 |
/* Stack support. */
|
251 |
/* Stack support. */
|
| 252 |
VG_USERREQ__STACK_REGISTER = 0x1501,
|
252 |
VG_USERREQ__STACK_REGISTER = 0x1501,
|
| 253 |
VG_USERREQ__STACK_DEREGISTER = 0x1502,
|
253 |
VG_USERREQ__STACK_DEREGISTER = 0x1502,
|
| 254 |
VG_USERREQ__STACK_CHANGE = 0x1503,
|
254 |
VG_USERREQ__STACK_CHANGE = 0x1503 /* removed incorrect comma */
|
| 255 |
} Vg_ClientRequest;
|
255 |
} Vg_ClientRequest;
|
| 256 |
|
256 |
|
| 257 |
#ifndef __GNUC__
|
257 |
#ifndef __GNUC__
|
| 258 |
#define __extension__
|
258 |
#define __extension__
|
| 259 |
#endif
|
259 |
#endif
|
| 260 |
|
260 |
|
| 261 |
/* Returns the number of Valgrinds this code is running under. That is,
|
261 |
/* Returns the number of Valgrinds this code is running under. That is,
|
| 262 |
0 if running natively, 1 if running under Valgrind, 2 if running under
|
262 |
0 if running natively, 1 if running under Valgrind, 2 if running under
|
| 263 |
Valgrind which is running under another Valgrind, etc. */
|
263 |
Valgrind which is running under another Valgrind, etc. */
|
| 264 |
#define RUNNING_ON_VALGRIND __extension__ \
|
264 |
#define RUNNING_ON_VALGRIND __extension__ \
|
| 265 |
({unsigned int _qzz_res; \
|
265 |
({unsigned int _qzz_res; \
|
| 266 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0 /* returned if not */, \
|
266 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0 /* returned if not */, \
|
| 267 |
VG_USERREQ__RUNNING_ON_VALGRIND, \
|
267 |
VG_USERREQ__RUNNING_ON_VALGRIND, \
|
| 268 |
0, 0, 0, 0); \
|
268 |
0, 0, 0, 0); \
|
| 269 |
_qzz_res; \
|
269 |
_qzz_res; \
|
| 270 |
})
|
270 |
})
|
| 271 |
|
271 |
|
| 272 |
|
272 |
|
| 273 |
/* Discard translation of code in the range [_qzz_addr .. _qzz_addr +
|
273 |
/* Discard translation of code in the range [_qzz_addr .. _qzz_addr +
|
| 274 |
_qzz_len - 1]. Useful if you are debugging a JITter or some such,
|
274 |
_qzz_len - 1]. Useful if you are debugging a JITter or some such,
|
| 275 |
since it provides a way to make sure valgrind will retranslate the
|
275 |
since it provides a way to make sure valgrind will retranslate the
|
| 276 |
invalidated area. Returns no value. */
|
276 |
invalidated area. Returns no value. */
|
| 277 |
#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len) \
|
277 |
#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len) \
|
| 278 |
{unsigned int _qzz_res; \
|
278 |
{unsigned int _qzz_res; \
|
| 279 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
279 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 280 |
VG_USERREQ__DISCARD_TRANSLATIONS, \
|
280 |
VG_USERREQ__DISCARD_TRANSLATIONS, \
|
| 281 |
_qzz_addr, _qzz_len, 0, 0); \
|
281 |
_qzz_addr, _qzz_len, 0, 0); \
|
| 282 |
}
|
282 |
}
|
| 283 |
|
283 |
|
| 284 |
#ifdef NVALGRIND
|
284 |
#ifdef NVALGRIND
|
| 285 |
|
285 |
|
| 286 |
#define VALGRIND_PRINTF(...)
|
286 |
#define VALGRIND_PRINTF(...)
|
| 287 |
#define VALGRIND_PRINTF_BACKTRACE(...)
|
287 |
#define VALGRIND_PRINTF_BACKTRACE(...)
|
| 288 |
|
288 |
|
| 289 |
#else /* NVALGRIND */
|
289 |
#else /* NVALGRIND */
|
| 290 |
|
290 |
|
| 291 |
int VALGRIND_PRINTF(const char *format, ...)
|
291 |
int VALGRIND_PRINTF(const char *format, ...)
|
| 292 |
__attribute__((format(__printf__, 1, 2)));
|
292 |
__attribute__((format(__printf__, 1, 2)));
|
| 293 |
__attribute__((weak))
|
293 |
__attribute__((weak))
|
| 294 |
int
|
294 |
int
|
| 295 |
VALGRIND_PRINTF(const char *format, ...)
|
295 |
VALGRIND_PRINTF(const char *format, ...)
|
| 296 |
{
|
296 |
{
|
| 297 |
unsigned long _qzz_res;
|
297 |
unsigned long _qzz_res;
|
| 298 |
va_list vargs;
|
298 |
va_list vargs;
|
| 299 |
va_start(vargs, format);
|
299 |
va_start(vargs, format);
|
| 300 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF,
|
300 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF,
|
| 301 |
(unsigned long)format, (unsigned long)vargs, 0, 0);
|
301 |
(unsigned long)format, (unsigned long)vargs, 0, 0);
|
| 302 |
va_end(vargs);
|
302 |
va_end(vargs);
|
| 303 |
return (int)_qzz_res;
|
303 |
return (int)_qzz_res;
|
| 304 |
}
|
304 |
}
|
| 305 |
|
305 |
|
| 306 |
int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
|
306 |
int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
|
| 307 |
__attribute__((format(__printf__, 1, 2)));
|
307 |
__attribute__((format(__printf__, 1, 2)));
|
| 308 |
__attribute__((weak))
|
308 |
__attribute__((weak))
|
| 309 |
int
|
309 |
int
|
| 310 |
VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
|
310 |
VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
|
| 311 |
{
|
311 |
{
|
| 312 |
unsigned long _qzz_res;
|
312 |
unsigned long _qzz_res;
|
| 313 |
va_list vargs;
|
313 |
va_list vargs;
|
| 314 |
va_start(vargs, format);
|
314 |
va_start(vargs, format);
|
| 315 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE,
|
315 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE,
|
| 316 |
(unsigned long)format, (unsigned long)vargs, 0, 0);
|
316 |
(unsigned long)format, (unsigned long)vargs, 0, 0);
|
| 317 |
va_end(vargs);
|
317 |
va_end(vargs);
|
| 318 |
return (int)_qzz_res;
|
318 |
return (int)_qzz_res;
|
| 319 |
}
|
319 |
}
|
| 320 |
|
320 |
|
| 321 |
#endif /* NVALGRIND */
|
321 |
#endif /* NVALGRIND */
|
| 322 |
|
322 |
|
| 323 |
/* These requests allow control to move from the simulated CPU to the
|
323 |
/* These requests allow control to move from the simulated CPU to the
|
| 324 |
real CPU, calling an arbitary function */
|
324 |
real CPU, calling an arbitary function */
|
| 325 |
#define VALGRIND_NON_SIMD_CALL0(_qyy_fn) \
|
325 |
#define VALGRIND_NON_SIMD_CALL0(_qyy_fn) \
|
| 326 |
({unsigned long _qyy_res; \
|
326 |
({unsigned long _qyy_res; \
|
| 327 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
327 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
| 328 |
VG_USERREQ__CLIENT_CALL0, \
|
328 |
VG_USERREQ__CLIENT_CALL0, \
|
| 329 |
_qyy_fn, \
|
329 |
_qyy_fn, \
|
| 330 |
0, 0, 0); \
|
330 |
0, 0, 0); \
|
| 331 |
_qyy_res; \
|
331 |
_qyy_res; \
|
| 332 |
})
|
332 |
})
|
| 333 |
|
333 |
|
| 334 |
#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1) \
|
334 |
#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1) \
|
| 335 |
({unsigned long _qyy_res; \
|
335 |
({unsigned long _qyy_res; \
|
| 336 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
336 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
| 337 |
VG_USERREQ__CLIENT_CALL1, \
|
337 |
VG_USERREQ__CLIENT_CALL1, \
|
| 338 |
_qyy_fn, \
|
338 |
_qyy_fn, \
|
| 339 |
_qyy_arg1, 0, 0); \
|
339 |
_qyy_arg1, 0, 0); \
|
| 340 |
_qyy_res; \
|
340 |
_qyy_res; \
|
| 341 |
})
|
341 |
})
|
| 342 |
|
342 |
|
| 343 |
#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2) \
|
343 |
#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2) \
|
| 344 |
({unsigned long _qyy_res; \
|
344 |
({unsigned long _qyy_res; \
|
| 345 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
345 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
| 346 |
VG_USERREQ__CLIENT_CALL2, \
|
346 |
VG_USERREQ__CLIENT_CALL2, \
|
| 347 |
_qyy_fn, \
|
347 |
_qyy_fn, \
|
| 348 |
_qyy_arg1, _qyy_arg2, 0); \
|
348 |
_qyy_arg1, _qyy_arg2, 0); \
|
| 349 |
_qyy_res; \
|
349 |
_qyy_res; \
|
| 350 |
})
|
350 |
})
|
| 351 |
|
351 |
|
| 352 |
#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \
|
352 |
#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \
|
| 353 |
({unsigned long _qyy_res; \
|
353 |
({unsigned long _qyy_res; \
|
| 354 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
354 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
| 355 |
VG_USERREQ__CLIENT_CALL3, \
|
355 |
VG_USERREQ__CLIENT_CALL3, \
|
| 356 |
_qyy_fn, \
|
356 |
_qyy_fn, \
|
| 357 |
_qyy_arg1, _qyy_arg2, _qyy_arg3); \
|
357 |
_qyy_arg1, _qyy_arg2, _qyy_arg3); \
|
| 358 |
_qyy_res; \
|
358 |
_qyy_res; \
|
| 359 |
})
|
359 |
})
|
| 360 |
|
360 |
|
| 361 |
|
361 |
|
| 362 |
/* Counts the number of errors that have been recorded by a tool. Nb:
|
362 |
/* Counts the number of errors that have been recorded by a tool. Nb:
|
| 363 |
the tool must record the errors with VG_(maybe_record_error)() or
|
363 |
the tool must record the errors with VG_(maybe_record_error)() or
|
| 364 |
VG_(unique_error)() for them to be counted. */
|
364 |
VG_(unique_error)() for them to be counted. */
|
| 365 |
#define VALGRIND_COUNT_ERRORS \
|
365 |
#define VALGRIND_COUNT_ERRORS \
|
| 366 |
({unsigned int _qyy_res; \
|
366 |
({unsigned int _qyy_res; \
|
| 367 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
367 |
VALGRIND_MAGIC_SEQUENCE(_qyy_res, 0 /* default return */, \
|
| 368 |
VG_USERREQ__COUNT_ERRORS, \
|
368 |
VG_USERREQ__COUNT_ERRORS, \
|
| 369 |
0, 0, 0, 0); \
|
369 |
0, 0, 0, 0); \
|
| 370 |
_qyy_res; \
|
370 |
_qyy_res; \
|
| 371 |
})
|
371 |
})
|
| 372 |
|
372 |
|
| 373 |
/* Mark a block of memory as having been allocated by a malloc()-like
|
373 |
/* Mark a block of memory as having been allocated by a malloc()-like
|
| 374 |
function. `addr' is the start of the usable block (ie. after any
|
374 |
function. `addr' is the start of the usable block (ie. after any
|
| 375 |
redzone) `rzB' is redzone size if the allocator can apply redzones;
|
375 |
redzone) `rzB' is redzone size if the allocator can apply redzones;
|
| 376 |
use '0' if not. Adding redzones makes it more likely Valgrind will spot
|
376 |
use '0' if not. Adding redzones makes it more likely Valgrind will spot
|
| 377 |
block overruns. `is_zeroed' indicates if the memory is zeroed, as it is
|
377 |
block overruns. `is_zeroed' indicates if the memory is zeroed, as it is
|
| 378 |
for calloc(). Put it immediately after the point where a block is
|
378 |
for calloc(). Put it immediately after the point where a block is
|
| 379 |
allocated.
|
379 |
allocated.
|
| 380 |
|
380 |
|
| 381 |
If you're allocating memory via superblocks, and then handing out small
|
381 |
If you're allocating memory via superblocks, and then handing out small
|
| 382 |
chunks of each superblock, if you don't have redzones on your small
|
382 |
chunks of each superblock, if you don't have redzones on your small
|
| 383 |
blocks, it's worth marking the superblock with VALGRIND_MAKE_NOACCESS
|
383 |
blocks, it's worth marking the superblock with VALGRIND_MAKE_NOACCESS
|
| 384 |
when it's created, so that block overruns are detected. But if you can
|
384 |
when it's created, so that block overruns are detected. But if you can
|
| 385 |
put redzones on, it's probably better to not do this, so that messages
|
385 |
put redzones on, it's probably better to not do this, so that messages
|
| 386 |
for small overruns are described in terms of the small block rather than
|
386 |
for small overruns are described in terms of the small block rather than
|
| 387 |
the superblock (but if you have a big overrun that skips over a redzone,
|
387 |
the superblock (but if you have a big overrun that skips over a redzone,
|
| 388 |
you could miss an error this way). See memcheck/tests/custom_alloc.c
|
388 |
you could miss an error this way). See memcheck/tests/custom_alloc.c
|
| 389 |
for an example.
|
389 |
for an example.
|
| 390 |
|
390 |
|
| 391 |
Nb: block must be freed via a free()-like function specified
|
391 |
Nb: block must be freed via a free()-like function specified
|
| 392 |
with VALGRIND_FREELIKE_BLOCK or mismatch errors will occur. */
|
392 |
with VALGRIND_FREELIKE_BLOCK or mismatch errors will occur. */
|
| 393 |
#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) \
|
393 |
#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) \
|
| 394 |
{unsigned int _qzz_res; \
|
394 |
{unsigned int _qzz_res; \
|
| 395 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
395 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 396 |
VG_USERREQ__MALLOCLIKE_BLOCK, \
|
396 |
VG_USERREQ__MALLOCLIKE_BLOCK, \
|
| 397 |
addr, sizeB, rzB, is_zeroed); \
|
397 |
addr, sizeB, rzB, is_zeroed); \
|
| 398 |
}
|
398 |
}
|
| 399 |
|
399 |
|
| 400 |
/* Mark a block of memory as having been freed by a free()-like function.
|
400 |
/* Mark a block of memory as having been freed by a free()-like function.
|
| 401 |
`rzB' is redzone size; it must match that given to
|
401 |
`rzB' is redzone size; it must match that given to
|
| 402 |
VALGRIND_MALLOCLIKE_BLOCK. Memory not freed will be detected by the leak
|
402 |
VALGRIND_MALLOCLIKE_BLOCK. Memory not freed will be detected by the leak
|
| 403 |
checker. Put it immediately after the point where the block is freed. */
|
403 |
checker. Put it immediately after the point where the block is freed. */
|
| 404 |
#define VALGRIND_FREELIKE_BLOCK(addr, rzB) \
|
404 |
#define VALGRIND_FREELIKE_BLOCK(addr, rzB) \
|
| 405 |
{unsigned int _qzz_res; \
|
405 |
{unsigned int _qzz_res; \
|
| 406 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
406 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 407 |
VG_USERREQ__FREELIKE_BLOCK, \
|
407 |
VG_USERREQ__FREELIKE_BLOCK, \
|
| 408 |
addr, rzB, 0, 0); \
|
408 |
addr, rzB, 0, 0); \
|
| 409 |
}
|
409 |
}
|
| 410 |
|
410 |
|
| 411 |
/* Create a memory pool. */
|
411 |
/* Create a memory pool. */
|
| 412 |
#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) \
|
412 |
#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) \
|
| 413 |
{unsigned int _qzz_res; \
|
413 |
{unsigned int _qzz_res; \
|
| 414 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
414 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 415 |
VG_USERREQ__CREATE_MEMPOOL, \
|
415 |
VG_USERREQ__CREATE_MEMPOOL, \
|
| 416 |
pool, rzB, is_zeroed, 0); \
|
416 |
pool, rzB, is_zeroed, 0); \
|
| 417 |
}
|
417 |
}
|
| 418 |
|
418 |
|
| 419 |
/* Destroy a memory pool. */
|
419 |
/* Destroy a memory pool. */
|
| 420 |
#define VALGRIND_DESTROY_MEMPOOL(pool) \
|
420 |
#define VALGRIND_DESTROY_MEMPOOL(pool) \
|
| 421 |
{unsigned int _qzz_res; \
|
421 |
{unsigned int _qzz_res; \
|
| 422 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
422 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 423 |
VG_USERREQ__DESTROY_MEMPOOL, \
|
423 |
VG_USERREQ__DESTROY_MEMPOOL, \
|
| 424 |
pool, 0, 0, 0); \
|
424 |
pool, 0, 0, 0); \
|
| 425 |
}
|
425 |
}
|
| 426 |
|
426 |
|
| 427 |
/* Associate a piece of memory with a memory pool. */
|
427 |
/* Associate a piece of memory with a memory pool. */
|
| 428 |
#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) \
|
428 |
#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) \
|
| 429 |
{unsigned int _qzz_res; \
|
429 |
{unsigned int _qzz_res; \
|
| 430 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
430 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 431 |
VG_USERREQ__MEMPOOL_ALLOC, \
|
431 |
VG_USERREQ__MEMPOOL_ALLOC, \
|
| 432 |
pool, addr, size, 0); \
|
432 |
pool, addr, size, 0); \
|
| 433 |
}
|
433 |
}
|
| 434 |
|
434 |
|
| 435 |
/* Disassociate a piece of memory from a memory pool. */
|
435 |
/* Disassociate a piece of memory from a memory pool. */
|
| 436 |
#define VALGRIND_MEMPOOL_FREE(pool, addr) \
|
436 |
#define VALGRIND_MEMPOOL_FREE(pool, addr) \
|
| 437 |
{unsigned int _qzz_res; \
|
437 |
{unsigned int _qzz_res; \
|
| 438 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
438 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 439 |
VG_USERREQ__MEMPOOL_FREE, \
|
439 |
VG_USERREQ__MEMPOOL_FREE, \
|
| 440 |
pool, addr, 0, 0); \
|
440 |
pool, addr, 0, 0); \
|
| 441 |
}
|
441 |
}
|
| 442 |
|
442 |
|
| 443 |
/* Mark a piece of memory as being a stack. Returns a stack id. */
|
443 |
/* Mark a piece of memory as being a stack. Returns a stack id. */
|
| 444 |
#define VALGRIND_STACK_REGISTER(start, end) \
|
444 |
#define VALGRIND_STACK_REGISTER(start, end) \
|
| 445 |
({unsigned int _qzz_res; \
|
445 |
({unsigned int _qzz_res; \
|
| 446 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
446 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 447 |
VG_USERREQ__STACK_REGISTER, \
|
447 |
VG_USERREQ__STACK_REGISTER, \
|
| 448 |
start, end, 0, 0); \
|
448 |
start, end, 0, 0); \
|
| 449 |
_qzz_res; \
|
449 |
_qzz_res; \
|
| 450 |
})
|
450 |
})
|
| 451 |
|
451 |
|
| 452 |
/* Unmark the piece of memory associated with a stack id as being a
|
452 |
/* Unmark the piece of memory associated with a stack id as being a
|
| 453 |
stack. */
|
453 |
stack. */
|
| 454 |
#define VALGRIND_STACK_DEREGISTER(id) \
|
454 |
#define VALGRIND_STACK_DEREGISTER(id) \
|
| 455 |
{unsigned int _qzz_res; \
|
455 |
{unsigned int _qzz_res; \
|
| 456 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
456 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 457 |
VG_USERREQ__STACK_DEREGISTER, \
|
457 |
VG_USERREQ__STACK_DEREGISTER, \
|
| 458 |
id, 0, 0, 0); \
|
458 |
id, 0, 0, 0); \
|
| 459 |
}
|
459 |
}
|
| 460 |
|
460 |
|
| 461 |
/* Change the start and end address of the stack id. */
|
461 |
/* Change the start and end address of the stack id. */
|
| 462 |
#define VALGRIND_STACK_CHANGE(id, start, end) \
|
462 |
#define VALGRIND_STACK_CHANGE(id, start, end) \
|
| 463 |
{unsigned int _qzz_res; \
|
463 |
{unsigned int _qzz_res; \
|
| 464 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
464 |
VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, \
|
| 465 |
VG_USERREQ__STACK_CHANGE, \
|
465 |
VG_USERREQ__STACK_CHANGE, \
|
| 466 |
id, start, end, 0); \
|
466 |
id, start, end, 0); \
|
| 467 |
}
|
467 |
}
|
| 468 |
|
468 |
|
| 469 |
#endif /* __VALGRIND_H */
|
469 |
#endif /* __VALGRIND_H */
|