[compiler-rt] r192711 - tsan: be silent if verbosity=0

Dmitry Vyukov dvyukov at google.com
Tue Oct 15 08:35:56 PDT 2013


Author: dvyukov
Date: Tue Oct 15 10:35:56 2013
New Revision: 192711

URL: http://llvm.org/viewvc/llvm-project?rev=192711&view=rev
Log:
tsan: be silent if verbosity=0

Currently tests fail with:
Check failed: 'AAA' == 'AAA ==26017==Could not detach from thread 361395 (errno 3).'


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=192711&r1=192710&r2=192711&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Tue Oct 15 10:35:56 2013
@@ -18,7 +18,6 @@
 namespace __sanitizer {
 
 const char *SanitizerToolName = "SanitizerTool";
-uptr SanitizerVerbosity = 0;
 
 uptr GetPageSizeCached() {
   static uptr PageSize;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=192711&r1=192710&r2=192711&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Tue Oct 15 10:35:56 2013
@@ -36,7 +36,6 @@ const uptr kCacheLineSize = 64;
 const uptr kMaxPathLength = 512;
 
 extern const char *SanitizerToolName;  // Can be changed by the tool.
-extern uptr SanitizerVerbosity;
 
 uptr GetPageSize();
 uptr GetPageSizeCached();

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=192711&r1=192710&r2=192711&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc Tue Oct 15 10:35:56 2013
@@ -42,6 +42,7 @@
 #endif
 
 #include "sanitizer_common.h"
+#include "sanitizer_flags.h"
 #include "sanitizer_libc.h"
 #include "sanitizer_linux.h"
 #include "sanitizer_mutex.h"
@@ -99,10 +100,11 @@ bool ThreadSuspender::SuspendThread(Susp
                        &pterrno)) {
     // Either the thread is dead, or something prevented us from attaching.
     // Log this event and move on.
-    Report("Could not attach to thread %d (errno %d).\n", thread_id, pterrno);
+    if (common_flags()->verbosity)
+      Report("Could not attach to thread %d (errno %d).\n", thread_id, pterrno);
     return false;
   } else {
-    if (SanitizerVerbosity > 0)
+    if (common_flags()->verbosity)
       Report("Attached to thread %d.\n", thread_id);
     // The thread is not guaranteed to stop before ptrace returns, so we must
     // wait on it.
@@ -112,8 +114,9 @@ bool ThreadSuspender::SuspendThread(Susp
     if (internal_iserror(waitpid_status, &wperrno)) {
       // Got a ECHILD error. I don't think this situation is possible, but it
       // doesn't hurt to report it.
-      Report("Waiting on thread %d failed, detaching (errno %d).\n", thread_id,
-             wperrno);
+      if (common_flags()->verbosity)
+        Report("Waiting on thread %d failed, detaching (errno %d).\n",
+            thread_id, wperrno);
       internal_ptrace(PTRACE_DETACH, thread_id, NULL, NULL);
       return false;
     }
@@ -128,13 +131,14 @@ void ThreadSuspender::ResumeAllThreads()
     int pterrno;
     if (!internal_iserror(internal_ptrace(PTRACE_DETACH, tid, NULL, NULL),
                           &pterrno)) {
-      if (SanitizerVerbosity > 0)
+      if (common_flags()->verbosity)
         Report("Detached from thread %d.\n", tid);
     } else {
       // Either the thread is dead, or we are already detached.
       // The latter case is possible, for instance, if this function was called
       // from a signal handler.
-      Report("Could not detach from thread %d (errno %d).\n", tid, pterrno);
+      if (common_flags()->verbosity)
+        Report("Could not detach from thread %d (errno %d).\n", tid, pterrno);
     }
   }
 }
@@ -256,7 +260,8 @@ static int TracerThread(void* argument)
 
   int exit_code = 0;
   if (!thread_suspender.SuspendAllThreads()) {
-    Report("Failed suspending threads.\n");
+    if (common_flags()->verbosity)
+      Report("Failed suspending threads.\n");
     exit_code = 3;
   } else {
     tracer_thread_argument->callback(thread_suspender.suspended_threads_list(),
@@ -370,7 +375,8 @@ void StopTheWorld(StopTheWorldCallback c
       /* child_tidptr */);
   int local_errno = 0;
   if (internal_iserror(tracer_pid, &local_errno)) {
-    Report("Failed spawning a tracer thread (errno %d).\n", local_errno);
+    if (common_flags()->verbosity)
+      Report("Failed spawning a tracer thread (errno %d).\n", local_errno);
     tracer_thread_argument.mutex.Unlock();
   } else {
     // On some systems we have to explicitly declare that we want to be traced
@@ -385,8 +391,11 @@ void StopTheWorld(StopTheWorldCallback c
     // At this point, any signal will either be blocked or kill us, so waitpid
     // should never return (and set errno) while the tracer thread is alive.
     uptr waitpid_status = internal_waitpid(tracer_pid, NULL, __WALL);
-    if (internal_iserror(waitpid_status, &local_errno))
-      Report("Waiting on the tracer thread failed (errno %d).\n", local_errno);
+    if (internal_iserror(waitpid_status, &local_errno)) {
+      if (common_flags()->verbosity)
+        Report("Waiting on the tracer thread failed (errno %d).\n",
+            local_errno);
+    }
   }
 }
 
@@ -427,7 +436,8 @@ int SuspendedThreadsList::GetRegistersAn
   int pterrno;
   if (internal_iserror(internal_ptrace(PTRACE_GETREGS, tid, NULL, &regs),
                        &pterrno)) {
-    Report("Could not get registers from thread %d (errno %d).\n",
+    if (common_flags()->verbosity)
+      Report("Could not get registers from thread %d (errno %d).\n",
            tid, pterrno);
     return -1;
   }





More information about the llvm-commits mailing list