1 /* -*- mode: C; c-basic-offset: 3; -*- */
3 This file is part of drd, a thread error detector.
5 Copyright (C) 2006-2010 Bart Van Assche <bart.vanassche@gmail.com>.
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.
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.
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
22 The GNU General Public License is contained in the file COPYING.
27 * This header file contains the tool-internal interface for the code that
28 * processes client requests.
32 #ifndef __DRD_CLIENTREQ_H
33 #define __DRD_CLIENTREQ_H
37 #include "drd_basics.h" /* DRD_() */
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
48 /* To ask the drd tool to start a new segment in the specified thread. */
49 VG_USERREQ__DRD_START_NEW_SEGMENT = VG_USERREQ_TOOL_BASE('D', 'r'),
50 /* args: POSIX thread ID. */
52 /* Tell drd the pthread_t of the running thread. */
53 VG_USERREQ__SET_PTHREADID,
54 /* args: pthread_t. */
55 /* Ask drd that a the thread's state transition from */
56 /* VgTs_Zombie to VgTs_Empty is delayed until */
57 /* VG_USERREQ__POST_THREAD_JOIN is performed. */
58 VG_USERREQ__SET_JOINABLE,
59 /* args: pthread_t, Bool */
61 /* Tell DRD that the calling thread is about to enter pthread_create(). */
62 VG_USERREQ__ENTERING_PTHREAD_CREATE,
64 /* Tell DRD that the calling thread has left pthread_create(). */
65 VG_USERREQ__LEFT_PTHREAD_CREATE,
68 /* To notify drd that a thread finished because */
69 /* pthread_thread_join() was called on it. */
70 VG_USERREQ__POST_THREAD_JOIN,
71 /* args: pthread_t (joinee) */
73 /* To notify drd before a pthread_cancel call. */
74 VG_USERREQ__PRE_THREAD_CANCEL,
76 /* To notify drd after a pthread_cancel call. */
77 VG_USERREQ__POST_THREAD_CANCEL,
78 /* args: pthread_t, Bool */
80 /* to notify the drd tool of a pthread_mutex_init call. */
81 VG_USERREQ__PRE_MUTEX_INIT,
82 /* args: Addr, MutexT */
83 /* to notify the drd tool of a pthread_mutex_init call. */
84 VG_USERREQ__POST_MUTEX_INIT,
86 /* to notify the drd tool of a pthread_mutex_destroy call. */
87 VG_USERREQ__PRE_MUTEX_DESTROY,
89 /* to notify the drd tool of a pthread_mutex_destroy call. */
90 VG_USERREQ__POST_MUTEX_DESTROY,
91 /* args: Addr, MutexT */
92 /* to notify the drd tool of pthread_mutex_lock calls */
93 VG_USERREQ__PRE_MUTEX_LOCK,
94 /* args: Addr, MutexT, Bool */
95 /* to notify the drd tool of pthread_mutex_lock calls */
96 VG_USERREQ__POST_MUTEX_LOCK,
97 /* args: Addr, Bool */
98 /* to notify the drd tool of pthread_mutex_unlock calls */
99 VG_USERREQ__PRE_MUTEX_UNLOCK,
101 /* to notify the drd tool of pthread_mutex_unlock calls */
102 VG_USERREQ__POST_MUTEX_UNLOCK,
104 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
105 VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK,
107 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
108 VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK,
112 /* to notify the drd tool of a pthread_cond_init call. */
113 VG_USERREQ__PRE_COND_INIT,
115 /* to notify the drd tool of a pthread_cond_init call. */
116 VG_USERREQ__POST_COND_INIT,
118 /* to notify the drd tool of a pthread_cond_destroy call. */
119 VG_USERREQ__PRE_COND_DESTROY,
121 /* to notify the drd tool of a pthread_cond_destroy call. */
122 VG_USERREQ__POST_COND_DESTROY,
124 VG_USERREQ__PRE_COND_WAIT,
125 /* args: Addr cond, Addr mutex, MutexT mt */
126 VG_USERREQ__POST_COND_WAIT,
127 /* args: Addr cond, Addr mutex, Bool took_lock*/
128 VG_USERREQ__PRE_COND_SIGNAL,
129 /* args: Addr cond */
130 VG_USERREQ__POST_COND_SIGNAL,
131 /* args: Addr cond */
132 VG_USERREQ__PRE_COND_BROADCAST,
133 /* args: Addr cond */
134 VG_USERREQ__POST_COND_BROADCAST,
135 /* args: Addr cond */
137 /* To notify the drd tool of a sem_init call. */
138 VG_USERREQ__PRE_SEM_INIT,
139 /* args: Addr sem, Word pshared, Word value */
140 /* To notify the drd tool of a sem_init call. */
141 VG_USERREQ__POST_SEM_INIT,
143 /* To notify the drd tool of a sem_destroy call. */
144 VG_USERREQ__PRE_SEM_DESTROY,
146 /* To notify the drd tool of a sem_destroy call. */
147 VG_USERREQ__POST_SEM_DESTROY,
149 /* To notify the drd tool of a sem_open call. */
150 VG_USERREQ__PRE_SEM_OPEN,
151 /* args: Addr name, Word oflag, Word mode, Word value */
152 /* To notify the drd tool of a sem_open call. */
153 VG_USERREQ__POST_SEM_OPEN,
154 /* args: Addr sem, Word oflag, Word mode, Word value */
155 /* To notify the drd tool of a sem_close call. */
156 VG_USERREQ__PRE_SEM_CLOSE,
158 /* To notify the drd tool of a sem_close call. */
159 VG_USERREQ__POST_SEM_CLOSE,
161 /* To notify the drd tool of a sem_wait call. */
162 VG_USERREQ__PRE_SEM_WAIT,
164 /* To notify the drd tool of a sem_wait call. */
165 VG_USERREQ__POST_SEM_WAIT,
166 /* args: Addr sem, Bool waited */
167 /* To notify the drd tool before a sem_post call. */
168 VG_USERREQ__PRE_SEM_POST,
170 /* To notify the drd tool after a sem_post call. */
171 VG_USERREQ__POST_SEM_POST,
172 /* args: Addr sem, Bool waited */
174 /* To notify the drd tool of a pthread_barrier_init call. */
175 VG_USERREQ__PRE_BARRIER_INIT,
176 /* args: Addr barrier, BarrierT type, Word count, Bool reinit */
177 /* To notify the drd tool of a pthread_barrier_init call. */
178 VG_USERREQ__POST_BARRIER_INIT,
179 /* args: Addr barrier, BarrierT type */
180 /* To notify the drd tool of a pthread_barrier_destroy call. */
181 VG_USERREQ__PRE_BARRIER_DESTROY,
182 /* args: Addr barrier, BarrierT type. */
183 /* To notify the drd tool of a pthread_barrier_destroy call. */
184 VG_USERREQ__POST_BARRIER_DESTROY,
185 /* args: Addr barrier, BarrierT type. */
186 /* To notify the drd tool of a pthread_barrier_wait call. */
187 VG_USERREQ__PRE_BARRIER_WAIT,
188 /* args: Addr barrier, BarrierT type. */
189 /* To notify the drd tool of a pthread_barrier_wait call. */
190 VG_USERREQ__POST_BARRIER_WAIT,
191 /* args: Addr barrier, BarrierT type, Word has_waited, Word serializing */
193 /* To notify the drd tool of a pthread_rwlock_init call. */
194 VG_USERREQ__PRE_RWLOCK_INIT,
195 /* args: Addr rwlock, RwLockT */
196 /* To notify the drd tool of a pthread_rwlock_destroy call. */
197 VG_USERREQ__POST_RWLOCK_DESTROY,
198 /* args: Addr rwlock, RwLockT */
199 /* To notify the drd tool of a pthread_rwlock_rdlock call. */
200 VG_USERREQ__PRE_RWLOCK_RDLOCK,
201 /* args: Addr rwlock, RwLockT */
202 /* To notify the drd tool of a pthread_rwlock_rdlock call. */
203 VG_USERREQ__POST_RWLOCK_RDLOCK,
204 /* args: Addr rwlock, RwLockT, Bool took_lock */
205 /* To notify the drd tool of a pthread_rwlock_wrlock call. */
206 VG_USERREQ__PRE_RWLOCK_WRLOCK,
207 /* args: Addr rwlock, RwLockT */
208 /* To notify the drd tool of a pthread_rwlock_wrlock call. */
209 VG_USERREQ__POST_RWLOCK_WRLOCK,
210 /* args: Addr rwlock, RwLockT, Bool took_lock */
211 /* To notify the drd tool of a pthread_rwlock_unlock call. */
212 VG_USERREQ__PRE_RWLOCK_UNLOCK,
213 /* args: Addr rwlock, RwLockT */
214 /* To notify the drd tool of a pthread_rwlock_unlock call. */
215 VG_USERREQ__POST_RWLOCK_UNLOCK
216 /* args: Addr rwlock, RwLockT, Bool unlocked */
221 * Error checking on POSIX recursive mutexes, POSIX error checking mutexes,
222 * POSIX default mutexes and POSIX spinlocks happens the code in drd_mutex.c.
223 * The values defined below specify the mutex type.
226 mutex_type_unknown = -1,
227 mutex_type_invalid_mutex = 0,
228 mutex_type_recursive_mutex = 1,
229 mutex_type_errorcheck_mutex = 2,
230 mutex_type_default_mutex = 3,
231 mutex_type_spinlock = 4,
235 * Error checking on POSIX reader/writer locks and user-defined reader/writer
236 * locks happens by the code in drd_rwlock.c. The values defined below specify
245 * Error checking on POSIX barriers and GOMP barriers happens by the same
246 * code. The integer values defined below specify the type of a barrier with
247 * a given client address.
255 void DRD_(clientreq_init)(void);
258 #endif // __DRD_CLIENTREQ_H