Fix thread suspension in ObjectReference.MonitorInfo JDWP command.
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
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 2c671aa..c702229 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -721,13 +721,14 @@
// 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()));