Use static thread safety analysis when available, and fix the bugs GCC finds.

It's impossible to express the Heap locking and the ThreadList locking with
GCC, but Clang is supposed to be able to do it. This patch does what's possible
for now.

Change-Id: Ib64a890c9d27c6ce255d5003cb755c2ef1beba95
diff --git a/src/thread_list.h b/src/thread_list.h
index dc6e820..36cd094 100644
--- a/src/thread_list.h
+++ b/src/thread_list.h
@@ -47,7 +47,7 @@
   void Suspend(Thread* thread, bool for_debugger = false);
   void UndoDebuggerSuspensions();
 
-  // Iterates over all the threads. The caller must hold the thread list lock.
+  // Iterates over all the threads.
   void ForEach(void (*callback)(Thread*, void*), void* context);
 
   void Register();
@@ -77,10 +77,10 @@
   static void ModifySuspendCount(Thread* thread, int delta, bool for_debugger);
 
   mutable Mutex allocated_ids_lock_;
-  std::bitset<kMaxThreadId> allocated_ids_;
+  std::bitset<kMaxThreadId> allocated_ids_ GUARDED_BY(allocated_ids_lock_);
 
   mutable Mutex thread_list_lock_;
-  std::list<Thread*> list_;
+  std::list<Thread*> list_; // TODO: GUARDED_BY(thread_list_lock_);
 
   ConditionVariable thread_start_cond_;
   ConditionVariable thread_exit_cond_;
@@ -88,7 +88,7 @@
   // This lock guards every thread's suspend_count_ field...
   mutable Mutex thread_suspend_count_lock_;
   // ...and is used in conjunction with this condition variable.
-  ConditionVariable thread_suspend_count_cond_;
+  ConditionVariable thread_suspend_count_cond_ GUARDED_BY(thread_suspend_count_lock_);
 
   friend class Thread;
   friend class ScopedThreadListLock;