Added more detailed statistics about thread_new_segment() calls.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7891 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/exp-drd/drd_barrier.c b/exp-drd/drd_barrier.c
index c1273cf..96e2b74 100644
--- a/exp-drd/drd_barrier.c
+++ b/exp-drd/drd_barrier.c
@@ -60,6 +60,7 @@
// Local variables.
static Bool s_trace_barrier = False;
+static ULong s_barrier_segment_creation_count;
// Function definitions.
@@ -343,6 +344,7 @@
}
thread_new_segment(tid);
+ s_barrier_segment_creation_count++;
if (--p->post_waiters_left <= 0)
{
@@ -386,3 +388,8 @@
}
return "?";
}
+
+ULong get_barrier_segment_creation_count(void)
+{
+ return s_barrier_segment_creation_count;
+}
diff --git a/exp-drd/drd_barrier.h b/exp-drd/drd_barrier.h
index 54deb49..f525f15 100644
--- a/exp-drd/drd_barrier.h
+++ b/exp-drd/drd_barrier.h
@@ -50,6 +50,7 @@
const BarrierT barrier_type, const Bool waited);
void barrier_thread_delete(const DrdThreadId threadid);
void barrier_stop_using_mem(const Addr a1, const Addr a2);
+ULong get_barrier_segment_creation_count(void);
#endif /* __DRD_BARRIER_H */
diff --git a/exp-drd/drd_main.c b/exp-drd/drd_main.c
index d501cb8..3b9563a 100644
--- a/exp-drd/drd_main.c
+++ b/exp-drd/drd_main.c
@@ -50,7 +50,6 @@
#include "pub_tool_mallocfree.h" // VG_(malloc)(), VG_(free)()
#include "pub_tool_options.h" // command line options
#include "pub_tool_replacemalloc.h"
-#include "pub_tool_replacemalloc.h"
#include "pub_tool_threadstate.h" // VG_(get_running_tid)()
#include "pub_tool_tooliface.h"
@@ -1079,6 +1078,12 @@
sg_get_max_alive_segments_count(),
thread_get_discard_ordered_segments_count());
VG_(message)(Vg_UserMsg,
+ " (%lld m, %lld rw, %lld s, %lld b)",
+ get_mutex_segment_creation_count(),
+ get_rwlock_segment_creation_count(),
+ get_semaphore_segment_creation_count(),
+ get_barrier_segment_creation_count());
+ VG_(message)(Vg_UserMsg,
" bitmaps: %lld level 1 / %lld level 2 bitmap refs",
bm_get_bitmap_creation_count(),
bm_get_bitmap2_node_creation_count());
diff --git a/exp-drd/drd_mutex.c b/exp-drd/drd_mutex.c
index c28487d..dca84a7 100644
--- a/exp-drd/drd_mutex.c
+++ b/exp-drd/drd_mutex.c
@@ -45,6 +45,7 @@
static Bool s_trace_mutex;
static ULong s_mutex_lock_count;
+static ULong s_mutex_segment_creation_count;
// Function definitions.
@@ -284,6 +285,7 @@
thread_combine_vc2(drd_tid, &p->last_locked_segment->vc);
}
thread_new_segment(drd_tid);
+ s_mutex_segment_creation_count++;
p->owner = drd_tid;
s_mutex_lock_count++;
@@ -374,6 +376,7 @@
thread_get_latest_segment(&p->last_locked_segment, drd_tid);
thread_new_segment(drd_tid);
+ s_mutex_segment_creation_count++;
}
}
@@ -457,3 +460,8 @@
{
return s_mutex_lock_count;
}
+
+ULong get_mutex_segment_creation_count(void)
+{
+ return s_mutex_segment_creation_count;
+}
diff --git a/exp-drd/drd_mutex.h b/exp-drd/drd_mutex.h
index 52880ff..77f24e9 100644
--- a/exp-drd/drd_mutex.h
+++ b/exp-drd/drd_mutex.h
@@ -55,6 +55,7 @@
int mutex_get_recursion_count(const Addr mutex);
void mutex_thread_delete(const DrdThreadId tid);
ULong get_mutex_lock_count(void);
+ULong get_mutex_segment_creation_count(void);
#endif /* __DRD_MUTEX_H */
diff --git a/exp-drd/drd_rwlock.c b/exp-drd/drd_rwlock.c
index 7e23173..dd1d0c6 100644
--- a/exp-drd/drd_rwlock.c
+++ b/exp-drd/drd_rwlock.c
@@ -50,6 +50,7 @@
// Local functions.
static void rwlock_cleanup(struct rwlock_info* p);
+static ULong s_rwlock_segment_creation_count;
// Local variables.
@@ -350,6 +351,7 @@
{
rwlock_combine_other_vc(p, drd_tid, False);
thread_new_segment(drd_tid);
+ s_rwlock_segment_creation_count++;
}
}
@@ -423,6 +425,7 @@
tl_assert(q->writer_nesting_count == 1);
rwlock_combine_other_vc(p, drd_tid, True);
thread_new_segment(drd_tid);
+ s_rwlock_segment_creation_count++;
}
/**
@@ -479,6 +482,7 @@
thread_get_latest_segment(&q->last_unlock_segment, drd_tid);
q->last_lock_was_writer_lock = False;
thread_new_segment(drd_tid);
+ s_rwlock_segment_creation_count++;
}
}
@@ -508,3 +512,8 @@
}
}
}
+
+ULong get_rwlock_segment_creation_count(void)
+{
+ return s_rwlock_segment_creation_count;
+}
diff --git a/exp-drd/drd_rwlock.h b/exp-drd/drd_rwlock.h
index 6abc203..77e3abf 100644
--- a/exp-drd/drd_rwlock.h
+++ b/exp-drd/drd_rwlock.h
@@ -48,6 +48,7 @@
void rwlock_post_wrlock(const Addr rwlock, const Bool took_lock);
void rwlock_pre_unlock(const Addr rwlock);
void rwlock_thread_delete(const DrdThreadId tid);
+ULong get_rwlock_segment_creation_count(void);
#endif /* __DRD_RWLOCK_H */
diff --git a/exp-drd/drd_semaphore.c b/exp-drd/drd_semaphore.c
index dc5c9f5..38d3b9a 100644
--- a/exp-drd/drd_semaphore.c
+++ b/exp-drd/drd_semaphore.c
@@ -43,6 +43,7 @@
// Local variables.
static Bool s_trace_semaphore;
+static ULong s_semaphore_segment_creation_count;
// Function definitions.
@@ -222,6 +223,7 @@
thread_combine_vc2(tid, &p->last_sem_post_segment->vc);
}
thread_new_segment(tid);
+ s_semaphore_segment_creation_count++;
}
/** Called before sem_post(). */
@@ -244,6 +246,7 @@
p->last_sem_post_tid = tid;
thread_new_segment(tid);
thread_get_latest_segment(&p->last_sem_post_segment, tid);
+ s_semaphore_segment_creation_count++;
}
}
@@ -264,3 +267,8 @@
void semaphore_thread_delete(const DrdThreadId threadid)
{ }
+
+ULong get_semaphore_segment_creation_count(void)
+{
+ return s_semaphore_segment_creation_count;
+}
diff --git a/exp-drd/drd_semaphore.h b/exp-drd/drd_semaphore.h
index c55dc9d..2b5107f 100644
--- a/exp-drd/drd_semaphore.h
+++ b/exp-drd/drd_semaphore.h
@@ -49,6 +49,7 @@
void semaphore_post_post(const DrdThreadId tid, const Addr semaphore,
const Bool waited);
void semaphore_thread_delete(const DrdThreadId tid);
+ULong get_semaphore_segment_creation_count(void);
#endif /* __DRD_SEMAPHORE_H */