]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Converted triple "Destroying locked mutex" messages into single messages.
authorBart Van Assche <bvanassche@acm.org>
Thu, 28 Feb 2008 19:49:37 +0000 (19:49 +0000)
committerBart Van Assche <bvanassche@acm.org>
Thu, 28 Feb 2008 19:49:37 +0000 (19:49 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7501

exp-drd/drd_mutex.c
exp-drd/drd_mutex.h
exp-drd/tests/tc04_free_lock.stderr.exp2 [new file with mode: 0644]
exp-drd/tests/tc20_verifywrap.stderr.exp2

index 547bdfe403096dc8bd99a9b40b0fb6e30a5692f9..16cd92ef36d3b57ab4f7cc8ad67878beed9e5bc8 100644 (file)
@@ -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 @@ void mutex_initialize(struct mutex_info* const p,
 
   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 @@ static void mutex_destroy(struct mutex_info* const p)
                  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 @@ void mutex_post_destroy(const Addr mutex)
    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);
    }
 }
 
index ae6568b2c707eef9c0d04fe42623d206535f72e5..5c5c7a050773c5e034ca3ff43b600a7eacfddd52 100644 (file)
@@ -42,7 +42,6 @@ struct mutex_info;
 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);
diff --git a/exp-drd/tests/tc04_free_lock.stderr.exp2 b/exp-drd/tests/tc04_free_lock.stderr.exp2
new file mode 100644 (file)
index 0000000..768b25e
--- /dev/null
@@ -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)
index 4f9b5201241f691935b7d64453fb26276a5e6aca..b5115ca839caf92432185b87ca2003f4ff57f8d7 100644 (file)
@@ -16,14 +16,6 @@ Other segment end (thread 2)
 ---------------- pthread_mutex_lock et al ----------------
 
 
-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)
-
 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)
@@ -75,4 +67,4 @@ FIXME: can't figure out how to verify wrap of sem_post
 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)