Debugging help for issue #8734824: WATCHDOG KILLING SYSTEM PROCESS

The monkey now gets told about system hangs, and does stuff about
it!  Most especially, it can collect a bug report.  Monkey wins!

Change-Id: Ic8350721e715ef21d1ec813c6aff9a83262d5faa
This commit is contained in:
Dianne Hackborn
2013-05-03 16:27:39 -07:00
parent 2cd4b68cab
commit cb8739c53f
2 changed files with 59 additions and 0 deletions

View File

@@ -107,6 +107,10 @@ public class BadBehaviorActivity extends Activity {
public int appNotResponding(String proc, int pid, String st) { public int appNotResponding(String proc, int pid, String st) {
return 0; return 0;
} }
public int systemNotResponding(String message) {
return 0;
}
} }
@Override @Override

View File

@@ -132,6 +132,18 @@ public class Monkey {
*/ */
private boolean mRequestAnrBugreport = false; private boolean mRequestAnrBugreport = false;
/**
* This is set by the ActivityController thread to request a
* bugreport after a system watchdog report
*/
private boolean mRequestWatchdogBugreport = false;
/**
* Synchronization for the ActivityController callback to block
* until we are done handling the reporting of the watchdog error.
*/
private boolean mWatchdogWaiting = false;
/** /**
* This is set by the ActivityController thread to request a * This is set by the ActivityController thread to request a
* bugreport after java application crash * bugreport after java application crash
@@ -355,6 +367,31 @@ public class Monkey {
} }
return (mKillProcessAfterError) ? -1 : 1; return (mKillProcessAfterError) ? -1 : 1;
} }
public int systemNotResponding(String message) {
StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskWrites();
System.err.println("// WATCHDOG: " + message);
StrictMode.setThreadPolicy(savedPolicy);
synchronized (Monkey.this) {
if (!mIgnoreCrashes) {
mAbort = true;
}
if (mRequestBugreport) {
mRequestWatchdogBugreport = true;
}
mWatchdogWaiting = true;
}
synchronized (Monkey.this) {
while (mWatchdogWaiting) {
try {
Monkey.this.wait();
} catch (InterruptedException e) {
}
}
}
return (mKillProcessAfterError) ? -1 : 1;
}
} }
/** /**
@@ -635,6 +672,11 @@ public class Monkey {
getBugreport("anr_" + mReportProcessName + "_"); getBugreport("anr_" + mReportProcessName + "_");
mRequestAnrBugreport = false; mRequestAnrBugreport = false;
} }
if (mRequestWatchdogBugreport) {
System.out.println("Print the watchdog report");
getBugreport("anr_watchdog_");
mRequestWatchdogBugreport = false;
}
if (mRequestAppCrashBugreport){ if (mRequestAppCrashBugreport){
getBugreport("app_crash" + mReportProcessName + "_"); getBugreport("app_crash" + mReportProcessName + "_");
mRequestAppCrashBugreport = false; mRequestAppCrashBugreport = false;
@@ -647,6 +689,10 @@ public class Monkey {
getBugreport("Bugreport_"); getBugreport("Bugreport_");
mRequestPeriodicBugreport = false; mRequestPeriodicBugreport = false;
} }
if (mWatchdogWaiting) {
mWatchdogWaiting = false;
notifyAll();
}
} }
if (mGenerateHprof) { if (mGenerateHprof) {
@@ -1027,6 +1073,11 @@ public class Monkey {
getBugreport("anr_" + mReportProcessName + "_"); getBugreport("anr_" + mReportProcessName + "_");
mRequestAnrBugreport = false; mRequestAnrBugreport = false;
} }
if (mRequestWatchdogBugreport) {
System.out.println("Print the watchdog report");
getBugreport("anr_watchdog_");
mRequestWatchdogBugreport = false;
}
if (mRequestAppCrashBugreport){ if (mRequestAppCrashBugreport){
getBugreport("app_crash" + mReportProcessName + "_"); getBugreport("app_crash" + mReportProcessName + "_");
mRequestAppCrashBugreport = false; mRequestAppCrashBugreport = false;
@@ -1053,6 +1104,10 @@ public class Monkey {
if (mAbort) { if (mAbort) {
shouldAbort = true; shouldAbort = true;
} }
if (mWatchdogWaiting) {
mWatchdogWaiting = false;
notifyAll();
}
} }
// Report ANR, dumpsys after releasing lock on this. // Report ANR, dumpsys after releasing lock on this.