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. */ |
| 55 | /* Let the drd tool stop recording memory accesses in the calling thread. */ |
| 56 | VG_USERREQ__DRD_STOP_RECORDING, |
| 57 | /* args: none. */ |
| 58 | /* Let the drd tool start recording memory accesses in the calling thread. */ |
| 59 | VG_USERREQ__DRD_START_RECORDING, |
| 60 | /* args: none. */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 61 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 62 | /* Tell drd the pthread_t of the running thread. */ |
| 63 | VG_USERREQ__SET_PTHREADID, |
| 64 | /* args: pthread_t. */ |
| 65 | /* Ask drd that a the thread's state transition from */ |
| 66 | /* VgTs_Zombie to VgTs_Empty is delayed until */ |
| 67 | /* VG_USERREQ__POST_THREAD_JOIN is performed. */ |
| 68 | VG_USERREQ__SET_JOINABLE, |
| 69 | /* args: pthread_t, Bool */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 70 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 71 | /* To notify drd that a thread finished because */ |
| 72 | /* pthread_thread_join() was called on it. */ |
| 73 | VG_USERREQ__POST_THREAD_JOIN, |
| 74 | /* args: pthread_t (joinee) */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 75 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 76 | /* To notify drd before a pthread_cancel call. */ |
| 77 | VG_USERREQ__PRE_THREAD_CANCEL, |
| 78 | /* args: pthread_t */ |
| 79 | /* To notify drd after a pthread_cancel call. */ |
| 80 | VG_USERREQ__POST_THREAD_CANCEL, |
| 81 | /* args: pthread_t, Bool */ |
bart | 0f099cd | 2008-09-27 12:36:48 +0000 | [diff] [blame] | 82 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 83 | /* to notify the drd tool of a pthread_mutex_init call. */ |
| 84 | VG_USERREQ__PRE_MUTEX_INIT, |
| 85 | /* args: Addr, MutexT */ |
| 86 | /* to notify the drd tool of a pthread_mutex_init call. */ |
| 87 | VG_USERREQ__POST_MUTEX_INIT, |
| 88 | /* args: Addr */ |
| 89 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
| 90 | VG_USERREQ__PRE_MUTEX_DESTROY, |
| 91 | /* args: Addr */ |
| 92 | /* to notify the drd tool of a pthread_mutex_destroy call. */ |
| 93 | VG_USERREQ__POST_MUTEX_DESTROY, |
| 94 | /* args: Addr, MutexT */ |
| 95 | /* to notify the drd tool of pthread_mutex_lock calls */ |
| 96 | VG_USERREQ__PRE_MUTEX_LOCK, |
| 97 | /* args: Addr, MutexT, Bool */ |
| 98 | /* to notify the drd tool of pthread_mutex_lock calls */ |
| 99 | VG_USERREQ__POST_MUTEX_LOCK, |
| 100 | /* args: Addr, Bool */ |
| 101 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
| 102 | VG_USERREQ__PRE_MUTEX_UNLOCK, |
| 103 | /* args: Addr */ |
| 104 | /* to notify the drd tool of pthread_mutex_unlock calls */ |
| 105 | VG_USERREQ__POST_MUTEX_UNLOCK, |
| 106 | /* args: Addr */ |
| 107 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 108 | VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK, |
| 109 | /* args: Addr */ |
| 110 | /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */ |
| 111 | VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK, |
| 112 | /* args: Addr */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 113 | |
| 114 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 115 | /* to notify the drd tool of a pthread_cond_init call. */ |
| 116 | VG_USERREQ__PRE_COND_INIT, |
| 117 | /* args: Addr */ |
| 118 | /* to notify the drd tool of a pthread_cond_init call. */ |
| 119 | VG_USERREQ__POST_COND_INIT, |
| 120 | /* args: Addr */ |
| 121 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
| 122 | VG_USERREQ__PRE_COND_DESTROY, |
| 123 | /* args: Addr */ |
| 124 | /* to notify the drd tool of a pthread_cond_destroy call. */ |
| 125 | VG_USERREQ__POST_COND_DESTROY, |
| 126 | /* args: Addr */ |
| 127 | VG_USERREQ__PRE_COND_WAIT, |
| 128 | /* args: Addr cond, Addr mutex, MutexT mt */ |
| 129 | VG_USERREQ__POST_COND_WAIT, |
| 130 | /* args: Addr cond, Addr mutex, Bool took_lock*/ |
| 131 | VG_USERREQ__PRE_COND_SIGNAL, |
| 132 | /* args: Addr cond */ |
| 133 | VG_USERREQ__POST_COND_SIGNAL, |
| 134 | /* args: Addr cond */ |
| 135 | VG_USERREQ__PRE_COND_BROADCAST, |
| 136 | /* args: Addr cond */ |
| 137 | VG_USERREQ__POST_COND_BROADCAST, |
| 138 | /* args: Addr cond */ |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 139 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 140 | /* To notify the drd tool of a sem_init call. */ |
| 141 | VG_USERREQ__PRE_SEM_INIT, |
| 142 | /* args: Addr sem, Word pshared, Word value */ |
| 143 | /* To notify the drd tool of a sem_init call. */ |
| 144 | VG_USERREQ__POST_SEM_INIT, |
| 145 | /* args: Addr sem */ |
| 146 | /* To notify the drd tool of a sem_destroy call. */ |
| 147 | VG_USERREQ__PRE_SEM_DESTROY, |
| 148 | /* args: Addr sem */ |
| 149 | /* To notify the drd tool of a sem_destroy call. */ |
| 150 | VG_USERREQ__POST_SEM_DESTROY, |
| 151 | /* args: Addr sem */ |
| 152 | /* To notify the drd tool of a sem_wait call. */ |
| 153 | VG_USERREQ__PRE_SEM_WAIT, |
| 154 | /* args: Addr sem */ |
| 155 | /* To notify the drd tool of a sem_wait call. */ |
| 156 | VG_USERREQ__POST_SEM_WAIT, |
| 157 | /* args: Addr sem, Bool waited */ |
| 158 | /* To notify the drd tool before a sem_post call. */ |
| 159 | VG_USERREQ__PRE_SEM_POST, |
| 160 | /* args: Addr sem */ |
| 161 | /* To notify the drd tool after a sem_post call. */ |
| 162 | VG_USERREQ__POST_SEM_POST, |
| 163 | /* args: Addr sem, Bool waited */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 164 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 165 | /* To notify the drd tool of a pthread_barrier_init call. */ |
| 166 | VG_USERREQ__PRE_BARRIER_INIT, |
| 167 | /* args: Addr barrier, BarrierT type, Word count, Bool reinit */ |
| 168 | /* To notify the drd tool of a pthread_barrier_init call. */ |
| 169 | VG_USERREQ__POST_BARRIER_INIT, |
| 170 | /* args: Addr barrier, BarrierT type */ |
| 171 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
| 172 | VG_USERREQ__PRE_BARRIER_DESTROY, |
| 173 | /* args: Addr barrier, BarrierT type. */ |
| 174 | /* To notify the drd tool of a pthread_barrier_destroy call. */ |
| 175 | VG_USERREQ__POST_BARRIER_DESTROY, |
| 176 | /* args: Addr barrier, BarrierT type. */ |
| 177 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 178 | VG_USERREQ__PRE_BARRIER_WAIT, |
| 179 | /* args: Addr barrier, BarrierT type. */ |
| 180 | /* To notify the drd tool of a pthread_barrier_wait call. */ |
| 181 | VG_USERREQ__POST_BARRIER_WAIT, |
| 182 | /* args: Addr barrier, BarrierT type, Word has_waited, Word serializing */ |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 183 | |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 184 | /* To notify the drd tool of a pthread_rwlock_init call. */ |
| 185 | VG_USERREQ__PRE_RWLOCK_INIT, |
| 186 | /* args: Addr rwlock */ |
| 187 | /* To notify the drd tool of a pthread_rwlock_destroy call. */ |
| 188 | VG_USERREQ__POST_RWLOCK_DESTROY, |
| 189 | /* args: Addr rwlock */ |
| 190 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 191 | VG_USERREQ__PRE_RWLOCK_RDLOCK, |
| 192 | /* args: Addr rwlock */ |
| 193 | /* To notify the drd tool of a pthread_rwlock_rdlock call. */ |
| 194 | VG_USERREQ__POST_RWLOCK_RDLOCK, |
| 195 | /* args: Addr rwlock, Bool took_lock */ |
| 196 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 197 | VG_USERREQ__PRE_RWLOCK_WRLOCK, |
| 198 | /* args: Addr rwlock */ |
| 199 | /* To notify the drd tool of a pthread_rwlock_wrlock call. */ |
| 200 | VG_USERREQ__POST_RWLOCK_WRLOCK, |
| 201 | /* args: Addr rwlock, Bool took_lock */ |
| 202 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
| 203 | VG_USERREQ__PRE_RWLOCK_UNLOCK, |
| 204 | /* args: Addr rwlock */ |
| 205 | /* To notify the drd tool of a pthread_rwlock_unlock call. */ |
| 206 | VG_USERREQ__POST_RWLOCK_UNLOCK |
| 207 | /* args: Addr rwlock, Bool unlocked */ |
bart | 0034464 | 2008-03-01 15:27:41 +0000 | [diff] [blame] | 208 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 209 | }; |
| 210 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 211 | /* |
| 212 | * Error checking on POSIX recursive mutexes, POSIX error checking mutexes, |
| 213 | * POSIX default mutexes and POSIX spinlocks happens by the same code. The |
| 214 | * values defined below specify which of these types a mutex really is. |
| 215 | */ |
sewardj | 721ad7b | 2007-11-30 08:30:29 +0000 | [diff] [blame] | 216 | typedef enum |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 217 | { |
| 218 | mutex_type_unknown = -1, |
| 219 | mutex_type_invalid_mutex = 0, |
| 220 | mutex_type_recursive_mutex = 1, |
| 221 | mutex_type_errorcheck_mutex = 2, |
| 222 | mutex_type_default_mutex = 3, |
| 223 | mutex_type_spinlock = 4 |
| 224 | } MutexT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 225 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 226 | /* |
| 227 | * Error checking on POSIX barriers and GOMP barriers happens by the same |
| 228 | * code. The integer values defined below specify the type of a barrier with |
| 229 | * a given client address. |
| 230 | */ |
bart | 0268dfa | 2008-03-11 20:10:21 +0000 | [diff] [blame] | 231 | typedef enum |
bart | bedfd23 | 2009-03-26 19:07:15 +0000 | [diff] [blame^] | 232 | { |
| 233 | pthread_barrier = 1, |
| 234 | gomp_barrier = 2 |
| 235 | } BarrierT; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 236 | |
bart | 09dc13f | 2009-02-14 15:13:31 +0000 | [diff] [blame] | 237 | |
| 238 | void DRD_(clientreq_init)(void); |
bart | 5f57be9 | 2008-07-01 08:48:56 +0000 | [diff] [blame] | 239 | |
bart | 3c1e9d8 | 2008-06-30 17:10:29 +0000 | [diff] [blame] | 240 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 241 | #endif // __DRD_CLIENTREQ_H |