diff options
author | Andy McFadden <fadden@android.com> | 2010-01-28 16:54:37 -0800 |
---|---|---|
committer | Andy McFadden <fadden@android.com> | 2010-01-29 13:29:51 -0800 |
commit | 07a9661f31797a68b8ecd3f135fe1417f214663b (patch) | |
tree | 6aefeeef71d4cae101bf20e993925b64ae56a2e0 /core/java/android/ddm/DdmHandleHeap.java | |
parent | d425a45f8d7c0e94d2db4c0a5c8157e6c846b853 (diff) | |
download | frameworks_base-07a9661f31797a68b8ecd3f135fe1417f214663b.zip frameworks_base-07a9661f31797a68b8ecd3f135fe1417f214663b.tar.gz frameworks_base-07a9661f31797a68b8ecd3f135fe1417f214663b.tar.bz2 |
Added dumpHprofDataDdms() call.
This adds a hidden dumpHprofDataDdms() method, which initiates an hprof
dump that sends its data directly to DDMS.
Diffstat (limited to 'core/java/android/ddm/DdmHandleHeap.java')
-rw-r--r-- | core/java/android/ddm/DdmHandleHeap.java | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/core/java/android/ddm/DdmHandleHeap.java b/core/java/android/ddm/DdmHandleHeap.java index 95fa0a2..fa0fbbf 100644 --- a/core/java/android/ddm/DdmHandleHeap.java +++ b/core/java/android/ddm/DdmHandleHeap.java @@ -34,6 +34,7 @@ public class DdmHandleHeap extends ChunkHandler { public static final int CHUNK_HPIF = type("HPIF"); public static final int CHUNK_HPSG = type("HPSG"); public static final int CHUNK_HPDU = type("HPDU"); + public static final int CHUNK_HPDS = type("HPDS"); public static final int CHUNK_NHSG = type("NHSG"); public static final int CHUNK_HPGC = type("HPGC"); public static final int CHUNK_REAE = type("REAE"); @@ -53,6 +54,7 @@ public class DdmHandleHeap extends ChunkHandler { DdmServer.registerHandler(CHUNK_HPIF, mInstance); DdmServer.registerHandler(CHUNK_HPSG, mInstance); DdmServer.registerHandler(CHUNK_HPDU, mInstance); + DdmServer.registerHandler(CHUNK_HPDS, mInstance); DdmServer.registerHandler(CHUNK_NHSG, mInstance); DdmServer.registerHandler(CHUNK_HPGC, mInstance); DdmServer.registerHandler(CHUNK_REAE, mInstance); @@ -86,6 +88,8 @@ public class DdmHandleHeap extends ChunkHandler { return handleHPSGNHSG(request, false); } else if (type == CHUNK_HPDU) { return handleHPDU(request); + } else if (type == CHUNK_HPDS) { + return handleHPDS(request); } else if (type == CHUNK_NHSG) { return handleHPSGNHSG(request, true); } else if (type == CHUNK_HPGC) { @@ -167,7 +171,7 @@ public class DdmHandleHeap extends ChunkHandler { result = -1; } catch (IOException ioe) { result = -1; - } catch (RuntimeException ioe) { + } catch (RuntimeException re) { result = -1; } @@ -177,6 +181,38 @@ public class DdmHandleHeap extends ChunkHandler { } /* + * Handle a "HeaP Dump Streaming" request. + * + * This tells the VM to create a heap dump and send it directly to + * DDMS. The dumps are large enough that we don't want to copy the + * data into a byte[] and send it from here. + */ + private Chunk handleHPDS(Chunk request) { + ByteBuffer in = wrapChunk(request); + byte result; + + /* get the filename for the output file */ + if (Config.LOGD) + Log.d("ddm-heap", "Heap dump: [DDMS]"); + + String failMsg = null; + try { + Debug.dumpHprofDataDdms(); + } catch (UnsupportedOperationException uoe) { + failMsg = "hprof dumps not supported in this VM"; + } catch (RuntimeException re) { + failMsg = "Exception: " + re.getMessage(); + } + + if (failMsg != null) { + Log.w("ddm-heap", failMsg); + return createFailChunk(1, failMsg); + } else { + return null; + } + } + + /* * Handle a "HeaP Garbage Collection" request. */ private Chunk handleHPGC(Chunk request) { |