Try to show lock owner in MONITOR thread dump.
A thread in the MONITOR state is blocked waiting on a monitor. This
raises two interesting questions: (1) what lock is it waiting on, and
(2) who holds that lock? The answer to (1) can be determined easily by
looking at the source code, but (2) is a bit harder.
This change extracts the target object from the instruction stream and
prints some information about it, e.g.:
- waiting to lock <0x40028c68> (a java.lang.Object) held by threadid=1 (main)
Change-Id: Iad18fc6f2df4142368bdf1063b8cc71de2d66156
Also: fiddled with "must [not] be locked" on a recently-added function.
diff --git a/vm/Thread.h b/vm/Thread.h
index 44004bf..e2af253 100644
--- a/vm/Thread.h
+++ b/vm/Thread.h
@@ -441,13 +441,21 @@
/*
* Given a pthread handle, return the associated Thread*.
- * Caller must NOT hold the thread list lock.
+ * Caller must hold the thread list lock.
*
* Returns NULL if the thread was not found.
*/
Thread* dvmGetThreadByHandle(pthread_t handle);
/*
+ * Given a thread ID, return the associated Thread*.
+ * Caller must hold the thread list lock.
+ *
+ * Returns NULL if the thread was not found.
+ */
+Thread* dvmGetThreadByThreadId(u4 threadId);
+
+/*
* Sleep in a thread. Returns when the sleep timer returns or the thread
* is interrupted.
*/