Various fixes for JDWP.

- Moved lock of thread list lock into DecodeThread from its callers
- Fixed scope of various locks to prevent locking violations
- Added transition for current thread from runnable to suspended before
  suspending vm, and then a transition back
- Reworked lock ordering to allow JDWP locks to be held while grabbing
  the thread list lock
- Moved debugger PostException until after suspension is re-allowed

Change-Id: Ie53e47ff1538e6cd3125c48ddb4c13758b29be63
diff --git a/src/thread.cc b/src/thread.cc
index 7490d2a..f6053a9 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -1725,8 +1725,6 @@
 
   void DoLongJump() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     AbstractMethod* catch_method = *handler_quick_frame_;
-    Dbg::PostException(self_, throw_frame_id_, throw_method_, throw_dex_pc_,
-                       catch_method, handler_dex_pc_, exception_);
     if (kDebugExceptionDelivery) {
       if (catch_method == NULL) {
         LOG(INFO) << "Handler is upcall";
@@ -1738,6 +1736,9 @@
     }
     self_->SetException(exception_);  // Exception back in root set.
     self_->EndAssertNoThreadSuspension(last_no_assert_suspension_cause_);
+    // Do debugger PostException after allowing thread suspension again.
+    Dbg::PostException(self_, throw_frame_id_, throw_method_, throw_dex_pc_,
+                       catch_method, handler_dex_pc_, exception_);
     // Place context back on thread so it will be available when we continue.
     self_->ReleaseLongJumpContext(context_);
     context_->SetSP(reinterpret_cast<uintptr_t>(handler_quick_frame_));