diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-10-28 21:59:18 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-10-28 21:59:18 +0000 |
commit | 3a702cb5d7eac0d8504c67145dded5d45a9c1027 (patch) | |
tree | 7537b33c5a551a2e713ea49545f3af65889ab1bb /services/java/com/android/server/am | |
parent | 170735d46001659e64522f451681a0618685efc6 (diff) | |
parent | e77187d01856fbc083d3fb651f43b2fb9ced716c (diff) | |
download | frameworks_base-3a702cb5d7eac0d8504c67145dded5d45a9c1027.zip frameworks_base-3a702cb5d7eac0d8504c67145dded5d45a9c1027.tar.gz frameworks_base-3a702cb5d7eac0d8504c67145dded5d45a9c1027.tar.bz2 |
Merge "Fix issue #11391003: Allow dumpsys meminfo to be used with native processes" into klp-dev
Diffstat (limited to 'services/java/com/android/server/am')
-rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 83 |
1 files changed, 69 insertions, 14 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index ab9d9bd..7cef0a4 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -11503,7 +11503,6 @@ public final class ActivityManagerService extends ActivityManagerNative try { pid = Integer.parseInt(args[start]); } catch (NumberFormatException e) { - } for (int i=mLruProcesses.size()-1; i>=0; i--) { ProcessRecord proc = mLruProcesses.get(i); @@ -11514,7 +11513,6 @@ public final class ActivityManagerService extends ActivityManagerNative } } if (procs.size() <= 0) { - pw.println("No process found for: " + args[start]); return null; } } else { @@ -11528,6 +11526,7 @@ public final class ActivityManagerService extends ActivityManagerNative PrintWriter pw, String[] args) { ArrayList<ProcessRecord> procs = collectProcesses(pw, 0, args); if (procs == null) { + pw.println("No process found for: " + args[0]); return; } @@ -11563,6 +11562,7 @@ public final class ActivityManagerService extends ActivityManagerNative final void dumpDbInfo(FileDescriptor fd, PrintWriter pw, String[] args) { ArrayList<ProcessRecord> procs = collectProcesses(pw, 0, args); if (procs == null) { + pw.println("No process found for: " + args[0]); return; } @@ -11709,6 +11709,17 @@ public final class ActivityManagerService extends ActivityManagerNative "prev", "serviceb", "cached" }; + private final void dumpApplicationMemoryUsageHeader(PrintWriter pw, long uptime, + long realtime, boolean isCheckinRequest, boolean isCompact) { + if (isCheckinRequest || isCompact) { + // short checkin version + pw.print("time,"); pw.print(uptime); pw.print(","); pw.println(realtime); + } else { + pw.println("Applications Memory Usage (kB):"); + pw.println("Uptime: " + uptime + " Realtime: " + realtime); + } + } + final void dumpApplicationMemoryUsage(FileDescriptor fd, PrintWriter pw, String prefix, String[] args, boolean brief, PrintWriter categoryPw) { boolean dumpDetails = false; @@ -11748,26 +11759,71 @@ public final class ActivityManagerService extends ActivityManagerNative } } + final boolean isCheckinRequest = scanArgs(args, "--checkin"); + long uptime = SystemClock.uptimeMillis(); + long realtime = SystemClock.elapsedRealtime(); + final long[] tmpLong = new long[1]; + ArrayList<ProcessRecord> procs = collectProcesses(pw, opti, args); if (procs == null) { + // No Java processes. Maybe they want to print a native process. + if (args != null && args.length > opti + && args[opti].charAt(0) != '-') { + ArrayList<ProcessCpuTracker.Stats> nativeProcs + = new ArrayList<ProcessCpuTracker.Stats>(); + updateCpuStatsNow(); + int findPid = -1; + try { + findPid = Integer.parseInt(args[opti]); + } catch (NumberFormatException e) { + } + synchronized (mProcessCpuThread) { + final int N = mProcessCpuTracker.countStats(); + for (int i=0; i<N; i++) { + ProcessCpuTracker.Stats st = mProcessCpuTracker.getStats(i); + if (st.pid == findPid || (st.baseName != null + && st.baseName.equals(args[opti]))) { + nativeProcs.add(st); + } + } + } + if (nativeProcs.size() > 0) { + dumpApplicationMemoryUsageHeader(pw, uptime, realtime, isCheckinRequest, + isCompact); + Debug.MemoryInfo mi = null; + for (int i = nativeProcs.size() - 1 ; i >= 0 ; i--) { + final ProcessCpuTracker.Stats r = nativeProcs.get(i); + final int pid = r.pid; + if (!isCheckinRequest && dumpDetails) { + pw.println("\n** MEMINFO in pid " + pid + " [" + r.baseName + "] **"); + } + if (mi == null) { + mi = new Debug.MemoryInfo(); + } + if (dumpDetails || (!brief && !oomOnly)) { + Debug.getMemoryInfo(pid, mi); + } else { + mi.dalvikPss = (int)Debug.getPss(pid, tmpLong); + mi.dalvikPrivateDirty = (int)tmpLong[0]; + } + ActivityThread.dumpMemInfoTable(pw, mi, isCheckinRequest, dumpFullDetails, + dumpDalvik, pid, r.baseName, 0, 0, 0, 0, 0, 0); + if (isCheckinRequest) { + pw.println(); + } + } + return; + } + } + pw.println("No process found for: " + args[opti]); return; } - final boolean isCheckinRequest = scanArgs(args, "--checkin"); - long uptime = SystemClock.uptimeMillis(); - long realtime = SystemClock.elapsedRealtime(); - if (!brief && !oomOnly && (procs.size() == 1 || isCheckinRequest)) { dumpDetails = true; } - if (isCheckinRequest || isCompact) { - // short checkin version - pw.print("time,"); pw.print(uptime); pw.print(","); pw.println(realtime); - } else { - pw.println("Applications Memory Usage (kB):"); - pw.println("Uptime: " + uptime + " Realtime: " + realtime); - } + dumpApplicationMemoryUsageHeader(pw, uptime, realtime, isCheckinRequest, isCompact); String[] innerArgs = new String[args.length-opti]; System.arraycopy(args, opti, innerArgs, 0, args.length-opti); @@ -11780,7 +11836,6 @@ public final class ActivityManagerService extends ActivityManagerNative long oomPss[] = new long[DUMP_MEM_OOM_LABEL.length]; ArrayList<MemItem>[] oomProcs = (ArrayList<MemItem>[]) new ArrayList[DUMP_MEM_OOM_LABEL.length]; - final long[] tmpLong = new long[1]; long totalPss = 0; long cachedPss = 0; |