use of com.oracle.truffle.espresso.jdwp.impl.ClassPrepareRequest in project graal by oracle.
the class VMEventListenerImpl method classPrepared.
@Override
@TruffleBoundary
public void classPrepared(KlassRef klass, Object prepareThread) {
if (connection == null) {
return;
}
// prepare the event and ship
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
// check if event should be reported based on the current patterns
String dotName = klass.getNameAsString().replace('/', '.');
ClassPrepareRequest[] allClassPrepareRequests = getAllClassPrepareRequests();
ArrayList<ClassPrepareRequest> toSend = new ArrayList<>();
byte suspendPolicy = SuspendStrategy.NONE;
for (ClassPrepareRequest cpr : allClassPrepareRequests) {
Pattern[] patterns = cpr.getPatterns();
for (Pattern pattern : patterns) {
if ("".equals(pattern.pattern()) || pattern.matcher(dotName).matches()) {
toSend.add(cpr);
byte cprPolicy = cpr.getSuspendPolicy();
if (cprPolicy == SuspendStrategy.ALL) {
suspendPolicy = SuspendStrategy.ALL;
} else if (cprPolicy == SuspendStrategy.EVENT_THREAD && suspendPolicy != SuspendStrategy.ALL) {
suspendPolicy = SuspendStrategy.EVENT_THREAD;
}
}
}
}
if (!toSend.isEmpty()) {
stream.writeByte(suspendPolicy);
stream.writeInt(toSend.size());
for (ClassPrepareRequest cpr : toSend) {
stream.writeByte(RequestedJDWPEvents.CLASS_PREPARE);
stream.writeInt(cpr.getRequestId());
stream.writeLong(ids.getIdAsLong(prepareThread));
stream.writeByte(TypeTag.getKind(klass));
stream.writeLong(ids.getIdAsLong(klass));
stream.writeString(klass.getTypeAsString());
stream.writeInt(klass.getStatus());
}
if (suspendPolicy != SuspendStrategy.NONE) {
// the current thread has just prepared the class
// so we must suspend according to suspend policy
debuggerController.immediateSuspend(prepareThread, suspendPolicy, new Callable<Void>() {
@Override
public Void call() {
if (holdEvents) {
heldEvents.add(stream);
} else {
JDWP.LOGGER.fine(() -> "SENDING CLASS PREPARE EVENT FOR KLASS: " + klass.getNameAsString() + " WITH THREAD " + context.getThreadName(prepareThread));
connection.queuePacket(stream);
}
return null;
}
});
} else {
if (holdEvents) {
heldEvents.add(stream);
} else {
connection.queuePacket(stream);
}
}
}
}
Aggregations