bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | ---------------------------------------------------------------- |
| 4 | |
| 5 | Notice that the following BSD-style license applies to this one |
| 6 | file (drd.h) only. The rest of Valgrind is licensed under the |
| 7 | terms of the GNU General Public License, version 2, unless |
| 8 | otherwise indicated. See the COPYING file in the source |
| 9 | distribution for details. |
| 10 | |
| 11 | ---------------------------------------------------------------- |
| 12 | |
| 13 | This file is part of drd, a Valgrind tool for verification of |
| 14 | multithreaded programs. |
| 15 | |
| 16 | Copyright (C) 2006-2008 Bart Van Assche. All rights reserved. |
| 17 | |
| 18 | Redistribution and use in source and binary forms, with or without |
| 19 | modification, are permitted provided that the following conditions |
| 20 | are met: |
| 21 | |
| 22 | 1. Redistributions of source code must retain the above copyright |
| 23 | notice, this list of conditions and the following disclaimer. |
| 24 | |
| 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 |
| 27 | software in a product, an acknowledgment in the product |
| 28 | documentation would be appreciated but is not required. |
| 29 | |
| 30 | 3. Altered source versions must be plainly marked as such, and must |
| 31 | not be misrepresented as being the original software. |
| 32 | |
| 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 |
| 35 | permission. |
| 36 | |
| 37 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 38 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 39 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 40 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 41 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 42 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 43 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 44 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 45 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 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. |
| 48 | |
| 49 | ---------------------------------------------------------------- |
| 50 | |
| 51 | Notice that the above BSD-style license applies to this one file |
| 52 | (drd.h) only. The entire rest of Valgrind is licensed under |
| 53 | the terms of the GNU General Public License, version 2. See the |
| 54 | COPYING file in the source distribution for details. |
| 55 | |
| 56 | ---------------------------------------------------------------- |
| 57 | */ |
| 58 | |
| 59 | #ifndef __VALGRIND_DRD_H |
| 60 | #define __VALGRIND_DRD_H |
| 61 | |
| 62 | |
| 63 | #include "valgrind.h" |
| 64 | |
| 65 | |
| 66 | /* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! |
| 67 | This enum comprises an ABI exported by Valgrind to programs |
| 68 | which use client requests. DO NOT CHANGE THE ORDER OF THESE |
| 69 | ENTRIES, NOR DELETE ANY -- add new ones at the end. |
| 70 | */ |
| 71 | |
| 72 | |
| 73 | /** Tell DRD to suppress data race detection on the specified variable. */ |
| 74 | #define DRD_IGNORE_VAR(x) vg_drd_ignore_range(&(x), sizeof(x)) |
| 75 | |
| 76 | /** Tell DRD to trace all memory accesses on the specified variable. |
| 77 | * until the memory that was allocated for the variable is freed. |
| 78 | */ |
| 79 | #define DRD_TRACE_VAR(x) vg_drd_trace_range(&(x), sizeof(x)) |
| 80 | |
| 81 | |
| 82 | enum |
| 83 | { |
| 84 | /* Ask the core the thread ID assigned by Valgrind. */ |
| 85 | VG_USERREQ__GET_THREAD_SELF = VG_USERREQ_TOOL_BASE('D','R'), |
| 86 | /* args: none. */ |
| 87 | |
| 88 | /* To tell the drd tool to suppress data race detection on the specified */ |
| 89 | /* address range. */ |
| 90 | VG_USERREQ__DRD_START_SUPPRESSION, |
| 91 | /* args: start address, size in bytes */ |
| 92 | /* To tell the drd tool no longer to suppress data race detection on the */ |
| 93 | /* specified address range. */ |
| 94 | VG_USERREQ__DRD_FINISH_SUPPRESSION, |
| 95 | /* args: start address, size in bytes */ |
| 96 | |
| 97 | /* To ask the drd tool to trace all accesses to the specified range. */ |
| 98 | VG_USERREQ__DRD_START_TRACE_ADDR, |
| 99 | /* args: Addr, SizeT. */ |
| 100 | /* To ask the drd tool to stop tracing accesses to the specified range. */ |
| 101 | VG_USERREQ__DRD_STOP_TRACE_ADDR, |
| 102 | /* args: Addr, SizeT. */ |
| 103 | }; |
| 104 | |
| 105 | |
| 106 | static __inline__ |
| 107 | int vg_get_drd_threadid(void) |
| 108 | { |
| 109 | int res; |
| 110 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__GET_THREAD_SELF, 0,0,0,0,0); |
| 111 | return res; |
| 112 | } |
| 113 | |
| 114 | static __inline__ |
| 115 | void vg_drd_ignore_range(const void* const p, const int size) |
| 116 | { |
| 117 | int res; |
| 118 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_START_SUPPRESSION, |
| 119 | p, size, 0, 0, 0); |
| 120 | } |
| 121 | |
| 122 | static __inline__ |
| 123 | void vg_drd_trace_range(const void* const p, const int size) |
| 124 | { |
| 125 | int res; |
| 126 | VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_START_TRACE_ADDR, |
| 127 | p, size, 0, 0, 0); |
| 128 | } |
| 129 | |
| 130 | |
| 131 | #endif /* __VALGRIND_DRD_H */ |