blob: e43d845c15e8a4c1c26e2ef1aac7d366dd4440b7 [file] [log] [blame]
bart5f57be92008-07-01 08:48:56 +00001/*
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
bart09dc13f2009-02-14 15:13:31 +000025/*
26 * This header file contains the tool-internal interface for the code that
27 * processes client requests.
28 */
29
bart5f57be92008-07-01 08:48:56 +000030
sewardjaf44c822007-11-25 14:01:38 +000031#ifndef __DRD_CLIENTREQ_H
32#define __DRD_CLIENTREQ_H
33
34
bart3c1e9d82008-06-30 17:10:29 +000035#include "drd.h"
bart09dc13f2009-02-14 15:13:31 +000036#include "drd_basics.h" /* DRD_() */
bartd00bd222008-03-30 08:40:49 +000037
38
bart09dc13f2009-02-14 15:13:31 +000039/*
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
44 * source files.
45 */
sewardjaf44c822007-11-25 14:01:38 +000046enum {
sewardjaf44c822007-11-25 14:01:38 +000047 /* Ask drd to suppress data race reports on all currently allocated stack */
48 /* data of the current thread. */
bart3c1e9d82008-06-30 17:10:29 +000049 VG_USERREQ__DRD_SUPPRESS_CURRENT_STACK = VG_USERREQ_TOOL_BASE('D', 'r'),
sewardjaf44c822007-11-25 14:01:38 +000050 /* args: none */
51 /* To ask the drd tool to start a new segment in the specified thread. */
52 VG_USERREQ__DRD_START_NEW_SEGMENT,
53 /* args: POSIX thread ID. */
bartbf3a60c2008-04-04 19:10:21 +000054 /* Let the drd tool stop recording memory accesses in the calling thread. */
55 VG_USERREQ__DRD_STOP_RECORDING,
56 /* args: none. */
57 /* Let the drd tool start recording memory accesses in the calling thread. */
58 VG_USERREQ__DRD_START_RECORDING,
59 /* args: none. */
sewardjaf44c822007-11-25 14:01:38 +000060
sewardjaf44c822007-11-25 14:01:38 +000061 /* Tell the core the pthread_t of the running thread */
62 VG_USERREQ__SET_PTHREADID,
63 /* args: pthread_t. */
64 /* Ask the core that a the thread's state transition from */
65 /* VgTs_Zombie to VgTs_Empty is delayed until */
66 /* VG_USERREQ__POST_THREAD_JOIN is performed. */
67 VG_USERREQ__SET_JOINABLE,
68 /* args: pthread_t, Bool */
69
70 /* To notify drd that a thread finished because */
71 /* pthread_thread_join() was called on it. */
72 VG_USERREQ__POST_THREAD_JOIN,
73 /* args: pthread_t (joinee) */
74
bart0f099cd2008-09-27 12:36:48 +000075 /* To notify drd before a pthread_cancel call. */
76 VG_USERREQ__PRE_THREAD_CANCEL,
77 /* args: pthread_t */
78 /* To notify drd after a pthread_cancel call. */
79 VG_USERREQ__POST_THREAD_CANCEL,
80 /* args: pthread_t, Bool */
81
sewardj85642922008-01-14 11:54:56 +000082 /* to notify the drd tool of a pthread_mutex_init call. */
sewardjaf44c822007-11-25 14:01:38 +000083 VG_USERREQ__PRE_MUTEX_INIT,
sewardj721ad7b2007-11-30 08:30:29 +000084 /* args: Addr, MutexT */
bart0268dfa2008-03-11 20:10:21 +000085 /* to notify the drd tool of a pthread_mutex_init call. */
86 VG_USERREQ__POST_MUTEX_INIT,
87 /* args: Addr */
88 /* to notify the drd tool of a pthread_mutex_destroy call. */
89 VG_USERREQ__PRE_MUTEX_DESTROY,
90 /* args: Addr */
sewardj85642922008-01-14 11:54:56 +000091 /* to notify the drd tool of a pthread_mutex_destroy call. */
sewardjaf44c822007-11-25 14:01:38 +000092 VG_USERREQ__POST_MUTEX_DESTROY,
bart0268dfa2008-03-11 20:10:21 +000093 /* args: Addr, MutexT */
sewardj85642922008-01-14 11:54:56 +000094 /* to notify the drd tool of pthread_mutex_lock calls */
bart0268dfa2008-03-11 20:10:21 +000095 VG_USERREQ__PRE_MUTEX_LOCK,
bart2e3a3c12008-03-24 08:33:47 +000096 /* args: Addr, MutexT, Bool */
sewardj85642922008-01-14 11:54:56 +000097 /* to notify the drd tool of pthread_mutex_lock calls */
bart0268dfa2008-03-11 20:10:21 +000098 VG_USERREQ__POST_MUTEX_LOCK,
bart00344642008-03-01 15:27:41 +000099 /* args: Addr, Bool */
sewardj85642922008-01-14 11:54:56 +0000100 /* to notify the drd tool of pthread_mutex_unlock calls */
bart0268dfa2008-03-11 20:10:21 +0000101 VG_USERREQ__PRE_MUTEX_UNLOCK,
102 /* args: Addr */
103 /* to notify the drd tool of pthread_mutex_unlock calls */
104 VG_USERREQ__POST_MUTEX_UNLOCK,
sewardjaf44c822007-11-25 14:01:38 +0000105 /* args: Addr */
bartf4f05812008-07-07 08:10:56 +0000106 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
107 VG_USERREQ__PRE_SPIN_INIT_OR_UNLOCK,
108 /* args: Addr */
109 /* to notify the drd tool of a pthread_spin_init/pthread_spin_unlock call */
110 VG_USERREQ__POST_SPIN_INIT_OR_UNLOCK,
111 /* args: Addr */
sewardjaf44c822007-11-25 14:01:38 +0000112
113
sewardj85642922008-01-14 11:54:56 +0000114 /* to notify the drd tool of a pthread_cond_init call. */
bart0268dfa2008-03-11 20:10:21 +0000115 VG_USERREQ__PRE_COND_INIT,
sewardj721ad7b2007-11-30 08:30:29 +0000116 /* args: Addr */
bart3f4623e2008-07-07 16:53:07 +0000117 /* to notify the drd tool of a pthread_cond_init call. */
118 VG_USERREQ__POST_COND_INIT,
119 /* args: Addr */
120 /* to notify the drd tool of a pthread_cond_destroy call. */
121 VG_USERREQ__PRE_COND_DESTROY,
122 /* args: Addr */
sewardj85642922008-01-14 11:54:56 +0000123 /* to notify the drd tool of a pthread_cond_destroy call. */
bart0268dfa2008-03-11 20:10:21 +0000124 VG_USERREQ__POST_COND_DESTROY,
bart3f4623e2008-07-07 16:53:07 +0000125 /* args: Addr */
bart0268dfa2008-03-11 20:10:21 +0000126 VG_USERREQ__PRE_COND_WAIT,
127 /* args: Addr cond, Addr mutex, MutexT mt */
128 VG_USERREQ__POST_COND_WAIT,
129 /* args: Addr cond, Addr mutex, Bool took_lock*/
130 VG_USERREQ__PRE_COND_SIGNAL,
131 /* args: Addr cond */
bart3f4623e2008-07-07 16:53:07 +0000132 VG_USERREQ__POST_COND_SIGNAL,
133 /* args: Addr cond */
bart0268dfa2008-03-11 20:10:21 +0000134 VG_USERREQ__PRE_COND_BROADCAST,
sewardjaf44c822007-11-25 14:01:38 +0000135 /* args: Addr cond */
bart3f4623e2008-07-07 16:53:07 +0000136 VG_USERREQ__POST_COND_BROADCAST,
137 /* args: Addr cond */
sewardjaf44c822007-11-25 14:01:38 +0000138
sewardj85642922008-01-14 11:54:56 +0000139 /* To notify the drd tool of a sem_init call. */
bart0268dfa2008-03-11 20:10:21 +0000140 VG_USERREQ__PRE_SEM_INIT,
141 /* args: Addr sem, Word pshared, Word value */
142 /* To notify the drd tool of a sem_init call. */
143 VG_USERREQ__POST_SEM_INIT,
144 /* args: Addr sem */
sewardj85642922008-01-14 11:54:56 +0000145 /* To notify the drd tool of a sem_destroy call. */
bart0268dfa2008-03-11 20:10:21 +0000146 VG_USERREQ__PRE_SEM_DESTROY,
147 /* args: Addr sem */
148 /* To notify the drd tool of a sem_destroy call. */
149 VG_USERREQ__POST_SEM_DESTROY,
sewardj85642922008-01-14 11:54:56 +0000150 /* args: Addr sem */
151 /* To notify the drd tool of a sem_wait call. */
bart28230a32008-02-29 17:27:03 +0000152 VG_USERREQ__PRE_SEM_WAIT,
bart0268dfa2008-03-11 20:10:21 +0000153 /* args: Addr sem */
bart28230a32008-02-29 17:27:03 +0000154 /* To notify the drd tool of a sem_wait call. */
155 VG_USERREQ__POST_SEM_WAIT,
156 /* args: Addr sem, Bool waited */
sewardj85642922008-01-14 11:54:56 +0000157 /* To notify the drd tool before a sem_post call. */
158 VG_USERREQ__PRE_SEM_POST,
bart0268dfa2008-03-11 20:10:21 +0000159 /* args: Addr sem */
sewardj85642922008-01-14 11:54:56 +0000160 /* To notify the drd tool after a sem_post call. */
161 VG_USERREQ__POST_SEM_POST,
bart0268dfa2008-03-11 20:10:21 +0000162 /* args: Addr sem, Bool waited */
sewardj85642922008-01-14 11:54:56 +0000163
164 /* To notify the drd tool of a pthread_barrier_init call. */
bart0268dfa2008-03-11 20:10:21 +0000165 VG_USERREQ__PRE_BARRIER_INIT,
166 /* args: Addr barrier, BarrierT type, Word count, Bool reinit */
167 /* To notify the drd tool of a pthread_barrier_init call. */
168 VG_USERREQ__POST_BARRIER_INIT,
169 /* args: Addr barrier, BarrierT type */
sewardj85642922008-01-14 11:54:56 +0000170 /* To notify the drd tool of a pthread_barrier_destroy call. */
bart0268dfa2008-03-11 20:10:21 +0000171 VG_USERREQ__PRE_BARRIER_DESTROY,
172 /* args: Addr barrier, BarrierT type. */
173 /* To notify the drd tool of a pthread_barrier_destroy call. */
174 VG_USERREQ__POST_BARRIER_DESTROY,
175 /* args: Addr barrier, BarrierT type. */
sewardj85642922008-01-14 11:54:56 +0000176 /* To notify the drd tool of a pthread_barrier_wait call. */
177 VG_USERREQ__PRE_BARRIER_WAIT,
bart0268dfa2008-03-11 20:10:21 +0000178 /* args: Addr barrier, BarrierT type. */
sewardj85642922008-01-14 11:54:56 +0000179 /* To notify the drd tool of a pthread_barrier_wait call. */
180 VG_USERREQ__POST_BARRIER_WAIT,
bart0268dfa2008-03-11 20:10:21 +0000181 /* args: Addr barrier, BarrierT type, Word has_waited */
sewardj85642922008-01-14 11:54:56 +0000182
bart00344642008-03-01 15:27:41 +0000183 /* To notify the drd tool of a pthread_rwlock_init call. */
184 VG_USERREQ__PRE_RWLOCK_INIT,
bart0268dfa2008-03-11 20:10:21 +0000185 /* args: Addr rwlock */
bart00344642008-03-01 15:27:41 +0000186 /* To notify the drd tool of a pthread_rwlock_destroy call. */
187 VG_USERREQ__POST_RWLOCK_DESTROY,
bart0268dfa2008-03-11 20:10:21 +0000188 /* args: Addr rwlock */
bart00344642008-03-01 15:27:41 +0000189 /* To notify the drd tool of a pthread_rwlock_rdlock call. */
190 VG_USERREQ__PRE_RWLOCK_RDLOCK,
bart0268dfa2008-03-11 20:10:21 +0000191 /* args: Addr rwlock */
bart00344642008-03-01 15:27:41 +0000192 /* To notify the drd tool of a pthread_rwlock_rdlock call. */
193 VG_USERREQ__POST_RWLOCK_RDLOCK,
194 /* args: Addr rwlock, Bool took_lock */
195 /* To notify the drd tool of a pthread_rwlock_wrlock call. */
196 VG_USERREQ__PRE_RWLOCK_WRLOCK,
bart0268dfa2008-03-11 20:10:21 +0000197 /* args: Addr rwlock */
bart00344642008-03-01 15:27:41 +0000198 /* To notify the drd tool of a pthread_rwlock_wrlock call. */
199 VG_USERREQ__POST_RWLOCK_WRLOCK,
200 /* args: Addr rwlock, Bool took_lock */
201 /* To notify the drd tool of a pthread_rwlock_unlock call. */
bart777f7fe2008-03-02 17:43:18 +0000202 VG_USERREQ__PRE_RWLOCK_UNLOCK,
bart0268dfa2008-03-11 20:10:21 +0000203 /* args: Addr rwlock */
204 /* To notify the drd tool of a pthread_rwlock_unlock call. */
bartd00bd222008-03-30 08:40:49 +0000205 VG_USERREQ__POST_RWLOCK_UNLOCK
bart00344642008-03-01 15:27:41 +0000206 /* args: Addr rwlock, Bool unlocked */
207
sewardjaf44c822007-11-25 14:01:38 +0000208};
209
bart09dc13f2009-02-14 15:13:31 +0000210/*
211 * Error checking on POSIX recursive mutexes, POSIX error checking mutexes,
212 * POSIX default mutexes and POSIX spinlocks happens by the same code. The
213 * values defined below specify which of these types a mutex really is.
214 */
sewardj721ad7b2007-11-30 08:30:29 +0000215typedef enum
216{
bart3f4623e2008-07-07 16:53:07 +0000217 mutex_type_unknown = -1,
218 mutex_type_invalid_mutex = 0,
219 mutex_type_recursive_mutex = 1,
220 mutex_type_errorcheck_mutex = 2,
221 mutex_type_default_mutex = 3,
222 mutex_type_spinlock = 4
sewardj721ad7b2007-11-30 08:30:29 +0000223} MutexT;
sewardjaf44c822007-11-25 14:01:38 +0000224
bart09dc13f2009-02-14 15:13:31 +0000225/*
226 * Error checking on POSIX barriers and GOMP barriers happens by the same
227 * code. The integer values defined below specify the type of a barrier with
228 * a given client address.
229 */
bart0268dfa2008-03-11 20:10:21 +0000230typedef enum
231 {
232 pthread_barrier = 1,
bartd00bd222008-03-30 08:40:49 +0000233 gomp_barrier = 2
bart0268dfa2008-03-11 20:10:21 +0000234 } BarrierT;
sewardjaf44c822007-11-25 14:01:38 +0000235
bart09dc13f2009-02-14 15:13:31 +0000236
237void DRD_(clientreq_init)(void);
bart5f57be92008-07-01 08:48:56 +0000238
bart3c1e9d82008-06-30 17:10:29 +0000239
sewardjaf44c822007-11-25 14:01:38 +0000240#endif // __DRD_CLIENTREQ_H