Merge "Merge MPSE and SPSE Chunk handlers for ddms."
This commit is contained in:
@@ -37,6 +37,7 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
public static final int CHUNK_SPSS = type("SPSS");
|
public static final int CHUNK_SPSS = type("SPSS");
|
||||||
public static final int CHUNK_SPSE = type("SPSE");
|
public static final int CHUNK_SPSE = type("SPSE");
|
||||||
|
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
private static DdmHandleProfiling mInstance = new DdmHandleProfiling();
|
private static DdmHandleProfiling mInstance = new DdmHandleProfiling();
|
||||||
|
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
* Handle a chunk of data.
|
* Handle a chunk of data.
|
||||||
*/
|
*/
|
||||||
public Chunk handleChunk(Chunk request) {
|
public Chunk handleChunk(Chunk request) {
|
||||||
if (false)
|
if (DEBUG)
|
||||||
Log.v("ddm-heap", "Handling " + name(request.type) + " chunk");
|
Log.v("ddm-heap", "Handling " + name(request.type) + " chunk");
|
||||||
int type = request.type;
|
int type = request.type;
|
||||||
|
|
||||||
@@ -83,13 +84,13 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
} else if (type == CHUNK_MPSS) {
|
} else if (type == CHUNK_MPSS) {
|
||||||
return handleMPSS(request);
|
return handleMPSS(request);
|
||||||
} else if (type == CHUNK_MPSE) {
|
} else if (type == CHUNK_MPSE) {
|
||||||
return handleMPSE(request);
|
return handleMPSEOrSPSE(request, "Method");
|
||||||
} else if (type == CHUNK_MPRQ) {
|
} else if (type == CHUNK_MPRQ) {
|
||||||
return handleMPRQ(request);
|
return handleMPRQ(request);
|
||||||
} else if (type == CHUNK_SPSS) {
|
} else if (type == CHUNK_SPSS) {
|
||||||
return handleSPSS(request);
|
return handleSPSS(request);
|
||||||
} else if (type == CHUNK_SPSE) {
|
} else if (type == CHUNK_SPSE) {
|
||||||
return handleSPSE(request);
|
return handleMPSEOrSPSE(request, "Sample");
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unknown packet "
|
throw new RuntimeException("Unknown packet "
|
||||||
+ ChunkHandler.name(type));
|
+ ChunkHandler.name(type));
|
||||||
@@ -106,7 +107,7 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
int flags = in.getInt();
|
int flags = in.getInt();
|
||||||
int len = in.getInt();
|
int len = in.getInt();
|
||||||
String fileName = getString(in, len);
|
String fileName = getString(in, len);
|
||||||
if (false)
|
if (DEBUG)
|
||||||
Log.v("ddm-heap", "Method profiling start: filename='" + fileName
|
Log.v("ddm-heap", "Method profiling start: filename='" + fileName
|
||||||
+ "', size=" + bufferSize + ", flags=" + flags);
|
+ "', size=" + bufferSize + ", flags=" + flags);
|
||||||
|
|
||||||
@@ -146,7 +147,7 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
|
|
||||||
int bufferSize = in.getInt();
|
int bufferSize = in.getInt();
|
||||||
int flags = in.getInt();
|
int flags = in.getInt();
|
||||||
if (false) {
|
if (DEBUG) {
|
||||||
Log.v("ddm-heap", "Method prof stream start: size=" + bufferSize
|
Log.v("ddm-heap", "Method prof stream start: size=" + bufferSize
|
||||||
+ ", flags=" + flags);
|
+ ", flags=" + flags);
|
||||||
}
|
}
|
||||||
@@ -160,20 +161,18 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle a "Method Profiling w/Streaming End" request.
|
* Handle a "Method Profiling w/Streaming End" request or a
|
||||||
|
* "Sample Profiling w/Streaming End" request.
|
||||||
*/
|
*/
|
||||||
private Chunk handleMPSE(Chunk request) {
|
private Chunk handleMPSEOrSPSE(Chunk request, String type) {
|
||||||
byte result;
|
if (DEBUG) {
|
||||||
|
Log.v("ddm-heap", type + " prof stream end");
|
||||||
if (false) {
|
|
||||||
Log.v("ddm-heap", "Method prof stream end");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Debug.stopMethodTracing();
|
Debug.stopMethodTracing();
|
||||||
result = 0;
|
|
||||||
} catch (RuntimeException re) {
|
} catch (RuntimeException re) {
|
||||||
Log.w("ddm-heap", "Method prof stream end failed: "
|
Log.w("ddm-heap", type + " prof stream end failed: "
|
||||||
+ re.getMessage());
|
+ re.getMessage());
|
||||||
return createFailChunk(1, re.getMessage());
|
return createFailChunk(1, re.getMessage());
|
||||||
}
|
}
|
||||||
@@ -202,7 +201,7 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
int bufferSize = in.getInt();
|
int bufferSize = in.getInt();
|
||||||
int flags = in.getInt();
|
int flags = in.getInt();
|
||||||
int interval = in.getInt();
|
int interval = in.getInt();
|
||||||
if (false) {
|
if (DEBUG) {
|
||||||
Log.v("ddm-heap", "Sample prof stream start: size=" + bufferSize
|
Log.v("ddm-heap", "Sample prof stream start: size=" + bufferSize
|
||||||
+ ", flags=" + flags + ", interval=" + interval);
|
+ ", flags=" + flags + ", interval=" + interval);
|
||||||
}
|
}
|
||||||
@@ -214,25 +213,5 @@ public class DdmHandleProfiling extends ChunkHandler {
|
|||||||
return createFailChunk(1, re.getMessage());
|
return createFailChunk(1, re.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Handle a "Sample Profiling w/Streaming End" request.
|
|
||||||
*/
|
|
||||||
private Chunk handleSPSE(Chunk request) {
|
|
||||||
if (false) {
|
|
||||||
Log.v("ddm-heap", "Sample prof stream end");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Debug.stopMethodTracing();
|
|
||||||
} catch (RuntimeException re) {
|
|
||||||
Log.w("ddm-heap", "Sample prof stream end failed: "
|
|
||||||
+ re.getMessage());
|
|
||||||
return createFailChunk(1, re.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* VM sent the (perhaps very large) response directly */
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user