Turn on some basic tsan annotations.

The most useful bit here is that tsan now knows the names of our threads.

Change-Id: I8eef8f31e954ffc373555b392d6d9678d76ead34
diff --git a/src/thread.cc b/src/thread.cc
index a484f92..6be7f7d 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -290,6 +290,10 @@
   // a native peer!
   if (self->thin_lock_id_ != ThreadList::kMainId && !Runtime::Current()->IsCompiler()) {
     self->CreatePeer(name, as_daemon);
+  } else {
+    // These aren't necessary, but they improve diagnostics for unit tests & command-line tools.
+    self->name_->assign(name);
+    ::art::SetThreadName(name);
   }
 
   self->GetJniEnv()->locals.AssertEmpty();
@@ -643,7 +647,10 @@
      * on SMP and slightly more correct, but less convenient.
      */
     android_atomic_acquire_store(new_state, addr);
-    if (ANNOTATE_UNPROTECTED_READ(suspend_count_) != 0) {
+    ANNOTATE_IGNORE_READS_BEGIN();
+    int suspend_count = suspend_count_;
+    ANNOTATE_IGNORE_READS_END();
+    if (suspend_count != 0) {
       Runtime::Current()->GetThreadList()->FullSuspendCheck(this);
     }
   } else {
@@ -661,7 +668,10 @@
 }
 
 bool Thread::IsSuspended() {
-  return ANNOTATE_UNPROTECTED_READ(suspend_count_) != 0 && GetState() != Thread::kRunnable;
+  ANNOTATE_IGNORE_READS_BEGIN();
+  int suspend_count = suspend_count_;
+  ANNOTATE_IGNORE_READS_END();
+  return suspend_count != 0 && GetState() != Thread::kRunnable;
 }
 
 static void ReportThreadSuspendTimeout(Thread* waiting_thread) {
diff --git a/src/utils.cc b/src/utils.cc
index cb76636..78f524f 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -16,6 +16,7 @@
 
 #include "utils.h"
 
+#include <dynamic_annotations.h>
 #include <pthread.h>
 #include <sys/stat.h>
 #include <sys/syscall.h>
@@ -651,6 +652,8 @@
 }
 
 void SetThreadName(const char* threadName) {
+  ANNOTATE_THREAD_NAME(threadName); // For tsan.
+
   int hasAt = 0;
   int hasDot = 0;
   const char* s = threadName;