OSDN Git Service

* include/jvmti-int.h (JVMTI): Declare member "enabled".
authorkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Jan 2007 23:25:39 +0000 (23:25 +0000)
committerkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Jan 2007 23:25:39 +0000 (23:25 +0000)
        * jvmti.cc (JVMTI): Add member "enabled".
        (_Jv_GetJVMTIEnv): Mark JVMTI enabled.
        * interpret.cc (_Jv_InterpMethod::ncode): Use JVMTI::enabled
        instead of gnu::classpath::jdwp::Jdwp::isDebugging.
        (_Jv_CompileMethod): If JVMTI is enabled, use run_debug
        instead of run to compile the method.

        * interpret-run.cc [DEBUG] (NEXT_INSN): Add JVMTI single step
        notification.

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

libjava/include/jvmti-int.h
libjava/interpret-run.cc
libjava/interpret.cc
libjava/jvmti.cc

index 822163a..f868655 100644 (file)
@@ -37,6 +37,10 @@ executable file might be covered by the GNU General Public License. */
    False means no JVMTI environment requested that event type. */
 namespace JVMTI
 {
+  // Is JVMTI enabled? (i.e., any jvmtiEnv created?)
+  extern bool enabled;
+
+  // Event notifications
   extern bool VMInit;
   extern bool VMDeath;
   extern bool ThreadStart;
index f368745..12d0b9a 100644 (file)
@@ -248,7 +248,27 @@ details.  */
 
 #ifdef DIRECT_THREADED
 
+#ifdef DEBUG
+#undef NEXT_INSN
+#define NEXT_INSN                                                      \
+  do                                                                   \
+    {                                                                  \
+      if (JVMTI_REQUESTED_EVENT (SingleStep))                          \
+       {                                                               \
+         JNIEnv *env = _Jv_GetCurrentJNIEnv ();                        \
+         jmethodID method = meth->self;                                \
+         jlocation loc = meth->insn_index (pc);                        \
+         _Jv_JVMTI_PostEvent (JVMTI_EVENT_SINGLE_STEP, thread,         \
+                              env, method, loc);                       \
+       }                                                               \
+      goto *((pc++)->insn);                                            \
+    }                                                                  \
+  while (0)
+#else
+#undef NEXT_INSN
 #define NEXT_INSN goto *((pc++)->insn)
+#endif
+
 #define INTVAL() ((pc++)->int_val)
 #define AVAL() ((pc++)->datum)
 
@@ -281,7 +301,22 @@ details.  */
 
 #else
 
+#ifdef DEBUG
+#define NEXT_INSN                                                      \
+  do                                                                   \
+    {                                                                  \
+      if (JVMTI_REQUESTED_EVENT (SingleStep))                          \
+       {                                                               \
+         JNIEnv *env = _Jv_GetCurrentJNIEnv ();                        \
+         jmethodID method = meth->self;                                \
+         jlocation loc = meth->insn_index (pc);                        \
+         _Jv_JVMTI_PostEvent (JVMTI_EVENT_SINGLE_STEP, thread,         \
+                              env, method, loc);                       \
+       }                                                               \
+      goto *(insn_target[*pc++])
+#else
 #define NEXT_INSN goto *(insn_target[*pc++])
+#endif
 
 #define GET1S() get1s (pc++)
 #define GET2S() (pc += 2, get2s (pc- 2))
index 7e694a3..7e7d36d 100644 (file)
@@ -1297,34 +1297,34 @@ _Jv_InterpMethod::ncode ()
     {
       if (staticp)
         {
-        if (::gnu::classpath::jdwp::Jdwp::isDebugging)
-                 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class_debug;
-               else
-                 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class;
+         if (JVMTI::enabled)
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class_debug;
+         else
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class;
         }
       else
         {
-             if (::gnu::classpath::jdwp::Jdwp::isDebugging)
-                   fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_object_debug;
-                 else
-                       fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_object;
-        } 
+         if (JVMTI::enabled)
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_object_debug;
+         else
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_object;
+        }
     }
   else
     {
       if (staticp)
         {
-             if (::gnu::classpath::jdwp::Jdwp::isDebugging)
-                   fun = (ffi_closure_fun)&_Jv_InterpMethod::run_class_debug;
-                 else
-                   fun = (ffi_closure_fun)&_Jv_InterpMethod::run_class;
+         if (JVMTI::enabled)
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_class_debug;
+         else
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_class;
         }
       else
         {
-             if (::gnu::classpath::jdwp::Jdwp::isDebugging)
-                   fun = (ffi_closure_fun)&_Jv_InterpMethod::run_normal_debug;
-                 else
-                   fun = (ffi_closure_fun)&_Jv_InterpMethod::run_normal;
+         if (JVMTI::enabled)
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_normal_debug;
+         else
+           fun = (ffi_closure_fun)&_Jv_InterpMethod::run_normal;
         }
     }
 
@@ -1680,7 +1680,12 @@ void
 _Jv_CompileMethod (_Jv_InterpMethod* method)
 {
   if (method->prepared == NULL)
-    _Jv_InterpMethod::run (NULL, NULL, method);
+    {
+      if (JVMTI::enabled)
+       _Jv_InterpMethod::run_debug (NULL, NULL, method);
+      else
+      _Jv_InterpMethod::run (NULL, NULL, method);
+    }
 }
 #endif // DIRECT_THREADED
 
index c9c7e7b..2e32634 100644 (file)
@@ -44,6 +44,10 @@ static void check_enabled_event (jvmtiEvent);
 
 namespace JVMTI
 {
+  // Is JVMTI enabled? (i.e., any jvmtiEnv created?)
+  bool enabled;
+
+  // Event notifications
   bool VMInit = false;
   bool VMDeath = false;
   bool ThreadStart = false;
@@ -1754,6 +1758,10 @@ _Jv_GetJVMTIEnv (void)
       }
   }
 
+  /* Mark JVMTI active. This is used to force the interpreter
+     to use either debugging or non-debugging code. Once JVMTI
+     has been enabled, the non-debug interpreter cannot be used. */
+  JVMTI::enabled = true;
   return env;
 }