use of com.oracle.truffle.espresso.jdwp.impl.PacketStream in project graal by oracle.
the class VMEventListenerImpl method threadStarted.
@Override
public void threadStarted(Object thread) {
if (connection == null || threadStartedRequestId == 0) {
return;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
stream.writeByte(threadStartSuspendPolicy);
suspend(threadStartSuspendPolicy, thread);
// # events in reply
stream.writeInt(1);
stream.writeByte(RequestedJDWPEvents.THREAD_START);
stream.writeInt(threadStartedRequestId);
stream.writeLong(ids.getIdAsLong(thread));
JDWP.LOGGER.fine(() -> "sending thread started event for thread: " + context.getThreadName(thread));
if (holdEvents) {
heldEvents.add(stream);
} else {
connection.queuePacket(stream);
}
}
use of com.oracle.truffle.espresso.jdwp.impl.PacketStream in project graal by oracle.
the class VMEventListenerImpl method vmStarted.
public void vmStarted(boolean suspend) {
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
stream.writeByte(suspend ? SuspendStrategy.ALL : SuspendStrategy.NONE);
stream.writeInt(1);
stream.writeByte(RequestedJDWPEvents.VM_START);
stream.writeInt(vmStartRequestId != -1 ? vmStartRequestId : 0);
stream.writeLong(context.getIds().getIdAsLong(initialThread));
connection.queuePacket(stream);
}
use of com.oracle.truffle.espresso.jdwp.impl.PacketStream 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);
}
}
}
}
use of com.oracle.truffle.espresso.jdwp.impl.PacketStream in project graal by oracle.
the class VMEventListenerImpl method threadDied.
@Override
public void threadDied(Object thread) {
if (connection == null || threadDeathRequestId == 0) {
return;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
stream.writeByte(threadDeathSuspendPolicy);
suspend(threadDeathSuspendPolicy, thread);
// # events in reply
stream.writeInt(1);
stream.writeByte(RequestedJDWPEvents.THREAD_DEATH);
stream.writeInt(threadDeathRequestId);
stream.writeLong(ids.getIdAsLong(thread));
if (holdEvents) {
heldEvents.add(stream);
} else {
connection.queuePacket(stream);
}
}
use of com.oracle.truffle.espresso.jdwp.impl.PacketStream in project graal by oracle.
the class VMEventListenerImpl method sendMonitorWaitEvent.
public void sendMonitorWaitEvent(Object monitor, long timeout, RequestFilter filter, CallFrame currentFrame) {
if (connection == null) {
return;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
stream.writeByte(filter.getSuspendPolicy());
// # events in reply
stream.writeInt(1);
stream.writeByte(RequestedJDWPEvents.MONITOR_WAIT);
stream.writeInt(filter.getRequestId());
stream.writeLong(currentFrame.getThreadId());
// tagged object ID
stream.writeByte(context.getTag(monitor));
stream.writeLong(context.getIds().getIdAsLong(monitor));
// location
stream.writeByte(currentFrame.getTypeTag());
stream.writeLong(currentFrame.getClassId());
stream.writeLong(currentFrame.getMethodId());
long codeIndex = currentFrame.getCodeIndex();
stream.writeLong(codeIndex);
// timeout
stream.writeLong(timeout);
JDWP.LOGGER.fine(() -> "Sending monitor wait event");
if (holdEvents) {
heldEvents.add(stream);
} else {
connection.queuePacket(stream);
}
}
Aggregations