Fix a thread suspend timeout, and improve the diagnostics for thread suspend timeouts.

I still needed gdb to understand this, but when we dump _native_ stacks, the
additional diagnostics here will be more helpful. (They're somewhat helpful
anyway, in that they let you see the state all threads are in. Also, in a
started runtime rather than the compiler, threads will have informative managed
stacks.)

Also make the apparent duplication in the dex2oat timings clearer, and only
include time spent on resolving strings if we resolved any strings.

Change-Id: Icd469d9b085171ebb2dede2afb5140387cd3240c
diff --git a/src/thread.cc b/src/thread.cc
index 54b17d0..6c8e1bb 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -659,6 +659,16 @@
   return ANNOTATE_UNPROTECTED_READ(suspend_count_) != 0 && GetState() != Thread::kRunnable;
 }
 
+static void ReportThreadSuspendTimeout(Thread* waiting_thread) {
+  Runtime* runtime = Runtime::Current();
+  std::ostringstream ss;
+  ss << "Thread suspend timeout; waiting thread=" << *waiting_thread << "\n";
+  runtime->DumpLockHolders(ss);
+  ss << "\n";
+  runtime->GetThreadList()->DumpLocked(ss);
+  LOG(FATAL) << ss.str();
+}
+
 void Thread::WaitUntilSuspended() {
   static const useconds_t kTimeoutUs = 30 * 1000000; // 30s.
 
@@ -666,7 +676,7 @@
   useconds_t delay = 0;
   while (GetState() == Thread::kRunnable) {
     if (total_delay >= kTimeoutUs) {
-      Runtime::Current()->DumpLockHolders(LOG(FATAL) << "Thread suspend timeout: " << *this << "\n");
+      ReportThreadSuspendTimeout(this);
     }
     useconds_t new_delay = delay * 2;
     CHECK_GE(new_delay, delay);