Author: bart
Date: 2008-02-28 19:49:37 +0000 (Thu, 28 Feb 2008)
New Revision: 7501

Log:
Converted triple "Destroying locked mutex" messages into single messages.

Added:
   trunk/exp-drd/tests/tc04_free_lock.stderr.exp2
Modified:
   trunk/exp-drd/drd_mutex.c
   trunk/exp-drd/drd_mutex.h
   trunk/exp-drd/tests/tc20_verifywrap.stderr.exp2


Modified: trunk/exp-drd/drd_mutex.c
===================================================================
--- trunk/exp-drd/drd_mutex.c   2008-02-28 19:08:04 UTC (rev 7500)
+++ trunk/exp-drd/drd_mutex.c   2008-02-28 19:49:37 UTC (rev 7501)
@@ -36,6 +36,7 @@
 
 // Local functions.
 
+static void mutex_cleanup(struct mutex_info* p);
 static Bool mutex_is_locked(struct mutex_info* const p);
 static void mutex_destroy(struct mutex_info* const p);
 
@@ -65,13 +66,29 @@
 
   tl_assert(p->a1 == mutex);
   tl_assert(p->a2 == mutex + size);
-  p->cleanup         = (void(*)(DrdClientobj*))&mutex_destroy;
+  p->cleanup         = (void(*)(DrdClientobj*))&mutex_cleanup;
   p->mutex_type      = mutex_type;
   p->recursion_count = 0;
   p->owner           = DRD_INVALID_THREADID;
   vc_init(&p->vc, 0, 0);
 }
 
+/** Deallocate the memory that was allocated by mutex_initialize(). */
+static void mutex_cleanup(struct mutex_info* p)
+{
+  if (mutex_is_locked(p))
+  {
+    MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner };
+    VG_(maybe_record_error)(VG_(get_running_tid)(),
+                            MutexErr,
+                            VG_(get_IP)(VG_(get_running_tid)()),
+                            "Destroying locked mutex",
+                            &MEI);
+  }
+
+  vc_cleanup(&p->vc);
+}
+
 static
 struct mutex_info*
 mutex_get_or_allocate(const Addr mutex,
@@ -152,24 +169,10 @@
                  p->a1);
   }
 
-  if (mutex_is_locked(p))
-  {
-    MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner };
-    VG_(maybe_record_error)(VG_(get_running_tid)(),
-                            MutexErr,
-                            VG_(get_IP)(VG_(get_running_tid)()),
-                            "Destroying locked mutex",
-                            &MEI);
-  }
-
   drd_clientobj_remove(p->a1);
 }
 
-void mutex_pre_destroy(struct mutex_info* const p)
-{
-   return mutex_destroy(p);
-}
-
+/** Called after pthread_mutex_destroy(). */
 void mutex_post_destroy(const Addr mutex)
 {
    struct mutex_info* p;
@@ -178,17 +181,7 @@
    tl_assert(p);
    if (p)
    {
-      if (mutex_get_recursion_count(mutex) > 0)
-      {
-        const ThreadId vg_tid = VG_(get_running_tid)();
-         MutexErrInfo MEI = { p->a1, p->recursion_count, p->owner };
-         VG_(maybe_record_error)(vg_tid,
-                                 MutexErr,
-                                 VG_(get_IP)(vg_tid),
-                                 "Destroying locked mutex",
-                                 &MEI);
-      }
-      mutex_pre_destroy(p);
+      mutex_destroy(p);
    }
 }
 

Modified: trunk/exp-drd/drd_mutex.h
===================================================================
--- trunk/exp-drd/drd_mutex.h   2008-02-28 19:08:04 UTC (rev 7500)
+++ trunk/exp-drd/drd_mutex.h   2008-02-28 19:49:37 UTC (rev 7501)
@@ -42,7 +42,6 @@
 void mutex_set_trace(const Bool trace_mutex);
 struct mutex_info* mutex_init(const Addr mutex, const SizeT size,
                               const MutexT mutex_type);
-void mutex_pre_destroy(struct mutex_info* const p);
 void mutex_post_destroy(const Addr mutex);
 struct mutex_info* mutex_get(const Addr mutex);
 void mutex_pre_lock(const Addr mutex, const SizeT size, const MutexT 
mutex_type);

Added: trunk/exp-drd/tests/tc04_free_lock.stderr.exp2
===================================================================
--- trunk/exp-drd/tests/tc04_free_lock.stderr.exp2                              
(rev 0)
+++ trunk/exp-drd/tests/tc04_free_lock.stderr.exp2      2008-02-28 19:49:37 UTC 
(rev 7501)
@@ -0,0 +1,14 @@
+
+Destroying locked mutex: address 0x........, recursion count 1, owner 1.
+   at 0x........: bar (tc04_free_lock.c:40)
+   by 0x........: (below main) (in /...libc...)
+
+Destroying locked mutex: address 0x........, recursion count 1, owner 1.
+   at 0x........: foo (tc04_free_lock.c:49)
+   by 0x........: (below main) (in /...libc...)
+
+Destroying locked mutex: address 0x........, recursion count 1, owner 1.
+   at 0x........: bar (tc04_free_lock.c:40)
+   by 0x........: (below main) (in /...libc...)
+
+ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)

Modified: trunk/exp-drd/tests/tc20_verifywrap.stderr.exp2
===================================================================
--- trunk/exp-drd/tests/tc20_verifywrap.stderr.exp2     2008-02-28 19:08:04 UTC 
(rev 7500)
+++ trunk/exp-drd/tests/tc20_verifywrap.stderr.exp2     2008-02-28 19:49:37 UTC 
(rev 7501)
@@ -20,14 +20,6 @@
    at 0x........: pthread_mutex_destroy (drd_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:102)
 
-Destroying locked mutex: address 0x........, recursion count 1, owner 1.
-   at 0x........: pthread_mutex_destroy (drd_intercepts.c:?)
-   by 0x........: main (tc20_verifywrap.c:102)
-
-Destroying locked mutex: address 0x........, recursion count 1, owner 1.
-   at 0x........: pthread_mutex_destroy (drd_intercepts.c:?)
-   by 0x........: main (tc20_verifywrap.c:102)
-
 Invalid mutex
    at 0x........: pthread_mutex_unlock (drd_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:125)
@@ -75,4 +67,4 @@
 Destroying locked mutex: address 0x........, recursion count 1, owner 1.
    at 0x........: main (tc20_verifywrap.c:262)
 
-ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)
+ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to