Move Heap::GetInstances to use Handles
Prevent moving GC bugs from VisitObjects. Fix JDWP tests.
Test: art/tools/run-jdwp-tests.sh '--mode=host' '--variant=X32' --debug
Bug: 31113334
Change-Id: Ie7f51f1980ec0c1eddc3b59c3e49564eacb3be85
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 073750e..ada1a23 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -918,11 +918,11 @@
if (c == nullptr) {
return error;
}
- std::vector<ObjPtr<mirror::Object>> raw_instances;
- StackHandleScope<1> hs(Thread::Current());
- Runtime::Current()->GetHeap()->GetInstances(hs.NewHandle(c), max_count, raw_instances);
+ VariableSizedHandleScope hs(Thread::Current());
+ std::vector<Handle<mirror::Object>> raw_instances;
+ Runtime::Current()->GetHeap()->GetInstances(hs, hs.NewHandle(c), max_count, raw_instances);
for (size_t i = 0; i < raw_instances.size(); ++i) {
- instances->push_back(gRegistry->Add(raw_instances[i]));
+ instances->push_back(gRegistry->Add(raw_instances[i].Get()));
}
return JDWP::ERR_NONE;
}