Change --trace-pthread= flag to accept none|some|all, for finer level
of pthread event tracing. And allow this info to be passed across to
the client, where vg_libpthread.c uses it to also control verbosity.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@91 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/vg_scheduler.c b/vg_scheduler.c
index 33cb157..770fbd3 100644
--- a/vg_scheduler.c
+++ b/vg_scheduler.c
@@ -176,7 +176,7 @@
static
void print_sched_event ( ThreadId tid, Char* what )
{
- VG_(message)(Vg_DebugMsg, "SCHED[%d]: %s", tid, what );
+ VG_(message)(Vg_DebugMsg, " SCHED[%d]: %s", tid, what );
}
@@ -555,6 +555,8 @@
SIMPLE_RETURN(tid);
case VG_USERREQ__RUNNING_ON_VALGRIND:
SIMPLE_RETURN(1);
+ case VG_USERREQ__GET_PTHREAD_TRACE_LEVEL:
+ SIMPLE_RETURN(VG_(clo_trace_pthread_level));
default:
/* Too hard; wimp out. */
@@ -1477,7 +1479,7 @@
vg_mutexes[mid].owner = VG_INVALID_THREADID; /* irrelevant */
mutex->__m_reserved = mid;
mutex->__m_count = 1; /* initialised */
- if (VG_(clo_trace_pthread)) {
+ if (VG_(clo_trace_pthread_level) >= 1) {
VG_(sprintf)(msg_buf, "(initialise mutex) (%p) -> %d",
mutex, mid );
print_pthread_event(tid, msg_buf);
@@ -1497,7 +1499,7 @@
initialise_mutex(tid, mutex);
- if (VG_(clo_trace_pthread)) {
+ if (VG_(clo_trace_pthread_level) >= 1) {
VG_(sprintf)(msg_buf, "pthread_mutex_init (%p) -> %d",
mutex, mutex->__m_reserved );
print_pthread_event(tid, msg_buf);
@@ -1541,7 +1543,7 @@
return;
}
- if (VG_(clo_trace_pthread)) {
+ if (VG_(clo_trace_pthread_level) >= 2) {
VG_(sprintf)(msg_buf, "pthread_mutex_lock %d (%p)",
mid, mutex );
print_pthread_event(tid, msg_buf);
@@ -1562,9 +1564,9 @@
vg_threads[tid].status = VgTs_WaitMX;
vg_threads[tid].waited_on_mid = mid;
/* No assignment to %EDX, since we're blocking. */
- if (VG_(clo_trace_pthread)) {
- VG_(sprintf)(msg_buf, "pthread_mutex_lock %d (%p): BLOCK",
- mid, mutex );
+ if (VG_(clo_trace_pthread_level) >= 1) {
+ VG_(sprintf)(msg_buf, "pthread_mutex_lock %d: BLOCK",
+ mid );
print_pthread_event(tid, msg_buf);
}
} else {
@@ -1597,7 +1599,7 @@
return;
}
- if (VG_(clo_trace_pthread)) {
+ if (VG_(clo_trace_pthread_level) >= 2) {
VG_(sprintf)(msg_buf, "pthread_mutex_unlock %d (%p)",
mid, mutex );
print_pthread_event(tid, msg_buf);
@@ -1633,7 +1635,7 @@
vg_threads[i].status = VgTs_Runnable;
vg_threads[i].m_edx = 0; /* pth_lock() success */
- if (VG_(clo_trace_pthread)) {
+ if (VG_(clo_trace_pthread_level) >= 1) {
VG_(sprintf)(msg_buf, "pthread_mutex_lock %d: RESUME",
mid );
print_pthread_event(tid, msg_buf);
@@ -1664,7 +1666,7 @@
return;
}
- if (VG_(clo_trace_pthread)) {
+ if (VG_(clo_trace_pthread_level) >= 1) {
VG_(sprintf)(msg_buf, "pthread_mutex_destroy %d (%p)",
mid, mutex );
print_pthread_event(tid, msg_buf);