summaryrefslogtreecommitdiffstats
path: root/vm/Thread.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-04-05 15:45:24 -0700
committerElliott Hughes <enh@google.com>2013-04-05 15:45:24 -0700
commit890ce010c4846deb82d3ac09b6d2ceb76e59fb67 (patch)
tree78d20973cf1de2ea8f892abe9c647e2df0f6f008 /vm/Thread.cpp
parent22d8366a51298a3ace15307ab62b5d5772c8f3ae (diff)
downloadandroid_dalvik-890ce010c4846deb82d3ac09b6d2ceb76e59fb67.tar.gz
android_dalvik-890ce010c4846deb82d3ac09b6d2ceb76e59fb67.tar.bz2
android_dalvik-890ce010c4846deb82d3ac09b6d2ceb76e59fb67.zip
Dump native stacks for all threads in native code.
Bug: 7432159 Change-Id: I83cb530155edfc35ae3be0f7a2a044245223d2d5
Diffstat (limited to 'vm/Thread.cpp')
-rw-r--r--vm/Thread.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/vm/Thread.cpp b/vm/Thread.cpp
index 5ca055fe0..c0321c105 100644
--- a/vm/Thread.cpp
+++ b/vm/Thread.cpp
@@ -3309,6 +3309,26 @@ static void getSchedulerStats(SchedulerStats* stats, pid_t tid) {
}
}
+static bool shouldShowNativeStack(Thread* thread) {
+ // In native code somewhere in the VM? That's interesting.
+ if (thread->status == THREAD_VMWAIT) {
+ return true;
+ }
+
+ // In an Object.wait variant? That's not interesting.
+ if (thread->status == THREAD_TIMED_WAIT || thread->status == THREAD_WAIT) {
+ return false;
+ }
+
+ // In some other native method? That's interesting.
+ // We don't just check THREAD_NATIVE because native methods will be in
+ // state THREAD_SUSPENDED if they're calling back into the VM, or THREAD_MONITOR
+ // if they're blocked on a monitor, or one of the thread-startup states if
+ // it's early enough in their life cycle (http://b/7432159).
+ const Method* currentMethod = SAVEAREA_FROM_FP(thread->interpSave.curFrame)->method;
+ return dvmIsNativeMethod(currentMethod);
+}
+
/*
* Print information about the specified thread.
*
@@ -3387,16 +3407,7 @@ void dvmDumpThreadEx(const DebugOutputTarget* target, Thread* thread,
dumpSchedStat(target, thread->systemTid);
- /*
- * Grab the native stack, if possible.
- *
- * The native thread is still running, even if the Dalvik side is
- * suspended. This means the thread can move itself out of NATIVE state
- * while we're in here, shifting to SUSPENDED after a brief moment at
- * RUNNING. At that point the native stack isn't all that interesting,
- * though, so if we fail to dump it there's little lost.
- */
- if (thread->status == THREAD_NATIVE || thread->status == THREAD_VMWAIT) {
+ if (shouldShowNativeStack(thread)) {
dvmDumpNativeStack(target, thread->systemTid);
}