1 /* 2 This file is part of drd, a thread error detector. 3 4 Copyright (C) 2006-2015 Bart Van Assche <bvanassche@acm.org>. 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as 8 published by the Free Software Foundation; either version 2 of the 9 License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 02111-1307, USA. 20 21 The GNU General Public License is contained in the file COPYING. 22 */ 23 24 25 /* 26 * This header file contains the tool-internal interface for the code that 27 * processes client requests. 28 */ 29 30 31 #ifndef __DRD_CLIENTREQ_H 32 #define __DRD_CLIENTREQ_H 33 34 35 #include "drd.h" 36 #include "drd_basics.h" /* DRD_() */ 37 38 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 */ 46 enum { 47 /* Declare the address and size of a variable with value 48 * PTHREAD_COND_INITIALIZER. 49 */ 50 VG_USERREQ__SET_PTHREAD_COND_INITIALIZER = VG_USERREQ_TOOL_BASE('D', 'r'), 51 /* args: address, size. */ 52 53 /* To ask the drd tool to start a new segment in the specified thread. */ 54 VG_USERREQ__DRD_START_NEW_SEGMENT, 55 /* args: POSIX thread ID. */ 56 57 /* Tell drd the pthread_t of the running thread. */ 58 VG_USERREQ__SET_PTHREADID, 59 /* args: pthread_t. */ 60 /* Ask drd that a the thread's state transition from */ 61 /* VgTs_Zombie to VgTs_Empty is delayed until */ 62 /* VG_USERREQ__POST_THREAD_JOIN is performed. */ 63 VG_USERREQ__SET_JOINABLE, 64 /* args: pthread_t, Bool */ 65 66 /* Tell DRD that the calling thread is about to enter pthread_create(). */ 67 VG_USERREQ__ENTERING_PTHREAD_CREATE, 68 /* args: (none) */ 69 /* Tell DRD that the calling thread has left pthread_create(). */ 70 VG_USERREQ__LEFT_PTHREAD_CREATE, 71 /* args: (none) */ 72 73 /* To notify drd that a thread finished because */ 74 /* pthread_thread_join() was called on it. */ 75 VG_USERREQ__POST_THREAD_JOIN, 76 /* args: pthread_t (joinee) */ 77 78 /* To notify drd before a pthread_cancel call. */ 79 VG_USERREQ__PRE_THREAD_CANCEL, 80 /* args: pthread_t */ 81 /* To notify drd after a pthread_cancel call. */ 82 VG_USERREQ__POST_THREAD_CANCEL, 83 /* args: pthread_t, Bool */ 84 85 /* to notify the drd tool of a pthread_mutex_init call. */ 86 VG_USERREQ__PRE_MUTEX_INIT, 87 /* args: Addr, MutexT */ 88 /* to notify the drd tool of a pthread_mutex_init call. */ 89 VG_USERREQ__POST_MUTEX_INIT, 90 /* args: Addr */ 91 /* to notify the drd tool of a pthread_mutex_destroy call. */ 92 VG_USERREQ__PRE_MUTEX_DESTROY, 93 /* args: Addr */ 94 /* to notify the drd tool of a pthread_mutex_destroy call. */ 95 VG_USERREQ__POST_MUTEX_DESTROY, 96 /* args: Addr, MutexT */ 97 /* to notify the drd tool of pthread_mutex_lock calls */ 98 VG_USERREQ__PRE_MUTEX_LOCK, 99 /* args: Addr, MutexT, Bool */ 100 /* to notify the drd tool of pthread_mutex_lock calls */ 101 VG_USERREQ__POST_MUTEX_LOCK, 102 /* args: Addr, Bool */ 103 /* to notify the drd tool of pthread_mutex_unlock calls */ 104 VG_USERREQ__PRE_MUTEX_UNLOCK, 105 /* args: Addr */ 106 /* to notify the drd tool of pthread_mutex_unlock calls */ 107 VG_USERREQ__POST_MUTEX_UNLOCK, 108 /* args: Addr */ 109 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ 110 VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK, 111 /* args: Addr */ 112 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ 113 VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK, 114 /* args: Addr */ 115 116 117 /* to notify the drd tool of a pthread_cond_init call. */ 118 VG_USERREQ__PRE_COND_INIT, 119 /* args: Addr */ 120 /* to notify the drd tool of a pthread_cond_init call. */ 121 VG_USERREQ__POST_COND_INIT, 122 /* args: Addr */ 123 /* to notify the drd tool of a pthread_cond_destroy call. */ 124 VG_USERREQ__PRE_COND_DESTROY, 125 /* args: Addr */ 126 /* to notify the drd tool of a pthread_cond_destroy call. */ 127 VG_USERREQ__POST_COND_DESTROY, 128 /* args: Addr cond, Bool destroy_succeeded */ 129 VG_USERREQ__PRE_COND_WAIT, 130 /* args: Addr cond, Addr mutex, MutexT mt */ 131 VG_USERREQ__POST_COND_WAIT, 132 /* args: Addr cond, Addr mutex, Bool took_lock*/ 133 VG_USERREQ__PRE_COND_SIGNAL, 134 /* args: Addr cond */ 135 VG_USERREQ__POST_COND_SIGNAL, 136 /* args: Addr cond */ 137 VG_USERREQ__PRE_COND_BROADCAST, 138 /* args: Addr cond */ 139 VG_USERREQ__POST_COND_BROADCAST, 140 /* args: Addr cond */ 141 142 /* To notify the drd tool of a sem_init call. */ 143 VG_USERREQ__PRE_SEM_INIT, 144 /* args: Addr sem, Word pshared, Word value */ 145 /* To notify the drd tool of a sem_init call. */ 146 VG_USERREQ__POST_SEM_INIT, 147 /* args: Addr sem */ 148 /* To notify the drd tool of a sem_destroy call. */ 149 VG_USERREQ__PRE_SEM_DESTROY, 150 /* args: Addr sem */ 151 /* To notify the drd tool of a sem_destroy call. */ 152 VG_USERREQ__POST_SEM_DESTROY, 153 /* args: Addr sem */ 154 /* To notify the drd tool of a sem_open call. */ 155 VG_USERREQ__PRE_SEM_OPEN, 156 /* args: Addr name, Word oflag, Word mode, Word value */ 157 /* To notify the drd tool of a sem_open call. */ 158 VG_USERREQ__POST_SEM_OPEN, 159 /* args: Addr sem, Word oflag, Word mode, Word value */ 160 /* To notify the drd tool of a sem_close call. */ 161 VG_USERREQ__PRE_SEM_CLOSE, 162 /* args: Addr sem */ 163 /* To notify the drd tool of a sem_close call. */ 164 VG_USERREQ__POST_SEM_CLOSE, 165 /* args: Addr sem */ 166 /* To notify the drd tool of a sem_wait call. */ 167 VG_USERREQ__PRE_SEM_WAIT, 168 /* args: Addr sem */ 169 /* To notify the drd tool of a sem_wait call. */ 170 VG_USERREQ__POST_SEM_WAIT, 171 /* args: Addr sem, Bool waited */ 172 /* To notify the drd tool before a sem_post call. */ 173 VG_USERREQ__PRE_SEM_POST, 174 /* args: Addr sem */ 175 /* To notify the drd tool after a sem_post call. */ 176 VG_USERREQ__POST_SEM_POST, 177 /* args: Addr sem, Bool waited */ 178 179 /* To notify the drd tool of a pthread_barrier_init call. */ 180 VG_USERREQ__PRE_BARRIER_INIT, 181 /* args: Addr barrier, BarrierT type, Word count, Bool reinit */ 182 /* To notify the drd tool of a pthread_barrier_init call. */ 183 VG_USERREQ__POST_BARRIER_INIT, 184 /* args: Addr barrier, BarrierT type */ 185 /* To notify the drd tool of a pthread_barrier_destroy call. */ 186 VG_USERREQ__PRE_BARRIER_DESTROY, 187 /* args: Addr barrier, BarrierT type. */ 188 /* To notify the drd tool of a pthread_barrier_destroy call. */ 189 VG_USERREQ__POST_BARRIER_DESTROY, 190 /* args: Addr barrier, BarrierT type. */ 191 /* To notify the drd tool of a pthread_barrier_wait call. */ 192 VG_USERREQ__PRE_BARRIER_WAIT, 193 /* args: Addr barrier, BarrierT type. */ 194 /* To notify the drd tool of a pthread_barrier_wait call. */ 195 VG_USERREQ__POST_BARRIER_WAIT, 196 /* args: Addr barrier, BarrierT type, Word has_waited, Word serializing */ 197 198 /* To notify the drd tool of a pthread_rwlock_init call. */ 199 VG_USERREQ__PRE_RWLOCK_INIT, 200 /* args: Addr rwlock */ 201 /* To notify the drd tool of a pthread_rwlock_init call. */ 202 VG_USERREQ__POST_RWLOCK_INIT, 203 /* args: Addr rwlock */ 204 /* To notify the drd tool of a pthread_rwlock_destroy call. */ 205 VG_USERREQ__PRE_RWLOCK_DESTROY, 206 /* args: Addr rwlock, RwLockT */ 207 /* To notify the drd tool of a pthread_rwlock_destroy call. */ 208 VG_USERREQ__POST_RWLOCK_DESTROY, 209 /* args: Addr rwlock, RwLockT */ 210 /* To notify the drd tool of a pthread_rwlock_rdlock call. */ 211 VG_USERREQ__PRE_RWLOCK_RDLOCK, 212 /* args: Addr rwlock, RwLockT */ 213 /* To notify the drd tool of a pthread_rwlock_rdlock call. */ 214 VG_USERREQ__POST_RWLOCK_RDLOCK, 215 /* args: Addr rwlock, RwLockT, Bool took_lock */ 216 /* To notify the drd tool of a pthread_rwlock_wrlock call. */ 217 VG_USERREQ__PRE_RWLOCK_WRLOCK, 218 /* args: Addr rwlock, RwLockT */ 219 /* To notify the drd tool of a pthread_rwlock_wrlock call. */ 220 VG_USERREQ__POST_RWLOCK_WRLOCK, 221 /* args: Addr rwlock, RwLockT, Bool took_lock */ 222 /* To notify the drd tool of a pthread_rwlock_unlock call. */ 223 VG_USERREQ__PRE_RWLOCK_UNLOCK, 224 /* args: Addr rwlock, RwLockT */ 225 /* To notify the drd tool of a pthread_rwlock_unlock call. */ 226 VG_USERREQ__POST_RWLOCK_UNLOCK 227 /* args: Addr rwlock, RwLockT, Bool unlocked */ 228 229 #if defined(VGO_solaris) 230 , 231 /* To notify the drd tool of a bind_guard call from runtime linker. */ 232 VG_USERREQ__RTLD_BIND_GUARD, 233 /* args: Int flags */ 234 /* To notify the drd tool of a bind_clear call from runtime linker. */ 235 VG_USERREQ__RTLD_BIND_CLEAR 236 /* args: Int flags */ 237 #endif /* VGO_solaris */ 238 }; 239 240 /** 241 * Error checking on POSIX recursive mutexes, POSIX error checking mutexes, 242 * POSIX default mutexes and POSIX spinlocks happens the code in drd_mutex.c. 243 * The values defined below specify the mutex type. 244 */ 245 typedef enum { 246 mutex_type_unknown = -1, 247 mutex_type_invalid_mutex = 0, 248 mutex_type_recursive_mutex = 1, 249 mutex_type_errorcheck_mutex = 2, 250 mutex_type_default_mutex = 3, 251 mutex_type_spinlock = 4, 252 mutex_type_cxa_guard = 5, 253 } MutexT; 254 255 /** 256 * Error checking on POSIX reader/writer locks and user-defined reader/writer 257 * locks happens by the code in drd_rwlock.c. The values defined below specify 258 * the rwlock type. 259 */ 260 typedef enum { 261 pthread_rwlock = 1, 262 user_rwlock = 2, 263 } RwLockT; 264 265 /* 266 * Error checking on POSIX barriers and GOMP barriers happens by the same 267 * code. The integer values defined below specify the type of a barrier with 268 * a given client address. 269 */ 270 typedef enum { 271 pthread_barrier = 1, 272 gomp_barrier = 2, 273 } BarrierT; 274 275 276 extern Bool DRD_(g_free_is_write); 277 278 void DRD_(clientreq_init)(void); 279 280 281 #endif // __DRD_CLIENTREQ_H 282