bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 1 | /* -*- mode: C; c-basic-offset: 3; -*- */ |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 2 | /* |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 3 | This file is part of drd, a thread error detector. |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 4 | |
bart | 86562bd | 2009-02-16 19:43:56 +0000 | [diff] [blame] | 5 | Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>. |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 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 | 1335ecc | 2009-02-14 16:10:53 +0000 | [diff] [blame] | 25 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 26 | /* |
| 27 | * This header file contains the tool-internal interface for the code that |
| 28 | * processes client requests. |
| 29 | */ |
| 30 | |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 31 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 32 | #ifndef __DRD_CLIENTREQ_H |
| 33 | #define __DRD_CLIENTREQ_H |
| 34 | |
| 35 | |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 36 | #include "drd.h" |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 37 | #include "drd_basics.h" /* DRD_() */ |
bart | d00bd22 | 2008-03-30 08:40:49 +0000 | [diff] [blame] | 38 | |
| 39 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 40 | /* |
| 41 | * While the client requests defined in the header file "drd.h" define a |
| 42 | * public interface between client programs and the DRD tool, the client |
| 43 | * requests defined below are a tool-internal interface. These last client |
| 44 | * requests must only be used by the source code in the various *_intercepts.c |
| 45 | * source files. |
| 46 | */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 47 | enum { |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 48 | /* Ask drd to suppress data race reports on all currently allocated stack */ |
| 49 | /* data of the current thread. */ |
| 50 | VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK = VG_USERREQ_TOOL_BASE('D', 'r'), |
| 51 | /* args: none */ |
| 52 | /* To ask the drd tool to start a new segment in the specified thread. */ |
| 53 | VG_USERREQ__DRD_START_NEW_SEGMENT, |
| 54 | /* args: POSIX thread ID. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 55 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 56 | /* Tell drd the pthread_t of the running thread. */ |
| 57 | VG_USERREQ__SET_PTHREADID, |
| 58 | /* args: pthread_t. */ |
| 59 | /* Ask drd that a the thread's state transition from */ |
| 60 | /* VgTs_Zombie to VgTs_Empty is delayed until */ |
| 61 | /* VG_USERREQ__POST_THREAD_JOIN is performed. */ |
| 62 | VG_USERREQ__SET_JOINABLE, |
| 63 | /* args: pthread_t, Bool */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 64 | |
bart | dd75cdf | 2009-07-24 08:20:10 +0000 | [diff] [blame^] | 65 | /* Tell DRD that the calling thread is about to enter pthread_create(). */ |
| 66 | VG_USERREQ__ENTERING_PTHREAD_CREATE, |
| 67 | /* args: (none) */ |
| 68 | /* Tell DRD that the calling thread has left pthread_create(). */ |
| 69 | VG_USERREQ__LEFT_PTHREAD_CREATE, |
| 70 | /* args: (none) */ |
| 71 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 72 | /* To notify drd that a thread finished because */ |
| 73 | /* pthread_thread_join() was called on it. */ |
| 74 | VG_USERREQ__POST_THREAD_JOIN, |
| 75 | /* args: pthread_t (joinee) */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 76 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 77 | /* To notify drd before a pthread_cancel call. */ |
| 78 | VG_USERREQ__PRE_THREAD_CANCEL, |
| 79 | /* args: pthread_t */ |
| 80 | /* To notify drd after a pthread_cancel call. */ |
| 81 | VG_USERREQ__POST_THREAD_CANCEL, |
| 82 | /* args: pthread_t, Bool */ |
bart | 0f099cd | 2008-09-27 12:36:48 +0000 | [diff] [blame] | 83 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 84 | /* to notify the drd tool of a pthread_mutex_init call. */ |
| 85 | VG_USERREQ__PRE_MUTEX_INIT, |
| 86 | /* args: Addr, MutexT */ |
| 87 | /* to notify the drd tool of a pthread_mutex_init call. */ |
| 88 | VG_USERREQ__POST_MUTEX_INIT, |
| 89 | /* args: Addr */ |
| 90 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
| 91 | VG_USERREQ__PRE_MUTEX_DESTROY, |
| 92 | /* args: Addr */ |
| 93 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
| 94 | VG_USERREQ__POST_MUTEX_DESTROY, |
| 95 | /* args: Addr, MutexT */ |
| 96 | /* to notify the drd tool of pthread_mutex_lock calls */ |
| 97 | VG_USERREQ__PRE_MUTEX_LOCK, |
| 98 | /* args: Addr, MutexT, Bool */ |
| 99 | /* to notify the drd tool of pthread_mutex_lock calls */ |
| 100 | VG_USERREQ__POST_MUTEX_LOCK, |
| 101 | /* args: Addr, Bool */ |
| 102 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
| 103 | VG_USERREQ__PRE_MUTEX_UNLOCK, |
| 104 | /* args: Addr */ |
| 105 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
| 106 | VG_USERREQ__POST_MUTEX_UNLOCK, |
| 107 | /* args: Addr */ |
| 108 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 109 | VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK, |
| 110 | /* args: Addr */ |
| 111 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 112 | VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK, |
| 113 | /* args: Addr */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 114 | |
| 115 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 116 | /* to notify the drd tool of a pthread_cond_init call. */ |
| 117 | VG_USERREQ__PRE_COND_INIT, |
| 118 | /* args: Addr */ |
| 119 | /* to notify the drd tool of a pthread_cond_init call. */ |
| 120 | VG_USERREQ__POST_COND_INIT, |
| 121 | /* args: Addr */ |
| 122 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
| 123 | VG_USERREQ__PRE_COND_DESTROY, |
| 124 | /* args: Addr */ |
| 125 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
| 126 | VG_USERREQ__POST_COND_DESTROY, |
| 127 | /* args: Addr */ |
| 128 | VG_USERREQ__PRE_COND_WAIT, |
| 129 | /* args: Addr cond, Addr mutex, MutexT mt */ |
| 130 | VG_USERREQ__POST_COND_WAIT, |
| 131 | /* args: Addr cond, Addr mutex, Bool took_lock*/ |
| 132 | VG_USERREQ__PRE_COND_SIGNAL, |
| 133 | /* args: Addr cond */ |
| 134 | VG_USERREQ__POST_COND_SIGNAL, |
| 135 | /* args: Addr cond */ |
| 136 | VG_USERREQ__PRE_COND_BROADCAST, |
| 137 | /* args: Addr cond */ |
| 138 | VG_USERREQ__POST_COND_BROADCAST, |
| 139 | /* args: Addr cond */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 140 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 141 | /* To notify the drd tool of a sem_init call. */ |
| 142 | VG_USERREQ__PRE_SEM_INIT, |
| 143 | /* args: Addr sem, Word pshared, Word value */ |
| 144 | /* To notify the drd tool of a sem_init call. */ |
| 145 | VG_USERREQ__POST_SEM_INIT, |
| 146 | /* args: Addr sem */ |
| 147 | /* To notify the drd tool of a sem_destroy call. */ |
| 148 | VG_USERREQ__PRE_SEM_DESTROY, |
| 149 | /* args: Addr sem */ |
| 150 | /* To notify the drd tool of a sem_destroy call. */ |
| 151 | VG_USERREQ__POST_SEM_DESTROY, |
| 152 | /* args: Addr sem */ |
bart | 25f9f54 | 2009-07-23 16:31:39 +0000 | [diff] [blame] | 153 | /* To notify the drd tool of a sem_open call. */ |
| 154 | VG_USERREQ__PRE_SEM_OPEN, |
| 155 | /* args: Addr name, Word oflag, Word mode, Word value */ |
| 156 | /* To notify the drd tool of a sem_open call. */ |
| 157 | VG_USERREQ__POST_SEM_OPEN, |
| 158 | /* args: Addr sem, Word oflag, Word mode, Word value */ |
| 159 | /* To notify the drd tool of a sem_close call. */ |
| 160 | VG_USERREQ__PRE_SEM_CLOSE, |
| 161 | /* args: Addr sem */ |
| 162 | /* To notify the drd tool of a sem_close call. */ |
| 163 | VG_USERREQ__POST_SEM_CLOSE, |
| 164 | /* args: Addr sem */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 165 | /* To notify the drd tool of a sem_wait call. */ |
| 166 | VG_USERREQ__PRE_SEM_WAIT, |
| 167 | /* args: Addr sem */ |
| 168 | /* To notify the drd tool of a sem_wait call. */ |
| 169 | VG_USERREQ__POST_SEM_WAIT, |
| 170 | /* args: Addr sem, Bool waited */ |
| 171 | /* To notify the drd tool before a sem_post call. */ |
| 172 | VG_USERREQ__PRE_SEM_POST, |
| 173 | /* args: Addr sem */ |
| 174 | /* To notify the drd tool after a sem_post call. */ |
| 175 | VG_USERREQ__POST_SEM_POST, |
| 176 | /* args: Addr sem, Bool waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 177 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 178 | /* To notify the drd tool of a pthread_barrier_init call. */ |
| 179 | VG_USERREQ__PRE_BARRIER_INIT, |
| 180 | /* args: Addr barrier, BarrierT type, Word count, Bool reinit */ |
| 181 | /* To notify the drd tool of a pthread_barrier_init call. */ |
| 182 | VG_USERREQ__POST_BARRIER_INIT, |
| 183 | /* args: Addr barrier, BarrierT type */ |
| 184 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
| 185 | VG_USERREQ__PRE_BARRIER_DESTROY, |
| 186 | /* args: Addr barrier, BarrierT type. */ |
| 187 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
| 188 | VG_USERREQ__POST_BARRIER_DESTROY, |
| 189 | /* args: Addr barrier, BarrierT type. */ |
| 190 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 191 | VG_USERREQ__PRE_BARRIER_WAIT, |
| 192 | /* args: Addr barrier, BarrierT type. */ |
| 193 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 194 | VG_USERREQ__POST_BARRIER_WAIT, |
| 195 | /* args: Addr barrier, BarrierT type, Word has_waited, Word serializing */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 196 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 197 | /* To notify the drd tool of a pthread_rwlock_init call. */ |
| 198 | VG_USERREQ__PRE_RWLOCK_INIT, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 199 | /* args: Addr rwlock, RwLockT */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 200 | /* To notify the drd tool of a pthread_rwlock_destroy call. */ |
| 201 | VG_USERREQ__POST_RWLOCK_DESTROY, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 202 | /* args: Addr rwlock, RwLockT */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 203 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 204 | VG_USERREQ__PRE_RWLOCK_RDLOCK, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 205 | /* args: Addr rwlock, RwLockT */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 206 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 207 | VG_USERREQ__POST_RWLOCK_RDLOCK, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 208 | /* args: Addr rwlock, RwLockT, Bool took_lock */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 209 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 210 | VG_USERREQ__PRE_RWLOCK_WRLOCK, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 211 | /* args: Addr rwlock, RwLockT */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 212 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 213 | VG_USERREQ__POST_RWLOCK_WRLOCK, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 214 | /* args: Addr rwlock, RwLockT, Bool took_lock */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 215 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
| 216 | VG_USERREQ__PRE_RWLOCK_UNLOCK, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 217 | /* args: Addr rwlock, RwLockT */ |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame] | 218 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
| 219 | VG_USERREQ__POST_RWLOCK_UNLOCK |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 220 | /* args: Addr rwlock, RwLockT, Bool unlocked */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 221 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 222 | }; |
| 223 | |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 224 | /** |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 225 | * Error checking on POSIX recursive mutexes, POSIX error checking mutexes, |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 226 | * POSIX default mutexes and POSIX spinlocks happens the code in drd_mutex.c. |
| 227 | * The values defined below specify the mutex type. |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 228 | */ |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 229 | typedef enum { |
| 230 | mutex_type_unknown = -1, |
| 231 | mutex_type_invalid_mutex = 0, |
| 232 | mutex_type_recursive_mutex = 1, |
| 233 | mutex_type_errorcheck_mutex = 2, |
| 234 | mutex_type_default_mutex = 3, |
| 235 | mutex_type_spinlock = 4, |
| 236 | mutex_type_order_annotation = 5, |
| 237 | } MutexT; |
| 238 | |
| 239 | /** |
| 240 | * Error checking on POSIX reader/writer locks and user-defined reader/writer |
| 241 | * locks happens by the code in drd_rwlock.c. The values defined below specify |
| 242 | * the rwlock type. |
| 243 | */ |
| 244 | typedef enum { |
| 245 | pthread_rwlock = 1, |
| 246 | user_rwlock = 2, |
| 247 | } RwLockT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 248 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 249 | /* |
| 250 | * Error checking on POSIX barriers and GOMP barriers happens by the same |
| 251 | * code. The integer values defined below specify the type of a barrier with |
| 252 | * a given client address. |
| 253 | */ |
bart | d45d995 | 2009-05-31 18:53:54 +0000 | [diff] [blame] | 254 | typedef enum { |
| 255 | pthread_barrier = 1, |
| 256 | gomp_barrier = 2, |
| 257 | } BarrierT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 258 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 259 | |
| 260 | void DRD_(clientreq_init)(void); |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 261 | |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 262 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 263 | #endif // __DRD_CLIENTREQ_H |