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

Commit 573f6394 authored by Sri Krishna Chaitanya Madireddy's avatar Sri Krishna Chaitanya Madireddy Committed by Gerrit - the friendly Code Review server
Browse files

frameworks/base: creating sperate files for ANRs traces

If an ANR comes just after the framework reboot, the traces for the
framework reboot will get over-written with the ANR traces. So, We
are missing the traces for the framework reboot which makes debugging
the framework reboot difficult.
Even for multiple ANRs in different apps, we will get the traces for
the last ANR.
Most of the time traces show that the call is stuck in some native call
and we do not have any info about the native call stack becuase we do
not collect the tombstones for teh ANR.

This patch will create one trace file for each application in case of ANR
and the filename would be traces_<app_name>_<date>.txt and the traces for
framework reboot will be stored in traces.txt

Change-Id: I2b5bfefdee6a3c67f65fbb7796c6e92a0d24f3a7
parent 09ecabc3
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -260,6 +260,8 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.Date;
import java.text.SimpleDateFormat;
public final class ActivityManagerService extends ActivityManagerNative
        implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback {
@@ -481,6 +483,8 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    String mDeviceOwnerName;
    SimpleDateFormat mTraceDateFormat = new SimpleDateFormat("dd_MMM_HH_mm_ss.SSS");
    public class PendingAssistExtras extends Binder implements Runnable {
        public final ActivityRecord activity;
        public final Bundle extras;
@@ -5071,6 +5075,24 @@ public final class ActivityManagerService extends ActivityManagerNative
                    annotation != null ? "ANR " + annotation : "ANR",
                    info.toString());
            //Set the trace file name to app name + current date format to avoid overrinding trace file
            String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null);
            if (tracesPath != null && tracesPath.length() != 0) {
                File traceRenameFile = new File(tracesPath);
                String newTracesPath;
                int lpos = tracesPath.lastIndexOf (".");
                if (-1 != lpos)
                    newTracesPath = tracesPath.substring (0, lpos) + "_" + app.processName + "_" + mTraceDateFormat.format(new Date()) + tracesPath.substring (lpos);
                else
                    newTracesPath = tracesPath + "_" + app.processName;
                traceRenameFile.renameTo(new File(newTracesPath));
                Process.sendSignal(app.pid, 6);
                SystemClock.sleep(1000);
                Process.sendSignal(app.pid, 6);
                SystemClock.sleep(1000);
            }
            // Bring up the infamous App Not Responding dialog
            Message msg = Message.obtain();
            HashMap<String, Object> map = new HashMap<String, Object>();