summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2016-01-29 18:45:48 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-01-29 18:45:48 +0000
commit7169e51ca030d511955407ab28df937df792a9af (patch)
tree15985dcebd0170f643cccc1b997f53e7e5c176f6
parent1c8e12bc4dd6db47c87f4c0a976a01c6707440e5 (diff)
parent4c79fea9efea7cfa739cf5b5f525ddadb28e52a6 (diff)
Merge "Frameworks/base: Stop profiling on uncaught exception"
-rw-r--r--core/java/android/app/ActivityThread.java10
-rw-r--r--core/java/com/android/internal/os/RuntimeInit.java7
2 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 100e67badb43..99c275cf09a4 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -4660,6 +4660,16 @@ public final class ActivityThread {
}
}
+ /**
+ * Public entrypoint to stop profiling. This is required to end profiling when the app crashes,
+ * so that profiler data won't be lost.
+ *
+ * @hide
+ */
+ public void stopProfiling() {
+ mProfiler.stopProfiling();
+ }
+
static final void handleDumpHeap(boolean managed, DumpHeapData dhd) {
if (managed) {
try {
diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java
index f81658e01344..3b8b7cb2ba2f 100644
--- a/core/java/com/android/internal/os/RuntimeInit.java
+++ b/core/java/com/android/internal/os/RuntimeInit.java
@@ -86,6 +86,13 @@ public class RuntimeInit {
Clog_e(TAG, message.toString(), e);
}
+ // Try to end profiling. If a profiler is running at this point, and we kill the
+ // process (below), the in-memory buffer will be lost. So try to stop, which will
+ // flush the buffer. (This makes method trace profiling useful to debug crashes.)
+ if (ActivityThread.currentActivityThread() != null) {
+ ActivityThread.currentActivityThread().stopProfiling();
+ }
+
// Bring up crash dialog, wait for it to be dismissed
ActivityManagerNative.getDefault().handleApplicationCrash(
mApplicationObject, new ApplicationErrorReport.CrashInfo(e));