Implement ThreadReference.CurrentContendedMonitor and ThreadReference.Interrupt.
The JDWP test for CurrentContendedMonitor also uses Interrupt.
Change-Id: Id1f6add29b578a0494da672d21dd54f23e866475
diff --git a/src/jdwp/jdwp_handler.cc b/src/jdwp/jdwp_handler.cc
index f205c95..f0bb0b8 100644
--- a/src/jdwp/jdwp_handler.cc
+++ b/src/jdwp/jdwp_handler.cc
@@ -374,7 +374,7 @@
expandBufAdd1(reply, false); // canGetBytecodes
expandBufAdd1(reply, true); // canGetSyntheticAttribute
expandBufAdd1(reply, true); // canGetOwnedMonitorInfo
- expandBufAdd1(reply, false); // canGetCurrentContendedMonitor
+ expandBufAdd1(reply, true); // canGetCurrentContendedMonitor
expandBufAdd1(reply, true); // canGetMonitorInfo
return ERR_NONE;
}
@@ -1079,17 +1079,22 @@
return ERR_NONE;
}
-/*
- * Get the monitor that the thread is waiting on.
- */
-static JdwpError TR_CurrentContendedMonitor(JdwpState*, const uint8_t* buf, int, ExpandBuf*)
+static JdwpError TR_CurrentContendedMonitor(JdwpState*, const uint8_t* buf, int, ExpandBuf* reply)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- ReadObjectId(&buf); // thread_id
+ ObjectId thread_id = ReadObjectId(&buf);
- // TODO: create an Object to represent the monitor (we're currently
- // just using a raw Monitor struct in the VM)
+ ObjectId contended_monitor;
+ JdwpError rc = Dbg::GetContendedMonitor(thread_id, contended_monitor);
+ if (rc != ERR_NONE) {
+ return rc;
+ }
+ return WriteTaggedObject(reply, contended_monitor);
+}
- return ERR_NOT_IMPLEMENTED;
+static JdwpError TR_Interrupt(JdwpState*, const uint8_t* buf, int, ExpandBuf* reply)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ ObjectId thread_id = ReadObjectId(&buf);
+ return Dbg::Interrupt(thread_id);
}
/*
@@ -1623,7 +1628,7 @@
{ 11, 8, TR_OwnedMonitors, "ThreadReference.OwnedMonitors" },
{ 11, 9, TR_CurrentContendedMonitor, "ThreadReference.CurrentContendedMonitor" },
{ 11, 10, NULL, "ThreadReference.Stop" },
- { 11, 11, NULL, "ThreadReference.Interrupt" },
+ { 11, 11, TR_Interrupt, "ThreadReference.Interrupt" },
{ 11, 12, TR_DebugSuspendCount, "ThreadReference.SuspendCount" },
{ 11, 13, NULL, "ThreadReference.OwnedMonitorsStackDepthInfo" },
{ 11, 14, NULL, "ThreadReference.ForceEarlyReturn" },