summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/thread_list.cc11
-rw-r--r--runtime/thread_list.h9
2 files changed, 13 insertions, 7 deletions
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 6a8a7f566c..2acf58bfce 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -253,13 +253,16 @@ void ThreadList::Dump(std::ostream& os, bool dump_native_stack) {
os << "DALVIK THREADS (" << list_.size() << "):\n";
}
if (self != nullptr) {
+ // Dump() can be called in any mutator lock state.
+ bool mutator_lock_held = Locks::mutator_lock_->IsSharedHeld(self);
DumpCheckpoint checkpoint(dump_native_stack);
// Acquire mutator lock separately for each thread, to avoid long runnable code sequence
// without suspend checks.
- size_t threads_running_checkpoint = RunCheckpoint(&checkpoint,
- nullptr,
- true,
- /* acquire_mutator_lock= */ true);
+ size_t threads_running_checkpoint =
+ RunCheckpoint(&checkpoint,
+ nullptr,
+ true,
+ /* acquire_mutator_lock= */ !mutator_lock_held);
if (threads_running_checkpoint != 0) {
checkpoint.WaitForThreadsToRunThroughCheckpoint(threads_running_checkpoint);
}
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index 4bf08dc9c1..8312282ed5 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -62,11 +62,14 @@ class ThreadList {
void ShutDown();
- void DumpForSigQuit(std::ostream& os)
- REQUIRES(!Locks::thread_list_lock_, !Locks::mutator_lock_);
- // For thread suspend timeout dumps.
+ // Dump stacks for all threads.
+ // This version includes some additional data.
+ void DumpForSigQuit(std::ostream& os) REQUIRES(!Locks::thread_list_lock_, !Locks::mutator_lock_);
+
+ // This version is less jank-prone if mutator_lock_ is not held.
EXPORT void Dump(std::ostream& os, bool dump_native_stack = true)
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
+
pid_t GetLockOwner(); // For SignalCatcher.
// Thread suspension support.