From 8faab1f43bae896cd4fab5aa3e1e4dbfa16e2396 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Wed, 16 May 2007 20:12:33 +0000 Subject: [PATCH] java-interp.h (breakpoint_at): Declare. * 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. From-SVN: r124777 --- libjava/ChangeLog | 20 ++++++++++++ .../lib/gnu/classpath/jdwp/VMVirtualMachine.class | Bin 4017 -> 4063 bytes libjava/gnu/classpath/jdwp/VMVirtualMachine.h | 1 + libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc | 35 ++++++++++++++++++--- libjava/include/java-interp.h | 3 ++ libjava/interpret.cc | 17 ++++++++++ 6 files changed, 71 insertions(+), 5 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 74f9a7c..0f27b41 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,23 @@ +2007-05-16 Keith Seitz + + * 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 * classpath/lib/javax/swing/text/html/HTMLEditorKit.class: Regenerate diff --git a/libjava/classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class b/libjava/classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class index 09c69bf4234e0e26c6eb555fd04f188eeaff27e1..f62976a99f52472e00030c64e3ad368ea7401af8 100644 GIT binary patch delta 1427 zcmbu8NmCP16opTBI%!Bcidrc|1sp&iAw*431Q7uh$2j4LiY>%I#1NAZM1(jX&a2+J z!z!TEDisH$tkQBvl|R6(|G||j@q}i`uypg@>+|mTz1tIozY5Ji{(kueU^5<1m?d$k zrPUYn1*5H9osp;jn`V`BwI$+8(^>^gorjVRIL(i_tS1?N!m!EO943CllhGz&sJ z3#+i2Wb$dr*0~n&%f(&bZnS?!;RFvN)^Rn>inUnJv!WYd1Bw748^v@^?99cRQd&sd z%a9ERZ^R^p2?P(7EZTUYQz$<;g)Nh)I^;N9K8YRPahRR@$vHjqhf@7k$tHb;v)Wjm zXPm?yt-_ic-|ra3vOL*72GcmQ^5iKT8ZrqslT8|#`Dvd-;$F5>T`d0;Y)lzoVOL>6 z5LR?!IYLy!$VG(xhp-mCY~co+=z|CSe7*tHV-S0B8z*rOXE2Nl)Z>0Uq5D(1J)7lm zoc%});KdOpv7i%2af}44@Z&g7B2!()37!m0;6*dTNlep(Q#cJHwqX;4pCsdY7IKzR zWYXkwrO|BBX*MkYPT(w}GE0}eJWxwFFj5jUr!&x^|U}?&R1&aD0uFkc{ZkDC06MVC0|xK zsx+*@TK&6JsjNediuJlvo>#R2YXuzPP<(f=FBFYCu?`zGY{F)N?BMZuq(4;Gn~26! z*K9OS>osh_R=r&=F7#rXhDM{nEEX_t)6mzOh&ds!L&H)O=`ZBBO1p*wDEiQ5|1FEz zADWy(Bo{J*WAeLzg#26uSG(sE77lY`Ljk`^O02;m?lm(2i?IX{4iqxkSlNRo%NQYZ zErtUnJh9DC*g&kLlEs+#C_FnxQC2#F)lJ@=T&e>@aQe)h@9V@LO0}!yTzMScYI|wE zeFSy)w7g`4_XTF>tDcuohLDx7j$-?OB65{n`N_l&&j^fj)kAgq_N~Ze$1v~JjclAm z4tg*Lr>OQK4>1mYij&28(*%6z=S!VKH7=0-MQp`o?88-JyMe>hlVJ=p?GDc1ZVE>; z$B|j22|L*&8xaJsivV)ia5r~0w(7th?j$w{pc#7^??VGxSlEs#l%bWH!gdR=pH)=C zg9^N(zlTwa_o&B5&i08Dj-j1;2;)=Kk}|=V*c@bQV#{WjiOt0%6Wda3 zp2X&*?M-Z}rm)q{z;=jrW_XYwkKkyUatuLJNpd0@l|daio)*-}n_3HX@jb0dH{aT- zoXBW@GDGR1*~~1?Z?=!pP}V{*oK92vXgF(3JVQy)yVjVqbgWf5PhU?eF>Z|MFJ?5m gMAKW-t{|DFT*b9C6Yt{g6(m4XR__g8oKYI+yfdBvi diff --git a/libjava/gnu/classpath/jdwp/VMVirtualMachine.h b/libjava/gnu/classpath/jdwp/VMVirtualMachine.h index dd31694..f4ff5e8 100644 --- a/libjava/gnu/classpath/jdwp/VMVirtualMachine.h +++ b/libjava/gnu/classpath/jdwp/VMVirtualMachine.h @@ -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$; }; diff --git a/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc b/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc index 3c89b98..7fee49b 100644 --- a/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc +++ b/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc @@ -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 (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 *events + = ((JArray *) + 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 = diff --git a/libjava/include/java-interp.h b/libjava/include/java-interp.h index 4bded04..52a04e7 100644 --- a/libjava/include/java-interp.h +++ b/libjava/include/java-interp.h @@ -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 diff --git a/libjava/interpret.cc b/libjava/interpret.cc index b078676..18b4ae0 100644 --- a/libjava/interpret.cc +++ b/libjava/interpret.cc @@ -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 (bytecode ()); + return (code[index] == breakpoint_insn); +#endif + } + + return false; +} + void * _Jv_JNIMethod::ncode (jclass klass) { -- 2.7.4