summaryrefslogtreecommitdiffstats
path: root/runtime/thread_list.cc
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2015-01-12 08:14:54 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-01-12 08:14:56 +0000
commitf3401f7a21c99ebec7355de27ab7bc0840f28726 (patch)
tree1a74d2511b50d8eb35b257acfc3ef20934f1f52c /runtime/thread_list.cc
parentf9e0e191ad8d8ab1859de95ecb15a57d4bf32107 (diff)
parentf9d233dae8ca66ed5a2a474155d6bee0d74c355b (diff)
downloadart-f3401f7a21c99ebec7355de27ab7bc0840f28726.tar.gz
art-f3401f7a21c99ebec7355de27ab7bc0840f28726.tar.bz2
art-f3401f7a21c99ebec7355de27ab7bc0840f28726.zip
Merge "JDWP: allow VirtualMachine.Resume on partial suspension"
Diffstat (limited to 'runtime/thread_list.cc')
-rw-r--r--runtime/thread_list.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 20fbc371c1..364b7c2269 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -818,7 +818,6 @@ void ThreadList::SuspendSelfForDebugger() {
void ThreadList::ResumeAllForDebugger() {
Thread* self = Thread::Current();
Thread* debug_thread = Dbg::GetDebugThread();
- bool needs_resume = false;
VLOG(threads) << *self << " ResumeAllForDebugger starting...";
@@ -831,32 +830,34 @@ void ThreadList::ResumeAllForDebugger() {
MutexLock suspend_count_mu(self, *Locks::thread_suspend_count_lock_);
// Update global suspend all state for attaching threads.
DCHECK_GE(suspend_all_count_, debug_suspend_all_count_);
- needs_resume = (debug_suspend_all_count_ > 0);
- if (needs_resume) {
+ if (debug_suspend_all_count_ > 0) {
--suspend_all_count_;
--debug_suspend_all_count_;
- // Decrement everybody's suspend count (except our own).
- for (const auto& thread : list_) {
- if (thread == self || thread == debug_thread) {
- continue;
- }
- if (thread->GetDebugSuspendCount() == 0) {
- // This thread may have been individually resumed with ThreadReference.Resume.
- continue;
- }
- VLOG(threads) << "requesting thread resume: " << *thread;
- thread->ModifySuspendCount(self, -1, true);
- }
} else {
// We've been asked to resume all threads without being asked to
- // suspend them all before. Let's print a warning.
+ // suspend them all before. That may happen if a debugger tries
+ // to resume some suspended threads (with suspend count == 1)
+ // at once with a VirtualMachine.Resume command. Let's print a
+ // warning.
LOG(WARNING) << "Debugger attempted to resume all threads without "
<< "having suspended them all before.";
}
+ // Decrement everybody's suspend count (except our own).
+ for (const auto& thread : list_) {
+ if (thread == self || thread == debug_thread) {
+ continue;
+ }
+ if (thread->GetDebugSuspendCount() == 0) {
+ // This thread may have been individually resumed with ThreadReference.Resume.
+ continue;
+ }
+ VLOG(threads) << "requesting thread resume: " << *thread;
+ thread->ModifySuspendCount(self, -1, true);
+ }
}
}
- if (needs_resume) {
+ {
MutexLock mu(self, *Locks::thread_suspend_count_lock_);
Thread::resume_cond_->Broadcast(self);
}