use of com.oracle.truffle.espresso.jdwp.impl.PacketStream in project graal by oracle.
the class VMEventListenerImpl method fieldModificationBreakpointHit.
@Override
public void fieldModificationBreakpointHit(FieldBreakpointEvent event, Object currentThread, CallFrame callFrame) {
if (connection == null) {
return;
}
PacketStream stream = writeSharedFieldInformation(event, currentThread, callFrame, RequestedJDWPEvents.FIELD_MODIFICATION);
// value about to be set
Object value = event.getValue();
byte tag = context.getTag(value);
JDWP.writeValue(tag, value, 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 breakpointHit.
@Override
public void breakpointHit(BreakpointInfo info, CallFrame frame, Object currentThread) {
if (connection == null) {
return;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
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());
JDWP.LOGGER.fine(() -> "Sending breakpoint hit event in thread: " + context.getThreadName(currentThread) + " with suspension policy: " + info.getSuspendPolicy());
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 sendMonitorContendedEnterEvent.
private void sendMonitorContendedEnterEvent(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_ENTER);
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 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 stepCompleted.
@Override
public void stepCompleted(SteppingInfo info, CallFrame currentFrame) {
if (connection == null) {
return;
}
if (info.isPopFrames()) {
// send reply packet when "step" is completed
PacketStream reply = new PacketStream().replyPacket().id(info.getRequestId());
JDWP.LOGGER.fine(() -> "Sending pop frames reply packet");
if (holdEvents) {
heldEvents.add(reply);
} else {
connection.queuePacket(reply);
}
} else {
// single step completed events
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
stream.writeByte(info.getSuspendPolicy());
// # events in reply
stream.writeInt(1);
stream.writeByte(RequestedJDWPEvents.SINGLE_STEP);
stream.writeInt(info.getRequestId());
stream.writeLong(currentFrame.getThreadId());
// location
stream.writeByte(currentFrame.getTypeTag());
stream.writeLong(currentFrame.getClassId());
stream.writeLong(currentFrame.getMethodId());
long codeIndex = info.getStepOutBCI() != -1 ? info.getStepOutBCI() : currentFrame.getCodeIndex();
stream.writeLong(codeIndex);
JDWP.LOGGER.fine(() -> "Sending step completed 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 exceptionThrown.
@Override
public void exceptionThrown(BreakpointInfo info, Object currentThread, Object exception, CallFrame[] callFrames) {
if (connection == null) {
return;
}
PacketStream stream = new PacketStream().commandPacket().commandSet(64).command(100);
CallFrame top = callFrames[0];
stream.writeByte(info.getSuspendPolicy());
// # events in reply
stream.writeInt(1);
stream.writeByte(RequestedJDWPEvents.EXCEPTION);
stream.writeInt(info.getRequestId());
stream.writeLong(ids.getIdAsLong(currentThread));
// location
stream.writeByte(top.getTypeTag());
stream.writeLong(top.getClassId());
stream.writeLong(ids.getIdAsLong(top.getMethod()));
stream.writeLong(top.getCodeIndex());
// exception
stream.writeByte(TagConstants.OBJECT);
stream.writeLong(context.getIds().getIdAsLong(exception));
// catch-location
boolean caught = false;
for (CallFrame callFrame : callFrames) {
MethodRef method = callFrame.getMethod();
int catchLocation = context.getCatchLocation(method, exception, (int) callFrame.getCodeIndex());
if (catchLocation != -1) {
stream.writeByte(callFrame.getTypeTag());
stream.writeLong(callFrame.getClassId());
stream.writeLong(callFrame.getMethodId());
stream.writeLong(catchLocation);
caught = true;
break;
}
}
if (!caught) {
stream.writeByte((byte) 1);
stream.writeLong(0);
stream.writeLong(0);
stream.writeLong(0);
}
if (holdEvents) {
heldEvents.add(stream);
} else {
connection.queuePacket(stream);
}
}
Aggregations