From 410b0a2c947ed94a411b1c31b5280df50a884798 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Fri, 9 Feb 2007 18:43:21 +0000 Subject: [PATCH] * gnu/classpath/jdwp/VMVirtualMachine.java (_stepping_threads): New member. * classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class: Regenerated. * gnu/classpath/jdwp/VMVirtualMachine.h: Regenerated. * gnu/claspath/jdwp/natVMVirtualMachine.cc (get_request_step_filter): New function. (DISABLE_EVENT): New macro. (initialize): Initialize _stepping_threads. (registerEvent): Implement EVENT_SINGLE_STEP. (unregisterEvent): Likewise. From-SVN: r121769 --- libjava/ChangeLog | 15 ++++ .../gnu/classpath/jdwp/VMVirtualMachine.class | Bin 2863 -> 2891 bytes libjava/gnu/classpath/jdwp/VMVirtualMachine.h | 2 + .../gnu/classpath/jdwp/VMVirtualMachine.java | 3 + .../gnu/classpath/jdwp/natVMVirtualMachine.cc | 80 +++++++++++++++++- 5 files changed, 99 insertions(+), 1 deletion(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 5c228fb9073..c403efbb7a8 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,18 @@ +2007-02-09 Keith Seitz + + * gnu/classpath/jdwp/VMVirtualMachine.java + (_stepping_threads): New member. + * classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class: + Regenerated. + * gnu/classpath/jdwp/VMVirtualMachine.h: + Regenerated. + * gnu/claspath/jdwp/natVMVirtualMachine.cc + (get_request_step_filter): New function. + (DISABLE_EVENT): New macro. + (initialize): Initialize _stepping_threads. + (registerEvent): Implement EVENT_SINGLE_STEP. + (unregisterEvent): Likewise. + 2007-02-08 Keith Seitz * sources.am: Regenerate. diff --git a/libjava/classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class b/libjava/classpath/lib/gnu/classpath/jdwp/VMVirtualMachine.class index 526d30b221bf829075c7ce6745eeab2fa424dbf7..f48b6eb890ad060e4b41d8b0cbef1ab7dafd0ad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gxVh-1ajVAf zPlO$DR4Mszc3W5v=Ot;J>C?+TQk6bVMyfKvNlI0Qb`&(csoeN?{Rn$b4ZBDlsmd6K ZGgTRff15I~Lz(0lCq>Z?aDa4}{tF?~t>pj! diff --git a/libjava/gnu/classpath/jdwp/VMVirtualMachine.h b/libjava/gnu/classpath/jdwp/VMVirtualMachine.h index b90b476c04b..456053a6565 100644 --- a/libjava/gnu/classpath/jdwp/VMVirtualMachine.h +++ b/libjava/gnu/classpath/jdwp/VMVirtualMachine.h @@ -59,6 +59,8 @@ public: static void clearEvents (jbyte); private: static ::java::util::Hashtable *_jdwp_suspend_counts; +public: // actually package-private + static ::java::util::Hashtable * _stepping_threads; public: static ::java::lang::Class class$; diff --git a/libjava/gnu/classpath/jdwp/VMVirtualMachine.java b/libjava/gnu/classpath/jdwp/VMVirtualMachine.java index 1b0f7f6fa3c..da0fef28c10 100644 --- a/libjava/gnu/classpath/jdwp/VMVirtualMachine.java +++ b/libjava/gnu/classpath/jdwp/VMVirtualMachine.java @@ -61,6 +61,9 @@ public class VMVirtualMachine // Thread suspension table. Maps Thread to suspend count (Integer) private static Hashtable _jdwp_suspend_counts; + // List of stepping threads: maps Thread -> stepping info + static Hashtable _stepping_threads; + public static native void initialize (); /** diff --git a/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc b/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc index ab11b3ed299..e06daa7bb24 100644 --- a/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc +++ b/libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc @@ -11,6 +11,7 @@ details. */ #include #include #include +#include #include #include @@ -42,10 +43,12 @@ details. */ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -55,8 +58,19 @@ using namespace java::lang; using namespace gnu::classpath::jdwp::event; using namespace gnu::classpath::jdwp::util; +// Stepping information +struct step_info +{ + jint size; // See gnu.classpath.jdwp.JdwpConstants.StepSize + jint depth; // See gnu.classpath.jdwp.JdwpConstants.StepDepth + int stack_depth; // stack depth at start of stepping + jmethodID method; // method in which we are stepping +}; + // Forward declarations static Location *get_request_location (EventRequest *); +static gnu::classpath::jdwp::event::filters::StepFilter * +get_request_step_filter (EventRequest *); static void JNICALL jdwpClassPrepareCB (jvmtiEnv *, JNIEnv *, jthread, jclass); static void JNICALL jdwpThreadEndCB (jvmtiEnv *, JNIEnv *, jthread); static void JNICALL jdwpThreadStartCB (jvmtiEnv *, JNIEnv *, jthread); @@ -65,6 +79,9 @@ static void JNICALL jdwpVMInitCB (jvmtiEnv *, JNIEnv *, jthread); static void throw_jvmti_error (jvmtiError); #define DEFINE_CALLBACK(Cb,Event) Cb.Event = jdwp ## Event ## CB +#define DISABLE_EVENT(Event,Thread) \ + _jdwp_jvmtiEnv->SetEventNotificationMode (JVMTI_DISABLE, \ + JVMTI_EVENT_ ## Event, Thread) #define ENABLE_EVENT(Event,Thread) \ _jdwp_jvmtiEnv->SetEventNotificationMode (JVMTI_ENABLE, \ JVMTI_EVENT_ ## Event, Thread) @@ -81,6 +98,8 @@ void gnu::classpath::jdwp::VMVirtualMachine::initialize () { _jdwp_suspend_counts = new ::java::util::Hashtable (); + _stepping_threads = new ::java::util::Hashtable (); + JavaVM *vm = _Jv_GetJavaVM (); vm->GetEnv (reinterpret_cast (&_jdwp_jvmtiEnv), JVMTI_VERSION_1_0); @@ -200,6 +219,32 @@ gnu::classpath::jdwp::VMVirtualMachine::registerEvent (EventRequest *request) switch (request->getEventKind ()) { case EventRequest::EVENT_SINGLE_STEP: + { + Thread *thread; + filters::StepFilter *filter = get_request_step_filter (request); + if (filter == NULL) + { + // No filter specified: report every step in every + // thread. + thread = NULL; + } + else + { + // Add stepping information to list of stepping threads + thread = filter->getThread ()->getThread (); + _Jv_InterpFrame *frame + = reinterpret_cast<_Jv_InterpFrame *> (thread->interp_frame); + struct step_info *sinfo + = (struct step_info *) JvAllocBytes (sizeof (struct step_info)); + sinfo->size = filter->getSize (); + sinfo->depth = filter->getDepth (); + sinfo->stack_depth = frame->depth (); + sinfo->method = frame->self->get_method (); + _stepping_threads->put (thread, (jobject) sinfo); + } + + ENABLE_EVENT (SINGLE_STEP, thread); + } break; case EventRequest::EVENT_BREAKPOINT: @@ -225,7 +270,7 @@ gnu::classpath::jdwp::VMVirtualMachine::registerEvent (EventRequest *request) // Ignore the duplicate } } - break; + break; case EventRequest::EVENT_FRAME_POP: break; @@ -277,6 +322,19 @@ gnu::classpath::jdwp::VMVirtualMachine::unregisterEvent (EventRequest *request) switch (request->getEventKind ()) { case EventRequest::EVENT_SINGLE_STEP: + { + Thread *thread; + filters::StepFilter *filter = get_request_step_filter (request); + if (filter == NULL) + thread = NULL; + else + { + thread = filter->getThread ()->getThread (); + _stepping_threads->remove (thread); + } + + DISABLE_EVENT (SINGLE_STEP, thread); + } break; case EventRequest::EVENT_BREAKPOINT: @@ -527,6 +585,26 @@ getSourceFile (MAYBE_UNUSED jclass clazz) return NULL; } +static gnu::classpath::jdwp::event::filters::StepFilter * +get_request_step_filter (EventRequest *request) +{ + ::java::util::Collection *filters = request->getFilters (); + ::java::util::Iterator *iter = filters->iterator (); + filters::StepFilter *filter = NULL; + while (iter->hasNext ()) + { + using namespace gnu::classpath::jdwp::event::filters; + IEventFilter *next = (IEventFilter *) iter->next (); + if (next->getClass () == &StepFilter::class$) + { + filter = reinterpret_cast (next); + break; + } + } + + return filter; +} + static Location * get_request_location (EventRequest *request) { -- 2.30.2