This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Add JDWP VM_INIT JVMTI callback


Hi,

This patch adds a JVMTI VM_INIT callback to be used by the JDWP code. Currently this function simply sends the JDWP VM_INIT event notification, but later it will do install additional JVMTI callbacks for all the various JDWP event notifications.

Comments/questions/concerns?
Keith

ChangeLog
2007-01-15  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.
Index: gnu/classpath/jdwp/natVMVirtualMachine.cc
===================================================================
--- gnu/classpath/jdwp/natVMVirtualMachine.cc	(revision 120805)
+++ gnu/classpath/jdwp/natVMVirtualMachine.cc	(working copy)
@@ -24,10 +24,12 @@
 #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 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 @@
   _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 @@
 {
   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));
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]