Fix and reenable lock dumping in stack dumps.

This patch adds a flag to tell the method verifier not to load
classes when resolving types, so that when we ask the method verifier
to find monitor-enter instructions for stack dumping it doesn't try
to allocate (since the most common cause of stack dumping is SIGQUIT).
We believe that all the classes we care about will be loaded already
anyway, since we're only interested in _held_ locks, and you can only
hold a lock if you've executed the code that leads to the monitor-enter,
and you can't execute the code without loading the relevant classes.
Any not-yet-loaded classes shouldn't be relevant for our purposes.

Also clarify the stack dumps when a thread is starting up; although
strictly speaking a thread might be in the kNative state, it's more
helpful if we also explicitly say that it's still starting up.

Also a few GC log output fixes.

Change-Id: Ibf8519e9bde27838c511eafa5c13734c5bebeab6
diff --git a/src/monitor.cc b/src/monitor.cc
index 6172136..33383eb 100644
--- a/src/monitor.cc
+++ b/src/monitor.cc
@@ -901,41 +901,35 @@
     return; // No "tries" implies no synchronization, so no held locks to report.
   }
 
-  // TODO: Enable dex register lock descriptions, disabling as for the portable path GetVReg is
-  // unimplemented. There is also a possible deadlock relating to the verifier calling
-  // ClassLoader.loadClass and reentering managed code whilst the ThreadList lock is held.
-  const bool kEnableDexRegisterLockDescriptions = false;
-  if (kEnableDexRegisterLockDescriptions) {
-    // Ask the verifier for the dex pcs of all the monitor-enter instructions corresponding to
-    // the locks held in this stack frame.
-    std::vector<uint32_t> monitor_enter_dex_pcs;
-    verifier::MethodVerifier::FindLocksAtDexPc(m, stack_visitor->GetDexPc(), monitor_enter_dex_pcs);
-    if (monitor_enter_dex_pcs.empty()) {
-      return;
+  // Ask the verifier for the dex pcs of all the monitor-enter instructions corresponding to
+  // the locks held in this stack frame.
+  std::vector<uint32_t> monitor_enter_dex_pcs;
+  verifier::MethodVerifier::FindLocksAtDexPc(m, stack_visitor->GetDexPc(), monitor_enter_dex_pcs);
+  if (monitor_enter_dex_pcs.empty()) {
+    return;
+  }
+
+  // Verification is an iterative process, so it can visit the same monitor-enter instruction
+  // repeatedly with increasingly accurate type information. We don't want duplicates.
+  // TODO: is this fixed if we share the other std::vector-returning verifier code?
+  STLSortAndRemoveDuplicates(&monitor_enter_dex_pcs);
+
+  for (size_t i = 0; i < monitor_enter_dex_pcs.size(); ++i) {
+    // The verifier works in terms of the dex pcs of the monitor-enter instructions.
+    // We want the registers used by those instructions (so we can read the values out of them).
+    uint32_t dex_pc = monitor_enter_dex_pcs[i];
+    uint16_t monitor_enter_instruction = code_item->insns_[dex_pc];
+
+    // Quick sanity check.
+    if ((monitor_enter_instruction & 0xff) != Instruction::MONITOR_ENTER) {
+      LOG(FATAL) << "expected monitor-enter @" << dex_pc << "; was "
+                 << reinterpret_cast<void*>(monitor_enter_instruction);
     }
 
-    // Verification is an iterative process, so it can visit the same monitor-enter instruction
-    // repeatedly with increasingly accurate type information. Our callers don't want to see
-    // duplicates.
-    STLSortAndRemoveDuplicates(&monitor_enter_dex_pcs);
-
-    for (size_t i = 0; i < monitor_enter_dex_pcs.size(); ++i) {
-      // The verifier works in terms of the dex pcs of the monitor-enter instructions.
-      // We want the registers used by those instructions (so we can read the values out of them).
-      uint32_t dex_pc = monitor_enter_dex_pcs[i];
-      uint16_t monitor_enter_instruction = code_item->insns_[dex_pc];
-
-      // Quick sanity check.
-      if ((monitor_enter_instruction & 0xff) != Instruction::MONITOR_ENTER) {
-        LOG(FATAL) << "expected monitor-enter @" << dex_pc << "; was "
-            << reinterpret_cast<void*>(monitor_enter_instruction);
-      }
-
-      uint16_t monitor_register = ((monitor_enter_instruction >> 8) & 0xff);
-      Object* o = reinterpret_cast<Object*>(stack_visitor->GetVReg(m, monitor_register,
-                                                                   kReferenceVReg));
-      DumpLockedObject(os, o);
-    }
+    uint16_t monitor_register = ((monitor_enter_instruction >> 8) & 0xff);
+    Object* o = reinterpret_cast<Object*>(stack_visitor->GetVReg(m, monitor_register,
+                                                                 kReferenceVReg));
+    DumpLockedObject(os, o);
   }
 }