Added option to allow verification of objects on the stack.

Currently it's defined out by VERIFY_OBJECT_ENABLED. Also made various
fixes to allow heap object verification to work again.

(cherry picked from commit d4983495782be8d54c9c1f0266dc52395b947724)

Change-Id: Icd625e1e0dc240c0ad1d10e2c58c7d5d63fec030
diff --git a/src/thread.cc b/src/thread.cc
index 353f94d..f15bfd5 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1637,7 +1637,7 @@
   bool VisitFrame(const Frame& frame, uintptr_t pc) {
     Method* m = frame.GetMethod();
     if (false) {
-      LOG(INFO) << "Visiting stack roots in " << PrettyMethod(m, false)
+      LOG(INFO) << "Visiting stack roots in " << PrettyMethod(m)
                 << StringPrintf("@ PC:%04x", m->ToDexPC(pc));
     }
     // Process register map (which native and callee save methods don't have)
@@ -1728,6 +1728,18 @@
   WalkStack(&mapper);
 }
 
+#if VERIFY_OBJECT_ENABLED
+void VerifyObject(const Object* obj, void*) {
+  Runtime::Current()->GetHeap()->VerifyObject(obj);
+}
+
+void Thread::VerifyStack() {
+  Context* context = GetLongJumpContext();
+  ReferenceMapVisitor mapper(context, VerifyObject, NULL);
+  WalkStack(&mapper);
+}
+#endif
+
 static const char* kStateNames[] = {
   "Terminated",
   "Runnable",