diff options
author | 2017-06-12 13:10:01 -0700 | |
---|---|---|
committer | 2017-06-12 13:32:43 -0700 | |
commit | 4f5e3cb690547c0f85c1e6117786048d0348d3c6 (patch) | |
tree | 6e8ea7b16bce526e5b0bd3ad9fa7a6f408952a8a /runtime/gc/heap_verification_test.cc | |
parent | f22f68efca28c2e165f6db485b24f9ee02caa78c (diff) |
Add FirstPathFromRootSet and use it to debug reachability issues
Specifically issues where classes aren't pruned in image writer.
Added test.
Test: mm test-art-host-gtest-heap_verification_test -j32
Change-Id: Iea87309aaddf9e28f1856698699a925fb6ab92a1
Diffstat (limited to 'runtime/gc/heap_verification_test.cc')
-rw-r--r-- | runtime/gc/heap_verification_test.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/runtime/gc/heap_verification_test.cc b/runtime/gc/heap_verification_test.cc index a307c519cb..8ea0459c89 100644 --- a/runtime/gc/heap_verification_test.cc +++ b/runtime/gc/heap_verification_test.cc @@ -141,5 +141,24 @@ TEST_F(VerificationTest, LogHeapCorruption) { v->LogHeapCorruption(nullptr, MemberOffset(0), arr.Get(), false); } +TEST_F(VerificationTest, FindPathFromRootSet) { + TEST_DISABLED_FOR_MEMORY_TOOL(); + ScopedLogSeverity sls(LogSeverity::INFO); + ScopedObjectAccess soa(Thread::Current()); + Runtime* const runtime = Runtime::Current(); + VariableSizedHandleScope hs(soa.Self()); + Handle<mirror::ObjectArray<mirror::Object>> arr( + hs.NewHandle(AllocObjectArray<mirror::Object>(soa.Self(), 256))); + ObjPtr<mirror::String> str = mirror::String::AllocFromModifiedUtf8(soa.Self(), "obj"); + arr->Set(0, str); + const Verification* const v = runtime->GetHeap()->GetVerification(); + std::string path = v->FirstPathFromRootSet(str); + EXPECT_GT(path.length(), 0u); + std::ostringstream oss; + oss << arr.Get(); + EXPECT_NE(path.find(oss.str()), std::string::npos); + LOG(INFO) << path; +} + } // namespace gc } // namespace art |