]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd: Convert a few VG_(message)() calls into VG_(maybe_record_error)() calls
authorBart Van Assche <bvanassche@acm.org>
Sat, 8 Oct 2011 08:54:57 +0000 (08:54 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 8 Oct 2011 08:54:57 +0000 (08:54 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12121

drd/drd_barrier.c
drd/drd_load_store.c
drd/drd_mutex.c
drd/drd_rwlock.c
drd/tests/tc23_bogus_condwait.stderr.exp-darwin-amd64
drd/tests/tc23_bogus_condwait.stderr.exp-darwin-x86
drd/tests/tc23_bogus_condwait.stderr.exp-linux-x86

index 26947cd5ffecd351aae3f1a5442964be804463b1..b45977aa78d1700379414c49bafa0b95ad4b9f97 100644 (file)
@@ -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);
 
index 0cdcbcd6bccbe8b0b62361c3dc108a4274079594..5b7904d91c810ab80ed99071a0fffc5bd573da39 100644 (file)
@@ -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)
index 6ddc1f917296fa9202b759ca0ac15ed3c94575d9..289ebe54eab80266bec47947c50b28eebb135e17 100644 (file)
 #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);
index 74dc410d343311c7b42543f999c7e4e2b5ed6c26..448add2639434f47b097c786fff3e5d6722d20cc 100644 (file)
@@ -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);
    }
 }
 
index 26e3b9a5ca17b730522c59adbb7f97caec41de3a..d3053914716f9f1e1c7f98089aa7834a82b852b8 100644 (file)
@@ -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)
index 7832a6f6d137d77409431995a01e825af94ffa71..577e1467ee615b8f5d6d57ab3c4c887e337bad03 100644 (file)
@@ -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)
index 5e16bd2e460f82558ec9f0b41683130e802a77f2..141115122bd34d84da915cf4849c4b0a4fa275ee 100644 (file)
@@ -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)