Loading services/core/java/com/android/server/SystemServerInitThreadPool.java +1 −1 Original line number Diff line number Diff line Loading @@ -192,7 +192,7 @@ public final class SystemServerInitThreadPool implements Dumpable { final ArrayList<Integer> pids = new ArrayList<>(); pids.add(Process.myPid()); ActivityManagerService.dumpStackTraces(pids, null, null, Watchdog.getInterestingNativePids(), null); Watchdog.getInterestingNativePids(), null, null); } @Override Loading services/core/java/com/android/server/Watchdog.java +4 −3 Original line number Diff line number Diff line Loading @@ -658,7 +658,7 @@ public class Watchdog { // We've waited half the deadlock-detection interval. Pull a stack // trace and wait another half. ActivityManagerService.dumpStackTraces(pids, null, null, getInterestingNativePids(), null); getInterestingNativePids(), null, subject); continue; } Loading @@ -674,7 +674,7 @@ public class Watchdog { StringWriter tracesFileException = new StringWriter(); final File stack = ActivityManagerService.dumpStackTraces( pids, processCpuTracker, new SparseArray<>(), getInterestingNativePids(), tracesFileException); tracesFileException, subject); // Give some extra time to make sure the stack traces get written. // The system's been hanging for a minute, another second or two won't hurt much. Loading @@ -699,7 +699,8 @@ public class Watchdog { if (mActivity != null) { mActivity.addErrorToDropBox( "watchdog", null, "system_server", null, null, null, localSubject, report.toString(), stack, null, null, null, null); null, report.toString(), stack, null, null, null, null); } FrameworkStatsLog.write(FrameworkStatsLog.SYSTEM_SERVER_WATCHDOG_OCCURRED, localSubject); Loading services/core/java/com/android/server/am/ActivityManagerService.java +28 −2 Original line number Diff line number Diff line Loading @@ -407,6 +407,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -3153,7 +3154,23 @@ public class ActivityManagerService extends IActivityManager.Stub ProcessCpuTracker processCpuTracker, SparseArray<Boolean> lastPids, ArrayList<Integer> nativePids, StringWriter logExceptionCreatingFile) { return dumpStackTraces(firstPids, processCpuTracker, lastPids, nativePids, logExceptionCreatingFile, null); logExceptionCreatingFile, null, null); } /** * If a stack trace dump file is configured, dump process stack traces. * @param firstPids of dalvik VM processes to dump stack traces for first * @param lastPids of dalvik VM processes to dump stack traces for last * @param nativePids optional list of native pids to dump stack crawls * @param logExceptionCreatingFile optional writer to which we log errors creating the file * @param subject optional line related to the error */ public static File dumpStackTraces(ArrayList<Integer> firstPids, ProcessCpuTracker processCpuTracker, SparseArray<Boolean> lastPids, ArrayList<Integer> nativePids, StringWriter logExceptionCreatingFile, String subject) { return dumpStackTraces(firstPids, processCpuTracker, lastPids, nativePids, logExceptionCreatingFile, null, subject); } /** Loading @@ -3163,7 +3180,7 @@ public class ActivityManagerService extends IActivityManager.Stub /* package */ static File dumpStackTraces(ArrayList<Integer> firstPids, ProcessCpuTracker processCpuTracker, SparseArray<Boolean> lastPids, ArrayList<Integer> nativePids, StringWriter logExceptionCreatingFile, long[] firstPidOffsets) { long[] firstPidOffsets, String subject) { ArrayList<Integer> extraPids = null; Slog.i(TAG, "dumpStackTraces pids=" + lastPids + " nativepids=" + nativePids); Loading Loading @@ -3215,6 +3232,15 @@ public class ActivityManagerService extends IActivityManager.Stub return null; } if (subject != null) { try (FileOutputStream fos = new FileOutputStream(tracesFile, true)) { String header = "Subject: " + subject + "\n"; fos.write(header.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { Slog.w(TAG, "Exception writing subject to ANR dump file:", e); } } Pair<Long, Long> offsets = dumpStackTraces( tracesFile.getAbsolutePath(), firstPids, nativePids, extraPids); if (firstPidOffsets != null) { Loading services/core/java/com/android/server/am/ProcessErrorStateRecord.java +2 −2 Original line number Diff line number Diff line Loading @@ -377,7 +377,7 @@ class ProcessErrorStateRecord { final long[] offsets = new long[2]; File tracesFile = ActivityManagerService.dumpStackTraces(firstPids, isSilentAnr ? null : processCpuTracker, isSilentAnr ? null : lastPids, nativePids, tracesFileException, offsets); nativePids, tracesFileException, offsets, annotation); if (isMonitorCpuUsage()) { mService.updateCpuStatsNow(); Loading Loading @@ -467,7 +467,7 @@ class ProcessErrorStateRecord { final ProcessRecord parentPr = parentProcess != null ? (ProcessRecord) parentProcess.mOwner : null; mService.addErrorToDropBox("anr", mApp, mApp.processName, activityShortComponentName, parentShortComponentName, parentPr, annotation, report.toString(), tracesFile, parentShortComponentName, parentPr, null, report.toString(), tracesFile, null, new Float(loadingProgress), incrementalMetrics, errorId); if (mApp.getWindowProcessController().appNotResponding(info.toString(), Loading Loading
services/core/java/com/android/server/SystemServerInitThreadPool.java +1 −1 Original line number Diff line number Diff line Loading @@ -192,7 +192,7 @@ public final class SystemServerInitThreadPool implements Dumpable { final ArrayList<Integer> pids = new ArrayList<>(); pids.add(Process.myPid()); ActivityManagerService.dumpStackTraces(pids, null, null, Watchdog.getInterestingNativePids(), null); Watchdog.getInterestingNativePids(), null, null); } @Override Loading
services/core/java/com/android/server/Watchdog.java +4 −3 Original line number Diff line number Diff line Loading @@ -658,7 +658,7 @@ public class Watchdog { // We've waited half the deadlock-detection interval. Pull a stack // trace and wait another half. ActivityManagerService.dumpStackTraces(pids, null, null, getInterestingNativePids(), null); getInterestingNativePids(), null, subject); continue; } Loading @@ -674,7 +674,7 @@ public class Watchdog { StringWriter tracesFileException = new StringWriter(); final File stack = ActivityManagerService.dumpStackTraces( pids, processCpuTracker, new SparseArray<>(), getInterestingNativePids(), tracesFileException); tracesFileException, subject); // Give some extra time to make sure the stack traces get written. // The system's been hanging for a minute, another second or two won't hurt much. Loading @@ -699,7 +699,8 @@ public class Watchdog { if (mActivity != null) { mActivity.addErrorToDropBox( "watchdog", null, "system_server", null, null, null, localSubject, report.toString(), stack, null, null, null, null); null, report.toString(), stack, null, null, null, null); } FrameworkStatsLog.write(FrameworkStatsLog.SYSTEM_SERVER_WATCHDOG_OCCURRED, localSubject); Loading
services/core/java/com/android/server/am/ActivityManagerService.java +28 −2 Original line number Diff line number Diff line Loading @@ -407,6 +407,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -3153,7 +3154,23 @@ public class ActivityManagerService extends IActivityManager.Stub ProcessCpuTracker processCpuTracker, SparseArray<Boolean> lastPids, ArrayList<Integer> nativePids, StringWriter logExceptionCreatingFile) { return dumpStackTraces(firstPids, processCpuTracker, lastPids, nativePids, logExceptionCreatingFile, null); logExceptionCreatingFile, null, null); } /** * If a stack trace dump file is configured, dump process stack traces. * @param firstPids of dalvik VM processes to dump stack traces for first * @param lastPids of dalvik VM processes to dump stack traces for last * @param nativePids optional list of native pids to dump stack crawls * @param logExceptionCreatingFile optional writer to which we log errors creating the file * @param subject optional line related to the error */ public static File dumpStackTraces(ArrayList<Integer> firstPids, ProcessCpuTracker processCpuTracker, SparseArray<Boolean> lastPids, ArrayList<Integer> nativePids, StringWriter logExceptionCreatingFile, String subject) { return dumpStackTraces(firstPids, processCpuTracker, lastPids, nativePids, logExceptionCreatingFile, null, subject); } /** Loading @@ -3163,7 +3180,7 @@ public class ActivityManagerService extends IActivityManager.Stub /* package */ static File dumpStackTraces(ArrayList<Integer> firstPids, ProcessCpuTracker processCpuTracker, SparseArray<Boolean> lastPids, ArrayList<Integer> nativePids, StringWriter logExceptionCreatingFile, long[] firstPidOffsets) { long[] firstPidOffsets, String subject) { ArrayList<Integer> extraPids = null; Slog.i(TAG, "dumpStackTraces pids=" + lastPids + " nativepids=" + nativePids); Loading Loading @@ -3215,6 +3232,15 @@ public class ActivityManagerService extends IActivityManager.Stub return null; } if (subject != null) { try (FileOutputStream fos = new FileOutputStream(tracesFile, true)) { String header = "Subject: " + subject + "\n"; fos.write(header.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { Slog.w(TAG, "Exception writing subject to ANR dump file:", e); } } Pair<Long, Long> offsets = dumpStackTraces( tracesFile.getAbsolutePath(), firstPids, nativePids, extraPids); if (firstPidOffsets != null) { Loading
services/core/java/com/android/server/am/ProcessErrorStateRecord.java +2 −2 Original line number Diff line number Diff line Loading @@ -377,7 +377,7 @@ class ProcessErrorStateRecord { final long[] offsets = new long[2]; File tracesFile = ActivityManagerService.dumpStackTraces(firstPids, isSilentAnr ? null : processCpuTracker, isSilentAnr ? null : lastPids, nativePids, tracesFileException, offsets); nativePids, tracesFileException, offsets, annotation); if (isMonitorCpuUsage()) { mService.updateCpuStatsNow(); Loading Loading @@ -467,7 +467,7 @@ class ProcessErrorStateRecord { final ProcessRecord parentPr = parentProcess != null ? (ProcessRecord) parentProcess.mOwner : null; mService.addErrorToDropBox("anr", mApp, mApp.processName, activityShortComponentName, parentShortComponentName, parentPr, annotation, report.toString(), tracesFile, parentShortComponentName, parentPr, null, report.toString(), tracesFile, null, new Float(loadingProgress), incrementalMetrics, errorId); if (mApp.getWindowProcessController().appNotResponding(info.toString(), Loading