Loading core/java/android/os/Debug.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -2219,11 +2219,13 @@ public final class Debug } } /** /** * Have the stack traces of the given native process dumped to the * Append the stack traces of a given native process to a specified file. * specified file. Will be appended to the file. * @param pid pid to dump. * @param file path of file to append dump to. * @param timeoutSecs time to wait in seconds, or 0 to wait forever. * @hide * @hide */ */ public static native void dumpNativeBacktraceToFile(int pid, String file); public static native void dumpNativeBacktraceToFileTimeout(int pid, String file, int timeoutSecs); /** /** * Get description of unreachable native memory. * Get description of unreachable native memory. Loading core/jni/android_os_Debug.cpp +5 −6 Original line number Original line Diff line number Diff line Loading @@ -1006,9 +1006,8 @@ static void android_os_Debug_dumpNativeHeap(JNIEnv* env, jobject clazz, ALOGD("Native heap dump complete.\n"); ALOGD("Native heap dump complete.\n"); } } static void android_os_Debug_dumpNativeBacktraceToFileTimeout(JNIEnv* env, jobject clazz, static void android_os_Debug_dumpNativeBacktraceToFile(JNIEnv* env, jobject clazz, jint pid, jstring fileName, jint timeoutSecs) jint pid, jstring fileName) { { if (fileName == NULL) { if (fileName == NULL) { jniThrowNullPointerException(env, "file == null"); jniThrowNullPointerException(env, "file == null"); Loading @@ -1031,7 +1030,7 @@ static void android_os_Debug_dumpNativeBacktraceToFile(JNIEnv* env, jobject claz if (lseek(fd, 0, SEEK_END) < 0) { if (lseek(fd, 0, SEEK_END) < 0) { fprintf(stderr, "lseek: %s\n", strerror(errno)); fprintf(stderr, "lseek: %s\n", strerror(errno)); } else { } else { dump_backtrace_to_file(pid, fd); dump_backtrace_to_file_timeout(pid, fd, timeoutSecs); } } close(fd); close(fd); Loading Loading @@ -1077,8 +1076,8 @@ static const JNINativeMethod gMethods[] = { (void*)android_os_Debug_getProxyObjectCount }, (void*)android_os_Debug_getProxyObjectCount }, { "getBinderDeathObjectCount", "()I", { "getBinderDeathObjectCount", "()I", (void*)android_os_Debug_getDeathObjectCount }, (void*)android_os_Debug_getDeathObjectCount }, { "dumpNativeBacktraceToFile", "(ILjava/lang/String;)V", { "dumpNativeBacktraceToFileTimeout", "(ILjava/lang/String;I)V", (void*)android_os_Debug_dumpNativeBacktraceToFile }, (void*)android_os_Debug_dumpNativeBacktraceToFileTimeout }, { "getUnreachableMemory", "(IZ)Ljava/lang/String;", { "getUnreachableMemory", "(IZ)Ljava/lang/String;", (void*)android_os_Debug_getUnreachableMemory }, (void*)android_os_Debug_getUnreachableMemory }, }; }; Loading services/core/java/com/android/server/am/ActivityManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -5326,7 +5326,8 @@ public class ActivityManagerService extends IActivityManager.Stub for (int pid : pids) { for (int pid : pids) { if (DEBUG_ANR) Slog.d(TAG, "Collecting stacks for native pid " + pid); if (DEBUG_ANR) Slog.d(TAG, "Collecting stacks for native pid " + pid); final long sime = SystemClock.elapsedRealtime(); final long sime = SystemClock.elapsedRealtime(); Debug.dumpNativeBacktraceToFile(pid, tracesPath); Debug.dumpNativeBacktraceToFileTimeout(pid, tracesPath, 10); if (DEBUG_ANR) Slog.d(TAG, "Done with native pid " + pid if (DEBUG_ANR) Slog.d(TAG, "Done with native pid " + pid + " in " + (SystemClock.elapsedRealtime()-sime) + "ms"); + " in " + (SystemClock.elapsedRealtime()-sime) + "ms"); } } Loading Loading
core/java/android/os/Debug.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -2219,11 +2219,13 @@ public final class Debug } } /** /** * Have the stack traces of the given native process dumped to the * Append the stack traces of a given native process to a specified file. * specified file. Will be appended to the file. * @param pid pid to dump. * @param file path of file to append dump to. * @param timeoutSecs time to wait in seconds, or 0 to wait forever. * @hide * @hide */ */ public static native void dumpNativeBacktraceToFile(int pid, String file); public static native void dumpNativeBacktraceToFileTimeout(int pid, String file, int timeoutSecs); /** /** * Get description of unreachable native memory. * Get description of unreachable native memory. Loading
core/jni/android_os_Debug.cpp +5 −6 Original line number Original line Diff line number Diff line Loading @@ -1006,9 +1006,8 @@ static void android_os_Debug_dumpNativeHeap(JNIEnv* env, jobject clazz, ALOGD("Native heap dump complete.\n"); ALOGD("Native heap dump complete.\n"); } } static void android_os_Debug_dumpNativeBacktraceToFileTimeout(JNIEnv* env, jobject clazz, static void android_os_Debug_dumpNativeBacktraceToFile(JNIEnv* env, jobject clazz, jint pid, jstring fileName, jint timeoutSecs) jint pid, jstring fileName) { { if (fileName == NULL) { if (fileName == NULL) { jniThrowNullPointerException(env, "file == null"); jniThrowNullPointerException(env, "file == null"); Loading @@ -1031,7 +1030,7 @@ static void android_os_Debug_dumpNativeBacktraceToFile(JNIEnv* env, jobject claz if (lseek(fd, 0, SEEK_END) < 0) { if (lseek(fd, 0, SEEK_END) < 0) { fprintf(stderr, "lseek: %s\n", strerror(errno)); fprintf(stderr, "lseek: %s\n", strerror(errno)); } else { } else { dump_backtrace_to_file(pid, fd); dump_backtrace_to_file_timeout(pid, fd, timeoutSecs); } } close(fd); close(fd); Loading Loading @@ -1077,8 +1076,8 @@ static const JNINativeMethod gMethods[] = { (void*)android_os_Debug_getProxyObjectCount }, (void*)android_os_Debug_getProxyObjectCount }, { "getBinderDeathObjectCount", "()I", { "getBinderDeathObjectCount", "()I", (void*)android_os_Debug_getDeathObjectCount }, (void*)android_os_Debug_getDeathObjectCount }, { "dumpNativeBacktraceToFile", "(ILjava/lang/String;)V", { "dumpNativeBacktraceToFileTimeout", "(ILjava/lang/String;I)V", (void*)android_os_Debug_dumpNativeBacktraceToFile }, (void*)android_os_Debug_dumpNativeBacktraceToFileTimeout }, { "getUnreachableMemory", "(IZ)Ljava/lang/String;", { "getUnreachableMemory", "(IZ)Ljava/lang/String;", (void*)android_os_Debug_getUnreachableMemory }, (void*)android_os_Debug_getUnreachableMemory }, }; }; Loading
services/core/java/com/android/server/am/ActivityManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -5326,7 +5326,8 @@ public class ActivityManagerService extends IActivityManager.Stub for (int pid : pids) { for (int pid : pids) { if (DEBUG_ANR) Slog.d(TAG, "Collecting stacks for native pid " + pid); if (DEBUG_ANR) Slog.d(TAG, "Collecting stacks for native pid " + pid); final long sime = SystemClock.elapsedRealtime(); final long sime = SystemClock.elapsedRealtime(); Debug.dumpNativeBacktraceToFile(pid, tracesPath); Debug.dumpNativeBacktraceToFileTimeout(pid, tracesPath, 10); if (DEBUG_ANR) Slog.d(TAG, "Done with native pid " + pid if (DEBUG_ANR) Slog.d(TAG, "Done with native pid " + pid + " in " + (SystemClock.elapsedRealtime()-sime) + "ms"); + " in " + (SystemClock.elapsedRealtime()-sime) + "ms"); } } Loading