harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvj...@apache.org
Subject svn commit: r645814 [1/2] - in /harmony/enhanced/jdktools/branches/java6/modules/jpda: ./ src/main/native/jdwp/common/agent/commands/ src/main/native/jdwp/common/agent/core/ src/main/native/jdwp/common/generic/ src/test/java/org/apache/harmony/jpda/tes...
Date Tue, 08 Apr 2008 09:51:21 GMT
Author: lvjing
Date: Tue Apr  8 02:51:16 2008
New Revision: 645814

URL: http://svn.apache.org/viewvc?rev=645814&view=rev
Log:
Apply patch for HARMONY-5660, [jdktools][jdwp6] Uplift command Set and Composite for Java 6

Added:
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MethodExitWithReturnValueDebuggee.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MethodExitWithReturnValueTest.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MonitorContendedEnterAndEnteredDebuggee.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MonitorContendedEnterTest.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MonitorContendedEnteredTest.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MonitorWaitAndWaitedDebuggee.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MonitorWaitTest.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MonitorWaitedTest.java   (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/apache/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/apache/harmony/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/apache/harmony/jpda/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/apache/harmony/jpda/tests/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/apache/harmony/jpda/tests/jdwp/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/apache/harmony/jpda/tests/jdwp/Events/
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/resources/org/apache/harmony/jpda/tests/jdwp/Events/SourceDebugExtensionMockClass.class   (with props)
Modified:
    harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/EventRequest.cpp
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Agent.cpp
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.h
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.cpp
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.h
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/ParsedEvent.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareDebuggee.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareTest.java

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml Tue Apr  8 02:51:16 2008
@@ -207,13 +207,19 @@
         </javac>
     </target>
 
+    <target name="copy-test-resources">
+        <copy todir="${tests.build.output}/classes" includeemptydirs="false">
+            <fileset dir="${hy.jpda.src.test.resources}"/>
+        </copy>
+    </target>
+
     <target name="prepare-exclude">
         <echo message="JPDA exclude list: ${jpda.exclude.file}" />
         <prepare-exclude-list moduleName="jpda" dir="./make"
                              result="${jpda.exclude.file}" />
     </target>
 
-    <target name="run-tests" depends="build-tests, prepare-exclude">
+    <target name="run-tests" depends="build-tests, prepare-exclude, copy-test-resources">
 
         <property name="test.jre.home" value="${hy.jdk}/jre" />
         <property name="test.jre.jvm" value="${test.jre.home}/bin/java" />

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/EventRequest.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/EventRequest.cpp?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/EventRequest.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/EventRequest.cpp Tue Apr  8 02:51:16 2008
@@ -308,6 +308,22 @@
                     break;
                 }
 
+            // New modifier kind  for Java 6
+            case JDWP_MODIFIER_SOURCE_NAME_MATCH:
+                {
+                    if (eventKind != JDWP_EVENT_CLASS_PREPARE )
+                    {
+                        throw IllegalArgumentException();
+                    }
+
+                    char* pattern = m_cmdParser->command.ReadStringNoFree();
+                    JDWP_ASSERT(pattern != 0);
+
+                    modifier = new SourceNameMatchModifier(pattern);
+                    JDWP_TRACE_DATA("Set: modifier=SOURCE_NAME_MATCH, classPattern=" 
+                        << JDWP_CHECK_NULL(pattern));
+                    break;
+                }
             default:
                 JDWP_TRACE_DATA("Set: bad modifier: " << modifierByte);
                 throw IllegalArgumentException();

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Agent.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Agent.cpp?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Agent.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Agent.cpp Tue Apr  8 02:51:16 2008
@@ -385,6 +385,7 @@
         env.caps.canForceEarlyReturn =
             caps.can_force_early_return;
         caps.can_tag_objects = 1;
+        caps.can_generate_monitor_events = 1;
 
         // these caps should be added for full agent functionality
         // caps.can_suspend = 1;
@@ -407,7 +408,6 @@
         caps.can_get_thread_cpu_time = 0;
         caps.can_generate_all_class_hook_events = 0;
         caps.can_generate_compiled_method_load_events = 0;
-        caps.can_generate_monitor_events = 0;
         caps.can_generate_vm_object_alloc_events = 0;
         caps.can_generate_native_method_bind_events = 0;
         caps.can_generate_garbage_collection_events = 0;
@@ -441,6 +441,11 @@
         ecbs.SingleStep = &RequestManager::HandleSingleStep;
         ecbs.ThreadEnd = &RequestManager::HandleThreadEnd;
         ecbs.ThreadStart = &RequestManager::HandleThreadStart;
+        // New event callbacks for Java 6
+        ecbs.MonitorContendedEnter = &RequestManager::HandleMonitorContendedEnter;
+        ecbs.MonitorContendedEntered = &RequestManager::HandleMonitorContendedEntered;
+        ecbs.MonitorWait = &RequestManager::HandleMonitorWait;
+        ecbs.MonitorWaited = &RequestManager::HandleMonitorWaited;
 
         JVMTI_TRACE(err,
             jvmti->SetEventCallbacks(&ecbs, static_cast<jint>(sizeof(ecbs))));

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp Tue Apr  8 02:51:16 2008
@@ -101,6 +101,12 @@
             DeleteAllRequests(jni, JDWP_EVENT_METHOD_ENTRY);
             DeleteAllRequests(jni, JDWP_EVENT_METHOD_EXIT);
             DeleteAllRequests(jni, JDWP_EVENT_VM_DEATH);
+            // New events for Java 6
+            DeleteAllRequests(jni, JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE);   
+            DeleteAllRequests(jni, JDWP_EVENT_MONITOR_CONTENDED_ENTER); 
+            DeleteAllRequests(jni, JDWP_EVENT_MONITOR_CONTENDED_ENTERED); 
+            DeleteAllRequests(jni, JDWP_EVENT_MONITOR_WAIT);     
+            DeleteAllRequests(jni, JDWP_EVENT_MONITOR_WAITED);
         } catch (AgentException& e) {
             JDWP_INFO("JDWP error: " << e.what() << " [" << e.ErrCode() << "]");
         }
@@ -312,6 +318,22 @@
         eventType = JVMTI_EVENT_THREAD_END;
         nullThreadForSetEventNotificationMode = true;
         break;
+    // New events for Java 6
+    case JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE:
+        eventType = JVMTI_EVENT_METHOD_EXIT;
+        break;
+    case JDWP_EVENT_MONITOR_CONTENDED_ENTER:
+        eventType = JVMTI_EVENT_MONITOR_CONTENDED_ENTER;
+        break;
+    case JDWP_EVENT_MONITOR_CONTENDED_ENTERED:
+        eventType = JVMTI_EVENT_MONITOR_CONTENDED_ENTERED;
+        break;
+    case JDWP_EVENT_MONITOR_WAIT:
+        eventType = JVMTI_EVENT_MONITOR_WAIT;
+        break;
+    case JDWP_EVENT_MONITOR_WAITED:
+        eventType = JVMTI_EVENT_MONITOR_WAITED;
+        break;
     default:
         return;
     }
@@ -395,6 +417,17 @@
         return m_methodExitRequests;
     case JDWP_EVENT_VM_DEATH:
         return m_vmDeathRequests;
+    // New events for Java 6
+    case JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE:
+        return m_methodExitWithReturnValueRequests;
+    case JDWP_EVENT_MONITOR_CONTENDED_ENTER:
+        return m_monitorContendedEnterRequests;
+    case JDWP_EVENT_MONITOR_CONTENDED_ENTERED:
+       return m_monitorContendedEnteredRequests;
+    case JDWP_EVENT_MONITOR_WAIT:
+        return  m_monitorWaitRequests;
+    case JDWP_EVENT_MONITOR_WAITED:
+        return m_monitorWaitedRequests;
     default:
         throw AgentException(JDWP_ERROR_INVALID_EVENT_TYPE);
     }
@@ -579,6 +612,17 @@
         return "METHOD_EXIT";
     case JDWP_EVENT_VM_DEATH:
         return "VM_DEATH";
+    // New events for Java 6
+    case JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE:
+        return "METHOD_EXIT_WITH_RETURN_VALUE";
+    case JDWP_EVENT_MONITOR_CONTENDED_ENTER:
+        return "MONITOR_CONTENDED_ENTER";
+    case JDWP_EVENT_MONITOR_CONTENDED_ENTERED:
+        return "MONITOR_CONTENDED_ENTERED";
+    case JDWP_EVENT_MONITOR_WAIT:
+        return "MONITOR_WAIT";
+    case JDWP_EVENT_MONITOR_WAITED:
+        return "MONITOR_WAITED";
     default:
         return "UNKNOWN";
     }
@@ -951,6 +995,44 @@
     return isExit;
 }
 
+jdwpTag RequestManager::MethodReturnType(jvmtiEnv *env, jmethodID method)
+{
+    char *signature;
+    jvmtiError err;
+    JVMTI_TRACE(err, env->GetMethodName(method, NULL, &signature, NULL));
+    if(err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+    AgentAutoFree aafSignature(signature JDWP_FILE_LINE);
+
+    string str(signature);
+    string::size_type pos = str.find_first_of(")", 0);
+    string returnType = str.substr(pos+1, 1);
+    if (returnType == "V") {
+        return JDWP_TAG_VOID;
+    } else if (returnType == "[") {
+        return JDWP_TAG_OBJECT;
+    } else if (returnType == "B") {
+        return JDWP_TAG_BYTE;
+    } else if (returnType == "C") {
+        return JDWP_TAG_CHAR;
+    }else if (returnType == "F") {
+        return  JDWP_TAG_FLOAT;
+    }else if (returnType == "D") {
+        return JDWP_TAG_DOUBLE;
+    }else if (returnType == "I") {
+        return JDWP_TAG_INT;
+    }else if (returnType == "J") {
+        return JDWP_TAG_LONG;
+    }else if (returnType == "S") {
+        return JDWP_TAG_SHORT;
+    }else if (returnType == "Z") {
+        return JDWP_TAG_BOOLEAN;
+    } else {
+        return JDWP_TAG_OBJECT;
+    }
+}
+
 // --------------------- end of combined events support -----------------------
 
 //-----------------------------------------------------------------------------
@@ -1021,7 +1103,7 @@
         jthread thread, jclass cls)
 {
     JDWP_TRACE_ENTRY("HandleClassPrepare(" << jvmti << ',' << jni << ',' << thread << ',' << cls << ')');
-    
+
     bool isAgent = GetThreadManager().IsAgentThread(jni, thread);
     try {
         jvmtiError err;
@@ -1052,7 +1134,9 @@
         jint eventCount = 0;
         RequestID *eventList = 0;
         jdwpSuspendPolicy sp = JDWP_SUSPEND_NONE;
+
         GetRequestManager().GenerateEvents(jni, eInfo, eventCount, eventList, sp);
+
         eInfo.thread = isAgent ? 0 : thread;
         sp = isAgent ? JDWP_SUSPEND_NONE : sp;
     
@@ -1729,6 +1813,14 @@
         jthread thread, jmethodID method, jboolean was_popped_by_exception,
         jvalue return_value)
 {
+    HandleMethodExitWithoutReturnValue(jvmti, jni, thread, method, was_popped_by_exception, return_value);
+    HandleMethodExitWithReturnValue(jvmti, jni, thread, method, was_popped_by_exception, return_value);
+}
+
+void JNICALL RequestManager::HandleMethodExitWithoutReturnValue(jvmtiEnv* jvmti, JNIEnv* jni,
+        jthread thread, jmethodID method, jboolean was_popped_by_exception,
+        jvalue return_value)
+{
     JDWP_TRACE_ENTRY("HandleMethodExit(" << jvmti << ',' << jni << ',' << thread
         << ',' << method << ',' << was_popped_by_exception << ',' << &return_value << ')');
 
@@ -1737,6 +1829,11 @@
         return;
     }
 
+    // Method exit events are not generated if the method terminates with a thrown exception. 
+    if (was_popped_by_exception) {
+        return;
+    }
+
     try {
         jvmtiError err;
         EventInfo eInfo;
@@ -1817,6 +1914,103 @@
     }
 }
 
+void JNICALL RequestManager::HandleMethodExitWithReturnValue(jvmtiEnv* jvmti, JNIEnv* jni,
+        jthread thread, jmethodID method, jboolean was_popped_by_exception,
+        jvalue return_value)
+{
+    JDWP_TRACE_ENTRY("HandleMethodExitWithReturnValue(" << jvmti << ',' << jni << ',' << thread
+        << ',' << method << ',' << was_popped_by_exception << ',' << &return_value << ')');
+
+    // must be non-agent thread
+    if (GetThreadManager().IsAgentThread(jni, thread)) {
+        return;
+    }
+    // Method exit events are not generated if the method terminates with a thrown exception. 
+    if (was_popped_by_exception) {
+        return;
+    }
+
+    try {
+        jvmtiError err;
+        EventInfo eInfo;
+        memset(&eInfo, 0, sizeof(eInfo));
+        eInfo.kind = JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE;
+        eInfo.thread = thread;
+        CombinedEventsInfo::CombinedEventsKind combinedKind = CombinedEventsInfo::COMBINED_EVENT_METHOD_EXIT;
+
+        if (ENABLE_COMBINED_METHOD_EXIT_EVENT) {
+            // if this combined event was already prediced, ignore event
+            if (GetRequestManager().IsPredictedCombinedEvent(jni, eInfo, combinedKind)) {
+                return;
+            }
+        }
+
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetMethodDeclaringClass(method,
+            &eInfo.cls));
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(eInfo.cls,
+            &eInfo.signature, 0));
+        JvmtiAutoFree jafSignature(eInfo.signature);
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameLocation(thread, 0,
+            &eInfo.method, &eInfo.location));
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+        JDWP_ASSERT(method == eInfo.method);
+
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_EVENT)) {
+            char* name = 0;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetMethodName(eInfo.method, &name, 0, 0));
+
+            jvmtiThreadInfo info;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thread, &info));
+
+            JDWP_TRACE_EVENT("METHOD_EXIT_WITH_RETURN_VALUE event:"
+                << " class=" << JDWP_CHECK_NULL(eInfo.signature) 
+                << " method=" << JDWP_CHECK_NULL(name)
+                << " loc=" << eInfo.location
+                << " thread=" << JDWP_CHECK_NULL(info.name));
+        }
+#endif // NDEBUG
+
+        // there are no combined events to be generated after METHOD_EXIT_WITH_RETURN_VALUE event
+
+        jint eventCount = 0;
+        RequestID *eventList = 0;
+        jdwpSuspendPolicy sp = JDWP_SUSPEND_NONE;
+        GetRequestManager().GenerateEvents(jni, eInfo, eventCount, eventList, sp);
+        AgentAutoFree aafEL(eventList JDWP_FILE_LINE);
+
+        // post generated events
+        if (eventCount > 0) {
+            jdwpTypeTag typeTag = GetClassManager().GetJdwpTypeTag(eInfo.cls);
+            EventComposer *ec = new EventComposer(GetEventDispatcher().NewId(),
+                JDWP_COMMAND_SET_EVENT, JDWP_COMMAND_E_COMPOSITE, sp);
+            ec->event.WriteInt(eventCount);
+            for (jint i = 0; i < eventCount; i++) {
+                ec->event.WriteByte(JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE);
+                ec->event.WriteInt(eventList[i]);
+                ec->WriteThread(jni, thread);
+                ec->event.WriteLocation(jni,
+                    typeTag, eInfo.cls, method, eInfo.location);
+                ec->event.WriteValue(jni, MethodReturnType(GetJvmtiEnv(), method), return_value);
+            }
+            JDWP_TRACE_EVENT("MethodExitWithReturnValue : post set of " << eventCount << " events");
+            GetEventDispatcher().PostEventSet(jni, ec, JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE);
+        }
+    } catch (AgentException& e) {
+        JDWP_INFO("JDWP error in METHOD_EXIT_WITH_RETURN_VALUE: " << e.what() << " [" << e.ErrCode() << "]");
+    }
+}
+
 void JNICALL RequestManager::HandleFieldAccess(jvmtiEnv* jvmti, JNIEnv* jni,
         jthread thread, jmethodID method, jlocation location,
         jclass field_class, jobject object, jfieldID field)
@@ -2206,5 +2400,312 @@
         }
     } catch (AgentException& e) {
         JDWP_INFO("JDWP error in FRAME_POP: " << e.what() << " [" << e.ErrCode() << "]");
+    }
+}
+
+//-----------------------------------------------------------------------------
+// New event callbacks for Java 6
+//-----------------------------------------------------------------------------
+
+void JNICALL RequestManager::HandleMonitorWait(jvmtiEnv *jvmti, JNIEnv* jni, 
+            jthread thread, jobject object, jlong timeout)
+{
+    JDWP_TRACE_ENTRY("HandleMonitorWait(" << jvmti << ',' << jni << ',' << thread << ',' << object << ',' << timeout << ')');
+    
+    bool isAgent = GetThreadManager().IsAgentThread(jni, thread);
+    try {
+        jvmtiError err;
+        EventInfo eInfo;
+        memset(&eInfo, 0, sizeof(eInfo));
+        eInfo.kind = JDWP_EVENT_MONITOR_WAIT;
+        eInfo.thread = thread;
+        jclass cls = jni->GetObjectClass(object); 
+        eInfo.cls = cls;
+
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(eInfo.cls,
+            &eInfo.signature, 0));
+        JvmtiAutoFree jafSignature(eInfo.signature);
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_EVENT)) {
+            jvmtiThreadInfo info;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thread, &info));
+
+            JDWP_TRACE_EVENT("MONITOR_WAIT event:"
+                << " monitor object class=" << JDWP_CHECK_NULL(eInfo.signature)
+                << " thread=" << JDWP_CHECK_NULL(info.name));
+        }
+#endif // NDEBUG
+
+         JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameLocation(thread, 0,
+            &eInfo.method, &eInfo.location));
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+        jint eventCount = 0;
+        RequestID *eventList = 0;
+        jdwpSuspendPolicy sp = JDWP_SUSPEND_NONE;
+        GetRequestManager().GenerateEvents(jni, eInfo, eventCount, eventList, sp);
+        eInfo.thread = isAgent ? 0 : thread;
+        sp = isAgent ? JDWP_SUSPEND_NONE : sp;
+    
+        AgentAutoFree aafEL(eventList JDWP_FILE_LINE);
+
+        // post generated events
+        if (eventCount > 0) {
+            jdwpTypeTag typeTag = GetClassManager().GetJdwpTypeTag(cls);
+            jint status = 0;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetClassStatus(cls, &status));
+            if (err != JVMTI_ERROR_NONE) {
+                throw AgentException(err);
+            }
+            EventComposer *ec = new EventComposer(GetEventDispatcher().NewId(),
+                JDWP_COMMAND_SET_EVENT, JDWP_COMMAND_E_COMPOSITE, sp);
+            ec->event.WriteInt(eventCount);
+            for (jint i = 0; i < eventCount; i++) {
+                ec->event.WriteByte(JDWP_EVENT_MONITOR_WAIT);
+                ec->event.WriteInt(eventList[i]);
+                ec->WriteThread(jni, thread);
+                ec->event.WriteTaggedObjectID(jni, object);
+                ec->event.WriteLocation(jni,
+                    typeTag, eInfo.cls, eInfo.method, eInfo.location);
+                ec->event.WriteLong(timeout);
+            }
+            JDWP_TRACE_EVENT("MonitorWait: post set of " << eventCount << " events");
+            GetEventDispatcher().PostEventSet(jni, ec, JDWP_EVENT_MONITOR_WAIT);
+        }
+    } catch (AgentException& e) {
+        JDWP_INFO("JDWP error in MONITOR_WAIT: " << e.what() << " [" << e.ErrCode() << "]");
+    }
+}
+
+void JNICALL RequestManager::HandleMonitorWaited(jvmtiEnv *jvmti, JNIEnv* jni, 
+            jthread thread, jobject object, jboolean timed_out)
+{
+    JDWP_TRACE_ENTRY("HandleMonitorWaited(" << jvmti << ',' << jni << ',' << thread << ',' << object << ',' << timed_out << ')');
+    
+    bool isAgent = GetThreadManager().IsAgentThread(jni, thread);
+    try {
+        jvmtiError err;
+        EventInfo eInfo;
+        memset(&eInfo, 0, sizeof(eInfo));
+        eInfo.kind = JDWP_EVENT_MONITOR_WAITED;
+        eInfo.thread = thread;
+        jclass cls = jni->GetObjectClass(object); 
+        eInfo.cls = cls;
+
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(eInfo.cls,
+            &eInfo.signature, 0));
+        JvmtiAutoFree jafSignature(eInfo.signature);
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_EVENT)) {
+            jvmtiThreadInfo info;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thread, &info));
+
+            JDWP_TRACE_EVENT("MONITOR_WAITED event:"
+                << " monitor object class=" << JDWP_CHECK_NULL(eInfo.signature)
+                << " thread=" << JDWP_CHECK_NULL(info.name));
+        }
+#endif // NDEBUG
+
+         JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameLocation(thread, 0,
+            &eInfo.method, &eInfo.location));
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+        jint eventCount = 0;
+        RequestID *eventList = 0;
+        jdwpSuspendPolicy sp = JDWP_SUSPEND_NONE;
+        GetRequestManager().GenerateEvents(jni, eInfo, eventCount, eventList, sp);
+        eInfo.thread = isAgent ? 0 : thread;
+        sp = isAgent ? JDWP_SUSPEND_NONE : sp;
+    
+        AgentAutoFree aafEL(eventList JDWP_FILE_LINE);
+
+        // post generated events
+        if (eventCount > 0) {
+            jdwpTypeTag typeTag = GetClassManager().GetJdwpTypeTag(cls);
+            jint status = 0;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetClassStatus(cls, &status));
+            if (err != JVMTI_ERROR_NONE) {
+                throw AgentException(err);
+            }
+            EventComposer *ec = new EventComposer(GetEventDispatcher().NewId(),
+                JDWP_COMMAND_SET_EVENT, JDWP_COMMAND_E_COMPOSITE, sp);
+            ec->event.WriteInt(eventCount);
+            for (jint i = 0; i < eventCount; i++) {
+                ec->event.WriteByte(JDWP_EVENT_MONITOR_WAITED);
+                ec->event.WriteInt(eventList[i]);
+                ec->WriteThread(jni, thread);
+                ec->event.WriteTaggedObjectID(jni, object);
+                ec->event.WriteLocation(jni,
+                    typeTag, eInfo.cls, eInfo.method, eInfo.location);
+                ec->event.WriteBoolean(timed_out);
+            }
+            JDWP_TRACE_EVENT("MonitorWait: post set of " << eventCount << " events");
+            GetEventDispatcher().PostEventSet(jni, ec, JDWP_EVENT_MONITOR_WAITED);
+        }
+    } catch (AgentException& e) {
+        JDWP_INFO("JDWP error in MONITOR_WAITED: " << e.what() << " [" << e.ErrCode() << "]");
+    }
+}
+
+void JNICALL RequestManager::HandleMonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv* jni,
+            jthread thread, jobject object)
+{
+    JDWP_TRACE_ENTRY("HandleMonitorContendedEnter(" << jvmti << ',' << jni << ',' << thread << ',' << object << ')');
+    
+    bool isAgent = GetThreadManager().IsAgentThread(jni, thread);
+    try {
+        jvmtiError err;
+        EventInfo eInfo;
+        memset(&eInfo, 0, sizeof(eInfo));
+        eInfo.kind = JDWP_EVENT_MONITOR_CONTENDED_ENTER;
+        eInfo.thread = thread;
+        jclass cls = jni->GetObjectClass(object); 
+        eInfo.cls = cls;
+
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(eInfo.cls,
+            &eInfo.signature, 0));
+        JvmtiAutoFree jafSignature(eInfo.signature);
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_EVENT)) {
+            jvmtiThreadInfo info;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thread, &info));
+
+            JDWP_TRACE_EVENT("MONITOR_CONTENDED_ENTER event:"
+                << " monitor object class=" << JDWP_CHECK_NULL(eInfo.signature)
+                << " thread=" << JDWP_CHECK_NULL(info.name));
+        }
+#endif // NDEBUG
+
+         JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameLocation(thread, 0,
+            &eInfo.method, &eInfo.location));
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+        jint eventCount = 0;
+        RequestID *eventList = 0;
+        jdwpSuspendPolicy sp = JDWP_SUSPEND_NONE;
+        GetRequestManager().GenerateEvents(jni, eInfo, eventCount, eventList, sp);
+        eInfo.thread = isAgent ? 0 : thread;
+        sp = isAgent ? JDWP_SUSPEND_NONE : sp;
+    
+        AgentAutoFree aafEL(eventList JDWP_FILE_LINE);
+
+        // post generated events
+        if (eventCount > 0) {
+            jdwpTypeTag typeTag = GetClassManager().GetJdwpTypeTag(cls);
+            jint status = 0;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetClassStatus(cls, &status));
+            if (err != JVMTI_ERROR_NONE) {
+                throw AgentException(err);
+            }
+            EventComposer *ec = new EventComposer(GetEventDispatcher().NewId(),
+                JDWP_COMMAND_SET_EVENT, JDWP_COMMAND_E_COMPOSITE, sp);
+            ec->event.WriteInt(eventCount);
+            for (jint i = 0; i < eventCount; i++) {
+                ec->event.WriteByte(JDWP_EVENT_MONITOR_CONTENDED_ENTER);
+                ec->event.WriteInt(eventList[i]);
+                ec->WriteThread(jni, thread);
+                ec->event.WriteTaggedObjectID(jni, object);
+                ec->event.WriteLocation(jni,
+                    typeTag, eInfo.cls, eInfo.method, eInfo.location);
+            }
+            JDWP_TRACE_EVENT("MonitorContendedEnter: post set of " << eventCount << " events");
+            GetEventDispatcher().PostEventSet(jni, ec, JDWP_EVENT_MONITOR_CONTENDED_ENTER);
+        }
+    } catch (AgentException& e) {
+        JDWP_INFO("JDWP error in MONITOR_CONTENDED_ENTER: " << e.what() << " [" << e.ErrCode() << "]");
+    }
+
+}
+
+void JNICALL RequestManager::HandleMonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv* jni,
+            jthread thread, jobject object)
+{
+    JDWP_TRACE_ENTRY("HandleMonitorContendedEntered(" << jvmti << ',' << jni << ',' << thread << ',' << object << ')');
+    
+    bool isAgent = GetThreadManager().IsAgentThread(jni, thread);
+    try {
+        jvmtiError err;
+        EventInfo eInfo;
+        memset(&eInfo, 0, sizeof(eInfo));
+        eInfo.kind = JDWP_EVENT_MONITOR_CONTENDED_ENTERED;
+        eInfo.thread = thread;
+        jclass cls = jni->GetObjectClass(object); 
+        eInfo.cls = cls;
+
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(eInfo.cls,
+            &eInfo.signature, 0));
+        JvmtiAutoFree jafSignature(eInfo.signature);
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_EVENT)) {
+            jvmtiThreadInfo info;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thread, &info));
+
+            JDWP_TRACE_EVENT("MONITOR_CONTENDED_ENTERED event:"
+                << " monitor object class=" << JDWP_CHECK_NULL(eInfo.signature)
+                << " thread=" << JDWP_CHECK_NULL(info.name));
+        }
+#endif // NDEBUG
+
+         JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameLocation(thread, 0,
+            &eInfo.method, &eInfo.location));
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+        jint eventCount = 0;
+        RequestID *eventList = 0;
+        jdwpSuspendPolicy sp = JDWP_SUSPEND_NONE;
+        GetRequestManager().GenerateEvents(jni, eInfo, eventCount, eventList, sp);
+        eInfo.thread = isAgent ? 0 : thread;
+        sp = isAgent ? JDWP_SUSPEND_NONE : sp;
+    
+        AgentAutoFree aafEL(eventList JDWP_FILE_LINE);
+
+        // post generated events
+        if (eventCount > 0) {
+            jdwpTypeTag typeTag = GetClassManager().GetJdwpTypeTag(cls);
+            jint status = 0;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetClassStatus(cls, &status));
+            if (err != JVMTI_ERROR_NONE) {
+                throw AgentException(err);
+            }
+            EventComposer *ec = new EventComposer(GetEventDispatcher().NewId(),
+                JDWP_COMMAND_SET_EVENT, JDWP_COMMAND_E_COMPOSITE, sp);
+            ec->event.WriteInt(eventCount);
+            for (jint i = 0; i < eventCount; i++) {
+                ec->event.WriteByte(JDWP_EVENT_MONITOR_CONTENDED_ENTERED);
+                ec->event.WriteInt(eventList[i]);
+                ec->WriteThread(jni, thread);
+                ec->event.WriteTaggedObjectID(jni, object);
+                ec->event.WriteLocation(jni,
+                    typeTag, eInfo.cls, eInfo.method, eInfo.location);
+            }
+            JDWP_TRACE_EVENT("MonitorContendedEntered: post set of " << eventCount << " events");
+            GetEventDispatcher().PostEventSet(jni, ec, JDWP_EVENT_MONITOR_CONTENDED_ENTERED);
+        }
+    } catch (AgentException& e) {
+        JDWP_INFO("JDWP error in MONITOR_CONTENDED_ENTERED: " << e.what() << " [" << e.ErrCode() << "]");
     }
 }

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.h?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.h Tue Apr  8 02:51:16 2008
@@ -434,9 +434,76 @@
         static void JNICALL HandleFramePop(jvmtiEnv* jvmti, JNIEnv* jni,
             jthread thread, jmethodID method, jboolean was_popped_by_exception);
 
+        // New event callbacks for Java 6
+        /**
+         * <code>MonitorContendedEnter</code> event callbacks.
+         *
+         * @param jvmti                    - the JVMTI interface pointer
+         * @param jni                      - the JNI interface pointer
+         * @param thread                   - the thread attempting to enter the monitor 
+         * @param object                   - the monitor object
+         */
+        static void JNICALL HandleMonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv* jni,
+            jthread thread, jobject object);
+        
+        /**
+         * <code>MonitorContendedEntered</code> event callbacks.
+         *
+         * @param jvmti                    - the JVMTI interface pointer
+         * @param jni                      - the JNI interface pointer
+         * @param thread                   -  the thread entering the monitor 
+         * @param object                   - the monitor object
+         */
+        static void JNICALL HandleMonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv* jni,
+            jthread thread, jobject object);
+
+        /**
+         * <code>MonitorWait</code> event callbacks.
+         *
+         * @param jvmti                    - the JVMTI interface pointer
+         * @param jni                      - the JNI interface pointer
+         * @param thread                   - the  the thread that was finished waiting 
+         * @param object                   - the monitor object
+         * @param timeout                  - the number of milliseconds the thread will wait 
+         */
+        static void JNICALL HandleMonitorWait(jvmtiEnv *jvmti, JNIEnv* jni, 
+            jthread thread, jobject object, jlong timeout);
+
+        /**
+         * <code>MonitorWaited</code> event callbacks.
+         *
+         * @param jvmti                    - the JVMTI interface pointer
+         * @param jni                      - the JNI interface pointer
+         * @param thread                   - the Java thread-generating event
+         * @param object                   - the monitor object
+         * @param timeout               - true if the monitor timed out 
+         */
+        static void JNICALL HandleMonitorWaited(jvmtiEnv *jvmti, JNIEnv* jni, 
+            jthread thread, jobject object, jboolean timed_out);
+
+
     private:
 
         /**
+         * Get the return type of the method
+         */
+        static jdwpTag MethodReturnType(jvmtiEnv *env, jmethodID method);
+        
+        /**
+         * Generate event whose event kind is MethodExitWithReturnValue 
+         */
+        static void JNICALL HandleMethodExitWithReturnValue(jvmtiEnv* jvmti, JNIEnv* jni,
+        jthread thread, jmethodID method, jboolean was_popped_by_exception,
+        jvalue return_value);
+
+        /**
+         * Generate event whose event kind is MethodExit
+         */
+        static void JNICALL HandleMethodExitWithoutReturnValue(jvmtiEnv* jvmti, JNIEnv* jni,
+        jthread thread, jmethodID method, jboolean was_popped_by_exception,
+        jvalue return_value);
+
+        /**
          * Enables/disables all appropriate events for given Breakpoint event request. 
          */
         void ControlBreakpoint(JNIEnv* jni, AgentEventRequest* request,
@@ -549,6 +616,13 @@
         RequestList m_methodEntryRequests;
         RequestList m_methodExitRequests;
         RequestList m_vmDeathRequests;
+        // New list of event request IDs for Java 6
+        RequestList m_methodExitWithReturnValueRequests;
+        RequestList m_monitorContendedEnterRequests;
+        RequestList m_monitorContendedEnteredRequests;
+        RequestList m_monitorWaitRequests;
+        RequestList m_monitorWaitedRequests;
+
 
         CombinedEventsInfoList m_combinedEventsInfoList;
     };

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.cpp?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.cpp Tue Apr  8 02:51:16 2008
@@ -51,3 +51,84 @@
             strncmp(pattern, &signature[1], patternLength) == 0);
     }
 }
+
+bool SourceNameMatchModifier::Apply(JNIEnv* jni, EventInfo &eInfo) throw()
+{
+    JDWP_ASSERT(eInfo.cls != 0);
+    jclass jvmClass = eInfo.cls;
+    try {
+        char* sourceDebugExtension = 0;
+        char* sourceFileName = 0;
+        jvmtiError err;
+        // Get source name determined by SourceDebugExtension
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetSourceDebugExtension(jvmClass,
+            &sourceDebugExtension));
+
+        if (err != JVMTI_ERROR_NONE) {
+            // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY,JVMTI_ERROR_ABSENT_INFORMATION,
+            // JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_NULL_POINTER
+            if(err == JVMTI_ERROR_ABSENT_INFORMATION) {                   
+                // SourceDebugExtension is absent, get source name from SourceFile
+                JVMTI_TRACE(err, GetJvmtiEnv()->GetSourceFileName(jvmClass,
+                    &sourceFileName));
+
+                if (err != JVMTI_ERROR_NONE) {
+                    // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_ABSENT_INFORMATION,
+                    // JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_NULL_POINTER
+                    throw AgentException(err);
+                 }
+                 JvmtiAutoFree autoFreeFieldName(sourceFileName);
+                 return MatchPatternSourceName(sourceFileName, m_pattern);
+                 } else { 
+                    throw AgentException(err);
+                 }
+            }
+            JvmtiAutoFree autoFreeDebugExtension(sourceDebugExtension);            
+          
+            string str(sourceDebugExtension);
+            JDWP_TRACE_DATA("JDWP sourceDebugExtension: " << str);
+            vector<string> tokens;
+            ParseSourceDebugExtension(str, tokens, "\n");
+            return MatchPatternSourceName(tokens[1].c_str(), m_pattern);
+    } catch (AgentException& e) {
+        JDWP_TRACE_DATA("JDWP error in SourceNameMatchModifier.Apply: " << e.what() << " [" << e.ErrCode() << "]");
+        return false;
+    }
+}
+
+// match source name with pattern
+bool SourceNameMatchModifier::MatchPatternSourceName(const char *sourcename, const char *pattern)
+    const 
+{
+    JDWP_TRACE_DATA("JDWP in SourceNameMatchModifier::MatchPatternSourceName");
+   if(sourcename == 0) {
+        return false;
+    }
+
+    const size_t sourcenameLength = strlen(sourcename);
+    const size_t patternLength = strlen(pattern);
+
+    if((sourcenameLength -  patternLength + 1) < 0) { 
+        return false;
+    }
+    if (pattern[0] == '*') {
+        return (strcmp(&pattern[1], &sourcename[sourcenameLength-patternLength+1]) == 0);
+    } else if (pattern[patternLength-1] == '*') {
+        return (strncmp(pattern, &sourcename[0], patternLength-1) == 0);
+    } else {
+         return (patternLength == sourcenameLength &&
+            strncmp(pattern, &sourcename[0], patternLength) == 0);
+    }
+}
+
+// parse SourceDebugExtension by "\n" delimiter
+void SourceNameMatchModifier::ParseSourceDebugExtension(const string& str, vector<string>& tokens, const string& delimiters)
+{
+    string::size_type lastPos = str.find_first_not_of(delimiters, 0);
+    string::size_type pos = str.find_first_of(delimiters, lastPos);
+    while (string::npos != pos || string::npos != lastPos) {
+        tokens.push_back(str.substr(lastPos, pos - lastPos));
+        lastPos = str.find_first_not_of(delimiters, pos);
+        pos = str.find_first_of(delimiters, lastPos);
+    }
+}

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.h?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/RequestModifier.h Tue Apr  8 02:51:16 2008
@@ -31,6 +31,7 @@
 #define _REQUEST_MODIFIER_H_
 
 #include "AgentBase.h"
+#include <vector>
 
 namespace jdwp {
 
@@ -126,6 +127,7 @@
          * @return <code>TRUE</code>.
          */
         virtual bool Apply(JNIEnv* jni, EventInfo &eInfo) throw() {
+            JDWP_TRACE_DATA("RequestModifier.Apply is invoked.");
             return true;
         }
 
@@ -140,6 +142,7 @@
 
         bool MatchPattern(const char *signature, const char *pattern)
             const throw();
+        
 
         jdwpRequestModifier m_kind;
 
@@ -900,6 +903,61 @@
 
     };
 
+    // New modifier for Java 6
+    /**
+     * The class implements the <code>SourceNameMatch</code> modifier enabling the 
+     * requested events to be reported only for the reference type which have a source name 
+     * corresponding to the given pattern.
+     */
+    class SourceNameMatchModifier : public RequestModifier {
+
+    public:
+
+        /**
+         * A constructor.
+         *
+         * @param str - the source name match pattern
+         */
+        SourceNameMatchModifier(char* str)
+            : RequestModifier(JDWP_MODIFIER_SOURCE_NAME_MATCH)
+            , m_pattern(str)
+        {}
+
+        /**
+         * A destructor.
+         */
+        ~SourceNameMatchModifier() {
+            GetMemoryManager().Free(m_pattern JDWP_FILE_LINE);
+        }
+
+        /**
+         * Gets the source name match pattern.
+         *
+         * @return Zero-terminated string.
+         */
+        const char* GetPattern() const throw() {
+            return m_pattern;
+        }
+
+        /**
+         * Applies the source name match filtering for the given event.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param eInfo  - the request-event information
+         *
+         * @return Returns <code>TRUE</code>, if the source name matches the given pattern.
+         */
+        bool Apply(JNIEnv* jni, EventInfo &eInfo) throw();
+      
+
+    private:
+        bool MatchPatternSourceName(const char *sourcename, const char *pattern)
+            const ;
+        void ParseSourceDebugExtension(const string& str, vector<string>& tokens, const string& delimiters);
+
+        char* m_pattern;
+
+    };
 }
 
 #endif // _REQUEST_MODIFIER_H_

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h Tue Apr  8 02:51:16 2008
@@ -270,7 +270,13 @@
     JDWP_EVENT_VM_INIT = 90,
     JDWP_EVENT_VM_START = JDWP_EVENT_VM_INIT,
     JDWP_EVENT_VM_DEATH = 99,
-    JDWP_EVENT_VM_DISCONNECTED = 100
+    JDWP_EVENT_VM_DISCONNECTED = 100,
+    // New EventKind constants for Java 6
+    JDWP_EVENT_METHOD_EXIT_WITH_RETURN_VALUE = 42,    
+    JDWP_EVENT_MONITOR_CONTENDED_ENTER = 43,    
+    JDWP_EVENT_MONITOR_CONTENDED_ENTERED = 44, 
+    JDWP_EVENT_MONITOR_WAIT = 45,    
+    JDWP_EVENT_MONITOR_WAITED = 46
 } jdwpEventKind;
 
 /* EventRequest/ModifierKind Constants */
@@ -286,7 +292,9 @@
     JDWP_MODIFIER_EXCEPTION_ONLY = 8,
     JDWP_MODIFIER_FIELD_ONLY = 9,
     JDWP_MODIFIER_STEP = 10,
-    JDWP_MODIFIER_INSTANCE_ONLY = 11
+    JDWP_MODIFIER_INSTANCE_ONLY = 11,
+    // New ModifierKind constants for Java 6
+    JDWP_MODIFIER_SOURCE_NAME_MATCH = 12
 } jdwpRequestModifier;
 
 /* ThreadStatus Constants */

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java Tue Apr  8 02:51:16 2008
@@ -67,7 +67,7 @@
 
     public boolean canGetMonitorFrameInfo           = false;
 
-    public boolean reserved19                       = false;
+    public boolean canUseSourceNameFilters          = false;
 
     public boolean canGetConstantPool               = false;
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java Tue Apr  8 02:51:16 2008
@@ -55,6 +55,9 @@
         public static final byte Step          = 10;
 
         public static final byte InstanceOnly  = 11;
+        
+        // new case for Java 6
+        public static final byte SourceNameMatch = 12;
     }
 
     public byte modKind;
@@ -68,6 +71,8 @@
     public long     clazz;
 
     public String   classPattern;
+    
+    public String   sourceNamePattern;
 
     public Location loc;
 
@@ -103,6 +108,7 @@
         // referenceTypeID
         clazz = -1;
         classPattern = new String();
+        sourceNamePattern = new String();
         loc = new Location();
         // referenceTypeID
         exceptionOrNull = -1;

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPConstants.java Tue Apr  8 02:51:16 2008
@@ -303,6 +303,19 @@
         public static final byte METHOD_ENTRY = 40;
 
         public static final byte METHOD_EXIT = 41;
+        
+        // METHOD_EXIT_WITH_RETURN_VALUE
+        // MONITOR_CONTENDED_ENTER,MONITOR_CONTENDED_ENTER
+        // MONITOR_WAIT, MONITOR_WAITED are new events for Java 6
+        public static final byte METHOD_EXIT_WITH_RETURN_VALUE = 42;
+        
+        public static final byte MONITOR_CONTENDED_ENTER = 43;
+        
+        public static final byte MONITOR_CONTENDED_ENTERED = 44;
+        
+        public static final byte MONITOR_WAIT = 45;
+        
+        public static final byte MONITOR_WAITED = 46;   
 
         public static final byte VM_INIT = 90;
 
@@ -351,6 +364,16 @@
                 return "METHOD_ENTRY";
             case METHOD_EXIT:
                 return "METHOD_EXIT";
+            case METHOD_EXIT_WITH_RETURN_VALUE:
+                return "METHOD_EXIT_WITH_RETURN_VALUE";
+            case MONITOR_CONTENDED_ENTER:
+                return "MONITOR_CONTENDED_ENTER";
+            case MONITOR_CONTENDED_ENTERED:
+                return "MONITOR_CONTENDED_ENTERED";
+            case MONITOR_WAIT:
+                return "MONITOR_WAIT";
+            case MONITOR_WAITED:
+                return "MONITOR_WAITED";
             case VM_INIT:
                 return "VM_INIT";
             case VM_DEATH:

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/ParsedEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/ParsedEvent.java?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/ParsedEvent.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/ParsedEvent.java Tue Apr  8 02:51:16 2008
@@ -125,6 +125,42 @@
             return location;
         }
     }
+    
+    /**
+     * The class extends EventThread by associating it with monitor object and location.
+     */
+    private static class EventThreadMonitor extends EventThread {
+
+        private TaggedObject taggedObject;
+        private Location location;
+
+        /**
+         * A constructor.
+         * 
+         * @param suspendPolicy
+         * @param packet
+         */
+        protected EventThreadMonitor(byte suspendPolicy, Packet packet,
+                byte eventKind) {
+            super(suspendPolicy, packet, eventKind);
+            this.taggedObject = packet.getNextValueAsTaggedObject();
+            this.location = packet.getNextValueAsLocation();
+        }
+
+        /**
+         * @return Returns the location.
+         */
+        public Location getLocation() {
+            return location;
+        }
+        
+        /**
+         * @return Returns the taggedObject.
+         */
+        public TaggedObject getTaggedObject() {
+            return taggedObject;
+        }
+    }
 
     /**
      * The class implements JDWP VM_START event.
@@ -205,6 +241,109 @@
             super(suspendPolicy, packet, JDWPConstants.EventKind.METHOD_EXIT);
         }
     }
+    
+    /**
+     * The class implements JDWP METHOD_EXIT_WITH_RETURN_VALUE event.
+     */
+    public static final class Event_METHOD_EXIT_WITH_RETURN_VALUE extends EventThreadLocation {
+
+        private Value returnValue;
+        
+        /**
+         * A constructor.
+         * 
+         * @param suspendPolicy
+         * @param packet
+         */
+        private Event_METHOD_EXIT_WITH_RETURN_VALUE(byte suspendPolicy, Packet packet) {
+            super(suspendPolicy, packet, JDWPConstants.EventKind.METHOD_EXIT_WITH_RETURN_VALUE);
+            returnValue = packet.getNextValueAsValue();
+        }
+        
+        public Value getReturnValue(){
+			return returnValue;
+        }
+    }
+    
+    /**
+     * The class implements JDWP MONITOR_CONTENDED_ENTER event.
+     */
+    public static final class Event_MONITOR_CONTENDED_ENTER extends EventThreadMonitor {
+
+        /**
+         * A constructor.
+         * 
+         * @param suspendPolicy
+         * @param packet
+         */
+        private Event_MONITOR_CONTENDED_ENTER(byte suspendPolicy, Packet packet) {
+            super(suspendPolicy, packet, JDWPConstants.EventKind.MONITOR_CONTENDED_ENTER);
+        }
+
+    }
+    
+    /**
+     * The class implements JDWP MONITOR_CONTENDED_ENTERED event.
+     */
+    public static final class Event_MONITOR_CONTENDED_ENTERED extends EventThreadMonitor {
+
+        /**
+         * A constructor.
+         * 
+         * @param suspendPolicy
+         * @param packet
+         */
+        private Event_MONITOR_CONTENDED_ENTERED(byte suspendPolicy, Packet packet) {
+            super(suspendPolicy, packet, JDWPConstants.EventKind.MONITOR_CONTENDED_ENTERED);
+        }
+
+    }
+    
+    /**
+     * The class implements JDWP METHOD_EXIT_WITH_RETURN_VALUE event.
+     */
+    public static final class Event_MONITOR_WAIT extends EventThreadMonitor {
+
+        private long timeout;
+        
+        /**
+         * A constructor.
+         * 
+         * @param suspendPolicy
+         * @param packet
+         */
+        private Event_MONITOR_WAIT(byte suspendPolicy, Packet packet) {
+            super(suspendPolicy, packet, JDWPConstants.EventKind.MONITOR_WAIT);
+            this.timeout = packet.getNextValueAsLong();
+        }
+        
+        public long getTimeout(){
+            return timeout;
+        }
+    }
+    
+    /**
+     * The class implements JDWP METHOD_EXIT_WITH_RETURN_VALUE event.
+     */
+    public static final class Event_MONITOR_WAITED extends EventThreadMonitor {
+
+        private boolean timed_out;
+        
+        /**
+         * A constructor.
+         * 
+         * @param suspendPolicy
+         * @param packet
+         */
+        private Event_MONITOR_WAITED(byte suspendPolicy, Packet packet) {
+            super(suspendPolicy, packet, JDWPConstants.EventKind.MONITOR_WAITED);
+            this.timed_out = packet.getNextValueAsBoolean();
+        }
+        
+        public boolean getTimedout(){
+            return timed_out;
+        }
+    }
 
     /**
      * The class implements JDWP EXCEPTION event.
@@ -533,6 +672,26 @@
             }
             case JDWPConstants.EventKind.METHOD_EXIT: {
                 events[i] = new Event_METHOD_EXIT(suspendPolicy, packetCopy);
+                break;
+            }
+            case JDWPConstants.EventKind.METHOD_EXIT_WITH_RETURN_VALUE: {
+                events[i] = new Event_METHOD_EXIT_WITH_RETURN_VALUE(suspendPolicy, packetCopy);
+                break;
+            }
+            case JDWPConstants.EventKind.MONITOR_CONTENDED_ENTER: {
+                events[i] = new Event_MONITOR_CONTENDED_ENTER(suspendPolicy, packetCopy);
+                break;
+            }
+            case JDWPConstants.EventKind.MONITOR_CONTENDED_ENTERED: {
+                events[i] = new Event_MONITOR_CONTENDED_ENTERED(suspendPolicy, packetCopy);
+                break;
+            }
+            case JDWPConstants.EventKind.MONITOR_WAIT: {
+                events[i] = new Event_MONITOR_WAIT(suspendPolicy, packetCopy);
+                break;
+            }
+            case JDWPConstants.EventKind.MONITOR_WAITED: {
+                events[i] = new Event_MONITOR_WAITED(suspendPolicy, packetCopy);
                 break;
             }
             case JDWPConstants.EventKind.EXCEPTION: {

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java Tue Apr  8 02:51:16 2008
@@ -417,7 +417,7 @@
         targetVMCapabilities.reserved17 = replyPacket.getNextValueAsBoolean();
         targetVMCapabilities.canGetMonitorFrameInfo = replyPacket
                 .getNextValueAsBoolean();
-        targetVMCapabilities.reserved19 = replyPacket.getNextValueAsBoolean();
+        targetVMCapabilities.canUseSourceNameFilters = replyPacket.getNextValueAsBoolean();
         targetVMCapabilities.canGetConstantPool = replyPacket
                 .getNextValueAsBoolean();
         targetVMCapabilities.canForceEarlyReturn = replyPacket
@@ -931,6 +931,28 @@
         // Set event
         return setEvent(event);
     }
+    
+    /**
+     * Sets ClassPrepare event request for given source name pattern.
+     * 
+     * @param sourceNamePattern
+     *            Required source name pattern. Matches are limited to exact matches
+     *            of the given source name pattern and matches of patterns that begin
+     *            or end with '*'; for example, "*.Foo" or "java.*".
+     * @return ReplyPacket for setting request.
+     */
+    public ReplyPacket setClassPreparedForSourceNameMatch(String sourceNamePattern) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.CLASS_PREPARE;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].sourceNamePattern = sourceNamePattern; 
+        mods[0].modKind = EventMod.ModKind.SourceNameMatch;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
 
     /**
      * Sets ClassUnload event request for given class name pattern.
@@ -1010,6 +1032,176 @@
         // Set event
         return setEvent(event);
     }
+    
+    /**
+     * Set MonitorContendedEnter event request for given class's reference type
+     * 
+     * @param referenceTypeID
+     *            class referenceTypeID
+     * @return ReplyPacket for setting request
+     */
+    public ReplyPacket setMonitorContendedEnterForClassOnly(long referenceTypeID) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_CONTENDED_ENTER;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].clazz = referenceTypeID;
+        mods[0].modKind = EventMod.ModKind.ClassOnly;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
+
+    /**
+     * Set MonitorContendedEntered event request for given class's reference type
+     * 
+     * @param referenceTypeID
+     *            class referenceTypeID
+     * @return ReplyPacket for setting request
+     */
+    public ReplyPacket setMonitorContendedEnteredForClassOnly(long referenceTypeID) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_CONTENDED_ENTERED;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].clazz = referenceTypeID;
+        mods[0].modKind = EventMod.ModKind.ClassOnly;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
+    
+    /**
+     * Set MonitorWait event request for given class's reference type
+     * 
+     * @param referenceTypeID
+     *            class referenceTypeID
+     * @return ReplyPacket for setting request
+     */
+    public ReplyPacket setMonitorWaitForClassOnly(long referenceTypeID) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_WAIT;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].clazz = referenceTypeID;
+        mods[0].modKind = EventMod.ModKind.ClassOnly;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
+
+    /**
+     * Set MonitorWait event request for given given class name pattern.
+     * 
+     * @param classRegexp
+     *            Required class pattern. Matches are limited to exact matches
+     *            of the given class pattern and matches of patterns that begin
+     *            or end with '*'; for example, "*.Foo" or "java.*".
+     * @return ReplyPacket for setting request.
+     */
+    public ReplyPacket setMonitorWaitForClassMatch(String classRegexp) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_WAIT;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].classPattern = classRegexp;
+        mods[0].modKind = EventMod.ModKind.ClassMatch;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
+    
+    /**
+     * Set MonitorWait event request for classes 
+     * whose name does not match the given restricted regular expression.
+     * 
+     * @param classRegexp
+     *            Exclude class pattern. Matches are limited to exact matches
+     *            of the given class pattern and matches of patterns that begin
+     *            or end with '*'; for example, "*.Foo" or "java.*".
+     * @return ReplyPacket for setting request.
+     */
+    public ReplyPacket setMonitorWaitForClassExclude (String classRegexp) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_WAIT;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].classPattern = classRegexp;
+        mods[0].modKind = EventMod.ModKind.ClassExclude;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
+    
+    /**
+     * Set MonitorWaited event request for given class's reference type
+     * 
+     * @param referenceTypeID
+     *            class referenceTypeID
+     * @return ReplyPacket for setting request
+     */
+    public ReplyPacket setMonitorWaitedForClassOnly(long referenceTypeID) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_WAITED;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].clazz = referenceTypeID;
+        mods[0].modKind = EventMod.ModKind.ClassOnly;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
+    
+    /**
+     * Set MonitorWaited event request for given given source name pattern.
+     * 
+     * @param classRegexp
+     *            Required class pattern. Matches are limited to exact matches
+     *            of the given class pattern and matches of patterns that begin
+     *            or end with '*'; for example, "*.Foo" or "java.*".
+     * @return ReplyPacket for setting request.
+     */
+    public ReplyPacket setMonitorWaitedForClassMatch(String classRegexp) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_WAITED;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].classPattern = classRegexp;
+        mods[0].modKind = EventMod.ModKind.ClassMatch;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
+    
+    /**
+     * Set MonitorWaited event request for classes 
+     * whose name does not match the given restricted regular expression.
+     * 
+     * @param classRegexp
+     *            Required class pattern. Matches are limited to exact matches
+     *            of the given class pattern and matches of patterns that begin
+     *            or end with '*'; for example, "*.Foo" or "java.*".
+     * @return ReplyPacket for setting request.
+     */
+    public ReplyPacket setMonitorWaitedForClassExclude (String classRegexp) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.MONITOR_WAITED;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = new EventMod[] { new EventMod() };
+        mods[0].classPattern = classRegexp;
+        mods[0].modKind = EventMod.ModKind.ClassExclude;
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        // Set event
+        return setEvent(event);
+    }
 
     /**
      * Set event request for given event.
@@ -1099,6 +1291,10 @@
                 commandPacket.setNextValueAsObjectID(event.mods[i].instance);
                 break;
             }
+            case EventMod.ModKind.SourceNameMatch: {
+                // Case SourceNameMatch 
+                commandPacket.setNextValueAsString(event.mods[i].sourceNamePattern);
+            }
             }
         }
 
@@ -1314,6 +1510,32 @@
     public ReplyPacket setMethodExit(String classRegexp) {
         // Prepare corresponding event
         byte eventKind = JDWPConstants.EventKind.METHOD_EXIT;
+        byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
+        EventMod[] mods = null;
+        if (classRegexp == null) {
+            mods = new EventMod[0];
+        } else {
+            mods = new EventMod[1];
+            mods[0] = new EventMod();
+            mods[0].modKind = EventMod.ModKind.ClassMatch;
+            mods[0].classPattern = classRegexp;
+        }
+        Event event = new Event(eventKind, suspendPolicy, mods);
+
+        return setEvent(event);
+    }
+    
+    /**
+     * Sets METHOD_EXIT_WITH_RETURN_VALUE event request for specified class name pattern.
+     * 
+     * @param classRegexp
+     *            class name pattern or null for no pattern
+     * 
+     * @return ReplyPacket for corresponding command
+     */
+    public ReplyPacket setMethodExitWithReturnValue(String classRegexp) {
+        // Prepare corresponding event
+        byte eventKind = JDWPConstants.EventKind.METHOD_EXIT_WITH_RETURN_VALUE;
         byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
         EventMod[] mods = null;
         if (classRegexp == null) {

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareDebuggee.java?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareDebuggee.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareDebuggee.java Tue Apr  8 02:51:16 2008
@@ -38,7 +38,7 @@
     public static void main(String[] args) {
         runDebuggee(ClassPrepareDebuggee.class);
     }
-    
+
     public void run() {
         synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
         
@@ -48,13 +48,18 @@
         
         try {
             // Test class prepare
-            logWriter.println("Try to load and prepare class Class2Prepare");
+            logWriter.println("--> Try to load and prepare class Class2Prepare");
             Class.forName("org.apache.harmony.jpda.tests.jdwp.Events.Class2Prepare");
+            
+            // Prepare for SourceNameMatch case
+            logWriter.println("--> Try to load and prepare SourceDebugExtensionMockClass");
+            Class.forName("org.apache.harmony.jpda.tests.jdwp.Events.SourceDebugExtensionMockClass");
         } catch (ClassNotFoundException e) {
             e.printStackTrace();
         }
-        
+
         logWriter.println("ClassPrepareDebuggee finished");
+        
     }
     
 }

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareTest.java?rev=645814&r1=645813&r2=645814&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareTest.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepareTest.java Tue Apr  8 02:51:16 2008
@@ -26,14 +26,13 @@
  */
 package org.apache.harmony.jpda.tests.jdwp.Events;
 
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
 import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
 import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
 
-
-
 /**
  * JDWP Unit test for CLASS_PREPARE event.
  */
@@ -79,4 +78,124 @@
         //logWriter.println("parsedEvent="+parsedEvents[0].getClass().getCanonicalName());
         //logWriter.println(((ParsedEvent.Event_CLASS_PREPARE)parsedEvents[0]).getSignature());
     }
+    
+    /*
+     * This testcase is for CLASS_PREPARE event.
+     * <BR>It runs ClassPrepareDebuggee to load Class2Prepare class
+     * and verify that requested CLASS_PREPARE event occurs in case of SourceNameMatch.
+     * Class2Prepare doesn't contain source name field in SourceDebugExtension attribute.
+     * expectedSourceNamePattern is used to assign the source name's pattern
+     */
+    public void testClassPrepareEventWithoutSourceDebugExtension(String expectedSourceNamePattern){
+        String expectedClassSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/Class2Prepare;"; 
+        logWriter.println("==> testClassPrepareEventForSourceNameMatch started");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // Set ClassPrepare Event in case of SourceNameMatch
+        ReplyPacket reply = debuggeeWrapper.vmMirror.setClassPreparedForSourceNameMatch(expectedSourceNamePattern);
+        checkReplyPacket(reply, "Set CLASS_PREPARE event");
+        
+        // start loading SourceDebugExtensionMockClass class
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+        CommandPacket receiveEvent = debuggeeWrapper.vmMirror.receiveEvent();
+        ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(receiveEvent);
+        
+        assertEquals("Invalid number of events,", 1, parsedEvents.length);
+        assertEquals("Invalid event kind,", JDWPConstants.EventKind.CLASS_PREPARE, parsedEvents[0].getEventKind()
+                , JDWPConstants.EventKind.getName(JDWPConstants.EventKind.CLASS_PREPARE)
+                , JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()));
+        assertEquals("Invalid signature of prepared class,", expectedClassSignature, ((ParsedEvent.Event_CLASS_PREPARE)parsedEvents[0]).getSignature());
+    }
+    
+    /**
+     * Test ClassPrepareEvent without SourceDebugExtension attribute
+     * matching exactly.
+     */
+    public void testClassPrepareEventWithoutSourceDebugExtension001(){
+        String expectedSourceNamePattern = "Class2Prepare.java";
+        testClassPrepareEventWithoutSourceDebugExtension(expectedSourceNamePattern);
+        
+    }
+    
+    /**
+     * Test ClassPrepareEvent without SourceDebugExtension attribute
+     * matching the former part.
+     */
+    public void testClassPrepareEventWithoutSourceDebugExtension002(){
+        String expectedSourceNamePattern = "*Class2Prepare.java";
+        testClassPrepareEventWithoutSourceDebugExtension(expectedSourceNamePattern);
+    }
+    
+    /**
+     * Test ClassPrepareEvent without SourceDebugExtension attribute
+     * matching the latter part.
+     */
+    public void testClassPrepareEventWithoutSourceDebugExtension003(){
+        String expectedSourceNamePattern = "Class2Prepare.*";
+        testClassPrepareEventWithoutSourceDebugExtension(expectedSourceNamePattern);
+    }
+    
+    /*
+     * This testcase is for CLASS_PREPARE event.
+     * <BR>It runs ClassPrepareDebuggee to load SourceDebugExtensionMockClass 
+     * and verify that requested CLASS_PREPARE event occurs in case of SourceNameMatch.
+     * SourceDebugExtensionMockClass contains source name field in SourceDebugExtension attribute.
+     * expectedSourceNamePattern is used to assign the source name's pattern
+     */
+    private void testClassPrepareEventWithSourceDebugExtension(String expectedSourceNamePattern){
+        String expectedClassSignature = "Lorg/apache/harmony/jpda/tests/jdwp/Events/SourceDebugExtensionMockClass;";
+
+        logWriter.println("==> testClassPrepareEventForSourceNameMatch started");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // Set ClassPrepare Event in case of SourceNameMatch
+        ReplyPacket reply = debuggeeWrapper.vmMirror.setClassPreparedForSourceNameMatch(expectedSourceNamePattern);
+        checkReplyPacket(reply, "Set CLASS_PREPARE event");
+
+        // start loading SourceDebugExtensionMockClass class
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        
+        CommandPacket receiveEvent = null;
+        try {
+            receiveEvent = debuggeeWrapper.vmMirror.receiveEvent();
+        } catch (TestErrorException e) {
+            printErrorAndFail("There is no event received.");
+        }
+        ParsedEvent[] parsedEvents = ParsedEvent.parseEventPacket(receiveEvent);
+        
+        assertEquals("Invalid number of events,", 1, parsedEvents.length);
+        assertEquals("Invalid event kind,", JDWPConstants.EventKind.CLASS_PREPARE, parsedEvents[0].getEventKind()
+                , JDWPConstants.EventKind.getName(JDWPConstants.EventKind.CLASS_PREPARE)
+                , JDWPConstants.EventKind.getName(parsedEvents[0].getEventKind()));
+        assertEquals("Invalid signature of prepared class,", expectedClassSignature, ((ParsedEvent.Event_CLASS_PREPARE)parsedEvents[0]).getSignature());
+    }
+
+    /**
+     * Test ClassPrepareEvent with SourceDebugExtension attribute.
+     * matching exactly.
+     */
+    public void testClassPrepareEventWithSourceDebugExtension001(){
+        String expectedSourceNamePattern = "helloworld_jsp.java";
+        testClassPrepareEventWithSourceDebugExtension(expectedSourceNamePattern);
+    }
+
+    /**
+     * Test ClassPrepareEvent with SourceDebugExtension attribute
+     * matching the former part.
+     */
+    public void testClassPrepareEventWithSourceDebugExtension002(){
+        String expectedSourceNamePattern = "*helloworld_jsp.java";
+        testClassPrepareEventWithSourceDebugExtension(expectedSourceNamePattern);
+    }
+
+    /**
+     * Test ClassPrepareEvent with SourceDebugExtension attribute.
+     * matching the latter part.
+     */
+    public void testClassPrepareEventWithSourceDebugExtension003(){
+        String expectedSourceNamePattern = "helloworld*";
+        testClassPrepareEventWithSourceDebugExtension(expectedSourceNamePattern);
+    }
+
 }

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MethodExitWithReturnValueDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MethodExitWithReturnValueDebuggee.java?rev=645814&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MethodExitWithReturnValueDebuggee.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MethodExitWithReturnValueDebuggee.java Tue Apr  8 02:51:16 2008
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.Events;
+
+import java.io.IOException;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class MethodExitWithReturnValueDebuggee extends SyncDebuggee {
+    
+    public static final String BOOLEAN_TYPE = "BOOLEAN";
+    
+    public static final String SHORT_TYPE = "SHORT";
+    
+    public static final String CHAR_TYPE = "CHAR";
+    
+    public static final String INT_TYPE = "INT";
+    
+    public static final String LONG_TYPE = "LONG";
+    
+    public static final String DOUBLE_TYPE = "DOUBLE";
+    
+    public static final String EXCEPTION_TYPE = "EXCEPTION";
+    
+    public static final boolean EXPECTED_BOOLEAN = true;
+    
+    public static final short EXPECTED_SHORT = 2;
+    
+    public static final char EXPECTED_CHAR = 'B';
+    
+    public static final int EXPECTED_INT = 230;
+    
+    public static final long EXPECTED_LONG = 0523l;
+    
+    public static final double EXPECTED_DOUBLE = 5.23d;
+    
+    public static final Object EXPECTED_OBJECT = new MethodExitWithReturnValueDebuggee();
+
+    public static void main(String[] args) {
+        runDebuggee(MethodExitWithReturnValueDebuggee.class);
+    }
+    
+    /*
+     * tested methods with different return values 
+     */
+    
+    public boolean booleanMethod() {
+        logWriter.println("--> calling booleanMethod()");
+        return EXPECTED_BOOLEAN;
+    }
+    
+    public short shortMethod() {
+        logWriter.println("--> calling shortMethod()");
+        return EXPECTED_SHORT;
+    }
+    
+    public char charMethod() {
+        logWriter.println("--> calling charMethod()");
+        return EXPECTED_CHAR;
+    }
+    
+    public int intMethod() {
+        logWriter.println("--> calling intMethod()");
+        return EXPECTED_INT;
+    }
+
+    public long longMethod() {
+        logWriter.println("--> calling longMethod()");
+        return EXPECTED_LONG;
+    }
+    
+    public double doubleMethod() {
+        logWriter.println("--> calling doubleMethod()");
+        return EXPECTED_DOUBLE;
+    }
+    
+    public void run() {
+        logWriter.println("--> MethodExitWithReturnValueDebuggee started");
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+        // Receive required method type
+        String type = synchronizer.receiveMessage();
+        logWriter.println("--> invoke method's return type is:" + type);
+        
+        // Invoke desired method
+        if(type.equals(BOOLEAN_TYPE)){
+            boolean b = booleanMethod();
+            logWriter.println("--> booleanMethod() is invoked, return value:" + b);
+        }else if(type.equals(SHORT_TYPE)){
+            short s = shortMethod();
+            logWriter.println("--> shortMethod() is invoked, return value:" + s);
+        }else if(type.equals(CHAR_TYPE)){
+            char c = charMethod();
+            logWriter.println("--> charMethod() is invoked, return value:" + c);
+        }else if(type.equals(INT_TYPE)){
+            int i = intMethod();
+            logWriter.println("--> intMethod() is invoked, return value:" + i);
+        }else if(type.equals(LONG_TYPE)){
+            long l = longMethod();
+            logWriter.println("--> longMethod() is invoked, return value:" + l);
+        }else if(type.equals(DOUBLE_TYPE)){
+            double d = doubleMethod();
+            logWriter.println("--> doubleMethod() is invoked, return value:" + d);
+        }else if(type.equals(EXCEPTION_TYPE)){
+            try {
+                MockExceptionMethodClass.exceptionMethod();
+            } catch (IOException e) {
+                // expected
+            }
+            logWriter.println("--> exceptionMethod() is invoked.");
+        }
+        
+        logWriter.println("--> MethodExitWithReturnValueDebuggee finished");
+    }
+
+}
+
+class MockExceptionMethodClass{
+    
+    static public int exceptionMethod() throws IOException {
+        throw new IOException();
+    }
+}

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/MethodExitWithReturnValueDebuggee.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message