diff options
| author | 2025-02-07 08:55:00 -0800 | |
|---|---|---|
| committer | 2025-02-07 08:55:00 -0800 | |
| commit | 545b45d18dbe06eb76ffcc0cce3857cdb842beeb (patch) | |
| tree | 3e669a4c70f63fa9e67d2393572b438cdb2614d2 | |
| parent | 0769b88e50923e6ef3db31d0d4b0f900bd4ce688 (diff) | |
| parent | 5ee1d74cb36dfaa611681217a9e8c0e2f3666664 (diff) | |
ThreadList::Dump() fix am: 764be11a8f am: 5ee1d74cb3
Original change: https://android-review.googlesource.com/c/platform/art/+/3472429
Change-Id: Id14be59e65eb67b70405b30d9c00a3208d73077b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | runtime/thread_list.cc | 11 | ||||
| -rw-r--r-- | runtime/thread_list.h | 9 |
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. |