Improve Logging

A couple of changes here to improve logging. First, we eliminate some red herrings when a java app
is aborting by guarding some lock invariant checking when aborting.  Second, we print the name of the
thread (if it exists) if we try to suspend a thread with no peer.  A separate CL is coming that
eliminates most, if not all, of the occurences of this that we're seeing on device.

Change-Id: I9177e45462b1f0ff9b88be4d72c7d77edf6ac43c
diff --git a/src/thread.cc b/src/thread.cc
index aa87888..3ed388b 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -53,6 +53,7 @@
 #include "runtime_support.h"
 #include "scoped_thread_state_change.h"
 #include "ScopedLocalRef.h"
+#include "ScopedUtfChars.h"
 #include "sirt_ref.h"
 #include "gc/space.h"
 #include "stack.h"
@@ -605,10 +606,22 @@
     Thread* thread;
     {
       ScopedObjectAccess soa(Thread::Current());
-      MutexLock mu(soa.Self(), *Locks::thread_list_lock_);
+      Thread* self = soa.Self();
+      MutexLock mu(self, *Locks::thread_list_lock_);
       thread = Thread::FromManagedThread(soa, peer);
       if (thread == NULL) {
-        LOG(WARNING) << "No such thread for suspend: " << peer;
+        JNIEnv* env = self->GetJniEnv();
+        ScopedLocalRef<jstring> scoped_name_string(env,
+                                                   (jstring)env->GetObjectField(peer,
+                                                              WellKnownClasses::java_lang_Thread_name));
+        ScopedUtfChars scoped_name_chars(env,scoped_name_string.get());
+        if (scoped_name_chars.c_str() == NULL) {
+            LOG(WARNING) << "No such thread for suspend: " << peer;
+            env->ExceptionClear();
+        } else {
+            LOG(WARNING) << "No such thread for suspend: " << peer << ":" << scoped_name_chars.c_str();
+        }
+
         return NULL;
       }
       {