Bug 782183 - Add some code to the robocop harness to dump all stack traces in case of hanging/deadlock. r=gbrown

This commit is contained in:
Kartikaya Gupta 2012-08-13 12:03:00 -04:00
Родитель eca377a286
Коммит a70aaff212
2 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -18,6 +18,7 @@ import java.io.PrintWriter;
import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.lang.Class;
import java.lang.reflect.InvocationTargetException;
@ -422,6 +423,20 @@ public class FennecNativeDriver implements Driver {
return retVal;
}
public static void logAllStackTraces(LogLevel level) {
StringBuffer sb = new StringBuffer();
sb.append("Dumping ALL the threads!\n");
Map<Thread, StackTraceElement[]> allStacks = Thread.getAllStackTraces();
for (Thread t : allStacks.keySet()) {
sb.append(t.toString()).append('\n');
for (StackTraceElement ste : allStacks.get(t)) {
sb.append(ste.toString()).append('\n');
}
sb.append('\n');
}
log(level, sb.toString());
}
/**
* Set the filename used for logging. If the file already exists, delete it
* as a safe-guard against accidentally appending to an old log file.

Просмотреть файл

@ -69,6 +69,7 @@ public class FennecNativeElement implements Element {
if (syncQueue.poll(MAX_WAIT_MS, TimeUnit.MILLISECONDS) == null) {
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR,
"click: time-out waiting for UI thread");
FennecNativeDriver.logAllStackTraces(FennecNativeDriver.LogLevel.ERROR);
}
} catch (InterruptedException e) {
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
@ -121,6 +122,7 @@ public class FennecNativeElement implements Element {
if (syncQueue.poll(MAX_WAIT_MS, TimeUnit.MILLISECONDS) == null) {
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR,
"getText: time-out waiting for UI thread");
FennecNativeDriver.logAllStackTraces(FennecNativeDriver.LogLevel.ERROR);
}
} catch (InterruptedException e) {
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);
@ -157,6 +159,7 @@ public class FennecNativeElement implements Element {
if (syncQueue.poll(MAX_WAIT_MS, TimeUnit.MILLISECONDS) == null) {
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR,
"isDisplayed: time-out waiting for UI thread");
FennecNativeDriver.logAllStackTraces(FennecNativeDriver.LogLevel.ERROR);
}
} catch (InterruptedException e) {
FennecNativeDriver.log(FennecNativeDriver.LogLevel.ERROR, e);