2007-04-24 Kyle Galloway <kgallowa@redhat.com>
authorKyle Galloway <kgallowa@redhat.com>
Tue, 24 Apr 2007 19:56:55 +0000 (19:56 +0000)
committerKyle Galloway <kgallowa@gcc.gnu.org>
Tue, 24 Apr 2007 19:56:55 +0000 (19:56 +0000)
* gnu/classpath/jdwp/natVMVirtualMachine.java
(getThreadStatus): Implement.

From-SVN: r124117

libjava/ChangeLog
libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc

index 0c294216537690c6d2ed179cb5f4675434aca6d0..0596c8ac8be4005426692f134b660e36adb134a5 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-24  Kyle Galloway  <kgallowa@redhat.com>
+
+       * gnu/classpath/jdwp/natVMVirtualMachine.java
+       (getThreadStatus): Implement.
+
 2007-04-24  Keith Seitz  <keiths@redhat.com>
 
        * headers.txt (gnu/gcj/jvmti/Breakpoint.h)[DIRECT_THREADED]:
index c77aed257ddb8ee042aceb4a01dd186c3e545700..1dfc52995e05ec7d49c6e8e08418071c94ccd415 100644 (file)
@@ -31,6 +31,7 @@ details. */
 #include <gnu/classpath/jdwp/Jdwp.h>
 #include <gnu/classpath/jdwp/JdwpConstants$StepDepth.h>
 #include <gnu/classpath/jdwp/JdwpConstants$StepSize.h>
+#include <gnu/classpath/jdwp/JdwpConstants$ThreadStatus.h>
 #include <gnu/classpath/jdwp/VMFrame.h>
 #include <gnu/classpath/jdwp/VMMethod.h>
 #include <gnu/classpath/jdwp/VMVirtualMachine.h>
@@ -622,9 +623,37 @@ getFrameCount (Thread *thread)
 
 jint
 gnu::classpath::jdwp::VMVirtualMachine::
-getThreadStatus (MAYBE_UNUSED Thread *thread)
+getThreadStatus (Thread *thread)
 {
-  return 0;
+  jint thr_state, status;
+  
+  jvmtiError jerr = _jdwp_jvmtiEnv->GetThreadState (thread, &thr_state);
+  if (jerr != JVMTI_ERROR_NONE)
+    throw_jvmti_error (jerr);
+  
+  if (thr_state & JVMTI_THREAD_STATE_SLEEPING)
+    status = gnu::classpath::jdwp::JdwpConstants$ThreadStatus::SLEEPING;
+  else if (thr_state & JVMTI_THREAD_STATE_RUNNABLE)
+    status = gnu::classpath::jdwp::JdwpConstants$ThreadStatus::RUNNING;
+  else if (thr_state & JVMTI_THREAD_STATE_WAITING)
+    {
+      if (thr_state & (JVMTI_THREAD_STATE_IN_OBJECT_WAIT
+                       | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER))
+        status = gnu::classpath::jdwp::JdwpConstants$ThreadStatus::MONITOR;
+      else
+        status = gnu::classpath::jdwp::JdwpConstants$ThreadStatus::WAIT;
+    }
+  else
+    {
+      // The thread is not SLEEPING, MONITOR, or WAIT.  It may, however, be
+      // alive but not yet started.
+      if (!(thr_state & (JVMTI_THREAD_STATE_ALIVE 
+                         | JVMTI_THREAD_STATE_TERMINATED)))
+        status = gnu::classpath::jdwp::JdwpConstants$ThreadStatus::RUNNING;
+      status = gnu::classpath::jdwp::JdwpConstants$ThreadStatus::ZOMBIE;     
+    }   
+
+  return status;
 }
 
 java::util::ArrayList *