OSDN Git Service

Fix thread suspension in ObjectReference.MonitorInfo JDWP command.
authorSebastien Hertz <shertz@google.com>
Wed, 19 Mar 2014 17:16:50 +0000 (18:16 +0100)
committerSebastien Hertz <shertz@google.com>
Wed, 19 Mar 2014 17:17:32 +0000 (18:17 +0100)
Uses ThreadList::SuspendAll and ThreadList::ResumeAll to suspend/resume all
the threads so we collect monitor info while all threads are suspended.

Bug: 13528439
Change-Id: I81ad0698a759cae428aa6a0149dafda3db4cd198

runtime/debugger.cc

index 2c671aa..c702229 100644 (file)
@@ -721,13 +721,14 @@ JDWP::JdwpError Dbg::GetMonitorInfo(JDWP::ObjectId object_id, JDWP::ExpandBuf* r
 
   // Ensure all threads are suspended while we read objects' lock words.
   Thread* self = Thread::Current();
-  Locks::mutator_lock_->SharedUnlock(self);
-  Locks::mutator_lock_->ExclusiveLock(self);
+  CHECK_EQ(self->GetState(), kRunnable);
+  self->TransitionFromRunnableToSuspended(kSuspended);
+  Runtime::Current()->GetThreadList()->SuspendAll();
 
   MonitorInfo monitor_info(o);
 
-  Locks::mutator_lock_->ExclusiveUnlock(self);
-  Locks::mutator_lock_->SharedLock(self);
+  Runtime::Current()->GetThreadList()->ResumeAll();
+  self->TransitionFromSuspendedToRunnable();
 
   if (monitor_info.owner_ != NULL) {
     expandBufAddObjectId(reply, gRegistry->Add(monitor_info.owner_->GetPeer()));