logWriter.println("==> testedThreadID = " + testedThreadID);
logWriter.println("==> suspend testedThread...");
debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
// getting the thread group ID
CommandPacket packet = new CommandPacket(
JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
JDWPCommands.ThreadReferenceCommandSet.CurrentContendedMonitorCommand);
packet.setNextValueAsThreadID(testedThreadID);
logWriter.println("send \"CurrentContendedMonitor\" command");
ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet);
checkReplyPacket(reply, "ThreadReference::CurrentContendedMonitor command");
TaggedObject tobj = reply.getNextValueAsTaggedObject();
logWriter.println("\ttagged-object tag: "
+ JDWPConstants.Tag.getName(tobj.tag) + "(" + tobj.tag + ") "
+ "ID: " + tobj.objectID);
packet = new CommandPacket(
JDWPCommands.ObjectReferenceCommandSet.CommandSetID,
JDWPCommands.ObjectReferenceCommandSet.MonitorInfoCommand);
packet.setNextValueAsObjectID(tobj.objectID);
ReplyPacket replyObj = debuggeeWrapper.vmMirror.performCommand(packet);
checkReplyPacket(replyObj, "ObjectReference::MonitorInfo command");
replyObj.getNextValueAsThreadID();
replyObj.getNextValueAsInt();
int waiters = replyObj.getNextValueAsInt();
long waiterID;
String waiterName;
for (int i = 0; i < waiters; i++) {
waiterID = replyObj.getNextValueAsThreadID();
waiterName = debuggeeWrapper.vmMirror.getThreadName(waiterID);
logWriter.println("\twaiter: "
+ " " + waiterName
+ "(" + waiterID + ")");
if (waiterID != testedThreadID) {
logWriter.printError("wrong owner: " + waiterID);
assertEquals("ObjectReference::MonitorInfo returned wrong owner ID,",
testedThreadID, waiterID);
}
assertString("ObjectReference::MonitorInfo returned invalid waiter name,",
OwnedMonitorsDebuggee.TESTED_THREAD, waiterName);
}
// interrupt
packet = new CommandPacket(
JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
JDWPCommands.ThreadReferenceCommandSet.InterruptCommand);
packet.setNextValueAsThreadID(testedThreadID);
logWriter.println("send \"Interrupt\" command");
reply = debuggeeWrapper.vmMirror.performCommand(packet);
checkReplyPacket(reply, "ThreadReference::Interrupt command");
short err = reply.getErrorCode();