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