// Test sending an empty chunk.
System.out.println("Sending empty data array");
res = processChunk(newbyte[0]);
System.out.println("JVMTI returned chunk: " + printChunk(res));
// Test sending chunk through DdmServer#sendChunk
Chunk c = new Chunk(
MY_DDMS_TYPE, newbyte[] { 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10 }, 0, 8);
AwaitChunkHandler h = new AwaitChunkHandler((x) -> chunkEq(c, x), CURRENT_HANDLER);
CURRENT_HANDLER = h;
System.out.println("Sending chunk: " + printChunk(c));
DdmServer.sendChunk(c);
h.Await();
CURRENT_HANDLER = BaseHandler;
// Test getting back an empty chunk.
data = newbyte[] { 0x1 };
System.out.println( "Sending data " + Arrays.toString(data) + " to chunk handler " + MY_EMPTY_DDMS_TYPE);
res = processChunk(new Chunk(MY_EMPTY_DDMS_TYPE, data, 0, 1));
System.out.println("JVMTI returned chunk: " + printChunk(res));
// Test getting back an invalid chunk.
System.out.println( "Sending data " + Arrays.toString(data) + " to chunk handler " + MY_INVALID_DDMS_TYPE); try {
res = processChunk(new Chunk(MY_INVALID_DDMS_TYPE, data, 0, 1));
System.out.println("JVMTI returned chunk: " + printChunk(res));
} catch (RuntimeException e) {
System.out.println("Got error: " + e.getMessage());
}
// Test thread chunks are sent. finalboolean[] types_seen = newboolean[] { false, false, false };
AwaitChunkHandler wait_thd= new AwaitChunkHandler(
(x) -> types_seen[0] && types_seen[1] && types_seen[2],
(type, cdata) -> { switch (type) { case TYPE_THCR:
types_seen[0] = true; break; case TYPE_THNM:
types_seen[1] = true; break; case TYPE_THDE:
types_seen[2] = true; break; default: // We don't want to print other types. break;
}
});
CURRENT_HANDLER = wait_thd;
DdmVmInternal.setThreadNotifyEnabled(true);
System.out.println("threadNotify started!"); finalThread thr = newThread(() -> { return; }, "THREAD");
thr.start();
System.out.println("Target thread started!");
thr.join();
System.out.println("Target thread finished!");
DdmVmInternal.setThreadNotifyEnabled(false);
System.out.println("threadNotify Disabled!");
wait_thd.Await(); // Make sure we saw at least one of Thread-create, Thread name, & thread death. if (!types_seen[0] || !types_seen[1] || !types_seen[2]) {
System.out.println("Didn't see expected chunks for thread creation! got: " +
Arrays.toString(types_seen));
} else {
System.out.println("Saw expected thread events.");
}
// method Tracing
AwaitChunkHandler mpse = new AwaitChunkHandler((x) -> x.type == TYPE_MPSE, (type, cdata) -> { // This chunk includes timing and thread information so we just check the type. if (type == TYPE_MPSE) {
System.out.println("Expected chunk type published: " + type);
}
});
CURRENT_HANDLER = mpse;
VMDebug.startMethodTracingDdms(/*size: default*/0, /*flags: none*/ 0, /*sampling*/ false, /*interval*/ 0);
doNothing();
doNothing();
doNothing();
doNothing();
VMDebug.stopMethodTracing();
mpse.Await();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.