use of com.oracle.truffle.espresso.jdwp.impl.PacketStream in project graal by oracle.
the class VMEventListenerImpl method methodBreakpointHit.
@Override
public void methodBreakpointHit(MethodBreakpointEvent methodEvent, Object currentThread, CallFrame frame) {
if (connection == null) {
return;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
MethodBreakpointInfo info = methodEvent.getInfo();
stream.writeByte(info.getSuspendPolicy());
// # events in reply
stream.writeInt(1);
stream.writeByte(info.getEventKind());
stream.writeInt(info.getRequestId());
long threadId = ids.getIdAsLong(currentThread);
stream.writeLong(threadId);
// location
stream.writeByte(frame.getTypeTag());
stream.writeLong(frame.getClassId());
stream.writeLong(frame.getMethodId());
stream.writeLong(frame.getCodeIndex());
// return value if requested
if (info.getEventKind() == RequestedJDWPEvents.METHOD_EXIT_WITH_RETURN_VALUE) {
Object returnValue = methodEvent.getReturnValue();
byte tag = context.getTag(returnValue);
JDWP.writeValue(tag, returnValue, stream, true, context);
}
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 sendMonitorContendedEnteredEvent.
private void sendMonitorContendedEnteredEvent(MonitorEvent monitorEvent, CallFrame currentFrame) {
if (connection == null) {
return;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
stream.writeByte(monitorEvent.getFilter().getSuspendPolicy());
// # events in reply
stream.writeInt(1);
stream.writeByte(RequestedJDWPEvents.MONITOR_CONTENDED_ENTERED);
stream.writeInt(monitorEvent.getFilter().getRequestId());
stream.writeLong(currentFrame.getThreadId());
// tagged object ID
Object monitor = monitorEvent.getMonitor();
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);
JDWP.LOGGER.fine(() -> "Sending monitor contended entered event");
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 sendMonitorWaitedEvent.
private void sendMonitorWaitedEvent(Object monitor, boolean timedOut, 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_WAITED);
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.writeBoolean(timedOut);
JDWP.LOGGER.fine(() -> "Sending monitor wait event");
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 writeSharedFieldInformation.
private PacketStream writeSharedFieldInformation(FieldBreakpointEvent event, Object currentThread, CallFrame callFrame, byte eventType) {
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
FieldBreakpointInfo info = event.getInfo();
stream.writeByte(info.getSuspendPolicy());
// # events in reply
stream.writeInt(1);
stream.writeByte(eventType);
stream.writeInt(info.getRequestId());
long threadId = ids.getIdAsLong(currentThread);
stream.writeLong(threadId);
// location
stream.writeByte(callFrame.getTypeTag());
stream.writeLong(callFrame.getClassId());
stream.writeLong(callFrame.getMethodId());
stream.writeLong(callFrame.getCodeIndex());
// tagged refType
KlassRef klass = info.getKlass();
stream.writeByte(TypeTag.getKind(klass));
stream.writeLong(context.getIds().getIdAsLong(klass));
// fieldID
stream.writeLong(context.getIds().getIdAsLong(info.getField()));
// tagged object ID for field being accessed
stream.writeByte(TagConstants.OBJECT);
if (Modifier.isStatic(info.getField().getModifiers())) {
stream.writeLong(0);
} else {
stream.writeLong(context.getIds().getIdAsLong(event.getReceiver()));
}
return stream;
}
use of com.oracle.truffle.espresso.jdwp.impl.PacketStream in project graal by oracle.
the class VMEventListenerImpl method vmDied.
@Override
public boolean vmDied() {
if (connection == null) {
return false;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
stream.writeByte(vmDeathSuspendPolicy);
if (vmDeathRequestId != 0) {
stream.writeInt(2);
// requested event
stream.writeByte(RequestedJDWPEvents.VM_DEATH);
stream.writeInt(vmDeathRequestId);
// automatic event
} else {
// only automatic event to send
stream.writeInt(1);
}
stream.writeByte(RequestedJDWPEvents.VM_DEATH);
stream.writeInt(0);
// don't queue this packet, send immediately
connection.sendVMDied(stream);
return vmDeathSuspendPolicy != SuspendStrategy.NONE;
}
Aggregations