Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ad86a3d authored by Tobias Thierer's avatar Tobias Thierer
Browse files

Stop profiling on uncaught exception.

When "handling" an uncaught exception, make an attempt to stop
profiling. In case profiling was active, this will avoid losing
the profiling buffer.

This change is required as a base in order for
https://android-review.googlesource.com/#/c/249721/
to merge cleanly.

(Cherry picked from commit 4c79fea9)
Bug: 26291225
Change-Id: I35f352e5f28eafe4702da9eae587c3b65c360b3a
parent 6eb30f20
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -4294,6 +4294,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) {
    static final void handleDumpHeap(boolean managed, DumpHeapData dhd) {
        if (managed) {
        if (managed) {
            try {
            try {
+7 −0
Original line number Original line Diff line number Diff line
@@ -86,6 +86,13 @@ public class RuntimeInit {
                    Clog_e(TAG, message.toString(), e);
                    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
                // Bring up crash dialog, wait for it to be dismissed
                ActivityManagerNative.getDefault().handleApplicationCrash(
                ActivityManagerNative.getDefault().handleApplicationCrash(
                        mApplicationObject, new ApplicationErrorReport.CrashInfo(e));
                        mApplicationObject, new ApplicationErrorReport.CrashInfo(e));