OSDN Git Service

ART: Improve error message on oat writer failure
authorAndreas Gampe <agampe@google.com>
Tue, 22 Jul 2014 05:56:08 +0000 (22:56 -0700)
committerAndreas Gampe <agampe@google.com>
Tue, 26 Aug 2014 17:54:56 +0000 (10:54 -0700)
Try to log the pending exception to help resolve issues.

Bug: 16406811
Change-Id: I035ae9e59a5ee02b9e90c35c0644ec088d3c7d12

compiler/oat_writer.cc
runtime/thread.cc
runtime/thread.h

index 41a91ed..680ce0a 100644 (file)
@@ -527,7 +527,14 @@ class OatWriter::InitImageMethodVisitor : public OatDexMethodVisitor {
                                                       NullHandle<mirror::ClassLoader>(),
                                                       NullHandle<mirror::ArtMethod>(),
                                                       invoke_type);
-    CHECK(method != NULL) << PrettyMethod(it.GetMemberIndex(), *dex_file_, true);
+    if (method == nullptr) {
+      LOG(ERROR) << "Unexpected failure to resolve a method: "
+                 << PrettyMethod(it.GetMemberIndex(), *dex_file_, true);
+      soa.Self()->AssertPendingException();
+      mirror::Throwable* exc = soa.Self()->GetException(nullptr);
+      std::string dump = exc->Dump();
+      LOG(FATAL) << dump;
+    }
     // Portable code offsets are set by ElfWriterMclinker::FixupCompiledCodeOffset after linking.
     method->SetQuickOatCodeOffset(offsets.code_offset_);
     method->SetOatNativeGcMapOffset(offsets.gc_map_offset_);
index 7ac685b..0eaac6b 100644 (file)
@@ -1101,6 +1101,12 @@ bool Thread::IsStillStarting() const {
       (*tlsPtr_.name == kThreadNameDuringStartup);
 }
 
+void Thread::AssertPendingException() const {
+  if (UNLIKELY(!IsExceptionPending())) {
+    LOG(FATAL) << "Pending exception expected.";
+  }
+}
+
 void Thread::AssertNoPendingException() const {
   if (UNLIKELY(IsExceptionPending())) {
     ScopedObjectAccess soa(Thread::Current());
index fe950c4..5283ca6 100644 (file)
@@ -321,6 +321,7 @@ class Thread {
     return tlsPtr_.exception;
   }
 
+  void AssertPendingException() const;
   void AssertNoPendingException() const;
   void AssertNoPendingExceptionForNewException(const char* msg) const;