Bug 959214 - Use unwinder when getting ANR native stack; r=blassey

This commit is contained in:
Jim Chen 2014-02-05 12:37:54 -06:00
Родитель 8a047f2d54
Коммит 8cc0f19e61
3 изменённых файлов: 26 добавлений и 10 удалений

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

@ -54,7 +54,7 @@ public final class ANRReporter extends BroadcastReceiver
private Handler mHandler;
private volatile boolean mPendingANR;
private static native boolean requestNativeStack();
private static native boolean requestNativeStack(boolean unwind);
private static native String getNativeStack();
private static native void releaseNativeStack();
@ -460,7 +460,9 @@ public final class ANRReporter extends BroadcastReceiver
private static void processTraces(Reader traces, File pingFile) {
boolean haveNativeStack = requestNativeStack();
// Unwinding is memory intensive; only unwind if we have enough memory
boolean haveNativeStack = requestNativeStack(
/* unwind */ SysInfo.getMemSize() >= 640);
try {
OutputStream ping = new BufferedOutputStream(
new FileOutputStream(pingFile), TRACES_BLOCK_SIZE);

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

@ -533,16 +533,16 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode(JNIEnv * ar
#ifdef JNI_STUBS
typedef jboolean (*Java_org_mozilla_gecko_ANRReporter_requestNativeStack_t)(JNIEnv *, jclass);
typedef jboolean (*Java_org_mozilla_gecko_ANRReporter_requestNativeStack_t)(JNIEnv *, jclass, jboolean);
static Java_org_mozilla_gecko_ANRReporter_requestNativeStack_t f_Java_org_mozilla_gecko_ANRReporter_requestNativeStack;
extern "C" NS_EXPORT jboolean JNICALL
Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv * arg0, jclass arg1) {
Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv * arg0, jclass arg1, jboolean arg2) {
if (!f_Java_org_mozilla_gecko_ANRReporter_requestNativeStack) {
arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
"JNI Function called before it was loaded");
return false;
}
return f_Java_org_mozilla_gecko_ANRReporter_requestNativeStack(arg0, arg1);
return f_Java_org_mozilla_gecko_ANRReporter_requestNativeStack(arg0, arg1, arg2);
}
#endif

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

@ -945,7 +945,7 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode(JNIEnv* env
}
NS_EXPORT jboolean JNICALL
Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv*, jclass)
Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv*, jclass, jboolean aUnwind)
{
if (profiler_is_active()) {
// Don't proceed if profiler is already running
@ -955,11 +955,25 @@ Java_org_mozilla_gecko_ANRReporter_requestNativeStack(JNIEnv*, jclass)
// generally unsafe to use the profiler from off the main thread. However,
// the risk here is limited because for most users, the profiler is not run
// elsewhere. See the discussion in Bug 863777, comment 13
const char *NATIVE_STACK_FEATURES[] = {"leaf", "threads", "privacy"};
const char *NATIVE_STACK_FEATURES[] =
{"leaf", "threads", "privacy"};
const char *NATIVE_STACK_UNWIND_FEATURES[] =
{"leaf", "threads", "privacy", "stackwalk"};
const char **features = NATIVE_STACK_FEATURES;
size_t features_size = sizeof(NATIVE_STACK_FEATURES);
if (aUnwind) {
features = NATIVE_STACK_UNWIND_FEATURES;
features_size = sizeof(NATIVE_STACK_UNWIND_FEATURES);
// We want the new unwinder if the unwind mode has not been set yet
putenv("MOZ_PROFILER_NEW=1");
}
const char *NATIVE_STACK_THREADS[] =
{"GeckoMain", "Compositor"};
// Buffer one sample and let the profiler wait a long time
profiler_start(100, 10000, NATIVE_STACK_FEATURES,
sizeof(NATIVE_STACK_FEATURES) / sizeof(char*),
nullptr, 0);
profiler_start(100, 10000, features, features_size / sizeof(char*),
NATIVE_STACK_THREADS, sizeof(NATIVE_STACK_THREADS) / sizeof(char*));
return JNI_TRUE;
}