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 | |
| 25 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 26 | #ifndef __DRD_CLIENTREQ_H |
| 27 | #define __DRD_CLIENTREQ_H |
| 28 | |
| 29 | |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 30 | #include "drd.h" |
bart | d00bd22 | 2008-03-30 08:40:49 +0000 | [diff] [blame] | 31 | |
| 32 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 33 | enum { |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 34 | /* Ask drd to suppress data race reports on all currently allocated stack */ |
| 35 | /* data of the current thread. */ |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 36 | VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK = VG_USERREQ_TOOL_BASE('D', 'r'), |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 37 | /* args: none */ |
| 38 | /* To ask the drd tool to start a new segment in the specified thread. */ |
| 39 | VG_USERREQ__DRD_START_NEW_SEGMENT, |
| 40 | /* args: POSIX thread ID. */ |
bart | bf3a60c | 2008-04-04 19:10:21 +0000 | [diff] [blame] | 41 | /* Let the drd tool stop recording memory accesses in the calling thread. */ |
| 42 | VG_USERREQ__DRD_STOP_RECORDING, |
| 43 | /* args: none. */ |
| 44 | /* Let the drd tool start recording memory accesses in the calling thread. */ |
| 45 | VG_USERREQ__DRD_START_RECORDING, |
| 46 | /* args: none. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 47 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 48 | /* Tell the core the pthread_t of the running thread */ |
| 49 | VG_USERREQ__SET_PTHREADID, |
| 50 | /* args: pthread_t. */ |
| 51 | /* Ask the core that a the thread's state transition from */ |
| 52 | /* VgTs_Zombie to VgTs_Empty is delayed until */ |
| 53 | /* VG_USERREQ__POST_THREAD_JOIN is performed. */ |
| 54 | VG_USERREQ__SET_JOINABLE, |
| 55 | /* args: pthread_t, Bool */ |
| 56 | |
| 57 | /* To notify drd that a thread finished because */ |
| 58 | /* pthread_thread_join() was called on it. */ |
| 59 | VG_USERREQ__POST_THREAD_JOIN, |
| 60 | /* args: pthread_t (joinee) */ |
| 61 | |
bart | 0f099cd | 2008-09-27 12:36:48 +0000 | [diff] [blame] | 62 | /* To notify drd before a pthread_cancel call. */ |
| 63 | VG_USERREQ__PRE_THREAD_CANCEL, |
| 64 | /* args: pthread_t */ |
| 65 | /* To notify drd after a pthread_cancel call. */ |
| 66 | VG_USERREQ__POST_THREAD_CANCEL, |
| 67 | /* args: pthread_t, Bool */ |
| 68 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 69 | /* to notify the drd tool of a pthread_mutex_init call. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 70 | VG_USERREQ__PRE_MUTEX_INIT, |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 71 | /* args: Addr, MutexT */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 72 | /* to notify the drd tool of a pthread_mutex_init call. */ |
| 73 | VG_USERREQ__POST_MUTEX_INIT, |
| 74 | /* args: Addr */ |
| 75 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
| 76 | VG_USERREQ__PRE_MUTEX_DESTROY, |
| 77 | /* args: Addr */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 78 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 79 | VG_USERREQ__POST_MUTEX_DESTROY, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 80 | /* args: Addr, MutexT */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 81 | /* to notify the drd tool of pthread_mutex_lock calls */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 82 | VG_USERREQ__PRE_MUTEX_LOCK, |
bart | 2e3a3c1 | 2008-03-24 08:33:47 +0000 | [diff] [blame] | 83 | /* args: Addr, MutexT, Bool */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 84 | /* to notify the drd tool of pthread_mutex_lock calls */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 85 | VG_USERREQ__POST_MUTEX_LOCK, |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 86 | /* args: Addr, Bool */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 87 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 88 | VG_USERREQ__PRE_MUTEX_UNLOCK, |
| 89 | /* args: Addr */ |
| 90 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
| 91 | VG_USERREQ__POST_MUTEX_UNLOCK, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 92 | /* args: Addr */ |
bart | f4f0581 | 2008-07-07 08:10:56 +0000 | [diff] [blame] | 93 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 94 | VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK, |
| 95 | /* args: Addr */ |
| 96 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 97 | VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK, |
| 98 | /* args: Addr */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 99 | |
| 100 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 101 | /* to notify the drd tool of a pthread_cond_init call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 102 | VG_USERREQ__PRE_COND_INIT, |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 103 | /* args: Addr */ |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 104 | /* to notify the drd tool of a pthread_cond_init call. */ |
| 105 | VG_USERREQ__POST_COND_INIT, |
| 106 | /* args: Addr */ |
| 107 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
| 108 | VG_USERREQ__PRE_COND_DESTROY, |
| 109 | /* args: Addr */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 110 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 111 | VG_USERREQ__POST_COND_DESTROY, |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 112 | /* args: Addr */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 113 | VG_USERREQ__PRE_COND_WAIT, |
| 114 | /* args: Addr cond, Addr mutex, MutexT mt */ |
| 115 | VG_USERREQ__POST_COND_WAIT, |
| 116 | /* args: Addr cond, Addr mutex, Bool took_lock*/ |
| 117 | VG_USERREQ__PRE_COND_SIGNAL, |
| 118 | /* args: Addr cond */ |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 119 | VG_USERREQ__POST_COND_SIGNAL, |
| 120 | /* args: Addr cond */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 121 | VG_USERREQ__PRE_COND_BROADCAST, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 122 | /* args: Addr cond */ |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 123 | VG_USERREQ__POST_COND_BROADCAST, |
| 124 | /* args: Addr cond */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 125 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 126 | /* To notify the drd tool of a sem_init call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 127 | VG_USERREQ__PRE_SEM_INIT, |
| 128 | /* args: Addr sem, Word pshared, Word value */ |
| 129 | /* To notify the drd tool of a sem_init call. */ |
| 130 | VG_USERREQ__POST_SEM_INIT, |
| 131 | /* args: Addr sem */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 132 | /* To notify the drd tool of a sem_destroy call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 133 | VG_USERREQ__PRE_SEM_DESTROY, |
| 134 | /* args: Addr sem */ |
| 135 | /* To notify the drd tool of a sem_destroy call. */ |
| 136 | VG_USERREQ__POST_SEM_DESTROY, |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 137 | /* args: Addr sem */ |
| 138 | /* To notify the drd tool of a sem_wait call. */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 139 | VG_USERREQ__PRE_SEM_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 140 | /* args: Addr sem */ |
bart | 28230a3 | 2008-02-29 17:27:03 +0000 | [diff] [blame] | 141 | /* To notify the drd tool of a sem_wait call. */ |
| 142 | VG_USERREQ__POST_SEM_WAIT, |
| 143 | /* args: Addr sem, Bool waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 144 | /* To notify the drd tool before a sem_post call. */ |
| 145 | VG_USERREQ__PRE_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 146 | /* args: Addr sem */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 147 | /* To notify the drd tool after a sem_post call. */ |
| 148 | VG_USERREQ__POST_SEM_POST, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 149 | /* args: Addr sem, Bool waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 150 | |
| 151 | /* To notify the drd tool of a pthread_barrier_init call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 152 | VG_USERREQ__PRE_BARRIER_INIT, |
| 153 | /* args: Addr barrier, BarrierT type, Word count, Bool reinit */ |
| 154 | /* To notify the drd tool of a pthread_barrier_init call. */ |
| 155 | VG_USERREQ__POST_BARRIER_INIT, |
| 156 | /* args: Addr barrier, BarrierT type */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 157 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 158 | VG_USERREQ__PRE_BARRIER_DESTROY, |
| 159 | /* args: Addr barrier, BarrierT type. */ |
| 160 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
| 161 | VG_USERREQ__POST_BARRIER_DESTROY, |
| 162 | /* args: Addr barrier, BarrierT type. */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 163 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 164 | VG_USERREQ__PRE_BARRIER_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 165 | /* args: Addr barrier, BarrierT type. */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 166 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 167 | VG_USERREQ__POST_BARRIER_WAIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 168 | /* args: Addr barrier, BarrierT type, Word has_waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 169 | |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 170 | /* To notify the drd tool of a pthread_rwlock_init call. */ |
| 171 | VG_USERREQ__PRE_RWLOCK_INIT, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 172 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 173 | /* To notify the drd tool of a pthread_rwlock_destroy call. */ |
| 174 | VG_USERREQ__POST_RWLOCK_DESTROY, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 175 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 176 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 177 | VG_USERREQ__PRE_RWLOCK_RDLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 178 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 179 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 180 | VG_USERREQ__POST_RWLOCK_RDLOCK, |
| 181 | /* args: Addr rwlock, Bool took_lock */ |
| 182 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 183 | VG_USERREQ__PRE_RWLOCK_WRLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 184 | /* args: Addr rwlock */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 185 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 186 | VG_USERREQ__POST_RWLOCK_WRLOCK, |
| 187 | /* args: Addr rwlock, Bool took_lock */ |
| 188 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 189 | VG_USERREQ__PRE_RWLOCK_UNLOCK, |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 190 | /* args: Addr rwlock */ |
| 191 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
bart | d00bd22 | 2008-03-30 08:40:49 +0000 | [diff] [blame] | 192 | VG_USERREQ__POST_RWLOCK_UNLOCK |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 193 | /* args: Addr rwlock, Bool unlocked */ |
| 194 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 195 | }; |
| 196 | |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 197 | typedef enum |
| 198 | { |
bart | 3f4623e | 2008-07-07 16:53:07 +0000 | [diff] [blame] | 199 | mutex_type_unknown = -1, |
| 200 | mutex_type_invalid_mutex = 0, |
| 201 | mutex_type_recursive_mutex = 1, |
| 202 | mutex_type_errorcheck_mutex = 2, |
| 203 | mutex_type_default_mutex = 3, |
| 204 | mutex_type_spinlock = 4 |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 205 | } MutexT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 206 | |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 207 | typedef enum |
| 208 | { |
| 209 | pthread_barrier = 1, |
bart | d00bd22 | 2008-03-30 08:40:49 +0000 | [diff] [blame] | 210 | gomp_barrier = 2 |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 211 | } BarrierT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 212 | |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 213 | void drd_clientreq_init(void); |
| 214 | |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 215 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 216 | #endif // __DRD_CLIENTREQ_H |