Implement ObjectReference.ReferringObjects.
Bug: 4159882
Change-Id: Iac145715bec80b5900256d3f6bdb18e283eb9a12
diff --git a/src/debugger.cc b/src/debugger.cc
index f52c42a..1df7fe9 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -775,6 +775,22 @@
return JDWP::ERR_NONE;
}
+JDWP::JdwpError Dbg::GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count,
+ std::vector<JDWP::ObjectId>& referring_objects)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ Object* o = gRegistry->Get<Object*>(object_id);
+ if (o == NULL || o == kInvalidObject) {
+ return JDWP::ERR_INVALID_OBJECT;
+ }
+
+ std::vector<Object*> raw_instances;
+ Runtime::Current()->GetHeap()->GetReferringObjects(o, max_count, raw_instances);
+ for (size_t i = 0; i < raw_instances.size(); ++i) {
+ referring_objects.push_back(gRegistry->Add(raw_instances[i]));
+ }
+ return JDWP::ERR_NONE;
+}
+
JDWP::JdwpError Dbg::GetReflectedType(JDWP::RefTypeId class_id, JDWP::ExpandBuf* pReply) {
JDWP::JdwpError status;
Class* c = DecodeClass(class_id, status);