Implement ThreadContinuing and detach the JDWP thread before it exits.

This fixes Calculator.

Change-Id: Ic38e234a91469e9694e21bbf1507912b542bf908
diff --git a/Android.mk b/Android.mk
index 6de4cfb..e997326 100644
--- a/Android.mk
+++ b/Android.mk
@@ -158,6 +158,7 @@
 	adb sync
 	if [ "`adb shell getprop wrap.com.android.calculator2 | tr -d '\r'`" = "oat_processd" ]; then \
 	  echo wrap.com.android.calculator2 already set; \
+	  adb shell start; \
 	else \
 	  echo Setting wrap.com.android.calculator2 and restarting runtime; \
 	  adb shell setprop wrap.com.android.calculator2 "oat_processd"; \
diff --git a/src/debugger.cc b/src/debugger.cc
index f8b52bc..7c26bd0 100644
--- a/src/debugger.cc
+++ b/src/debugger.cc
@@ -212,9 +212,8 @@
   return static_cast<int>(Thread::Current()->SetState(Thread::kVmWait));
 }
 
-int Dbg::ThreadContinuing(int status) {
-  UNIMPLEMENTED(FATAL);
-  return 0;
+int Dbg::ThreadContinuing(int new_state) {
+  return static_cast<int>(Thread::Current()->SetState(static_cast<Thread::State>(new_state)));
 }
 
 void Dbg::UndoDebuggerSuspensions() {
diff --git a/src/jdwp/jdwp_main.cc b/src/jdwp/jdwp_main.cc
index 31337fd..a7857a1 100644
--- a/src/jdwp/jdwp_main.cc
+++ b/src/jdwp/jdwp_main.cc
@@ -383,7 +383,8 @@
   /* back to running, for thread shutdown */
   Dbg::ThreadRunning();
 
-  LOG(VERBOSE) << "JDWP: thread exiting";
+  LOG(VERBOSE) << "JDWP: thread detaching and exiting...";
+  runtime->DetachCurrentThread();
 }
 
 pthread_t JdwpState::GetDebugThread() {