Added more semaphore tracing info.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8825 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/drd/drd_semaphore.c b/drd/drd_semaphore.c
index d3d0d17..1125c1b 100644
--- a/drd/drd_semaphore.c
+++ b/drd/drd_semaphore.c
@@ -117,10 +117,11 @@
   if (s_trace_semaphore)
   {
     VG_(message)(Vg_UserMsg,
-                 "[%d/%d] semaphore_init      0x%lx",
+                 "[%d/%d] semaphore_init      0x%lx value %d",
                  VG_(get_running_tid)(),
                  thread_get_running_tid(),
-                 semaphore);
+                 semaphore,
+                 value);
   }
   p = semaphore_get(semaphore);
   if (p)
@@ -147,17 +148,18 @@
 {
   struct semaphore_info* p;
 
+  p = semaphore_get(semaphore);
+
   if (s_trace_semaphore)
   {
     VG_(message)(Vg_UserMsg,
-                 "[%d/%d] semaphore_destroy   0x%lx",
+                 "[%d/%d] semaphore_destroy   0x%lx value %d",
                  VG_(get_running_tid)(),
                  thread_get_running_tid(),
-                 semaphore);
+                 semaphore,
+                 p ? p->value : 0);
   }
 
-  p = semaphore_get(semaphore);
-
   if (p == 0)
   {
     GenericErrInfo GEI;
@@ -181,10 +183,11 @@
   if (s_trace_semaphore)
   {
     VG_(message)(Vg_UserMsg,
-                 "[%d/%d] semaphore_pre_wait  0x%lx",
+                 "[%d/%d] semaphore_pre_wait  0x%lx value %d",
                  VG_(get_running_tid)(),
                  thread_get_running_tid(),
-                 semaphore);
+                 semaphore,
+                 p->value);
   }
   tl_assert(p);
   tl_assert((int)p->waiters >= 0);
@@ -205,10 +208,11 @@
   if (s_trace_semaphore)
   {
     VG_(message)(Vg_UserMsg,
-                 "[%d/%d] semaphore_post_wait 0x%lx",
+                 "[%d/%d] semaphore_post_wait 0x%lx value %d",
                  VG_(get_running_tid)(),
                  thread_get_running_tid(),
-                 semaphore);
+                 semaphore,
+                 p ? p->value - 1 : 0);
   }
   tl_assert(p->waiters > 0);
   p->waiters--;
@@ -241,16 +245,19 @@
 {
   struct semaphore_info* p;
 
+  p = semaphore_get_or_allocate(semaphore);
+  p->value++;
+
   if (s_trace_semaphore)
   {
     VG_(message)(Vg_UserMsg,
-                 "[%d/%d] semaphore_post      0x%lx",
+                 "[%d/%d] semaphore_post      0x%lx value %d",
                  VG_(get_running_tid)(),
                  thread_get_running_tid(),
-                 semaphore);
+                 semaphore,
+                 p->value);
   }
-  p = semaphore_get_or_allocate(semaphore);
-  p->value++;
+
   if (p->value == 1)
   {
     p->last_sem_post_tid = tid;
diff --git a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3 b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3
index 8715188..e33af90 100644
--- a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3
+++ b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3
@@ -128,8 +128,8 @@
 
 ---------------- sem_* ----------------
 
-[1/1] semaphore_init      0x........
-[1/1] semaphore_init      0x........
+[1/1] semaphore_init      0x........ value -1
+[1/1] semaphore_init      0x........ value 0
 
 Semaphore reinitialization: semaphore 0x........
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
@@ -140,8 +140,8 @@
 
 FIXME: can't figure out how to verify wrap of sem_destroy
 
-[1/1] semaphore_pre_wait  0x........
-[1/1] semaphore_post_wait 0x........
+[1/1] semaphore_pre_wait  0x........ value 0
+[1/1] semaphore_post_wait 0x........ value -1
 
 Invalid semaphore: semaphore 0x........
    at 0x........: sem_wait* (drd_pthread_intercepts.c:?)
@@ -149,11 +149,11 @@
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........
+[1/1] semaphore_post      0x........ value 1
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........
+[1/1] semaphore_destroy   0x........ value 1
 
 ------------ dealloc of mem holding locks ------------
 
diff --git a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3-b b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3-b
index b6de7a1..b50c673 100644
--- a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3-b
+++ b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.3-b
@@ -128,8 +128,8 @@
 
 ---------------- sem_* ----------------
 
-[1/1] semaphore_init      0x........
-[1/1] semaphore_init      0x........
+[1/1] semaphore_init      0x........ value -1
+[1/1] semaphore_init      0x........ value 0
 
 Semaphore reinitialization: semaphore 0x........
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
@@ -140,8 +140,8 @@
 
 FIXME: can't figure out how to verify wrap of sem_destroy
 
-[1/1] semaphore_pre_wait  0x........
-[1/1] semaphore_post_wait 0x........
+[1/1] semaphore_pre_wait  0x........ value 0
+[1/1] semaphore_post_wait 0x........ value -1
 
 Invalid semaphore: semaphore 0x........
    at 0x........: sem_wait* (drd_pthread_intercepts.c:?)
@@ -149,11 +149,11 @@
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........
+[1/1] semaphore_post      0x........ value 1
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........
+[1/1] semaphore_destroy   0x........ value 1
 
 ------------ dealloc of mem holding locks ------------
 
diff --git a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5 b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5
index 38088e7..5584e53 100644
--- a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5
+++ b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5
@@ -134,8 +134,8 @@
 
 ---------------- sem_* ----------------
 
-[1/1] semaphore_init      0x........
-[1/1] semaphore_init      0x........
+[1/1] semaphore_init      0x........ value -1
+[1/1] semaphore_init      0x........ value 0
 
 Semaphore reinitialization: semaphore 0x........
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
@@ -146,8 +146,8 @@
 
 FIXME: can't figure out how to verify wrap of sem_destroy
 
-[1/1] semaphore_pre_wait  0x........
-[1/1] semaphore_post_wait 0x........
+[1/1] semaphore_pre_wait  0x........ value 0
+[1/1] semaphore_post_wait 0x........ value -1
 
 Invalid semaphore: semaphore 0x........
    at 0x........: sem_wait* (drd_pthread_intercepts.c:?)
@@ -155,11 +155,11 @@
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........
+[1/1] semaphore_post      0x........ value 1
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........
+[1/1] semaphore_destroy   0x........ value 1
 
 ------------ dealloc of mem holding locks ------------
 
diff --git a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5-ppc b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5-ppc
index 557fdf5..f79d69a 100644
--- a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5-ppc
+++ b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.5-ppc
@@ -134,8 +134,8 @@
 
 ---------------- sem_* ----------------
 
-[1/1] semaphore_init      0x........
-[1/1] semaphore_init      0x........
+[1/1] semaphore_init      0x........ value -1
+[1/1] semaphore_init      0x........ value 0
 
 Semaphore reinitialization: semaphore 0x........
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
@@ -146,8 +146,8 @@
 
 FIXME: can't figure out how to verify wrap of sem_destroy
 
-[1/1] semaphore_pre_wait  0x........
-[1/1] semaphore_post_wait 0x........
+[1/1] semaphore_pre_wait  0x........ value 0
+[1/1] semaphore_post_wait 0x........ value -1
 
 Invalid semaphore: semaphore 0x........
    at 0x........: sem_wait* (drd_pthread_intercepts.c:?)
@@ -155,11 +155,11 @@
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........
+[1/1] semaphore_post      0x........ value 1
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........
+[1/1] semaphore_destroy   0x........ value 1
 
 ------------ dealloc of mem holding locks ------------
 
diff --git a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.8 b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.8
index 61740ed..e551bad 100644
--- a/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.8
+++ b/drd/tests/tc20_verifywrap2.stderr.exp-glibc2.8
@@ -134,13 +134,13 @@
 
 ---------------- sem_* ----------------
 
-[1/1] semaphore_init      0x........
-[1/1] semaphore_init      0x........
+[1/1] semaphore_init      0x........ value -1
+[1/1] semaphore_init      0x........ value 0
 
 FIXME: can't figure out how to verify wrap of sem_destroy
 
-[1/1] semaphore_pre_wait  0x........
-[1/1] semaphore_post_wait 0x........
+[1/1] semaphore_pre_wait  0x........ value 0
+[1/1] semaphore_post_wait 0x........ value -1
 
 Invalid semaphore: semaphore 0x........
    at 0x........: sem_wait* (drd_pthread_intercepts.c:?)
@@ -148,11 +148,11 @@
 semaphore 0x........ was first observed at:
    at 0x........: sem_init* (drd_pthread_intercepts.c:?)
    by 0x........: main (tc20_verifywrap.c:228)
-[1/1] semaphore_post      0x........
+[1/1] semaphore_post      0x........ value 1
 
 FIXME: can't figure out how to verify wrap of sem_post
 
-[1/1] semaphore_destroy   0x........
+[1/1] semaphore_destroy   0x........ value 1
 
 ------------ dealloc of mem holding locks ------------