Eager verification GC maps are present in debug mode

Change-Id: Iaefc0bf937ae1476bcfb0aadd6a3e5e434e2d621
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 22f8a8a..3154a1b 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1798,6 +1798,29 @@
   }
 }
 
+#ifndef NDEBUG
+static void CheckMethodsHaveGcMaps(Class* klass) {
+  if (!Runtime::Current()->IsStarted()) {
+    return;
+  }
+  for (size_t i = 0; i < klass->NumDirectMethods(); i++) {
+    Method* method = klass->GetDirectMethod(i);
+    if (!method->IsNative() && !method->IsAbstract()) {
+      CHECK(method->GetGcMap() != NULL) << PrettyMethod(method);
+    }
+  }
+  for (size_t i = 0; i < klass->NumVirtualMethods(); i++) {
+    Method* method = klass->GetVirtualMethod(i);
+    if (!method->IsNative() && !method->IsAbstract()) {
+      CHECK(method->GetGcMap() != NULL) << PrettyMethod(method);
+    }
+  }
+}
+#else
+static void CheckMethodsHaveGcMaps(Class* klass) {
+}
+#endif
+
 void ClassLinker::VerifyClass(Class* klass) {
   // TODO: assert that the monitor on the Class is held
   if (klass->IsVerified()) {
@@ -1813,6 +1836,8 @@
     // Make sure all classes referenced by catch blocks are resolved
     ResolveClassExceptionHandlerTypes(dex_file, klass);
     klass->SetStatus(Class::kStatusVerified);
+    // Sanity check that a verified class has GC maps on all methods
+    CheckMethodsHaveGcMaps(klass);
   } else {
     LOG(ERROR) << "Verification failed on class " << PrettyClass(klass);
     Thread* self = Thread::Current();