OLD | NEW |
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 rest of Valgrind is licensed under the | 5 file (valgrind.h) only. The rest of Valgrind is licensed under the |
6 terms of the GNU General Public License, version 2, unless | 6 terms of the GNU General Public License, version 2, unless |
7 otherwise indicated. See the COPYING file in the source | 7 otherwise indicated. See the COPYING file in the source |
8 distribution for details. | 8 distribution for details. |
9 | 9 |
10 ---------------------------------------------------------------- | 10 ---------------------------------------------------------------- |
11 | 11 |
12 This file is part of Valgrind, a dynamic binary instrumentation | 12 This file is part of Valgrind, a dynamic binary instrumentation |
13 framework. | 13 framework. |
14 | 14 |
15 Copyright (C) 2000-2010 Julian Seward. All rights reserved. | 15 Copyright (C) 2000-2010 Julian Seward. All rights reserved. |
16 | 16 |
17 Redistribution and use in source and binary forms, with or without | 17 Redistribution and use in source and binary forms, with or without |
18 modification, are permitted provided that the following conditions | 18 modification, are permitted provided that the following conditions |
19 are met: | 19 are met: |
20 | 20 |
21 1. Redistributions of source code must retain the above copyright | 21 1. Redistributions of source code must retain the above copyright |
22 notice, this list of conditions and the following disclaimer. | 22 notice, this list of conditions and the following disclaimer. |
23 | 23 |
24 2. The origin of this software must not be misrepresented; you must | 24 2. The origin of this software must not be misrepresented; you must |
25 not claim that you wrote the original software. If you use this | 25 not claim that you wrote the original software. If you use this |
26 software in a product, an acknowledgment in the product | 26 software in a product, an acknowledgment in the product |
27 documentation would be appreciated but is not required. | 27 documentation would be appreciated but is not required. |
28 | 28 |
29 3. Altered source versions must be plainly marked as such, and must | 29 3. Altered source versions must be plainly marked as such, and must |
30 not be misrepresented as being the original software. | 30 not be misrepresented as being the original software. |
31 | 31 |
32 4. The name of the author may not be used to endorse or promote | 32 4. The name of the author may not be used to endorse or promote |
33 products derived from this software without specific prior written | 33 products derived from this software without specific prior written |
34 permission. | 34 permission. |
35 | 35 |
36 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | 36 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
37 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 37 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
38 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 38 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
39 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | 39 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
40 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 40 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
41 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 41 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
42 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 42 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
43 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 43 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
44 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 44 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
45 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 45 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
46 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 46 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
47 | 47 |
48 ---------------------------------------------------------------- | 48 ---------------------------------------------------------------- |
49 | 49 |
50 Notice that the above BSD-style license applies to this one file | 50 Notice that the above BSD-style license applies to this one file |
51 (valgrind.h) only. The entire rest of Valgrind is licensed under | 51 (valgrind.h) only. The entire rest of Valgrind is licensed under |
52 the terms of the GNU General Public License, version 2. See the | 52 the terms of the GNU General Public License, version 2. See the |
53 COPYING file in the source distribution for details. | 53 COPYING file in the source distribution for details. |
54 | 54 |
55 ---------------------------------------------------------------- | 55 ---------------------------------------------------------------- |
56 */ | 56 */ |
57 | 57 |
58 | 58 |
59 /* This file is for inclusion into client (your!) code. | 59 /* This file is for inclusion into client (your!) code. |
60 | 60 |
61 You can use these macros to manipulate and query Valgrind's | 61 You can use these macros to manipulate and query Valgrind's |
62 execution inside your own programs. | 62 execution inside your own programs. |
63 | 63 |
64 The resulting executables will still run without Valgrind, just a | 64 The resulting executables will still run without Valgrind, just a |
65 little bit more slowly than they otherwise would, but otherwise | 65 little bit more slowly than they otherwise would, but otherwise |
66 unchanged. When not running on valgrind, each client request | 66 unchanged. When not running on valgrind, each client request |
67 consumes very few (eg. 7) instructions, so the resulting performance | 67 consumes very few (eg. 7) instructions, so the resulting performance |
68 loss is negligible unless you plan to execute client requests | 68 loss is negligible unless you plan to execute client requests |
69 millions of times per second. Nevertheless, if that is still a | 69 millions of times per second. Nevertheless, if that is still a |
70 problem, you can compile with the NVALGRIND symbol defined (gcc | 70 problem, you can compile with the NVALGRIND symbol defined (gcc |
71 -DNVALGRIND) so that client requests are not even compiled in. */ | 71 -DNVALGRIND) so that client requests are not even compiled in. */ |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 The assembly code sequences for all architectures is in this one | 188 The assembly code sequences for all architectures is in this one |
189 file. This is because this file must be stand-alone, and we don't | 189 file. This is because this file must be stand-alone, and we don't |
190 want to have multiple files. | 190 want to have multiple files. |
191 | 191 |
192 For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default | 192 For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default |
193 value gets put in the return slot, so that everything works when | 193 value gets put in the return slot, so that everything works when |
194 this is executed not under Valgrind. Args are passed in a memory | 194 this is executed not under Valgrind. Args are passed in a memory |
195 block, and so there's no intrinsic limit to the number that could | 195 block, and so there's no intrinsic limit to the number that could |
196 be passed, but it's currently five. | 196 be passed, but it's currently five. |
197 | 197 |
198 The macro args are: | 198 The macro args are: |
199 _zzq_rlval result lvalue | 199 _zzq_rlval result lvalue |
200 _zzq_default default value (result returned when running on real CPU) | 200 _zzq_default default value (result returned when running on real CPU) |
201 _zzq_request request code | 201 _zzq_request request code |
202 _zzq_arg1..5 request params | 202 _zzq_arg1..5 request params |
203 | 203 |
204 The other two macros are used to support function wrapping, and are | 204 The other two macros are used to support function wrapping, and are |
205 a lot simpler. VALGRIND_GET_NR_CONTEXT returns the value of the | 205 a lot simpler. VALGRIND_GET_NR_CONTEXT returns the value of the |
206 guest's NRADDR pseudo-register and whatever other information is | 206 guest's NRADDR pseudo-register and whatever other information is |
207 needed to safely run the call original from the wrapper: on | 207 needed to safely run the call original from the wrapper: on |
208 ppc64-linux, the R2 value at the divert point is also needed. This | 208 ppc64-linux, the R2 value at the divert point is also needed. This |
209 information is abstracted into a user-visible type, OrigFn. | 209 information is abstracted into a user-visible type, OrigFn. |
210 | 210 |
211 VALGRIND_CALL_NOREDIR_* behaves the same as the following on the | 211 VALGRIND_CALL_NOREDIR_* behaves the same as the following on the |
212 guest, but guarantees that the branch instruction will not be | 212 guest, but guarantees that the branch instruction will not be |
213 redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64: | 213 redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64: |
214 branch-and-link-to-r11. VALGRIND_CALL_NOREDIR is just text, not a | 214 branch-and-link-to-r11. VALGRIND_CALL_NOREDIR is just text, not a |
215 complete inline asm, since it needs to be combined with more magic | 215 complete inline asm, since it needs to be combined with more magic |
216 inline asm stuff to be useful. | 216 inline asm stuff to be useful. |
217 */ | 217 */ |
218 | 218 |
219 /* ------------------------- x86-{linux,darwin} ---------------- */ | 219 /* ------------------------- x86-{linux,darwin} ---------------- */ |
220 | 220 |
221 #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin) \ | 221 #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin) \ |
222 || (defined(PLAT_x86_win32) && defined(__GNUC__)) | 222 || (defined(PLAT_x86_win32) && defined(__GNUC__)) |
223 | 223 |
224 typedef | 224 typedef |
225 struct { | 225 struct { |
226 unsigned int nraddr; /* where's the code? */ | 226 unsigned int nraddr; /* where's the code? */ |
227 } | 227 } |
228 OrigFn; | 228 OrigFn; |
229 | 229 |
230 #define __SPECIAL_INSTRUCTION_PREAMBLE \ | 230 #define __SPECIAL_INSTRUCTION_PREAMBLE \ |
231 "roll $3, %%edi ; roll $13, %%edi\n\t" \ | 231 "roll $3, %%edi ; roll $13, %%edi\n\t" \ |
232 "roll $29, %%edi ; roll $19, %%edi\n\t" | 232 "roll $29, %%edi ; roll $19, %%edi\n\t" |
233 | 233 |
234 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ | 234 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ |
235 _zzq_default, _zzq_request, \ | 235 _zzq_default, _zzq_request, \ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 __SPECIAL_INSTRUCTION_PREAMBLE \ | 270 __SPECIAL_INSTRUCTION_PREAMBLE \ |
271 /* call-noredir *%EAX */ \ | 271 /* call-noredir *%EAX */ \ |
272 "xchgl %%edx,%%edx\n\t" | 272 "xchgl %%edx,%%edx\n\t" |
273 #endif /* PLAT_x86_linux || PLAT_x86_darwin || (PLAT_x86_win32 && __GNUC__) */ | 273 #endif /* PLAT_x86_linux || PLAT_x86_darwin || (PLAT_x86_win32 && __GNUC__) */ |
274 | 274 |
275 /* ------------------------- x86-Win32 ------------------------- */ | 275 /* ------------------------- x86-Win32 ------------------------- */ |
276 | 276 |
277 #if defined(PLAT_x86_win32) && !defined(__GNUC__) | 277 #if defined(PLAT_x86_win32) && !defined(__GNUC__) |
278 | 278 |
279 typedef | 279 typedef |
280 struct { | 280 struct { |
281 unsigned int nraddr; /* where's the code? */ | 281 unsigned int nraddr; /* where's the code? */ |
282 } | 282 } |
283 OrigFn; | 283 OrigFn; |
284 | 284 |
285 #if defined(_MSC_VER) | 285 #if defined(_MSC_VER) |
286 | 286 |
287 #define __SPECIAL_INSTRUCTION_PREAMBLE \ | 287 #define __SPECIAL_INSTRUCTION_PREAMBLE \ |
288 __asm rol edi, 3 __asm rol edi, 13 \ | 288 __asm rol edi, 3 __asm rol edi, 13 \ |
289 __asm rol edi, 29 __asm rol edi, 19 | 289 __asm rol edi, 29 __asm rol edi, 19 |
290 | 290 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 #error Unsupported compiler. | 336 #error Unsupported compiler. |
337 #endif | 337 #endif |
338 | 338 |
339 #endif /* PLAT_x86_win32 */ | 339 #endif /* PLAT_x86_win32 */ |
340 | 340 |
341 /* ------------------------ amd64-{linux,darwin} --------------- */ | 341 /* ------------------------ amd64-{linux,darwin} --------------- */ |
342 | 342 |
343 #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin) | 343 #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin) |
344 | 344 |
345 typedef | 345 typedef |
346 struct { | 346 struct { |
347 uint64_t nraddr; /* where's the code? */ | 347 uint64_t nraddr; /* where's the code? */ |
348 } | 348 } |
349 OrigFn; | 349 OrigFn; |
350 | 350 |
351 #define __SPECIAL_INSTRUCTION_PREAMBLE \ | 351 #define __SPECIAL_INSTRUCTION_PREAMBLE \ |
352 "rolq $3, %%rdi ; rolq $13, %%rdi\n\t" \ | 352 "rolq $3, %%rdi ; rolq $13, %%rdi\n\t" \ |
353 "rolq $61, %%rdi ; rolq $51, %%rdi\n\t" | 353 "rolq $61, %%rdi ; rolq $51, %%rdi\n\t" |
354 | 354 |
355 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ | 355 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ |
356 _zzq_default, _zzq_request, \ | 356 _zzq_default, _zzq_request, \ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 __SPECIAL_INSTRUCTION_PREAMBLE \ | 391 __SPECIAL_INSTRUCTION_PREAMBLE \ |
392 /* call-noredir *%RAX */ \ | 392 /* call-noredir *%RAX */ \ |
393 "xchgq %%rdx,%%rdx\n\t" | 393 "xchgq %%rdx,%%rdx\n\t" |
394 #endif /* PLAT_amd64_linux || PLAT_amd64_darwin */ | 394 #endif /* PLAT_amd64_linux || PLAT_amd64_darwin */ |
395 | 395 |
396 /* ------------------------ ppc32-linux ------------------------ */ | 396 /* ------------------------ ppc32-linux ------------------------ */ |
397 | 397 |
398 #if defined(PLAT_ppc32_linux) | 398 #if defined(PLAT_ppc32_linux) |
399 | 399 |
400 typedef | 400 typedef |
401 struct { | 401 struct { |
402 unsigned int nraddr; /* where's the code? */ | 402 unsigned int nraddr; /* where's the code? */ |
403 } | 403 } |
404 OrigFn; | 404 OrigFn; |
405 | 405 |
406 #define __SPECIAL_INSTRUCTION_PREAMBLE \ | 406 #define __SPECIAL_INSTRUCTION_PREAMBLE \ |
407 "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \ | 407 "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \ |
408 "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t" | 408 "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t" |
409 | 409 |
410 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ | 410 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ |
411 _zzq_default, _zzq_request, \ | 411 _zzq_default, _zzq_request, \ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 __SPECIAL_INSTRUCTION_PREAMBLE \ | 452 __SPECIAL_INSTRUCTION_PREAMBLE \ |
453 /* branch-and-link-to-noredir *%R11 */ \ | 453 /* branch-and-link-to-noredir *%R11 */ \ |
454 "or 3,3,3\n\t" | 454 "or 3,3,3\n\t" |
455 #endif /* PLAT_ppc32_linux */ | 455 #endif /* PLAT_ppc32_linux */ |
456 | 456 |
457 /* ------------------------ ppc64-linux ------------------------ */ | 457 /* ------------------------ ppc64-linux ------------------------ */ |
458 | 458 |
459 #if defined(PLAT_ppc64_linux) | 459 #if defined(PLAT_ppc64_linux) |
460 | 460 |
461 typedef | 461 typedef |
462 struct { | 462 struct { |
463 uint64_t nraddr; /* where's the code? */ | 463 uint64_t nraddr; /* where's the code? */ |
464 uint64_t r2; /* what tocptr do we need? */ | 464 uint64_t r2; /* what tocptr do we need? */ |
465 } | 465 } |
466 OrigFn; | 466 OrigFn; |
467 | 467 |
468 #define __SPECIAL_INSTRUCTION_PREAMBLE \ | 468 #define __SPECIAL_INSTRUCTION_PREAMBLE \ |
469 "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \ | 469 "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \ |
470 "rotldi 0,0,61 ; rotldi 0,0,51\n\t" | 470 "rotldi 0,0,61 ; rotldi 0,0,51\n\t" |
471 | 471 |
472 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ | 472 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 /* branch-and-link-to-noredir *%R11 */ \ | 519 /* branch-and-link-to-noredir *%R11 */ \ |
520 "or 3,3,3\n\t" | 520 "or 3,3,3\n\t" |
521 | 521 |
522 #endif /* PLAT_ppc64_linux */ | 522 #endif /* PLAT_ppc64_linux */ |
523 | 523 |
524 /* ------------------------- arm-linux ------------------------- */ | 524 /* ------------------------- arm-linux ------------------------- */ |
525 | 525 |
526 #if defined(PLAT_arm_linux) | 526 #if defined(PLAT_arm_linux) |
527 | 527 |
528 typedef | 528 typedef |
529 struct { | 529 struct { |
530 unsigned int nraddr; /* where's the code? */ | 530 unsigned int nraddr; /* where's the code? */ |
531 } | 531 } |
532 OrigFn; | 532 OrigFn; |
533 | 533 |
534 #define __SPECIAL_INSTRUCTION_PREAMBLE \ | 534 #define __SPECIAL_INSTRUCTION_PREAMBLE \ |
535 "mov r12, r12, ror #3 ; mov r12, r12, ror #13 \n\t" \ | 535 "mov r12, r12, ror #3 ; mov r12, r12, ror #13 \n\t" \ |
536 "mov r12, r12, ror #29 ; mov r12, r12, ror #19 \n\t" | 536 "mov r12, r12, ror #29 ; mov r12, r12, ror #19 \n\t" |
537 | 537 |
538 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ | 538 #define VALGRIND_DO_CLIENT_REQUEST_EXPR( \ |
539 _zzq_default, _zzq_request, \ | 539 _zzq_default, _zzq_request, \ |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1702 | 1702 |
1703 /* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ | 1703 /* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ |
1704 | 1704 |
1705 /* These regs are trashed by the hidden call. */ | 1705 /* These regs are trashed by the hidden call. */ |
1706 #define __CALLER_SAVED_REGS \ | 1706 #define __CALLER_SAVED_REGS \ |
1707 "lr", "ctr", "xer", \ | 1707 "lr", "ctr", "xer", \ |
1708 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ | 1708 "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ |
1709 "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ | 1709 "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ |
1710 "r11", "r12", "r13" | 1710 "r11", "r12", "r13" |
1711 | 1711 |
1712 /* These CALL_FN_ macros assume that on ppc32-linux, | 1712 /* These CALL_FN_ macros assume that on ppc32-linux, |
1713 sizeof(unsigned long) == 4. */ | 1713 sizeof(unsigned long) == 4. */ |
1714 | 1714 |
1715 #define CALL_FN_W_v(lval, orig) \ | 1715 #define CALL_FN_W_v(lval, orig) \ |
1716 do { \ | 1716 do { \ |
1717 volatile OrigFn _orig = (orig); \ | 1717 volatile OrigFn _orig = (orig); \ |
1718 volatile unsigned long _argvec[1]; \ | 1718 volatile unsigned long _argvec[1]; \ |
1719 volatile unsigned long _res; \ | 1719 volatile unsigned long _res; \ |
1720 _argvec[0] = (unsigned long)_orig.nraddr; \ | 1720 _argvec[0] = (unsigned long)_orig.nraddr; \ |
1721 __asm__ volatile( \ | 1721 __asm__ volatile( \ |
1722 "mr 11,%1\n\t" \ | 1722 "mr 11,%1\n\t" \ |
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3574 ones start at 0x2000. | 3574 ones start at 0x2000. |
3575 */ | 3575 */ |
3576 | 3576 |
3577 /* These macros are used by tools -- they must be public, but don't | 3577 /* These macros are used by tools -- they must be public, but don't |
3578 embed them into other programs. */ | 3578 embed them into other programs. */ |
3579 #define VG_USERREQ_TOOL_BASE(a,b) \ | 3579 #define VG_USERREQ_TOOL_BASE(a,b) \ |
3580 ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16)) | 3580 ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16)) |
3581 #define VG_IS_TOOL_USERREQ(a, b, v) \ | 3581 #define VG_IS_TOOL_USERREQ(a, b, v) \ |
3582 (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000)) | 3582 (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000)) |
3583 | 3583 |
3584 /* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! | 3584 /* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! |
3585 This enum comprises an ABI exported by Valgrind to programs | 3585 This enum comprises an ABI exported by Valgrind to programs |
3586 which use client requests. DO NOT CHANGE THE ORDER OF THESE | 3586 which use client requests. DO NOT CHANGE THE ORDER OF THESE |
3587 ENTRIES, NOR DELETE ANY -- add new ones at the end. */ | 3587 ENTRIES, NOR DELETE ANY -- add new ones at the end. */ |
3588 typedef | 3588 typedef |
3589 enum { VG_USERREQ__RUNNING_ON_VALGRIND = 0x1001, | 3589 enum { VG_USERREQ__RUNNING_ON_VALGRIND = 0x1001, |
3590 VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002, | 3590 VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002, |
3591 | 3591 |
3592 /* These allow any function to be called from the simulated | 3592 /* These allow any function to be called from the simulated |
3593 CPU but run on the real CPU. Nb: the first arg passed to | 3593 CPU but run on the real CPU. Nb: the first arg passed to |
3594 the function is always the ThreadId of the running | 3594 the function is always the ThreadId of the running |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3703 #if defined(_MSC_VER) | 3703 #if defined(_MSC_VER) |
3704 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, | 3704 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, |
3705 VG_USERREQ__PRINTF_VALIST_BY_REF, | 3705 VG_USERREQ__PRINTF_VALIST_BY_REF, |
3706 (uintptr_t)format, | 3706 (uintptr_t)format, |
3707 (uintptr_t)&vargs, | 3707 (uintptr_t)&vargs, |
3708 0, 0, 0); | 3708 0, 0, 0); |
3709 #else | 3709 #else |
3710 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, | 3710 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, |
3711 VG_USERREQ__PRINTF_VALIST_BY_REF, | 3711 VG_USERREQ__PRINTF_VALIST_BY_REF, |
3712 (unsigned long)format, | 3712 (unsigned long)format, |
3713 (unsigned long)&vargs, | 3713 (unsigned long)&vargs, |
3714 0, 0, 0); | 3714 0, 0, 0); |
3715 #endif | 3715 #endif |
3716 va_end(vargs); | 3716 va_end(vargs); |
3717 return (int)_qzz_res; | 3717 return (int)_qzz_res; |
3718 #endif /* NVALGRIND */ | 3718 #endif /* NVALGRIND */ |
3719 } | 3719 } |
3720 | 3720 |
3721 #if defined(__GNUC__) || defined(__INTEL_COMPILER) | 3721 #if defined(__GNUC__) || defined(__INTEL_COMPILER) |
3722 static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) | 3722 static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) |
3723 __attribute__((format(__printf__, 1, 2), __unused__)); | 3723 __attribute__((format(__printf__, 1, 2), __unused__)); |
(...skipping 17 matching lines...) Expand all Loading... |
3741 #if defined(_MSC_VER) | 3741 #if defined(_MSC_VER) |
3742 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, | 3742 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, |
3743 VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF, | 3743 VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF, |
3744 (uintptr_t)format, | 3744 (uintptr_t)format, |
3745 (uintptr_t)&vargs, | 3745 (uintptr_t)&vargs, |
3746 0, 0, 0); | 3746 0, 0, 0); |
3747 #else | 3747 #else |
3748 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, | 3748 _qzz_res = VALGRIND_DO_CLIENT_REQUEST_EXPR(0, |
3749 VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF, | 3749 VG_USERREQ__PRINTF_BACKTRACE_VALIST_BY_REF, |
3750 (unsigned long)format, | 3750 (unsigned long)format, |
3751 (unsigned long)&vargs, | 3751 (unsigned long)&vargs, |
3752 0, 0, 0); | 3752 0, 0, 0); |
3753 #endif | 3753 #endif |
3754 va_end(vargs); | 3754 va_end(vargs); |
3755 return (int)_qzz_res; | 3755 return (int)_qzz_res; |
3756 #endif /* NVALGRIND */ | 3756 #endif /* NVALGRIND */ |
3757 } | 3757 } |
3758 | 3758 |
3759 | 3759 |
3760 /* These requests allow control to move from the simulated CPU to the | 3760 /* These requests allow control to move from the simulated CPU to the |
3761 real CPU, calling an arbitary function. | 3761 real CPU, calling an arbitary function. |
3762 | 3762 |
3763 Note that the current ThreadId is inserted as the first argument. | 3763 Note that the current ThreadId is inserted as the first argument. |
3764 So this call: | 3764 So this call: |
3765 | 3765 |
3766 VALGRIND_NON_SIMD_CALL2(f, arg1, arg2) | 3766 VALGRIND_NON_SIMD_CALL2(f, arg1, arg2) |
3767 | 3767 |
3768 requires f to have this signature: | 3768 requires f to have this signature: |
3769 | 3769 |
3770 Word f(Word tid, Word arg1, Word arg2) | 3770 Word f(Word tid, Word arg1, Word arg2) |
3771 | 3771 |
3772 where "Word" is a word-sized type. | 3772 where "Word" is a word-sized type. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3838 does two things: | 3838 does two things: |
3839 | 3839 |
3840 - It records that the block has been allocated. This means any addresses | 3840 - It records that the block has been allocated. This means any addresses |
3841 within the block mentioned in error messages will be | 3841 within the block mentioned in error messages will be |
3842 identified as belonging to the block. It also means that if the block | 3842 identified as belonging to the block. It also means that if the block |
3843 isn't freed it will be detected by the leak checker. | 3843 isn't freed it will be detected by the leak checker. |
3844 | 3844 |
3845 - It marks the block as being addressable and undefined (if 'is_zeroed' is | 3845 - It marks the block as being addressable and undefined (if 'is_zeroed' is |
3846 not set), or addressable and defined (if 'is_zeroed' is set). This | 3846 not set), or addressable and defined (if 'is_zeroed' is set). This |
3847 controls how accesses to the block by the program are handled. | 3847 controls how accesses to the block by the program are handled. |
3848 | 3848 |
3849 'addr' is the start of the usable block (ie. after any | 3849 'addr' is the start of the usable block (ie. after any |
3850 redzone), 'sizeB' is its size. 'rzB' is the redzone size if the allocator | 3850 redzone), 'sizeB' is its size. 'rzB' is the redzone size if the allocator |
3851 can apply redzones -- these are blocks of padding at the start and end of | 3851 can apply redzones -- these are blocks of padding at the start and end of |
3852 each block. Adding redzones is recommended as it makes it much more likely | 3852 each block. Adding redzones is recommended as it makes it much more likely |
3853 Valgrind will spot block overruns. `is_zeroed' indicates if the memory is | 3853 Valgrind will spot block overruns. `is_zeroed' indicates if the memory is |
3854 zeroed (or filled with another predictable value), as is the case for | 3854 zeroed (or filled with another predictable value), as is the case for |
3855 calloc(). | 3855 calloc(). |
3856 | 3856 |
3857 VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a | 3857 VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a |
3858 heap block -- that will be used by the client program -- is allocated. | 3858 heap block -- that will be used by the client program -- is allocated. |
3859 It's best to put it at the outermost level of the allocator if possible; | 3859 It's best to put it at the outermost level of the allocator if possible; |
3860 for example, if you have a function my_alloc() which calls | 3860 for example, if you have a function my_alloc() which calls |
3861 internal_alloc(), and the client request is put inside internal_alloc(), | 3861 internal_alloc(), and the client request is put inside internal_alloc(), |
3862 stack traces relating to the heap block will contain entries for both | 3862 stack traces relating to the heap block will contain entries for both |
3863 my_alloc() and internal_alloc(), which is probably not what you want. | 3863 my_alloc() and internal_alloc(), which is probably not what you want. |
3864 | 3864 |
3865 For Memcheck users: if you use VALGRIND_MALLOCLIKE_BLOCK to carve out | 3865 For Memcheck users: if you use VALGRIND_MALLOCLIKE_BLOCK to carve out |
3866 custom blocks from within a heap block, B, that has been allocated with | 3866 custom blocks from within a heap block, B, that has been allocated with |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4024 #undef PLAT_amd64_darwin | 4024 #undef PLAT_amd64_darwin |
4025 #undef PLAT_x86_win32 | 4025 #undef PLAT_x86_win32 |
4026 #undef PLAT_x86_linux | 4026 #undef PLAT_x86_linux |
4027 #undef PLAT_amd64_linux | 4027 #undef PLAT_amd64_linux |
4028 #undef PLAT_ppc32_linux | 4028 #undef PLAT_ppc32_linux |
4029 #undef PLAT_ppc64_linux | 4029 #undef PLAT_ppc64_linux |
4030 #undef PLAT_arm_linux | 4030 #undef PLAT_arm_linux |
4031 #undef PLAT_s390x_linux | 4031 #undef PLAT_s390x_linux |
4032 | 4032 |
4033 #endif /* __VALGRIND_H */ | 4033 #endif /* __VALGRIND_H */ |
OLD | NEW |