Skip to content

Commit 784827b

Browse files
author
Jean-Baptiste Queru
committed
Revert "Watchdog: Improvement of debuggability"
This reverts commit 9211b13.
1 parent b307ceb commit 784827b

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
@@ -25,7 +25,6 @@
2525
import android.content.Context;
2626
import android.content.Intent;
2727
import android.content.IntentFilter;
28-
import android.os.Build;
2928
import android.os.Debug;
3029
import android.os.Handler;
3130
import android.os.Message;
@@ -39,8 +38,6 @@
3938
import android.util.Slog;
4039

4140
import java.io.File;
42-
import java.io.FileWriter;
43-
import java.io.IOException;
4441
import java.util.ArrayList;
4542
import java.util.Calendar;
4643

@@ -431,10 +428,11 @@ public void run() {
431428
}
432429

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

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

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

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

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

0 commit comments

Comments
 (0)