OSDN Git Service

* include/java-interp.h (breakpoint_at): Declare.
authorkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 May 2007 20:12:33 +0000 (20:12 +0000)
committerkseitz <kseitz@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 May 2007 20:12:33 +0000 (20:12 +0000)
        * interpret.cc (breakpoint_at): New function.
        * gnu/classpath/jdwp/VMVirtualMachine.java (_event_list):
        New member.
        * gnu/classpath/jdwp/natVMVirtualMachine.cc (initialize):
        Initialize _event_list.
        (handle_single_step): If there is a breakpoint at the
        location at which we are stopping, do not send the notification.
        Instead add the event to a list of events that occur at this
        location.
        (jdwpBreakpointCB): If the event list is not empty, send
        whatever events are in it and the breakpoint event in a single
        notification.
        Mark parameter jni_env as MAYBE_UNUSED.
        * classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class:
        Regenerated.
        * gnu/classpath/jdwp/VMVirtualMachine.h: Regenerated.

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

libjava/ChangeLog
libjava/classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class
libjava/gnu/classpath/jdwp/VMVirtualMachine.h
libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc
libjava/include/java-interp.h
libjava/interpret.cc

index 74f9a7c..0f27b41 100644 (file)
@@ -1,3 +1,23 @@
+2007-05-16  Keith Seitz  <keiths@redhat.com>
+
+       * include/java-interp.h (breakpoint_at): Declare.
+       * interpret.cc (breakpoint_at): New function.
+       * gnu/classpath/jdwp/VMVirtualMachine.java (_event_list):
+       New member.
+       * gnu/classpath/jdwp/natVMVirtualMachine.cc (initialize):
+       Initialize _event_list.
+       (handle_single_step): If there is a breakpoint at the
+       location at which we are stopping, do not send the notification.
+       Instead add the event to a list of events that occur at this
+       location.
+       (jdwpBreakpointCB): If the event list is not empty, send
+       whatever events are in it and the breakpoint event in a single
+       notification.
+       Mark parameter jni_env as MAYBE_UNUSED.
+       * classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class:
+       Regenerated.
+       * gnu/classpath/jdwp/VMVirtualMachine.h: Regenerated.
+
 2007-05-15  David Daney  <ddaney@avtrex.com>
 
        * classpath/lib/javax/swing/text/html/HTMLEditorKit.class: Regenerate
index 09c69bf..f62976a 100644 (file)
Binary files a/libjava/classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class and b/libjava/classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class differ
index dd31694..f4ff5e8 100644 (file)
@@ -86,6 +86,7 @@ private:
   static ::java::util::Hashtable * _jdwp_suspend_counts;
 public: // actually package-private
   static ::java::util::Hashtable * _stepping_threads;
+  static ::java::util::ArrayList * _event_list;
 public:
   static ::java::lang::Class class$;
 };
index 3c89b98..7fee49b 100644 (file)
@@ -116,6 +116,7 @@ gnu::classpath::jdwp::VMVirtualMachine::initialize ()
 {
   _jdwp_suspend_counts = new ::java::util::Hashtable ();
   _stepping_threads = new ::java::util::Hashtable ();
+  _event_list = new ::java::util::ArrayList ();
 
   JavaVM *vm = _Jv_GetJavaVM ();
   union
@@ -895,7 +896,23 @@ handle_single_step (jvmtiEnv *env, struct step_info *sinfo, jthread thread,
   jobject instance = iframe->get_this_ptr ();
   event::SingleStepEvent *event
     = new event::SingleStepEvent (thread, loc, instance);
-  Jdwp::notify (event);
+
+  // We only want to send the notification (and consequently
+  // suspend) if we are not about to execute a breakpoint.
+  _Jv_InterpMethod *im = reinterpret_cast<_Jv_InterpMethod *> (iframe->self);
+  if (im->breakpoint_at (location))
+    {
+      // Next insn is a breakpoint -- record event and
+      // wait for the JVMTI breakpoint notification to
+      // enforce a suspension policy.
+      VMVirtualMachine::_event_list->add (event);
+    }
+  else
+    {
+      // Next insn is not a breakpoint, so send notification
+      // and enforce the suspend policy.
+      Jdwp::notify (event);
+    }
 }
 
 static void
@@ -925,6 +942,7 @@ jdwpBreakpointCB (jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env,
   JvAssert (err == JVMTI_ERROR_NONE);
 
   using namespace gnu::classpath::jdwp;
+  using namespace gnu::classpath::jdwp::event;
 
   jlong methodId = reinterpret_cast<jlong> (method);
   VMMethod *meth = VMVirtualMachine::getClassMethod (klass, methodId);
@@ -933,9 +951,16 @@ jdwpBreakpointCB (jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env,
   _Jv_InterpFrame *iframe
     = reinterpret_cast<_Jv_InterpFrame *> (thread->interp_frame);
   jobject instance = iframe->get_this_ptr ();
-  event::BreakpointEvent *event
-    = new event::BreakpointEvent (thread, loc, instance);
-  Jdwp::notify (event);
+  BreakpointEvent *event = new BreakpointEvent (thread, loc, instance);
+  
+  VMVirtualMachine::_event_list->add (event);
+  JArray<Event *> *events
+    = ((JArray<Event *> *)
+       JvNewObjectArray (VMVirtualMachine::_event_list->size (),
+                        &Event::class$, NULL));
+  VMVirtualMachine::_event_list->toArray ((jobjectArray) events);
+  VMVirtualMachine::_event_list->clear ();
+  Jdwp::notify (events);
 }
 
 static void JNICALL
@@ -1001,7 +1026,7 @@ jdwpExceptionCB (jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env, jthread thread,
 }
 
 static void JNICALL
-jdwpSingleStepCB (jvmtiEnv *env, JNIEnv *jni_env, jthread thread,
+jdwpSingleStepCB (jvmtiEnv *env, MAYBE_UNUSED JNIEnv *jni_env, jthread thread,
                  jmethodID method, jlocation location)
 {
   jobject si =
index 4bded04..52a04e7 100644 (file)
@@ -274,6 +274,9 @@ class _Jv_InterpMethod : public _Jv_MethodBase
      the insn or NULL if index is invalid. */
   pc_t set_insn (jlong index, pc_t insn);
 
+  // Is the given location in this method a breakpoint?
+  bool breakpoint_at (jlong index);
+
 #ifdef DIRECT_THREADED
   friend void _Jv_CompileMethod (_Jv_InterpMethod*);
 #endif
index b078676..18b4ae0 100644 (file)
@@ -1580,6 +1580,23 @@ _Jv_InterpMethod::set_insn (jlong index, pc_t insn)
   return &code[index];
 }
 
+bool
+_Jv_InterpMethod::breakpoint_at (jlong index)
+{
+  pc_t insn = get_insn (index);
+  if (insn != NULL)
+    {
+#ifdef DIRECT_THREADED
+      return (insn->insn == breakpoint_insn->insn);
+#else
+      pc_t code = reinterpret_cast<pc_t> (bytecode ());
+      return (code[index] == breakpoint_insn);
+#endif
+    }
+
+  return false;
+}
+
 void *
 _Jv_JNIMethod::ncode (jclass klass)
 {