Check GetDumpNativeStackOnSigQuit() for daemons.
The flag is passed by run-test to avoid libunwind crash flakiness,
so we should check it when dumping threads.
Change-Id: I3a3fcfd80ab254a315d58d629c81161fea9900dc
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index afb11d3..a9ce056 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -133,22 +133,24 @@
suspend_all_historam_.PrintConfidenceIntervals(os, 0.99, data); // Dump time to suspend.
}
}
- Dump(os, Runtime::Current()->GetDumpNativeStackOnSigQuit());
- DumpUnattachedThreads(os);
+ bool dump_native_stack = Runtime::Current()->GetDumpNativeStackOnSigQuit();
+ Dump(os, dump_native_stack);
+ DumpUnattachedThreads(os, dump_native_stack);
}
-static void DumpUnattachedThread(std::ostream& os, pid_t tid) NO_THREAD_SAFETY_ANALYSIS {
+static void DumpUnattachedThread(std::ostream& os, pid_t tid, bool dump_native_stack)
+ NO_THREAD_SAFETY_ANALYSIS {
// TODO: No thread safety analysis as DumpState with a null thread won't access fields, should
// refactor DumpState to avoid skipping analysis.
Thread::DumpState(os, nullptr, tid);
DumpKernelStack(os, tid, " kernel: ", false);
- if (kDumpUnattachedThreadNativeStack) {
+ if (dump_native_stack && kDumpUnattachedThreadNativeStack) {
DumpNativeStack(os, tid, nullptr, " native: ");
}
os << "\n";
}
-void ThreadList::DumpUnattachedThreads(std::ostream& os) {
+void ThreadList::DumpUnattachedThreads(std::ostream& os, bool dump_native_stack) {
DIR* d = opendir("/proc/self/task");
if (!d) {
return;
@@ -166,7 +168,7 @@
contains = Contains(tid);
}
if (!contains) {
- DumpUnattachedThread(os, tid);
+ DumpUnattachedThread(os, tid, dump_native_stack);
}
}
}
diff --git a/runtime/thread_list.h b/runtime/thread_list.h
index 363cab8..f97ecd3 100644
--- a/runtime/thread_list.h
+++ b/runtime/thread_list.h
@@ -161,7 +161,7 @@
size_t RunCheckpoint(Closure* checkpoint_function, bool includeSuspended)
REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
- void DumpUnattachedThreads(std::ostream& os)
+ void DumpUnattachedThreads(std::ostream& os, bool dump_native_stack)
REQUIRES(!Locks::thread_list_lock_);
void SuspendAllDaemonThreadsForShutdown()