Permalink
Browse files

Log when the native trace is unavailable

This should allow us to differentiate between "couldn't get the
stack" and "didn't try to get the stack".  Also show the thread's
state (e.g. 'R' for running, 'D' for uninterruptible syscall).

Bug 7053953

(cherry-pick of b3667a1.)

Change-Id: I0a40cb3d3cdd9aef8589a39586cccd9c229aa8cb
  • Loading branch information...
1 parent a177aa5 commit c32a3774e9c1eeb289d71e0e53199893b6951b1b @fadden fadden committed with enh Sep 19, 2012
Showing with 19 additions and 6 deletions.
  1. +4 −2 vm/Misc.cpp
  2. +1 −0 vm/Misc.h
  3. +12 −4 vm/Thread.cpp
  4. +2 −0 vm/interp/Stack.cpp
View
@@ -699,8 +699,10 @@ bool dvmGetThreadStats(ProcStatData* pData, pid_t tid)
char* cp = strchr(lineBuf, ')');
if (cp == NULL)
goto parse_fail;
- cp++;
- for (i = 2; i < 13; i++) {
+ cp += 2;
+ pData->state = *cp++;
+
+ for (i = 3; i < 13; i++) {
cp = strchr(cp+1, ' ');
if (cp == NULL)
goto parse_fail;
View
@@ -300,6 +300,7 @@ void *dvmAllocRegion(size_t size, int prot, const char *name);
* Get some per-thread stats from /proc/self/task/N/stat.
*/
struct ProcStatData {
+ char state; /* process state, e.g. 'R', 'S', 'D' */
unsigned long utime; /* number of jiffies scheduled in user mode */
unsigned long stime; /* number of jiffies scheduled in kernel mode */
int processor; /* number of CPU that last executed thread */
View
@@ -3236,9 +3236,9 @@ static void dumpSchedStat(const DebugOutputTarget* target, pid_t tid) {
/* show what we got */
dvmPrintDebugMessage(target,
- " | schedstat=( %s ) utm=%lu stm=%lu core=%d\n",
- schedstatBuf, procStatData.utime, procStatData.stime,
- procStatData.processor);
+ " | state=%c schedstat=( %s ) utm=%lu stm=%lu core=%d\n",
+ procStatData.state, schedstatBuf, procStatData.utime,
+ procStatData.stime, procStatData.processor);
#endif
}
@@ -3344,7 +3344,15 @@ void dvmDumpThreadEx(const DebugOutputTarget* target, Thread* thread,
dumpSchedStat(target, thread->systemTid);
- /* grab the native stack, if possible */
+ /*
+ * 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) {
dvmDumpNativeStack(target, thread->systemTid);
}
View
@@ -1401,6 +1401,8 @@ void dvmDumpNativeStack(const DebugOutputTarget* target, pid_t tid)
}
free_backtrace_symbols(backtrace_symbols, frames);
+ } else {
+ dvmPrintDebugMessage(target, " (native backtrace unavailable)\n");
}
#endif
}

0 comments on commit c32a377

Please sign in to comment.