blob: 7793145b98c5316d0da668d121dac74622ace8d8 [file] [log] [blame]
sewardjaf44c822007-11-25 14:01:38 +00001/*
2 This file is part of drd, a data race detector.
3
sewardj85642922008-01-14 11:54:56 +00004 Copyright (C) 2006-2008 Bart Van Assche
sewardjaf44c822007-11-25 14:01:38 +00005 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
bart4bb53d82008-02-28 19:06:34 +000026#include "drd_clientobj.h"
sewardjaf44c822007-11-25 14:01:38 +000027#include "drd_error.h"
28#include "drd_mutex.h"
sewardj721ad7b2007-11-30 08:30:29 +000029#include "priv_drd_clientreq.h"
sewardjaf44c822007-11-25 14:01:38 +000030#include "pub_tool_errormgr.h" // VG_(maybe_record_error)()
31#include "pub_tool_libcassert.h" // tl_assert()
bart4bb53d82008-02-28 19:06:34 +000032#include "pub_tool_libcprint.h" // VG_(message)()
sewardjaf44c822007-11-25 14:01:38 +000033#include "pub_tool_machine.h" // VG_(get_IP)()
34#include "pub_tool_threadstate.h" // VG_(get_running_tid)()
35
36
sewardj347eeba2008-01-21 14:19:07 +000037// Local functions.
38
bart46d5f172008-02-28 19:49:37 +000039static void mutex_cleanup(struct mutex_info* p);
bart5357fcb2008-02-27 15:46:00 +000040static Bool mutex_is_locked(struct mutex_info* const p);
sewardj347eeba2008-01-21 14:19:07 +000041
42
sewardjaf44c822007-11-25 14:01:38 +000043// Local variables.
44
45static Bool s_trace_mutex;
46static ULong s_mutex_lock_count;
sewardjaf44c822007-11-25 14:01:38 +000047
48
49// Function definitions.
50
51void mutex_set_trace(const Bool trace_mutex)
52{
53 tl_assert(!! trace_mutex == trace_mutex);
54 s_trace_mutex = trace_mutex;
55}
56
57static
58void mutex_initialize(struct mutex_info* const p,
59 const Addr mutex,
sewardj721ad7b2007-11-30 08:30:29 +000060 const SizeT size,
61 const MutexT mutex_type)
sewardjaf44c822007-11-25 14:01:38 +000062{
63 tl_assert(mutex != 0);
64 tl_assert(size > 0);
65
bart4bb53d82008-02-28 19:06:34 +000066 tl_assert(p->a1 == mutex);
67 tl_assert(p->a2 == mutex + size);
bart46d5f172008-02-28 19:49:37 +000068 p->cleanup = (void(*)(DrdClientobj*))&mutex_cleanup;
sewardj721ad7b2007-11-30 08:30:29 +000069 p->mutex_type = mutex_type;
sewardjaf44c822007-11-25 14:01:38 +000070 p->recursion_count = 0;
71 p->owner = DRD_INVALID_THREADID;
72 vc_init(&p->vc, 0, 0);
73}
74
bart46d5f172008-02-28 19:49:37 +000075/** Deallocate the memory that was allocated by mutex_initialize(). */
76static void mutex_cleanup(struct mutex_info* p)
77{
bartb78312c2008-02-29 11:00:17 +000078 if (s_trace_mutex)
79 {
bart3b1ee452008-02-29 19:28:15 +000080 VG_(message)(Vg_UserMsg,
81 "[%d/%d] mutex_destroy %s 0x%lx",
82 VG_(get_running_tid)(),
83 thread_get_running_tid(),
bartb78312c2008-02-29 11:00:17 +000084 mutex_get_typename(p),
85 p->a1);
86 }
87
bart46d5f172008-02-28 19:49:37 +000088 if (mutex_is_locked(p))
89 {
90 MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner };
91 VG_(maybe_record_error)(VG_(get_running_tid)(),
92 MutexErr,
93 VG_(get_IP)(VG_(get_running_tid)()),
94 "Destroying locked mutex",
95 &MEI);
96 }
97
98 vc_cleanup(&p->vc);
99}
100
sewardjaf44c822007-11-25 14:01:38 +0000101static
sewardj721ad7b2007-11-30 08:30:29 +0000102struct mutex_info*
103mutex_get_or_allocate(const Addr mutex,
104 const SizeT size,
105 const MutexT mutex_type)
sewardjaf44c822007-11-25 14:01:38 +0000106{
bart4bb53d82008-02-28 19:06:34 +0000107 struct mutex_info* p;
sewardj721ad7b2007-11-30 08:30:29 +0000108
bart4bb53d82008-02-28 19:06:34 +0000109 tl_assert(offsetof(DrdClientobj, mutex) == 0);
bart72b751c2008-03-01 13:44:24 +0000110 p = &clientobj_get(mutex, ClientMutex)->mutex;
bart4bb53d82008-02-28 19:06:34 +0000111 if (p)
112 {
113 tl_assert(p->mutex_type == mutex_type);
114 tl_assert(p->a2 - p->a1 == size);
115 return p;
116 }
sewardj721ad7b2007-11-30 08:30:29 +0000117
bart72b751c2008-03-01 13:44:24 +0000118 if (clientobj_present(mutex, mutex + size))
sewardj721ad7b2007-11-30 08:30:29 +0000119 {
bart4bb53d82008-02-28 19:06:34 +0000120 GenericErrInfo GEI;
121 VG_(maybe_record_error)(VG_(get_running_tid)(),
122 GenericErr,
123 VG_(get_IP)(VG_(get_running_tid)()),
124 "Not a mutex",
125 &GEI);
126 return 0;
sewardj721ad7b2007-11-30 08:30:29 +0000127 }
bart4bb53d82008-02-28 19:06:34 +0000128
bart72b751c2008-03-01 13:44:24 +0000129 p = &clientobj_add(mutex, mutex + size, ClientMutex)->mutex;
bart4bb53d82008-02-28 19:06:34 +0000130 mutex_initialize(p, mutex, size, mutex_type);
131 return p;
sewardjaf44c822007-11-25 14:01:38 +0000132}
133
bart3b1ee452008-02-29 19:28:15 +0000134struct mutex_info* mutex_get(const Addr mutex)
135{
136 tl_assert(offsetof(DrdClientobj, mutex) == 0);
bart72b751c2008-03-01 13:44:24 +0000137 return &clientobj_get(mutex, ClientMutex)->mutex;
bart3b1ee452008-02-29 19:28:15 +0000138}
139
bart00344642008-03-01 15:27:41 +0000140/** Called before pthread_mutex_init(). */
sewardj721ad7b2007-11-30 08:30:29 +0000141struct mutex_info*
142mutex_init(const Addr mutex, const SizeT size, const MutexT mutex_type)
sewardjaf44c822007-11-25 14:01:38 +0000143{
bart00344642008-03-01 15:27:41 +0000144 struct mutex_info* p;
sewardjaf44c822007-11-25 14:01:38 +0000145
sewardjaf44c822007-11-25 14:01:38 +0000146 if (s_trace_mutex)
147 {
bart3b1ee452008-02-29 19:28:15 +0000148 VG_(message)(Vg_UserMsg,
149 "[%d/%d] mutex_init %s 0x%lx",
150 VG_(get_running_tid)(),
151 thread_get_running_tid(),
sewardj347eeba2008-01-21 14:19:07 +0000152 mutex_type_name(mutex_type),
sewardjaf44c822007-11-25 14:01:38 +0000153 mutex);
154 }
155
bart00344642008-03-01 15:27:41 +0000156 if (mutex_type == mutex_type_invalid_mutex)
157 {
158 GenericErrInfo GEI;
159 VG_(maybe_record_error)(VG_(get_running_tid)(),
160 GenericErr,
161 VG_(get_IP)(VG_(get_running_tid)()),
162 "Invalid mutex",
163 &GEI);
164 return 0;
165 }
166
167 p = mutex_get(mutex);
168 if (p)
sewardj347eeba2008-01-21 14:19:07 +0000169 {
170 const ThreadId vg_tid = VG_(get_running_tid)();
171 MutexErrInfo MEI
bart00344642008-03-01 15:27:41 +0000172 = { p->a1, p->recursion_count, p->owner };
sewardj347eeba2008-01-21 14:19:07 +0000173 VG_(maybe_record_error)(vg_tid,
174 MutexErr,
175 VG_(get_IP)(vg_tid),
176 "Mutex reinitialization",
177 &MEI);
bart00344642008-03-01 15:27:41 +0000178 return p;
sewardj347eeba2008-01-21 14:19:07 +0000179 }
bart00344642008-03-01 15:27:41 +0000180 p = mutex_get_or_allocate(mutex, size, mutex_type);
sewardj347eeba2008-01-21 14:19:07 +0000181
bart00344642008-03-01 15:27:41 +0000182 return p;
sewardjaf44c822007-11-25 14:01:38 +0000183}
184
bart46d5f172008-02-28 19:49:37 +0000185/** Called after pthread_mutex_destroy(). */
sewardj347eeba2008-01-21 14:19:07 +0000186void mutex_post_destroy(const Addr mutex)
187{
bart72b751c2008-03-01 13:44:24 +0000188 struct mutex_info* p;
sewardj347eeba2008-01-21 14:19:07 +0000189
bart72b751c2008-03-01 13:44:24 +0000190 p = mutex_get(mutex);
191 if (p == 0)
192 {
193 GenericErrInfo GEI;
194 VG_(maybe_record_error)(VG_(get_running_tid)(),
195 GenericErr,
196 VG_(get_IP)(VG_(get_running_tid)()),
197 "Not a mutex",
198 &GEI);
199 return;
200 }
201
202 clientobj_remove(mutex, ClientMutex);
sewardj347eeba2008-01-21 14:19:07 +0000203}
204
bart8bba1f72008-02-27 16:13:05 +0000205/** Called before pthread_mutex_lock() is invoked. If a data structure for
206 * the client-side object was not yet created, do this now. Also check whether
207 * an attempt is made to lock recursively a synchronization object that must
208 * not be locked recursively.
209 */
210void mutex_pre_lock(const Addr mutex, const SizeT size, MutexT mutex_type)
211{
bart635cb162008-02-28 08:30:43 +0000212 struct mutex_info* p;
213
214 p = mutex_get(mutex);
bart00344642008-03-01 15:27:41 +0000215
216 if (s_trace_mutex)
217 {
218 VG_(message)(Vg_UserMsg,
219 "[%d/%d] pre_mutex_lock %s 0x%lx rc %d owner %d",
220 VG_(get_running_tid)(),
221 thread_get_running_tid(),
222 p ? mutex_get_typename(p) : "(?)",
223 mutex,
224 p ? p->recursion_count : 0,
225 p ? p->owner : VG_INVALID_THREADID);
226 }
227
228 if (mutex_type == mutex_type_invalid_mutex)
229 {
230 GenericErrInfo GEI;
231 VG_(maybe_record_error)(VG_(get_running_tid)(),
232 GenericErr,
233 VG_(get_IP)(VG_(get_running_tid)()),
234 "Invalid mutex",
235 &GEI);
236 return;
237 }
238
bart8bba1f72008-02-27 16:13:05 +0000239 if (p == 0)
240 {
bart00344642008-03-01 15:27:41 +0000241 p = mutex_init(mutex, size, mutex_type);
bart8bba1f72008-02-27 16:13:05 +0000242 }
bart635cb162008-02-28 08:30:43 +0000243
bart8bba1f72008-02-27 16:13:05 +0000244 tl_assert(p);
245
246 if (p->owner == thread_get_running_tid()
247 && p->recursion_count >= 1
248 && mutex_type != mutex_type_recursive_mutex)
249 {
bart4bb53d82008-02-28 19:06:34 +0000250 MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner };
bart8bba1f72008-02-27 16:13:05 +0000251 VG_(maybe_record_error)(VG_(get_running_tid)(),
252 MutexErr,
253 VG_(get_IP)(VG_(get_running_tid)()),
254 "Recursive locking not allowed",
255 &MEI);
256 }
257}
258
sewardjaf44c822007-11-25 14:01:38 +0000259/**
260 * Update mutex_info state when locking the pthread_mutex_t mutex.
261 * Note: this function must be called after pthread_mutex_lock() has been
262 * called, or a race condition is triggered !
263 */
bart00344642008-03-01 15:27:41 +0000264int mutex_post_lock(const Addr mutex, const Bool took_lock)
sewardjaf44c822007-11-25 14:01:38 +0000265{
bart3b1ee452008-02-29 19:28:15 +0000266 const DrdThreadId drd_tid = thread_get_running_tid();
bart00344642008-03-01 15:27:41 +0000267 struct mutex_info* p;
268
269 p = mutex_get(mutex);
sewardjaf44c822007-11-25 14:01:38 +0000270
271 if (s_trace_mutex)
272 {
bart3b1ee452008-02-29 19:28:15 +0000273 VG_(message)(Vg_UserMsg,
274 "[%d/%d] post_mutex_lock %s 0x%lx rc %d owner %d",
275 VG_(get_running_tid)(),
sewardjaf44c822007-11-25 14:01:38 +0000276 drd_tid,
bart00344642008-03-01 15:27:41 +0000277 p ? mutex_get_typename(p) : "(?)",
sewardjaf44c822007-11-25 14:01:38 +0000278 mutex,
279 p ? p->recursion_count : 0,
280 p ? p->owner : VG_INVALID_THREADID);
281 }
282
bartab7a6442008-02-25 19:46:14 +0000283 if (p == 0)
284 {
bartab7a6442008-02-25 19:46:14 +0000285 return 0;
286 }
287
bart3b1ee452008-02-29 19:28:15 +0000288 if (! took_lock)
289 return p->recursion_count;
bart5357fcb2008-02-27 15:46:00 +0000290
sewardjaf44c822007-11-25 14:01:38 +0000291 if (p->recursion_count == 0)
292 {
293 p->owner = drd_tid;
294 s_mutex_lock_count++;
295 }
296 else if (p->owner != drd_tid)
297 {
bart3b1ee452008-02-29 19:28:15 +0000298 VG_(message)(Vg_UserMsg,
sewardjaf44c822007-11-25 14:01:38 +0000299 "The impossible happened: mutex 0x%lx is locked"
300 " simultaneously by two threads (recursion count %d,"
301 " owners %d and %d) !",
bart4bb53d82008-02-28 19:06:34 +0000302 p->a1, p->recursion_count, p->owner, drd_tid);
sewardj347eeba2008-01-21 14:19:07 +0000303 p->owner = drd_tid;
sewardjaf44c822007-11-25 14:01:38 +0000304 }
305 p->recursion_count++;
306
307 if (p->recursion_count == 1)
308 {
bartab7a6442008-02-25 19:46:14 +0000309 const DrdThreadId last_owner = p->owner;
310
sewardjaf44c822007-11-25 14:01:38 +0000311 if (last_owner != drd_tid && last_owner != DRD_INVALID_THREADID)
312 thread_combine_vc2(drd_tid, mutex_get_last_vc(mutex));
313 thread_new_segment(drd_tid);
314 }
315
316 return p->recursion_count;
317}
318
319/**
320 * Update mutex_info state when unlocking the pthread_mutex_t mutex.
321 * Note: this function must be called before pthread_mutex_unlock() is called,
322 * or a race condition is triggered !
bartb78312c2008-02-29 11:00:17 +0000323 * @return New value of the mutex recursion count.
sewardjaf44c822007-11-25 14:01:38 +0000324 * @param mutex Pointer to pthread_mutex_t data structure in the client space.
325 * @param tid ThreadId of the thread calling pthread_mutex_unlock().
326 * @param vc Pointer to the current vector clock of thread tid.
327 */
sewardj721ad7b2007-11-30 08:30:29 +0000328int mutex_unlock(const Addr mutex, const MutexT mutex_type)
sewardjaf44c822007-11-25 14:01:38 +0000329{
bartb78312c2008-02-29 11:00:17 +0000330 const DrdThreadId drd_tid = thread_get_running_tid();
331 const ThreadId vg_tid = VG_(get_running_tid)();
sewardjaf44c822007-11-25 14:01:38 +0000332 const VectorClock* const vc = thread_get_vc(drd_tid);
333 struct mutex_info* const p = mutex_get(mutex);
334
bartb78312c2008-02-29 11:00:17 +0000335 if (s_trace_mutex && p != 0)
sewardjaf44c822007-11-25 14:01:38 +0000336 {
bart3b1ee452008-02-29 19:28:15 +0000337 VG_(message)(Vg_UserMsg,
338 "[%d/%d] mutex_unlock %s 0x%lx rc %d",
339 vg_tid,
340 drd_tid,
sewardjaf44c822007-11-25 14:01:38 +0000341 mutex_get_typename(p),
342 mutex,
343 p->recursion_count,
344 p->owner);
345 }
346
bart635cb162008-02-28 08:30:43 +0000347 if (mutex_type == mutex_type_invalid_mutex)
348 {
349 GenericErrInfo GEI;
350 VG_(maybe_record_error)(VG_(get_running_tid)(),
351 GenericErr,
352 VG_(get_IP)(VG_(get_running_tid)()),
353 "Invalid mutex",
354 &GEI);
bart00344642008-03-01 15:27:41 +0000355 return 0;
bart635cb162008-02-28 08:30:43 +0000356 }
357
bart5357fcb2008-02-27 15:46:00 +0000358 if (p == 0)
bartab7a6442008-02-25 19:46:14 +0000359 {
barte883bc82008-02-26 19:13:04 +0000360 GenericErrInfo GEI;
bartab7a6442008-02-25 19:46:14 +0000361 VG_(maybe_record_error)(vg_tid,
barte883bc82008-02-26 19:13:04 +0000362 GenericErr,
bartab7a6442008-02-25 19:46:14 +0000363 VG_(get_IP)(vg_tid),
364 "Not a mutex",
barte883bc82008-02-26 19:13:04 +0000365 &GEI);
bartab7a6442008-02-25 19:46:14 +0000366 return 0;
367 }
368
bart5357fcb2008-02-27 15:46:00 +0000369 if (p->owner == DRD_INVALID_THREADID)
370 {
bart4bb53d82008-02-28 19:06:34 +0000371 MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner };
bart5357fcb2008-02-27 15:46:00 +0000372 VG_(maybe_record_error)(vg_tid,
373 MutexErr,
374 VG_(get_IP)(vg_tid),
375 "Mutex not locked",
376 &MEI);
377 return 0;
378 }
379
sewardjaf44c822007-11-25 14:01:38 +0000380 tl_assert(p);
bart5357fcb2008-02-27 15:46:00 +0000381 if (p->mutex_type != mutex_type)
382 {
bart3b1ee452008-02-29 19:28:15 +0000383 VG_(message)(Vg_UserMsg, "??? mutex %p: type changed from %d into %d",
bart4bb53d82008-02-28 19:06:34 +0000384 p->a1, p->mutex_type, mutex_type);
bart5357fcb2008-02-27 15:46:00 +0000385 }
sewardj721ad7b2007-11-30 08:30:29 +0000386 tl_assert(p->mutex_type == mutex_type);
sewardjaf44c822007-11-25 14:01:38 +0000387 tl_assert(p->owner != DRD_INVALID_THREADID);
sewardj721ad7b2007-11-30 08:30:29 +0000388
sewardjaf44c822007-11-25 14:01:38 +0000389 if (p->owner != drd_tid)
390 {
bart4bb53d82008-02-28 19:06:34 +0000391 MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner };
sewardjaf44c822007-11-25 14:01:38 +0000392 VG_(maybe_record_error)(vg_tid,
393 MutexErr,
394 VG_(get_IP)(vg_tid),
395 "Mutex not unlocked by owner thread",
396 &MEI);
397 }
398 p->recursion_count--;
sewardj347eeba2008-01-21 14:19:07 +0000399 if (p->recursion_count < 0)
400 {
401 MutexErrInfo MEI
bart4bb53d82008-02-28 19:06:34 +0000402 = { p->a1, p->recursion_count, p->owner };
sewardj347eeba2008-01-21 14:19:07 +0000403 VG_(maybe_record_error)(vg_tid,
404 MutexErr,
405 VG_(get_IP)(vg_tid),
406 "Attempt to unlock a mutex that is not locked",
407 &MEI);
408 p->recursion_count = 0;
409 }
410
sewardjaf44c822007-11-25 14:01:38 +0000411 if (p->recursion_count == 0)
412 {
413 /* This pthread_mutex_unlock() call really unlocks the mutex. Save the */
414 /* current vector clock of the thread such that it is available when */
415 /* this mutex is locked again. */
bart301c3112008-02-24 18:22:37 +0000416 vc_assign(&p->vc, vc);
sewardjaf44c822007-11-25 14:01:38 +0000417
418 thread_new_segment(drd_tid);
419 }
420 return p->recursion_count;
421}
422
423const char* mutex_get_typename(struct mutex_info* const p)
424{
425 tl_assert(p);
sewardj721ad7b2007-11-30 08:30:29 +0000426
sewardj347eeba2008-01-21 14:19:07 +0000427 return mutex_type_name(p->mutex_type);
428}
429
430const char* mutex_type_name(const MutexT mt)
431{
432 switch (mt)
sewardjaf44c822007-11-25 14:01:38 +0000433 {
bart635cb162008-02-28 08:30:43 +0000434 case mutex_type_invalid_mutex:
435 return "invalid mutex";
bart5357fcb2008-02-27 15:46:00 +0000436 case mutex_type_recursive_mutex:
437 return "recursive mutex";
438 case mutex_type_errorcheck_mutex:
439 return "error checking mutex";
440 case mutex_type_default_mutex:
sewardjaf44c822007-11-25 14:01:38 +0000441 return "mutex";
sewardj721ad7b2007-11-30 08:30:29 +0000442 case mutex_type_spinlock:
sewardjaf44c822007-11-25 14:01:38 +0000443 return "spinlock";
444 default:
445 tl_assert(0);
446 }
447 return "?";
448}
449
bart5357fcb2008-02-27 15:46:00 +0000450/** Return true if the specified mutex is locked by any thread. */
451static Bool mutex_is_locked(struct mutex_info* const p)
452{
453 tl_assert(p);
454 return (p->recursion_count > 0);
455}
456
sewardjaf44c822007-11-25 14:01:38 +0000457Bool mutex_is_locked_by(const Addr mutex, const DrdThreadId tid)
458{
459 struct mutex_info* const p = mutex_get(mutex);
sewardjaf44c822007-11-25 14:01:38 +0000460 if (p)
461 {
462 return (p->recursion_count > 0 && p->owner == tid);
463 }
464 return False;
465}
466
467const VectorClock* mutex_get_last_vc(const Addr mutex)
468{
469 struct mutex_info* const p = mutex_get(mutex);
470 return p ? &p->vc : 0;
471}
472
473int mutex_get_recursion_count(const Addr mutex)
474{
475 struct mutex_info* const p = mutex_get(mutex);
476 tl_assert(p);
477 return p->recursion_count;
478}
479
480/**
bart301c3112008-02-24 18:22:37 +0000481 * Call this function when thread tid stops to exist, such that the
sewardjaf44c822007-11-25 14:01:38 +0000482 * "last owner" field can be cleared if it still refers to that thread.
sewardjaf44c822007-11-25 14:01:38 +0000483 */
bart301c3112008-02-24 18:22:37 +0000484void mutex_thread_delete(const DrdThreadId tid)
sewardjaf44c822007-11-25 14:01:38 +0000485{
bart4bb53d82008-02-28 19:06:34 +0000486 struct mutex_info* p;
487
bart72b751c2008-03-01 13:44:24 +0000488 clientobj_resetiter();
489 for ( ; (p = &clientobj_next(ClientMutex)->mutex) != 0; )
sewardjaf44c822007-11-25 14:01:38 +0000490 {
bart4bb53d82008-02-28 19:06:34 +0000491 if (p->owner == tid && p->recursion_count > 0)
sewardjaf44c822007-11-25 14:01:38 +0000492 {
bart5357fcb2008-02-27 15:46:00 +0000493 MutexErrInfo MEI
bart4bb53d82008-02-28 19:06:34 +0000494 = { p->a1, p->recursion_count, p->owner };
bart5357fcb2008-02-27 15:46:00 +0000495 VG_(maybe_record_error)(VG_(get_running_tid)(),
496 MutexErr,
497 VG_(get_IP)(VG_(get_running_tid)()),
498 "Mutex still locked at thread exit",
499 &MEI);
sewardjaf44c822007-11-25 14:01:38 +0000500 p->owner = VG_INVALID_THREADID;
501 }
502 }
503}
504
sewardjaf44c822007-11-25 14:01:38 +0000505ULong get_mutex_lock_count(void)
506{
507 return s_mutex_lock_count;
508}
sewardj347eeba2008-01-21 14:19:07 +0000509
510
511/*
512 * Local variables:
513 * c-basic-offset: 3
514 * End:
515 */