From: Bart Van Assche Date: Sat, 8 Oct 2011 08:54:57 +0000 (+0000) Subject: drd: Convert a few VG_(message)() calls into VG_(maybe_record_error)() calls X-Git-Tag: svn/VALGRIND_3_7_0~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c05ada318036aabc0711c006fed44c3f3fd5e599;p=thirdparty%2Fvalgrind.git drd: Convert a few VG_(message)() calls into VG_(maybe_record_error)() calls git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12121 --- diff --git a/drd/drd_barrier.c b/drd/drd_barrier.c index 26947cd5ff..b45977aa78 100644 --- a/drd/drd_barrier.c +++ b/drd/drd_barrier.c @@ -335,20 +335,20 @@ void DRD_(barrier_pre_wait)(const DrdThreadId tid, const Addr barrier, OSet* oset; p = DRD_(barrier_get)(barrier); - if (p == 0 && barrier_type == gomp_barrier) - { + if (p == 0 && barrier_type == gomp_barrier) { /* * gomp_barrier_wait() call has been intercepted but gomp_barrier_init() * not. The only cause I know of that can trigger this is that libgomp.so * has been compiled with --enable-linux-futex. */ - VG_(message)(Vg_UserMsg, "\n"); - VG_(message)(Vg_UserMsg, - "Please verify whether gcc has been configured" - " with option --disable-linux-futex.\n"); - VG_(message)(Vg_UserMsg, - "See also the section about OpenMP in the DRD manual.\n"); - VG_(message)(Vg_UserMsg, "\n"); + BarrierErrInfo bei = { DRD_(thread_get_running_tid)(), 0, 0, 0 }; + VG_(maybe_record_error)(VG_(get_running_tid)(), + BarrierErr, + VG_(get_IP)(VG_(get_running_tid)()), + "Please verify whether gcc has been configured" + " with option --disable-linux-futex. See also" + " the section about OpenMP in the DRD manual.", + &bei); } tl_assert(p); diff --git a/drd/drd_load_store.c b/drd/drd_load_store.c index 0cdcbcd6bc..5b7904d91c 100644 --- a/drd/drd_load_store.c +++ b/drd/drd_load_store.c @@ -129,7 +129,7 @@ static void drd_report_race(const Addr addr, const SizeT size, VG_(maybe_record_error)(VG_(get_running_tid)(), DataRaceErr, VG_(get_IP)(VG_(get_running_tid)()), - "Conflicting accesses", + "Conflicting access", &drei); if (s_first_race_only) diff --git a/drd/drd_mutex.c b/drd/drd_mutex.c index 6ddc1f9172..289ebe54ea 100644 --- a/drd/drd_mutex.c +++ b/drd/drd_mutex.c @@ -28,13 +28,13 @@ #include "drd_error.h" #include "drd_mutex.h" #include "pub_tool_vki.h" -#include "pub_tool_errormgr.h" // VG_(maybe_record_error)() -#include "pub_tool_libcassert.h" // tl_assert() -#include "pub_tool_libcbase.h" // VG_(strlen) -#include "pub_tool_libcprint.h" // VG_(message)() -#include "pub_tool_libcproc.h" // VG_(read_millisecond_timer)() -#include "pub_tool_machine.h" // VG_(get_IP)() -#include "pub_tool_threadstate.h" // VG_(get_running_tid)() +#include "pub_tool_errormgr.h" /* VG_(maybe_record_error)() */ +#include "pub_tool_libcassert.h" /* tl_assert() */ +#include "pub_tool_libcbase.h" /* VG_(strlen) */ +#include "pub_tool_libcprint.h" /* VG_(message)() */ +#include "pub_tool_libcproc.h" /* VG_(read_millisecond_timer)() */ +#include "pub_tool_machine.h" /* VG_(get_IP)() */ +#include "pub_tool_threadstate.h" /* VG_(get_running_tid)() */ /* Local functions. */ @@ -302,8 +302,7 @@ void DRD_(mutex_post_lock)(const Addr mutex, const Bool took_lock, if (! p || ! took_lock) return; - if (p->recursion_count == 0) - { + if (p->recursion_count == 0) { if (p->owner != drd_tid && p->owner != DRD_INVALID_THREADID) { tl_assert(p->last_locked_segment); @@ -320,14 +319,16 @@ void DRD_(mutex_post_lock)(const Addr mutex, const Bool took_lock, p->acquiry_time_ms = VG_(read_millisecond_timer)(); p->acquired_at = VG_(record_ExeContext)(VG_(get_running_tid)(), 0); s_mutex_lock_count++; - } - else if (p->owner != drd_tid) - { - VG_(message)(Vg_UserMsg, - "The impossible happened: mutex 0x%lx is locked" - " simultaneously by two threads (recursion count %d," - " owners %d and %d) !\n", - p->a1, p->recursion_count, p->owner, drd_tid); + } else if (p->owner != drd_tid) { + const ThreadId vg_tid = VG_(get_running_tid)(); + MutexErrInfo MEI = { DRD_(thread_get_running_tid)(), + p->a1, p->recursion_count, p->owner }; + VG_(maybe_record_error)(vg_tid, + MutexErr, + VG_(get_IP)(vg_tid), + "The impossible happened: mutex is locked" + " simultaneously by two threads", + &MEI); p->owner = drd_tid; } p->recursion_count++; @@ -379,10 +380,11 @@ void DRD_(mutex_unlock)(const Addr mutex, MutexT mutex_type) } tl_assert(p); - if (p->mutex_type != mutex_type) - { - VG_(message)(Vg_UserMsg, "??? mutex 0x%lx: type changed from %d into %d\n", - p->a1, p->mutex_type, mutex_type); + if (p->mutex_type != mutex_type) { + MutexErrInfo MEI = { DRD_(thread_get_running_tid)(), + p->a1, p->recursion_count, p->owner }; + VG_(maybe_record_error)(vg_tid, MutexErr, VG_(get_IP)(vg_tid), + "Mutex type changed", &MEI); } tl_assert(p->mutex_type == mutex_type); tl_assert(p->owner != DRD_INVALID_THREADID); diff --git a/drd/drd_rwlock.c b/drd/drd_rwlock.c index 74dc410d34..448add2639 100644 --- a/drd/drd_rwlock.c +++ b/drd/drd_rwlock.c @@ -387,12 +387,13 @@ void DRD_(rwlock_pre_rdlock)(const Addr rwlock, const RwLockT rwlock_type) p = DRD_(rwlock_get_or_allocate)(rwlock, rwlock_type); tl_assert(p); - if (DRD_(rwlock_is_wrlocked_by)(p, DRD_(thread_get_running_tid)())) - { - VG_(message)(Vg_UserMsg, - "reader-writer lock 0x%lx is already locked for" - " writing by calling thread\n", - p->a1); + if (DRD_(rwlock_is_wrlocked_by)(p, DRD_(thread_get_running_tid)())) { + RwlockErrInfo REI = { DRD_(thread_get_running_tid)(), p->a1 }; + VG_(maybe_record_error)(VG_(get_running_tid)(), + RwlockErr, + VG_(get_IP)(VG_(get_running_tid)()), + "Already locked for writing by calling thread", + &REI); } } diff --git a/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-amd64 b/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-amd64 index 26e3b9a5ca..d305391471 100644 --- a/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-amd64 +++ b/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-amd64 @@ -49,7 +49,14 @@ mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:53) -The impossible happened: mutex 0x........ is locked simultaneously by two threads (recursion count 1, owners 2 and 1) ! +Thread 1: +The impossible happened: mutex is locked simultaneously by two threads: mutex 0x........, recursion count 1, owner 2. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:78) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:53) + Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) @@ -66,4 +73,4 @@ Process terminating with default action of signal 6 (SIGABRT) by 0x........: __assert_rtn (in /...libc...) by 0x........: main (tc23_bogus_condwait.c:86) -ERROR SUMMARY: 9 errors from 7 contexts (suppressed: 0 from 0) +ERROR SUMMARY: 10 errors from 8 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-x86 b/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-x86 index 7832a6f6d1..577e1467ee 100644 --- a/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-x86 +++ b/drd/tests/tc23_bogus_condwait.stderr.exp-darwin-x86 @@ -49,7 +49,14 @@ mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:53) -The impossible happened: mutex 0x........ is locked simultaneously by two threads (recursion count 1, owners 2 and 1) ! +Thread 1: +The impossible happened: mutex is locked simultaneously by two threads: mutex 0x........, recursion count 1, owner 2. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:78) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:53) + Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) @@ -60,4 +67,4 @@ mutex 0x........ was first observed at: by 0x........: main (tc23_bogus_condwait.c:53) -ERROR SUMMARY: 9 errors from 7 contexts (suppressed: 0 from 0) +ERROR SUMMARY: 10 errors from 8 contexts (suppressed: 0 from 0) diff --git a/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 b/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 index 5e16bd2e46..141115122b 100644 --- a/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 +++ b/drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86 @@ -72,7 +72,14 @@ mutex 0x........ was first observed at: at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) by 0x........: main (tc23_bogus_condwait.c:53) -The impossible happened: mutex 0x........ is locked simultaneously by two threads (recursion count 1, owners 2 and 1) ! +Thread 1: +The impossible happened: mutex is locked simultaneously by two threads: mutex 0x........, recursion count 1, owner 2. + at 0x........: pthread_cond_wait (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:78) +mutex 0x........ was first observed at: + at 0x........: pthread_mutex_init (drd_pthread_intercepts.c:?) + by 0x........: main (tc23_bogus_condwait.c:53) + Thread 2: Mutex not locked by calling thread: mutex 0x........, recursion count 2, owner 1. at 0x........: pthread_mutex_unlock (drd_pthread_intercepts.c:?) @@ -83,4 +90,4 @@ mutex 0x........ was first observed at: by 0x........: main (tc23_bogus_condwait.c:53) -ERROR SUMMARY: 11 errors from 9 contexts (suppressed: 0 from 0) +ERROR SUMMARY: 12 errors from 10 contexts (suppressed: 0 from 0)