summaryrefslogtreecommitdiffstats
path: root/cmds/am
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-03-03 17:04:12 -0800
committerDianne Hackborn <hackbod@google.com>2015-03-06 16:42:03 -0800
commitb9a5e4ad30c9add140fd13491419ae66e947809d (patch)
tree34000ecab4b9ef4175687e1cba78456524481a0f /cmds/am
parenteb803aef3b0f55785624e6a51deae867c1a95e88 (diff)
downloadframeworks_base-b9a5e4ad30c9add140fd13491419ae66e947809d.zip
frameworks_base-b9a5e4ad30c9add140fd13491419ae66e947809d.tar.gz
frameworks_base-b9a5e4ad30c9add140fd13491419ae66e947809d.tar.bz2
Add new debug feature to automatically create heap dumps.
Not yet working, unless you turn off SELinux enforcing. We need to update SElinux to allow the system process to give apps access to /data/system/heapdump/javaheap.bin. Currently watching can only be enabled through the shell, such as: adb shell am set-watch-heap com.android.systemui 1024 The last number is the process pss size in bytes, so this is asking us to warn if it goes about 1K which will be all the time. Change-Id: I2089e5db2927afca0bf01a363c6247ee5dcb26e8
Diffstat (limited to 'cmds/am')
-rw-r--r--cmds/am/src/com/android/commands/am/Am.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index bc0c451..29ba1d7 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -117,6 +117,8 @@ public class Am extends BaseCommand {
" am dumpheap [--user <USER_ID> current] [-n] <PROCESS> <FILE>\n" +
" am set-debug-app [-w] [--persistent] <PACKAGE>\n" +
" am clear-debug-app\n" +
+ " am set-watch-heap <PROCESS> <MEM-LIMIT>\n" +
+ " am clear-watch-heap\n" +
" am monitor [--gdb <port>]\n" +
" am hang [--allow-restart]\n" +
" am restart\n" +
@@ -211,6 +213,11 @@ public class Am extends BaseCommand {
"\n" +
"am clear-debug-app: clear the previously set-debug-app.\n" +
"\n" +
+ "am set-watch-heap: start monitoring pss size of <PROCESS>, if it is at or\n" +
+ " above <HEAP-LIMIT> then a heap dump is collected for the user to report\n" +
+ "\n" +
+ "am clear-watch-heap: clear the previously set-watch-heap.\n" +
+ "\n" +
"am bug-report: request bug report generation; will launch UI\n" +
" when done to select where it should be delivered.\n" +
"\n" +
@@ -342,6 +349,10 @@ public class Am extends BaseCommand {
runSetDebugApp();
} else if (op.equals("clear-debug-app")) {
runClearDebugApp();
+ } else if (op.equals("set-watch-heap")) {
+ runSetWatchHeap();
+ } else if (op.equals("clear-watch-heap")) {
+ runClearWatchHeap();
} else if (op.equals("bug-report")) {
runBugReport();
} else if (op.equals("monitor")) {
@@ -1172,6 +1183,17 @@ public class Am extends BaseCommand {
mAm.setDebugApp(null, false, true);
}
+ private void runSetWatchHeap() throws Exception {
+ String proc = nextArgRequired();
+ String limit = nextArgRequired();
+ mAm.setDumpHeapDebugLimit(proc, Long.parseLong(limit));
+ }
+
+ private void runClearWatchHeap() throws Exception {
+ String proc = nextArgRequired();
+ mAm.setDumpHeapDebugLimit(proc, -1);
+ }
+
private void runBugReport() throws Exception {
mAm.requestBugReport();
System.out.println("Your lovely bug report is being created; please be patient.");