bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | This file is part of drd, a data race detector. |
| 3 | |
| 4 | Copyright (C) 2006-2008 Bart Van Assche |
| 5 | bart.vanassche@gmail.com |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 2 of the |
| 10 | License, or (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 20 | 02111-1307, USA. |
| 21 | |
| 22 | The GNU General Public License is contained in the file COPYING. |
| 23 | */ |
| 24 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame^] | 25 | /* |
| 26 | * This header file contains the tool-internal interface for the code that |
| 27 | * processes client requests. |
| 28 | */ |
| 29 | |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 30 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 31 | #ifndef __DRD_CLIENTREQ_H |
| 32 | #define __DRD_CLIENTREQ_H |
| 33 | |
| 34 | |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 35 | #include "drd.h" |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame^] | 36 | #include "drd_basics.h" /* DRD_() */ |
bart | d00bd22 | 2008-03-30 08:40:49 +0000 | [diff] [blame] | 37 | |
| 38 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame^] | 39 | /* |
| 40 | * While the client requests defined in the header file "drd.h" define a |
| 41 | * public interface between client programs and the DRD tool, the client |
| 42 | * requests defined below are a tool-internal interface. These last client |
| 43 | * requests must only be used by the source code in the various *_intercepts.c |
| 44 | * source files. |
| 45 | */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 46 | enum { |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 47 | /* Ask drd to suppress data race reports on all currently allocated stack */ |
| 48 | /* data of the current thread. */ |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 49 | VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK = VG_USERREQ_TOOL_BASE('D', 'r'), |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 50 | /* args: none */ |
| 51 | /* To ask the drd tool to start a new segment in the specified thread. */ |
| 52 | VG_USERREQ__DRD_START_NEW_SEGMENT, |
| 53 | /* args: POSIX thread ID. */ |
bart | bf3a60c | 2008-04-04 19:10:21 +0000 | [diff] [blame] | 54 | /* Let the drd tool stop recording memory accesses in the calling thread. */ |
| 55 | VG_USERREQ__DRD_STOP_RECORDING, |
| 56 | /* args: none. */ |
| 57 | /* Let the drd tool start recording memory accesses in the calling thread. */ |
| 58 | VG_USERREQ__DRD_START_RECORDING, |
| 59 | /* args: none. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 60 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 61 | /* Tell the core the pthread_t of the running thread */ |
| 62 | VG_USERREQ__SET_PTHREADID, |
| 63 | /* args: pthread_t. */ |
| 64 | /* Ask the core that a the thread's state transition from */ |
| 65 | /* VgTs_Zombie to VgTs_Empty is delayed until */ |
| 66 | /* VG_USERREQ__POST_THREAD_JOIN is performed. */ |
| 67 | VG_USERREQ__SET_JOINABLE, |
| 68 | /* args: pthread_t, Bool */ |
| 69 | |
| 70 | /* To notify drd that a thread finished because */ |
| 71 | /* pthread_thread_join() was called on it. */ |
| 72 | VG_USERREQ__POST_THREAD_JOIN, |
| 73 | /* args: pthread_t (joinee) */ |
| 74 | |
bart | 0f099cd | 2008-09-27 12:36:48 +0000 | [diff] [blame] | 75 | /* To notify drd before a pthread_cancel call. */ |
| 76 | VG_USERREQ__PRE_THREAD_CANCEL, |
| 77 | /* args: pthread_t */ |
| 78 | /* To notify drd after a pthread_cancel call. */ |
| 79 | VG_USERREQ__POST_THREAD_CANCEL, |
| 80 | /* args: pthread_t, Bool */ |
| 81 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 82 | /* to notify the drd tool of a pthread_mutex_init call. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 83 | VG_USERREQ__PRE_MUTEX_INIT, |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 84 | /* args: Addr, MutexT */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 85 | /* to notify the drd tool of a pthread_mutex_init call. */ |
| 86 | VG_USERREQ__POST_MUTEX_INIT, |
| 87 | /* args: Addr */ |
| 88 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
| 89 | VG_USERREQ__PRE_MUTEX_DESTROY, |
| 90 | /* args: Addr */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 91 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 92 | VG_USERREQ__POST_MUTEX_DESTROY, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 93 | /* args: Addr, MutexT */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 94 | /* to notify the drd tool of pthread_mutex_lock calls */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 95 | VG_USERREQ__PRE_MUTEX_LOCK, |
bart | 2e3a3c1 | 2008-03-24 08:33:47 +0000 | [diff] [blame] | 96 | /* args: Addr, MutexT, Bool */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 97 | /* to notify the drd tool of pthread_mutex_lock calls */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 98 | VG_USERREQ__POST_MUTEX_LOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 99 | /* args: Addr, Bool */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 100 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 101 | VG_USERREQ__PRE_MUTEX_UNLOCK, |
| 102 | /* args: Addr */ |
| 103 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
| 104 | VG_USERREQ__POST_MUTEX_UNLOCK, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 105 | /* args: Addr */ |
bart | f4f0581 | 2008-07-07 08:10:56 +0000 | [diff] [blame] | 106 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 107 | VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK, |
| 108 | /* args: Addr */ |
| 109 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 110 | VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK, |
| 111 | /* args: Addr */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 112 | |
| 113 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 114 | /* to notify the drd tool of a pthread_cond_init call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 115 | VG_USERREQ__PRE_COND_INIT, |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 116 | /* args: Addr */ |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 117 | /* to notify the drd tool of a pthread_cond_init call. */ |
| 118 | VG_USERREQ__POST_COND_INIT, |
| 119 | /* args: Addr */ |
| 120 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
| 121 | VG_USERREQ__PRE_COND_DESTROY, |
| 122 | /* args: Addr */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 123 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 124 | VG_USERREQ__POST_COND_DESTROY, |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 125 | /* args: Addr */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 126 | VG_USERREQ__PRE_COND_WAIT, |
| 127 | /* args: Addr cond, Addr mutex, MutexT mt */ |
| 128 | VG_USERREQ__POST_COND_WAIT, |
| 129 | /* args: Addr cond, Addr mutex, Bool took_lock*/ |
| 130 | VG_USERREQ__PRE_COND_SIGNAL, |
| 131 | /* args: Addr cond */ |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 132 | VG_USERREQ__POST_COND_SIGNAL, |
| 133 | /* args: Addr cond */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 134 | VG_USERREQ__PRE_COND_BROADCAST, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 135 | /* args: Addr cond */ |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 136 | VG_USERREQ__POST_COND_BROADCAST, |
| 137 | /* args: Addr cond */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 138 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 139 | /* To notify the drd tool of a sem_init call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 140 | VG_USERREQ__PRE_SEM_INIT, |
| 141 | /* args: Addr sem, Word pshared, Word value */ |
| 142 | /* To notify the drd tool of a sem_init call. */ |
| 143 | VG_USERREQ__POST_SEM_INIT, |
| 144 | /* args: Addr sem */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 145 | /* To notify the drd tool of a sem_destroy call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 146 | VG_USERREQ__PRE_SEM_DESTROY, |
| 147 | /* args: Addr sem */ |
| 148 | /* To notify the drd tool of a sem_destroy call. */ |
| 149 | VG_USERREQ__POST_SEM_DESTROY, |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 150 | /* args: Addr sem */ |
| 151 | /* To notify the drd tool of a sem_wait call. */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 152 | VG_USERREQ__PRE_SEM_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 153 | /* args: Addr sem */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 154 | /* To notify the drd tool of a sem_wait call. */ |
| 155 | VG_USERREQ__POST_SEM_WAIT, |
| 156 | /* args: Addr sem, Bool waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 157 | /* To notify the drd tool before a sem_post call. */ |
| 158 | VG_USERREQ__PRE_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 159 | /* args: Addr sem */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 160 | /* To notify the drd tool after a sem_post call. */ |
| 161 | VG_USERREQ__POST_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 162 | /* args: Addr sem, Bool waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 163 | |
| 164 | /* To notify the drd tool of a pthread_barrier_init call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 165 | VG_USERREQ__PRE_BARRIER_INIT, |
| 166 | /* args: Addr barrier, BarrierT type, Word count, Bool reinit */ |
| 167 | /* To notify the drd tool of a pthread_barrier_init call. */ |
| 168 | VG_USERREQ__POST_BARRIER_INIT, |
| 169 | /* args: Addr barrier, BarrierT type */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 170 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 171 | VG_USERREQ__PRE_BARRIER_DESTROY, |
| 172 | /* args: Addr barrier, BarrierT type. */ |
| 173 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
| 174 | VG_USERREQ__POST_BARRIER_DESTROY, |
| 175 | /* args: Addr barrier, BarrierT type. */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 176 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 177 | VG_USERREQ__PRE_BARRIER_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 178 | /* args: Addr barrier, BarrierT type. */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 179 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 180 | VG_USERREQ__POST_BARRIER_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 181 | /* args: Addr barrier, BarrierT type, Word has_waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 182 | |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 183 | /* To notify the drd tool of a pthread_rwlock_init call. */ |
| 184 | VG_USERREQ__PRE_RWLOCK_INIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 185 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 186 | /* To notify the drd tool of a pthread_rwlock_destroy call. */ |
| 187 | VG_USERREQ__POST_RWLOCK_DESTROY, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 188 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 189 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 190 | VG_USERREQ__PRE_RWLOCK_RDLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 191 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 192 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 193 | VG_USERREQ__POST_RWLOCK_RDLOCK, |
| 194 | /* args: Addr rwlock, Bool took_lock */ |
| 195 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 196 | VG_USERREQ__PRE_RWLOCK_WRLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 197 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 198 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 199 | VG_USERREQ__POST_RWLOCK_WRLOCK, |
| 200 | /* args: Addr rwlock, Bool took_lock */ |
| 201 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 202 | VG_USERREQ__PRE_RWLOCK_UNLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 203 | /* args: Addr rwlock */ |
| 204 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
bart | d00bd22 | 2008-03-30 08:40:49 +0000 | [diff] [blame] | 205 | VG_USERREQ__POST_RWLOCK_UNLOCK |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 206 | /* args: Addr rwlock, Bool unlocked */ |
| 207 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 208 | }; |
| 209 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame^] | 210 | /* |
| 211 | * Error checking on POSIX recursive mutexes, POSIX error checking mutexes, |
| 212 | * POSIX default mutexes and POSIX spinlocks happens by the same code. The |
| 213 | * values defined below specify which of these types a mutex really is. |
| 214 | */ |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 215 | typedef enum |
| 216 | { |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 217 | mutex_type_unknown = -1, |
| 218 | mutex_type_invalid_mutex = 0, |
| 219 | mutex_type_recursive_mutex = 1, |
| 220 | mutex_type_errorcheck_mutex = 2, |
| 221 | mutex_type_default_mutex = 3, |
| 222 | mutex_type_spinlock = 4 |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 223 | } MutexT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 224 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame^] | 225 | /* |
| 226 | * Error checking on POSIX barriers and GOMP barriers happens by the same |
| 227 | * code. The integer values defined below specify the type of a barrier with |
| 228 | * a given client address. |
| 229 | */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 230 | typedef enum |
| 231 | { |
| 232 | pthread_barrier = 1, |
bart | d00bd22 | 2008-03-30 08:40:49 +0000 | [diff] [blame] | 233 | gomp_barrier = 2 |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 234 | } BarrierT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 235 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame^] | 236 | |
| 237 | void DRD_(clientreq_init)(void); |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 238 | |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 239 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 240 | #endif // __DRD_CLIENTREQ_H |