Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Log when the native trace is unavailable
Browse files Browse the repository at this point in the history
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
fadden authored and enh-google committed Sep 20, 2012
1 parent a177aa5 commit c32a377
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
6 changes: 4 additions & 2 deletions vm/Misc.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions vm/Misc.h
Expand Up @@ -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 */
Expand Down
16 changes: 12 additions & 4 deletions vm/Thread.cpp
Expand Up @@ -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
}

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions vm/interp/Stack.cpp
Expand Up @@ -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.