also add backtraces of CPUs before watchdog kills system server
Bug: 18003452
Change-Id: I052fe0b2948ea036c3f1b842ea6270b6f11eadef
diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java
index 89e3f49..8e46c4d 100644
--- a/services/core/java/com/android/server/Watchdog.java
+++ b/services/core/java/com/android/server/Watchdog.java
@@ -415,15 +415,9 @@
dumpKernelStackTraces();
}
- // Trigger the kernel to dump all blocked threads to the kernel log
- try {
- FileWriter sysrq_trigger = new FileWriter("/proc/sysrq-trigger");
- sysrq_trigger.write("w");
- sysrq_trigger.close();
- } catch (IOException e) {
- Slog.e(TAG, "Failed to write to /proc/sysrq-trigger");
- Slog.e(TAG, e.getMessage());
- }
+ // Trigger the kernel to dump all blocked threads, and backtraces on all CPUs to the kernel log
+ doSysRq('w');
+ doSysRq('l');
// Try to add the error to the dropbox, but assuming that the ActivityManager
// itself may be deadlocked. (which has happened, causing this statement to
@@ -488,6 +482,16 @@
}
}
+ private void doSysRq(char c) {
+ try {
+ FileWriter sysrq_trigger = new FileWriter("/proc/sysrq-trigger");
+ sysrq_trigger.write(c);
+ sysrq_trigger.close();
+ } catch (IOException e) {
+ Slog.w(TAG, "Failed to write to /proc/sysrq-trigger", e);
+ }
+ }
+
private File dumpKernelStackTraces() {
String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null);
if (tracesPath == null || tracesPath.length() == 0) {