2 This file is part of drd, a thread error detector.
4 Copyright (C) 2006-2011 Bart Van Assche <bvanassche@acm.org>.
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.
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.
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
21 The GNU General Public License is contained in the file COPYING.
26 * This header file contains the tool-internal interface for the code that
27 * processes client requests.
31 #ifndef __DRD_CLIENTREQ_H
32 #define __DRD_CLIENTREQ_H
36 #include "drd_basics.h" /* DRD_() */
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
47 /* Declare the address and size of a variable with value
48 * PTHREAD_COND_INITIALIZER.
50 VG_USERREQ__SET_PTHREAD_COND_INITIALIZER
= VG_USERREQ_TOOL_BASE('D', 'r'),
51 /* args: address, size. */
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. */
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 */
66 /* Tell DRD that the calling thread is about to enter pthread_create(). */
67 VG_USERREQ__ENTERING_PTHREAD_CREATE
,
69 /* Tell DRD that the calling thread has left pthread_create(). */
70 VG_USERREQ__LEFT_PTHREAD_CREATE
,
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) */
78 /* To notify drd before a pthread_cancel call. */
79 VG_USERREQ__PRE_THREAD_CANCEL
,
81 /* To notify drd after a pthread_cancel call. */
82 VG_USERREQ__POST_THREAD_CANCEL
,
83 /* args: pthread_t, Bool */
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
,
91 /* to notify the drd tool of a pthread_mutex_destroy call. */
92 VG_USERREQ__PRE_MUTEX_DESTROY
,
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
,
106 /* to notify the drd tool of pthread_mutex_unlock calls */
107 VG_USERREQ__POST_MUTEX_UNLOCK
,
109 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
110 VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK
,
112 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
113 VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK
,
117 /* to notify the drd tool of a pthread_cond_init call. */
118 VG_USERREQ__PRE_COND_INIT
,
120 /* to notify the drd tool of a pthread_cond_init call. */
121 VG_USERREQ__POST_COND_INIT
,
123 /* to notify the drd tool of a pthread_cond_destroy call. */
124 VG_USERREQ__PRE_COND_DESTROY
,
126 /* to notify the drd tool of a pthread_cond_destroy call. */
127 VG_USERREQ__POST_COND_DESTROY
,
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 */
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
,
148 /* To notify the drd tool of a sem_destroy call. */
149 VG_USERREQ__PRE_SEM_DESTROY
,
151 /* To notify the drd tool of a sem_destroy call. */
152 VG_USERREQ__POST_SEM_DESTROY
,
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
,
163 /* To notify the drd tool of a sem_close call. */
164 VG_USERREQ__POST_SEM_CLOSE
,
166 /* To notify the drd tool of a sem_wait call. */
167 VG_USERREQ__PRE_SEM_WAIT
,
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
,
175 /* To notify the drd tool after a sem_post call. */
176 VG_USERREQ__POST_SEM_POST
,
177 /* args: Addr sem, Bool waited */
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 */
198 /* To notify the drd tool of a pthread_rwlock_init call. */
199 VG_USERREQ__PRE_RWLOCK_INIT
,
200 /* args: Addr rwlock, RwLockT */
201 /* To notify the drd tool of a pthread_rwlock_destroy call. */
202 VG_USERREQ__POST_RWLOCK_DESTROY
,
203 /* args: Addr rwlock, RwLockT */
204 /* To notify the drd tool of a pthread_rwlock_rdlock call. */
205 VG_USERREQ__PRE_RWLOCK_RDLOCK
,
206 /* args: Addr rwlock, RwLockT */
207 /* To notify the drd tool of a pthread_rwlock_rdlock call. */
208 VG_USERREQ__POST_RWLOCK_RDLOCK
,
209 /* args: Addr rwlock, RwLockT, Bool took_lock */
210 /* To notify the drd tool of a pthread_rwlock_wrlock call. */
211 VG_USERREQ__PRE_RWLOCK_WRLOCK
,
212 /* args: Addr rwlock, RwLockT */
213 /* To notify the drd tool of a pthread_rwlock_wrlock call. */
214 VG_USERREQ__POST_RWLOCK_WRLOCK
,
215 /* args: Addr rwlock, RwLockT, Bool took_lock */
216 /* To notify the drd tool of a pthread_rwlock_unlock call. */
217 VG_USERREQ__PRE_RWLOCK_UNLOCK
,
218 /* args: Addr rwlock, RwLockT */
219 /* To notify the drd tool of a pthread_rwlock_unlock call. */
220 VG_USERREQ__POST_RWLOCK_UNLOCK
221 /* args: Addr rwlock, RwLockT, Bool unlocked */
226 * Error checking on POSIX recursive mutexes, POSIX error checking mutexes,
227 * POSIX default mutexes and POSIX spinlocks happens the code in drd_mutex.c.
228 * The values defined below specify the mutex type.
231 mutex_type_unknown
= -1,
232 mutex_type_invalid_mutex
= 0,
233 mutex_type_recursive_mutex
= 1,
234 mutex_type_errorcheck_mutex
= 2,
235 mutex_type_default_mutex
= 3,
236 mutex_type_spinlock
= 4,
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
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.
260 extern Bool
DRD_(g_free_is_write
);
262 void DRD_(clientreq_init
)(void);
265 #endif // __DRD_CLIENTREQ_H