More debugger support.

This gets us as far as the first DDMS-specific message, which means
it's time to bring in a bunch more code.

Change-Id: I3f9d75706d5ddde0aa21fcca558132282b94eff4
diff --git a/src/jdwp/jdwp.h b/src/jdwp/jdwp.h
index cd2bfa7..a590c27 100644
--- a/src/jdwp/jdwp.h
+++ b/src/jdwp/jdwp.h
@@ -31,6 +31,8 @@
 
 namespace art {
 
+struct Thread;
+
 namespace JDWP {
 
 /*
@@ -118,11 +120,10 @@
    */
   bool IsActive();
 
-  /*
-   * Return the debugger thread's handle, or 0 if the debugger thread isn't
-   * running.
+  /**
+   * Returns the Thread* for the JDWP daemon thread.
    */
-  pthread_t GetDebugThread();
+  Thread* GetDebugThread();
 
   /*
    * Get time, in milliseconds, since the last debugger activity.
@@ -247,7 +248,8 @@
   ConditionVariable thread_start_cond_;
 
   volatile int32_t debug_thread_started_;
-  pthread_t debugThreadHandle;
+  pthread_t pthread_;
+  Thread* thread_;
 public: // TODO: fix privacy
   ObjectId debugThreadId;
 private:
diff --git a/src/jdwp/jdwp_event.cc b/src/jdwp/jdwp_event.cc
index 835b182..c6bdddb 100644
--- a/src/jdwp/jdwp_event.cc
+++ b/src/jdwp/jdwp_event.cc
@@ -539,7 +539,7 @@
   }
 
   if (suspendPolicy == SP_ALL) {
-    Dbg::SuspendVM(true);
+    Dbg::SuspendVM();
   } else {
     CHECK_EQ(suspendPolicy, SP_EVENT_THREAD);
   }
@@ -560,7 +560,7 @@
      * The JDWP thread has told us (and possibly all other threads) to
      * resume.  See if it has left anything in our DebugInvokeReq mailbox.
      */
-    if (!pReq->invokeNeeded) {
+    if (!pReq->invoke_needed) {
       /*LOGD("suspendByPolicy: no invoke needed");*/
       break;
     }
@@ -568,14 +568,14 @@
     /* grab this before posting/suspending again */
     state->SetWaitForEventThread(Dbg::GetThreadSelfId());
 
-    /* leave pReq->invokeNeeded raised so we can check reentrancy */
+    /* leave pReq->invoke_needed raised so we can check reentrancy */
     LOG(VERBOSE) << "invoking method...";
     Dbg::ExecuteMethod(pReq);
 
-    pReq->err = ERR_NONE;
+    pReq->error = ERR_NONE;
 
     /* clear this before signaling */
-    pReq->invokeNeeded = false;
+    pReq->invoke_needed = false;
 
     LOG(VERBOSE) << "invoke complete, signaling and self-suspending";
     MutexLock mu(pReq->lock_);
@@ -587,12 +587,12 @@
  * Determine if there is a method invocation in progress in the current
  * thread.
  *
- * We look at the "invokeNeeded" flag in the per-thread DebugInvokeReq
+ * We look at the "invoke_needed" flag in the per-thread DebugInvokeReq
  * state.  If set, we're in the process of invoking a method.
  */
 static bool invokeInProgress(JdwpState* state) {
   DebugInvokeReq* pReq = Dbg::GetInvokeReq();
-  return pReq->invokeNeeded;
+  return pReq->invoke_needed;
 }
 
 /*
diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc
index 5e566ae..7003151 100644
--- a/src/jdwp/jdwp_handler.cc
+++ b/src/jdwp/jdwp_handler.cc
@@ -310,7 +310,7 @@
  * This needs to increment the "suspend count" on all threads.
  */
 static JdwpError handleVM_Suspend(JdwpState* state, const uint8_t* buf, int dataLen, ExpandBuf* pReply) {
-  Dbg::SuspendVM(false);
+  Dbg::SuspendVM();
   return ERR_NONE;
 }
 
diff --git a/src/jdwp/jdwp_main.cc b/src/jdwp/jdwp_main.cc
index a7857a1..1df0d66 100644
--- a/src/jdwp/jdwp_main.cc
+++ b/src/jdwp/jdwp_main.cc
@@ -151,7 +151,7 @@
    * We have bound to a port, or are trying to connect outbound to a
    * debugger.  Create the JDWP thread and let it continue the mission.
    */
-  CHECK_PTHREAD_CALL(pthread_create, (&state->debugThreadHandle, NULL, StartJdwpThread, state), "JDWP thread");
+  CHECK_PTHREAD_CALL(pthread_create, (&state->pthread_, NULL, StartJdwpThread, state), "JDWP thread");
 
   /*
    * Wait until the thread finishes basic initialization.
@@ -238,7 +238,7 @@
     if (debug_thread_started_) {
       run = false;
       void* threadReturn;
-      if (pthread_join(debugThreadHandle, &threadReturn) != 0) {
+      if (pthread_join(pthread_, &threadReturn) != 0) {
         LOG(WARNING) << "JDWP thread join failed";
       }
     }
@@ -281,7 +281,7 @@
    * Finish initializing, then notify the creating thread that
    * we're running.
    */
-  debugThreadHandle = pthread_self();
+  thread_ = Thread::Current();
   run = true;
   android_atomic_release_store(true, &debug_thread_started_);
 
@@ -387,8 +387,8 @@
   runtime->DetachCurrentThread();
 }
 
-pthread_t JdwpState::GetDebugThread() {
-  return debugThreadHandle;
+Thread* JdwpState::GetDebugThread() {
+  return thread_;
 }
 
 /*