Implement a bit more debugger functionality.
This fixes the deadlock by making SuspendSelfForDebugger not take the thread
list lock, making it more like the equivalent code in dalvikvm.
There's also some code cleanup, and a few more of the JDWP calls jdb makes
on startup. By fixing the deadlock, attaching jdb now causes us to hit
unimplemented code relating to thread stacks. That's tomorrow's job...
Change-Id: I7eac1b95946228fa60666587ff8766bcabb28bb1
diff --git a/src/thread.cc b/src/thread.cc
index e6dc2ff..c5f9095 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -192,9 +192,12 @@
gThread_vmData->SetInt(managed_thread, reinterpret_cast<uintptr_t>(native_thread));
}
+Thread* Thread::FromManagedThread(Object* thread_peer) {
+ return reinterpret_cast<Thread*>(static_cast<uintptr_t>(gThread_vmData->GetInt(thread_peer)));
+}
+
Thread* Thread::FromManagedThread(JNIEnv* env, jobject java_thread) {
- Object* thread = Decode<Object*>(env, java_thread);
- return reinterpret_cast<Thread*>(static_cast<uintptr_t>(gThread_vmData->GetInt(thread)));
+ return FromManagedThread(Decode<Object*>(env, java_thread));
}
size_t FixStackSize(size_t stack_size) {
@@ -633,6 +636,10 @@
return old_state;
}
+bool Thread::IsSuspended() {
+ return ANNOTATE_UNPROTECTED_READ(suspend_count_) != 0 && GetState() != Thread::kRunnable;
+}
+
void Thread::WaitUntilSuspended() {
// TODO: dalvik dropped the waiting thread's priority after a while.
// TODO: dalvik timed out and aborted.