Merge "ART: Forward-declare Instrumentation"
diff --git a/build/art.go b/build/art.go
index 01848c8..22f6410 100644
--- a/build/art.go
+++ b/build/art.go
@@ -282,7 +282,7 @@
 
 func init() {
 	android.RegisterModuleType("art_cc_library", artLibrary)
-	android.RegisterModuleType("art_cc_static_library", artStaticLibrary)
+	android.RegisterModuleType("art_cc_library_static", artStaticLibrary)
 	android.RegisterModuleType("art_cc_binary", artBinary)
 	android.RegisterModuleType("art_cc_test", artTest)
 	android.RegisterModuleType("art_cc_test_library", artTestLibrary)
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index f8bdb16..3a2ae75 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -114,7 +114,7 @@
     output_extension: "operator_out.cc",
 }
 
-art_cc_static_library {
+art_cc_library_static {
     name: "libart-dex2oat",
     defaults: ["libart-dex2oat-defaults"],
     shared_libs: [
@@ -139,7 +139,7 @@
     ],
 }
 
-art_cc_static_library {
+art_cc_library_static {
     name: "libartd-dex2oat",
     defaults: [
         "art_debug_defaults",
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 4bbd81a..75462ac 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -766,15 +766,29 @@
 #if ART_USE_FUTEXES
       if (futex(pending_threads.Address(), FUTEX_WAIT_PRIVATE, cur_val, &wait_timeout, nullptr, 0)
           != 0) {
-        // EAGAIN and EINTR both indicate a spurious failure, try again from the beginning.
-        if ((errno != EAGAIN) && (errno != EINTR)) {
-          if (errno == ETIMEDOUT) {
-            LOG(kIsDebugBuild ? ::android::base::FATAL : ::android::base::ERROR)
-                << "Timed out waiting for threads to suspend, waited for "
-                << PrettyDuration(NanoTime() - start_time);
-          } else {
-            PLOG(FATAL) << "futex wait failed for SuspendAllInternal()";
+        if ((errno == EAGAIN) || (errno == EINTR)) {
+          // EAGAIN and EINTR both indicate a spurious failure, try again from the beginning.
+          continue;
+        }
+        if (errno == ETIMEDOUT) {
+          const uint64_t wait_time = NanoTime() - start_time;
+          MutexLock mu(self, *Locks::thread_list_lock_);
+          MutexLock mu2(self, *Locks::thread_suspend_count_lock_);
+          std::ostringstream oss;
+          for (const auto& thread : list_) {
+            if (thread == ignore1 || thread == ignore2) {
+              continue;
+            }
+            if (!thread->IsSuspended()) {
+              oss << std::endl << "Thread not suspended: " << *thread;
+            }
           }
+          LOG(kIsDebugBuild ? ::android::base::FATAL : ::android::base::ERROR)
+              << "Timed out waiting for threads to suspend, waited for "
+              << PrettyDuration(wait_time)
+              << oss.str();
+        } else {
+          PLOG(FATAL) << "futex wait failed for SuspendAllInternal()";
         }
       }  // else re-check pending_threads in the next iteration (this may be a spurious wake-up).
 #else
diff --git a/test/911-get-stack-trace/expected.txt b/test/911-get-stack-trace/expected.txt
index 8dd49aa..3179424 100644
--- a/test/911-get-stack-trace/expected.txt
+++ b/test/911-get-stack-trace/expected.txt
@@ -388,7 +388,7 @@
 Test911
  getAllStackTraces (I)[[Ljava/lang/Object; -1 -2
  printAll (I)V 0 75
- doTest ()V 118 59
+ doTest ()V 120 59
  run ()V 24 37
 
 ---------
@@ -643,7 +643,7 @@
 Test911
  getAllStackTraces (I)[[Ljava/lang/Object; -1 -2
  printAll (I)V 0 75
- doTest ()V 123 61
+ doTest ()V 125 61
  run ()V 24 37
 
 ---------
@@ -675,7 +675,7 @@
 Test911
  getThreadListStackTraces ([Ljava/lang/Thread;I)[[Ljava/lang/Object; -1 -2
  printList ([Ljava/lang/Thread;I)V 0 68
- doTest ()V 108 54
+ doTest ()V 110 54
  run ()V 32 41
 
 ---------
@@ -732,7 +732,7 @@
 Test911
  getThreadListStackTraces ([Ljava/lang/Thread;I)[[Ljava/lang/Object; -1 -2
  printList ([Ljava/lang/Thread;I)V 0 68
- doTest ()V 113 56
+ doTest ()V 115 56
  run ()V 32 41
 
 ---------