Improve VerifyNoFromSpaceRefsObjectVisitor logging
Remove read barriers in PrettyTypeOf to prevent recursive failures.
Pass down holder and offset information to
VerifyNoFromSpaceRefsFieldVisitor.
Test: test-art-host
Bug: 37531237
Change-Id: I704ec18ebecfc1ca2982b38f67a2f0788e59dfe9
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index be3b937..9124a3a 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -823,7 +823,10 @@
}
inline const DexFile& Class::GetDexFile() {
- return *GetDexCache()->GetDexFile();
+ // From-space version is the same as the to-space version since the dex file never changes.
+ // Avoiding the read barrier here is important to prevent recursive AssertToSpaceInvariant issues
+ // from PrettyTypeOf.
+ return *GetDexCache<kDefaultVerifyFlags, kWithoutReadBarrier>()->GetDexFile();
}
inline bool Class::DescriptorEquals(const char* match) {
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index f5b9ab3..eabc29a 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -281,12 +281,16 @@
}
std::string Object::PrettyTypeOf() {
- if (GetClass() == nullptr) {
+ // From-space version is the same as the to-space version since the dex file never changes.
+ // Avoiding the read barrier here is important to prevent recursive AssertToSpaceInvariant
+ // issues.
+ ObjPtr<mirror::Class> klass = GetClass<kDefaultVerifyFlags, kWithoutReadBarrier>();
+ if (klass == nullptr) {
return "(raw)";
}
std::string temp;
- std::string result(PrettyDescriptor(GetClass()->GetDescriptor(&temp)));
- if (IsClass()) {
+ std::string result(PrettyDescriptor(klass->GetDescriptor(&temp)));
+ if (klass->IsClassClass()) {
result += "<" + PrettyDescriptor(AsClass()->GetDescriptor(&temp)) + ">";
}
return result;