OSDN Git Service

* gnu/classpath/jdwp/natVMVirtualMachine.cc (DEFINE_CALLBACK):
authorkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Jan 2007 19:54:16 +0000 (19:54 +0000)
committerkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 Jan 2007 19:54:16 +0000 (19:54 +0000)
        New macro.
        (ENABLE_EVENT): New macro.
        (initialize): Define and enable JVMTI VM_INIT callback.
        (jdwpVMInitCB): New function.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120833 138bc75d-0d04-0410-961f-82ee72b054a4

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

index af8efa0..b3b0908 100644 (file)
@@ -1,3 +1,11 @@
+2007-01-16  Keith Seitz  <keiths@redhat.com>
+
+       * gnu/classpath/jdwp/natVMVirtualMachine.cc (DEFINE_CALLBACK):
+       New macro.
+       (ENABLE_EVENT): New macro.
+       (initialize): Define and enable JVMTI VM_INIT callback.
+       (jdwpVMInitCB): New function.
+
 2007-01-16  Kyle Galloway  <kgallowa@redhat.com>
 
        * jvmti.cc (_Jv_JVMTI_GetAllThreads): New function.
index 522204f..351bb23 100644 (file)
@@ -24,10 +24,12 @@ details. */
 #include <java/util/Hashtable.h>
 #include <java/util/Iterator.h>
 
+#include <gnu/classpath/jdwp/Jdwp.h>
 #include <gnu/classpath/jdwp/VMFrame.h>
 #include <gnu/classpath/jdwp/VMMethod.h>
 #include <gnu/classpath/jdwp/VMVirtualMachine.h>
 #include <gnu/classpath/jdwp/event/EventRequest.h>
+#include <gnu/classpath/jdwp/event/VmInitEvent.h>
 #include <gnu/classpath/jdwp/exception/JdwpInternalErrorException.h>
 #include <gnu/classpath/jdwp/util/MethodResult.h>
 
@@ -35,6 +37,13 @@ using namespace java::lang;
 using namespace gnu::classpath::jdwp::event;
 using namespace gnu::classpath::jdwp::util;
 
+// Forward declarations
+static void jdwpVMInitCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread);
+
+#define DEFINE_CALLBACK(Cb,Event) Cb.Event = jdwp ## Event ## CB
+#define ENABLE_EVENT(Event,Thread)                                     \
+  _jdwp_jvmtiEnv->SetEventNotificationMode (JVMTI_ENABLE,              \
+                                           JVMTI_EVENT_ ## Event, Thread)
 // JVMTI environment
 static jvmtiEnv *_jdwp_jvmtiEnv;
 
@@ -44,6 +53,12 @@ gnu::classpath::jdwp::VMVirtualMachine::initialize ()
   _jdwp_suspend_counts = new ::java::util::Hashtable ();
   JavaVM *vm = _Jv_GetJavaVM ();
   vm->GetEnv (reinterpret_cast<void **> (&_jdwp_jvmtiEnv), JVMTI_VERSION_1_0);
+
+  // Wait for VM_INIT to do more initialization
+  jvmtiEventCallbacks callbacks;
+  DEFINE_CALLBACK (callbacks, VMInit);
+  _jdwp_jvmtiEnv->SetEventCallbacks (&callbacks, sizeof (callbacks));
+  ENABLE_EVENT (VM_INIT, NULL);
 }
 
 void
@@ -343,3 +358,13 @@ gnu::classpath::jdwp::VMVirtualMachine::getSourceFile (jclass clazz)
 {
   return NULL;
 }
+
+static void
+jdwpVMInitCB (MAYBE_UNUSED jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env,
+             jthread thread)
+{
+  // Send JDWP VMInit
+  using namespace gnu::classpath::jdwp::event;
+  Thread *init_thread = reinterpret_cast<Thread *> (thread);
+  gnu::classpath::jdwp::Jdwp::notify (new VmInitEvent (init_thread));
+}