ART: Improve error message on oat writer failure
Try to log the pending exception to help resolve issues.
Bug: 16406811
Change-Id: I035ae9e59a5ee02b9e90c35c0644ec088d3c7d12
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index 41a91ed..680ce0a 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -527,7 +527,14 @@
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_);
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 7ac685b..0eaac6b 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1101,6 +1101,12 @@
(*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());
diff --git a/runtime/thread.h b/runtime/thread.h
index fe950c4..5283ca6 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -321,6 +321,7 @@
return tlsPtr_.exception;
}
+ void AssertPendingException() const;
void AssertNoPendingException() const;
void AssertNoPendingExceptionForNewException(const char* msg) const;