Improve Throwable::Dump and log location of verify failing classes.
Change-Id: I167596931a338b3de265391df7b3a8f5a1d29bb3
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 0e9e43a..cccf0f6 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1898,9 +1898,10 @@
// Sanity check that a verified class has GC maps on all methods
CheckMethodsHaveGcMaps(klass);
} else {
- LOG(ERROR) << "Verification failed on class " << PrettyClass(klass);
+ LOG(ERROR) << "Verification failed on class " << PrettyDescriptor(klass)
+ << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8();
Thread* self = Thread::Current();
- CHECK(!self->IsExceptionPending()) << PrettyTypeOf(self->GetException()) << PrettyClass(klass);
+ CHECK(!self->IsExceptionPending()) << self->GetException()->Dump();
self->ThrowNewExceptionF("Ljava/lang/VerifyError;", "Verification of %s failed",
PrettyDescriptor(klass).c_str());
CHECK_EQ(klass->GetStatus(), Class::kStatusVerifying) << PrettyClass(klass);
diff --git a/src/object.cc b/src/object.cc
index c16cdb0..7f6e451 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -1347,20 +1347,25 @@
}
std::string Throwable::Dump() const {
- Object* stack_state = GetStackState();
- if (stack_state == NULL || !stack_state->IsObjectArray()) {
- // missing or corrupt stack state
- return "";
+ std::string result(PrettyTypeOf(this));
+ result += ": ";
+ String* msg = GetFieldObject<String*>(OFFSET_OF_OBJECT_MEMBER(Throwable, detail_message_), false);
+ if (msg != NULL) {
+ result += msg->ToModifiedUtf8();
}
- // Decode the internal stack trace into the depth and method trace
- ObjectArray<Object>* method_trace = down_cast<ObjectArray<Object>*>(stack_state);
- int32_t depth = method_trace->GetLength() - 1;
- std::string result;
- for (int32_t i = 0; i < depth; ++i) {
- Method* method = down_cast<Method*>(method_trace->Get(i));
- result += " at ";
- result += PrettyMethod(method, true);
- result += "\n";
+ result += "\n";
+ Object* stack_state = GetStackState();
+ // check stack state isn't missing or corrupt
+ if (stack_state != NULL && stack_state->IsObjectArray()) {
+ // Decode the internal stack trace into the depth and method trace
+ ObjectArray<Object>* method_trace = down_cast<ObjectArray<Object>*>(stack_state);
+ int32_t depth = method_trace->GetLength() - 1;
+ for (int32_t i = 0; i < depth; ++i) {
+ Method* method = down_cast<Method*>(method_trace->Get(i));
+ result += " at ";
+ result += PrettyMethod(method, true);
+ result += "\n";
+ }
}
return result;
}