diff options
author | Christopher Tate <ctate@google.com> | 2010-06-04 14:55:02 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2010-06-04 14:55:02 -0700 |
commit | ecaa7b41ca49154ceaa9a7504eb0a86b89a96026 (patch) | |
tree | a598349af5efb1e2a57e92862cf4a9b68d33f284 /services | |
parent | de56c27dab020bf85187c8bcfc6842cb31006c59 (diff) | |
download | frameworks_base-ecaa7b41ca49154ceaa9a7504eb0a86b89a96026.zip frameworks_base-ecaa7b41ca49154ceaa9a7504eb0a86b89a96026.tar.gz frameworks_base-ecaa7b41ca49154ceaa9a7504eb0a86b89a96026.tar.bz2 |
Watchdog now records kernel stacks when it fires
The kernel threads are appended to the usual /data/anr/traces.txt file
and dropboxed along with the usual Dalvik stack dumps.
Change-Id: I120f1f5ee54c965efe9ac0c7f40fdef56385f1fa
NOTE: this change depends on the kernel publishing /proc/$PID/stack
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/Watchdog.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/services/java/com/android/server/Watchdog.java b/services/java/com/android/server/Watchdog.java index 5eaadbc..d4133f3 100644 --- a/services/java/com/android/server/Watchdog.java +++ b/services/java/com/android/server/Watchdog.java @@ -39,6 +39,8 @@ import android.util.Log; import android.util.Slog; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Calendar; @@ -51,6 +53,9 @@ public class Watchdog extends Thread { // Set this to true to use debug default values. static final boolean DB = false; + // Set this to true to have the watchdog record kernel thread stacks when it fires + static final boolean RECORD_KERNEL_THREADS = true; + static final int MONITOR = 2718; static final int GLOBAL_PSS = 2719; @@ -850,6 +855,11 @@ public class Watchdog extends Thread { // The system's been hanging for a minute, another second or two won't hurt much. SystemClock.sleep(2000); + // Pull our own kernel thread stacks as well if we're configured for that + if (RECORD_KERNEL_THREADS) { + dumpKernelStackTraces(); + } + mActivity.addErrorToDropBox("watchdog", null, null, null, name, null, stack, null); // Only kill the process if the debugger is not attached. @@ -864,4 +874,16 @@ public class Watchdog extends Thread { waitedHalf = false; } } + + private File dumpKernelStackTraces() { + String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null); + if (tracesPath == null || tracesPath.length() == 0) { + return null; + } + + native_dumpKernelStacks(tracesPath); + return new File(tracesPath); + } + + private native void native_dumpKernelStacks(String tracesPath); } |