Implement EnableCollection, DisableCollection, IsCollected, and fix Exit.

Rewrites the object registry to not just be one big leak. We use jweaks
by default, which means (a) the GC doesn't need to know anything about us
and (b) we don't cause unnecessary heap retention. We promote to regular
JNI global references if the debugger asks us to.

The problem with VirtualMachine.Exit turned out to be that you're supposed
to send a success reply to the command before exiting. This is a bit awkward
with our current division of responsibilities, but it lets us pass another
test.

Also log a summary of our replies when -verbose:jdwp is in effect, not
just the requests.

Change-Id: Idb33e99fe7d8bee7a79152d81fee42e2af00852b
diff --git a/src/debugger.h b/src/debugger.h
index a796349..d63e44b 100644
--- a/src/debugger.h
+++ b/src/debugger.h
@@ -123,10 +123,6 @@
 
   static void UndoDebuggerSuspensions();
 
-  static void Exit(int status);
-
-  static void VisitRoots(RootVisitor* visitor, void* arg);
-
   /*
    * Class, Object, Array
    */
@@ -149,7 +145,8 @@
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   static void FindLoadedClassBySignature(const char* descriptor, std::vector<JDWP::RefTypeId>& ids)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-  static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply);
+  static JDWP::JdwpError GetReferenceType(JDWP::ObjectId object_id, JDWP::ExpandBuf* pReply)
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   static JDWP::JdwpError GetSignature(JDWP::RefTypeId ref_type_id, std::string& signature)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   static JDWP::JdwpError GetSourceFile(JDWP::RefTypeId ref_type_id, std::string& source_file)
@@ -202,6 +199,14 @@
   static JDWP::JdwpError GetReferringObjects(JDWP::ObjectId object_id, int32_t max_count,
                                              std::vector<JDWP::ObjectId>& referring_objects)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+  static JDWP::JdwpError DisableCollection(JDWP::ObjectId object_id)
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+  static JDWP::JdwpError EnableCollection(JDWP::ObjectId object_id)
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+  static JDWP::JdwpError IsCollected(JDWP::ObjectId object_id, bool& is_collected)
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+  static void DisposeObject(JDWP::ObjectId object_id, uint32_t reference_count)
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   //
   // Methods and fields.
@@ -360,9 +365,6 @@
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   static void ExecuteMethod(DebugInvokeReq* pReq);
 
-  /* perform "late registration" of an object ID */
-  static void RegisterObjectId(JDWP::ObjectId id);
-
   /*
    * DDM support.
    */