OSDN Git Service

Weaken condition to dump a thread's stack in a debug build.
authorIan Rogers <irogers@google.com>
Wed, 25 Jun 2014 05:48:01 +0000 (22:48 -0700)
committerIan Rogers <irogers@google.com>
Wed, 25 Jun 2014 05:48:01 +0000 (22:48 -0700)
If the current thread isn't suspended its also ok to dump the stack.
Bug: 14229281

Change-Id: I2810ea79bc4330bb6e9616436d74076b5997c20b

runtime/thread.cc

index e5ae6d0..ca8c2d7 100644 (file)
@@ -974,9 +974,14 @@ void Thread::DumpStack(std::ostream& os) const {
   // TODO: we call this code when dying but may not have suspended the thread ourself. The
   //       IsSuspended check is therefore racy with the use for dumping (normally we inhibit
   //       the race with the thread_suspend_count_lock_).
-  // No point dumping for an abort in debug builds where we'll hit the not suspended check in stack.
-  bool dump_for_abort = (gAborting > 0) && !kIsDebugBuild;
-  if (this == Thread::Current() || IsSuspended() || dump_for_abort) {
+  bool dump_for_abort = (gAborting > 0);
+  bool safe_to_dump = (this == Thread::Current() || IsSuspended());
+  if (!kIsDebugBuild) {
+    // We always want to dump the stack for an abort, however, there is no point dumping another
+    // thread's stack in debug builds where we'll hit the not suspended check in the stack walk.
+    safe_to_dump = (safe_to_dump || dump_for_abort);
+  }
+  if (safe_to_dump) {
     // If we're currently in native code, dump that stack before dumping the managed stack.
     if (dump_for_abort || ShouldShowNativeStack(this)) {
       DumpKernelStack(os, GetTid(), "  kernel: ", false);