Skip to content

Commit 0b5a4a1

Browse files
Jean-Baptiste QueruAndroid Git Automerger
authored andcommitted
am 11626a9: am 9eb3bd8: am 42a58ec: Merge "Revert "Watchdog: Improvement of debuggability""
* commit '11626a91b6e695e7a8fa9e9a9f1a37df11cfb4e2': Revert "Watchdog: Improvement of debuggability"
2 parents 4a332f5 + 11626a9 commit 0b5a4a1

File tree

1 file changed

+5
-55
lines changed

1 file changed

+5
-55
lines changed

services/java/com/android/server/Watchdog.java

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import android.content.Context;
2727
import android.content.Intent;
2828
import android.content.IntentFilter;
29-
import android.os.Build;
3029
import android.os.Debug;
3130
import android.os.Handler;
3231
import android.os.Message;
@@ -40,8 +39,6 @@
4039
import android.util.Slog;
4140

4241
import java.io.File;
43-
import java.io.FileWriter;
44-
import java.io.IOException;
4542
import java.util.ArrayList;
4643
import java.util.Calendar;
4744

@@ -432,10 +429,11 @@ public void run() {
432429
}
433430

434431
// If we got here, that means that the system is most likely hung.
432+
// First collect stack traces from all threads of the system process.
433+
// Then kill this process so that the system will restart.
435434

436435
final String name = (mCurrentMonitor != null) ?
437436
mCurrentMonitor.getClass().getName() : "null";
438-
Slog.w(TAG, "WATCHDOG PROBLEM IN SYSTEM SERVER: " + name);
439437
EventLog.writeEvent(EventLogTags.WATCHDOG, name);
440438

441439
ArrayList<Integer> pids = new ArrayList<Integer>();
@@ -470,15 +468,11 @@ public void run() {
470468
dropboxThread.join(2000); // wait up to 2 seconds for it to return.
471469
} catch (InterruptedException ignored) {}
472470

473-
// Only kill/crash the process if the debugger is not attached.
471+
// Only kill the process if the debugger is not attached.
474472
if (!Debug.isDebuggerConnected()) {
475473
Slog.w(TAG, "*** WATCHDOG KILLING SYSTEM PROCESS: " + name);
476-
if (!Build.TYPE.equals("user")) {
477-
forceCrashDump();
478-
} else {
479-
Process.killProcess(Process.myPid());
480-
System.exit(10);
481-
}
474+
Process.killProcess(Process.myPid());
475+
System.exit(10);
482476
} else {
483477
Slog.w(TAG, "Debugger connected: Watchdog is *not* killing the system process");
484478
}
@@ -487,50 +481,6 @@ public void run() {
487481
}
488482
}
489483

490-
private void forceCrashDump() {
491-
/* Sync file system to flash the data which is written just before the
492-
* crash.
493-
*/
494-
java.lang.Process p = null;
495-
try {
496-
p = Runtime.getRuntime().exec("sync");
497-
if (p != null) {
498-
// It is not necessary to check the exit code, here.
499-
// 'sync' command always succeeds, and this function returns 0.
500-
p.waitFor();
501-
} else {
502-
Slog.e(TAG, "Failed to execute 'sync' command. (no process handle)");
503-
}
504-
} catch (Exception e) {
505-
// This code is an emergency path to crash MUT. The system already
506-
// caused fatal error, and then calls this function to create a
507-
// crash dump. This function must run the code below to force a
508-
// crash, even if the sync command failed.
509-
// Therefore, ignore all exceptions, here.
510-
Slog.e(TAG, "Failed to execute 'sync' command prior to forcing crash: " + e);
511-
} finally {
512-
if (p != null) {
513-
p.destroy();
514-
}
515-
}
516-
517-
FileWriter out = null;
518-
try {
519-
out = new FileWriter("/proc/sysrq-trigger");
520-
out.write("c");
521-
} catch (IOException e) {
522-
Slog.e(TAG, "Failed to write to sysrq-trigger while triggering crash: " + e);
523-
} finally {
524-
if (out != null) {
525-
try {
526-
out.close();
527-
} catch (IOException e) {
528-
Slog.e(TAG, "Failed to close sysrq-trigger while triggering crash: " + e);
529-
}
530-
}
531-
}
532-
}
533-
534484
private File dumpKernelStackTraces() {
535485
String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null);
536486
if (tracesPath == null || tracesPath.length() == 0) {

0 commit comments

Comments
 (0)