harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r548713 - in /harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent: commands/ClassType.cpp commands/ObjectReference.cpp core/AgentEventRequest.cpp core/CommandHandler.cpp core/RequestManager.cpp
Date Tue, 19 Jun 2007 12:58:42 GMT
Author: gshimansky
Date: Tue Jun 19 05:58:41 2007
New Revision: 548713

URL: http://svn.apache.org/viewvc?view=rev&rev=548713
Log:
Applied HARMONY-4234
[jdktools][jpda][eut] JDWP command ClassType.InvokeMethod fails for method Class.forName(Ljava/lang/String;ZLjava/lang/ClassLoader;)


Modified:
    harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ClassType.cpp
    harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
    harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/AgentEventRequest.cpp
    harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp
    harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ClassType.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ClassType.cpp?view=diff&rev=548713&r1=548712&r2=548713
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ClassType.cpp
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ClassType.cpp
Tue Jun 19 05:58:41 2007
@@ -269,13 +269,14 @@
     JvmtiAutoFree afv3(name);
 
 #ifndef NDEBUG
-    if (JDWP_TRACE_ENABLED(LOG_KIND_LOG)) {
+    if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
-        char* signature = 0;
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &signature, 0));
-        JvmtiAutoFree afs(signature);
+        char* classSignature = 0;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &classSignature,
0));
+        JvmtiAutoFree afs(classSignature);
         JDWP_TRACE_DATA("InvokeMethod: call: method=" << JDWP_CHECK_NULL(name) 
-            << ", classSignature=" << JDWP_CHECK_NULL(signature)
+            << ", sig=" << JDWP_CHECK_NULL(signature)
+            << ", class=" << JDWP_CHECK_NULL(classSignature)
             << ", thread=" << m_thread);
     }
 #endif
@@ -343,13 +344,14 @@
     }
 
 #ifndef NDEBUG
-    if (JDWP_TRACE_ENABLED(LOG_KIND_LOG)) {
+    if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
-        char* signature = 0;
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &signature, 0));
-        JvmtiAutoFree afs(signature);
+        char* classSignature = 0;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &classSignature,
0));
+        JvmtiAutoFree afs(classSignature);
         JDWP_LOG("InvokeMethod: return: method=" << JDWP_CHECK_NULL(name)
-            << ", classSignature=" << JDWP_CHECK_NULL(signature)
+            << ", sig=" << JDWP_CHECK_NULL(signature)
+            << ", class=" << JDWP_CHECK_NULL(classSignature)
             << ", thread=" << m_thread
             << ", returnValueTag=" << m_returnValue.tag
             << ", returnException=" << m_returnException);
@@ -458,13 +460,14 @@
     JvmtiAutoFree afv3(name);
 
 #ifndef NDEBUG
-    if (JDWP_TRACE_ENABLED(LOG_KIND_LOG)) {
+    if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
-        char* signature = 0;
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &signature, 0));
-        JvmtiAutoFree afs(signature);
+        char* classSignature = 0;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &classSignature,
0));
+        JvmtiAutoFree afs(classSignature);
         JDWP_TRACE_DATA("NewInstance: call method=" << JDWP_CHECK_NULL(name) 
-            << ", signature=" << JDWP_CHECK_NULL(signature)
+            << ", sig=" << JDWP_CHECK_NULL(signature)
+            << ", class=" << JDWP_CHECK_NULL(classSignature)
             << ", thread=" << m_thread);
     }
 #endif
@@ -520,13 +523,14 @@
     }
 
 #ifndef NDEBUG
-    if (JDWP_TRACE_ENABLED(LOG_KIND_LOG)) {
+    if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
         jvmtiError err;
-        char* signature = 0;
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &signature, 0));
-        JvmtiAutoFree afs(signature);
+        char* classSignature = 0;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &classSignature,
0));
+        JvmtiAutoFree afs(classSignature);
         JDWP_LOG("NewInstance: return: methodName=" << JDWP_CHECK_NULL(name)
-            << ", signature=" << JDWP_CHECK_NULL(signature)
+            << ", sig=" << JDWP_CHECK_NULL(signature)
+            << ", class=" << JDWP_CHECK_NULL(classSignature)
             << ", thread=" << m_thread
             << ", returnObject=" << m_returnValue
             << ", returnException=" << m_returnException);

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp?view=diff&rev=548713&r1=548712&r2=548713
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/commands/ObjectReference.cpp
Tue Jun 19 05:58:41 2007
@@ -657,26 +657,12 @@
     m_methodID = m_cmdParser->command.ReadMethodID(jni);
     int arguments = m_cmdParser->command.ReadInt();
 
-#ifndef NDEBUG
-    if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
-        jvmtiError err;
-        char* signature = 0;
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &signature, 0));
-        JvmtiAutoFree afs(signature);
-        jvmtiThreadInfo threadInfo;
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(m_thread, &threadInfo));
-        JvmtiAutoFree aftn(threadInfo.name);
-        char* methodName = 0;
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetMethodName(m_methodID, &methodName, 0,
0));
-        JvmtiAutoFree afmn(methodName);
-        JDWP_TRACE_DATA("InvokeMethod: received: objectID=" << m_object
-            << ", classSignature=" << JDWP_CHECK_NULL(signature) 
-            << ", threadName=" << JDWP_CHECK_NULL(threadInfo.name)
-            << ", classID=" << m_clazz
-            << ", methodName=" << JDWP_CHECK_NULL(methodName)
-            << ", arguments=" << arguments);
-    }
-#endif
+    JDWP_TRACE_DATA("InvokeMethod: received: "
+        << "objectID=" << m_object 
+        << ", classID=" << m_clazz 
+        << ", threadID=" << m_thread 
+        << ", methodID=" << m_methodID
+        << ", arguments=" << arguments);
 
     if (AgentBase::GetClassManager().IsClass(jni, m_clazz) != JNI_TRUE) {
         throw AgentException(JDWP_ERROR_INVALID_CLASS);
@@ -693,6 +679,22 @@
     JvmtiAutoFree afv2(signature);
     JvmtiAutoFree afv3(name);
 
+#ifndef NDEBUG
+    if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
+        jvmtiError err;
+        char* classSignature = 0;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &classSignature,
0));
+        JvmtiAutoFree afs(classSignature);
+        jvmtiThreadInfo threadInfo;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(m_thread, &threadInfo));
+        JvmtiAutoFree aftn(threadInfo.name);
+        JDWP_TRACE_DATA("InvokeMethod: call: method=" << JDWP_CHECK_NULL(name)
+            << ", sig=" << JDWP_CHECK_NULL(signature)
+            << ", class=" << JDWP_CHECK_NULL(classSignature) 
+            << ", thread=" << JDWP_CHECK_NULL(threadInfo.name));
+    }
+#endif
+
     JDWP_ASSERT(signature[0] == '(');
     JDWP_ASSERT(strlen(signature) >= 3);
     JDWP_ASSERT(signature + strlen(signature) >= strchr(signature, ')'));
@@ -754,11 +756,20 @@
         throw AgentException(m_returnError);
     }
     
-    JDWP_LOG("InvokeMethod: return: method=" << JDWP_CHECK_NULL(name) 
-        << ", sig=" << JDWP_CHECK_NULL(signature) 
-        << ", thread=" << m_thread 
-        << ", returnValueTag=" << m_returnValue.tag
-        << ", returnException=" << m_returnException);
+#ifndef NDEBUG
+    if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
+        jvmtiError err;
+        char* classSignature = 0;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(m_clazz, &classSignature,
0));
+        JvmtiAutoFree afs(classSignature);
+        JDWP_LOG("InvokeMethod: return: method=" << JDWP_CHECK_NULL(name)
+            << ", sig=" << JDWP_CHECK_NULL(signature)
+            << ", class=" << JDWP_CHECK_NULL(classSignature)
+            << ", thread=" << m_thread
+            << ", returnValueTag=" << m_returnValue.tag
+            << ", returnException=" << m_returnException);
+    }
+#endif
 
 }
 

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/AgentEventRequest.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/AgentEventRequest.cpp?view=diff&rev=548713&r1=548712&r2=548713
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/AgentEventRequest.cpp
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/AgentEventRequest.cpp
Tue Jun 19 05:58:41 2007
@@ -268,7 +268,7 @@
         ControlSingleStep(true);
     }
 
-    JDWP_TRACE_EVENT("step start: size=" << m_size << "(depth=" << m_depth
+    JDWP_TRACE_EVENT("step start: size=" << m_size << ", depth=" << m_depth
         << ", frame=" << m_frameCount << ", line=" << m_lineNumber);
 }
 
@@ -328,6 +328,6 @@
     m_frameCount = currentCount;
     m_lineNumber = currentLine;
 
-    JDWP_TRACE_EVENT("step: frame=" << m_frameCount << "(line=" << m_lineNumber);
+    JDWP_TRACE_EVENT("step: frame=" << m_frameCount << ", line=" << m_lineNumber);
     return AgentEventRequest::ApplyModifiers(jni, eInfo);
 }

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp?view=diff&rev=548713&r1=548712&r2=548713
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/CommandHandler.cpp
Tue Jun 19 05:58:41 2007
@@ -160,8 +160,13 @@
 
 //-----------------------------------------------------------------------------
 
+/**
+ * Counts number of arguments in in the method signature.
+ */
 jint SpecialAsyncCommandHandler::getArgsNumber(char* sig)
 {
+    JDWP_TRACE_ENTRY("Async::getArgsNumber(" << JDWP_CHECK_NULL(sig) << ')');
+
     if (sig == 0) return 0;
 
     jint argsCount = 0;
@@ -173,13 +178,18 @@
         }
         argsCount++;
     }
-    JDWP_TRACE_CMD("sig=" << sig << "(args=" << argsCount);
+    JDWP_TRACE_DATA("getArgsNumber: sig=" << sig << ", args=" << argsCount);
 
     return argsCount;
 }
 
+/**
+ * Extracts jdwpTag letter for given argument index in the method signature.
+ */
 jdwpTag SpecialAsyncCommandHandler::getTag(jint index, char* sig)
 {
+    JDWP_TRACE_ENTRY("Async::getArgsNumber(" << index << ',' << JDWP_CHECK_NULL(sig)
<< ')');
+
     if (sig == 0) return JDWP_TAG_NONE;
 
     const size_t len = strlen(sig);
@@ -195,10 +205,20 @@
     return (index == 0) ? static_cast<jdwpTag>(sig[i]) : JDWP_TAG_NONE;
 }
 
+/**
+ * Extracts class name for given argument index in the method signature.
+ * Type signature for this argument should start with 'L' or '[' tag.
+ *
+ * @return extracted class name in 'name' argument or JNI_FALSE if any error occured
+ */
 bool SpecialAsyncCommandHandler::getClassNameArg(jint index, char* sig, char* name)
 {
+    JDWP_TRACE_ENTRY("Async::getArgsNumber(" << index << ',' << JDWP_CHECK_NULL(sig)
<< ')');
+
     if (sig == 0) return false;
 
+    // skip previous arguments
+
     const size_t len = strlen(sig);
     size_t i;
     for (i = 1; index > 0 && i < len && sig[i] != ')'; i++) {
@@ -209,44 +229,62 @@
         index--;
     }
 
-    if (index > 0 || (sig[i] != '[' && sig[i] != 'L')) return false;
+    if (index > 0) return false;
+
+    // extract type name for the next argument
 
+    bool isArrayType = false;
     size_t j = 0;
-    for (bool arrayFlag = false, classFlag = false; i < len; i++) {
-        char c = sig[i];
-        if (c == '[') {
-             if (classFlag) return false;
-             arrayFlag = true;
-             name[j++] = c;
-        } else if (c == 'L') {
-             if (classFlag) return false;
-             classFlag = true;
-             if (arrayFlag) {
-                 name[j++] = c;
-             }
-        } else if (c == ';') {
-             if (!classFlag) return false;
-             if (arrayFlag) {
-                 name[j++] = c;
-             }
-             break;
-        } else {
-             name[j++] = c;
-             if (arrayFlag && !classFlag) break;
+
+    if (sig[i] == '[') {
+        // copy all starting '[' chars for array type
+        isArrayType = true;
+        for (; i < len && sig[i] == '['; i++) {
+            name[j++] = sig[i];
         }
     }
-    name[j] = '\0';
 
+    if (sig[i] == 'L') {
+        // copy class name until ';'
+        if (!isArrayType) {
+            i++; // skip starting 'L' for not array type
+        }
+        for (; i < len && sig[i] != ';'; i++) {
+            name[j++] = sig[i];
+        }
+        if (isArrayType) {
+            name[j++] = sig[i]; // add trailing ';' for array type
+        }
+    } else if (isArrayType) {
+        // copy single char tag for primitive array type
+        name[j++] = sig[i];
+    } else {
+        // not a class or array type
+        return false;
+    }
+        
+    name[j] = '\0';
     return true;
 }
 
+/**
+ * Checks that type of the argument value matches declared type for given argument index

+ * in the method signature.
+ *
+ * @return JNI_FALSE in case of any mismatch or error
+ */
 jboolean
 SpecialAsyncCommandHandler::IsArgValid(JNIEnv *jni, jint index,
                                        jdwpTaggedValue value, char* sig)
                                        throw(AgentException)
 {
-    JDWP_TRACE_ENTRY("IsArgValid: index=" << index 
-        << ", value.tag=" << value.tag << ", arg tag=" << getTag(index,
sig));
+    JDWP_TRACE_ENTRY("IsArgValid(" << jni << ',' << index 
+        << ',' << (int)value.tag << ',' << JDWP_CHECK_NULL(sig) <<
')');
+
+    jdwpTag argTag = getTag(index, sig);
+
+    JDWP_TRACE_DATA("IsArgValid: index=" << index << ", value.tag=" <<
value.tag << ", argTag=" << argTag);
+
     switch (value.tag) {
         case JDWP_TAG_BOOLEAN:
         case JDWP_TAG_BYTE:
@@ -256,13 +294,15 @@
         case JDWP_TAG_LONG:
         case JDWP_TAG_FLOAT:
         case JDWP_TAG_DOUBLE:
-            if (value.tag != getTag(index, sig)) {
+            if (value.tag != argTag) {
+                JDWP_TRACE_DATA("IsArgValid: mismatched primitive type tag: index=" <<
index << ", value.tag=" << value.tag << ", argTag=" << argTag);
                 return JNI_FALSE;
             } else {
                 return JNI_TRUE;
             }
         case JDWP_TAG_ARRAY:
-            if ('[' != getTag(index, sig)) {
+            if ('[' != argTag) {
+                JDWP_TRACE_DATA("IsArgValid: mismatched array type tag: index=" <<
index << ", value.tag=" << value.tag << ", argTag=" << argTag);
                 return JNI_FALSE;
             }
             break;
@@ -272,24 +312,31 @@
         case JDWP_TAG_THREAD_GROUP:
         case JDWP_TAG_CLASS_LOADER:
         case JDWP_TAG_CLASS_OBJECT:
-            if ('L' != getTag(index, sig)) {
+            if ('L' != argTag) {
+                JDWP_TRACE_DATA("IsArgValid: mismatched reference type tag: index=" <<
index << ", value.tag=" << value.tag << ", argTag=" << argTag);
                 return JNI_FALSE;
             }
             break;
         default: 
+            JDWP_TRACE_DATA("IsArgValid: unknown value type tag: index=" << index <<
", value.tag=" << value.tag << ", argTag=" << argTag);
             return JNI_FALSE;
     }
     char* name = reinterpret_cast<char*>(GetMemoryManager().Allocate(strlen(sig) JDWP_FILE_LINE));
     AgentAutoFree afv(name JDWP_FILE_LINE);
     if (!getClassNameArg(index, sig, name)) {
+        JDWP_TRACE_DATA("IsArgValid: bad class name: index=" << index << ", class="
<< JDWP_CHECK_NULL(name));
         return JNI_FALSE;
     }
-    JDWP_TRACE_CMD("IsArgValid: name =" << JDWP_CHECK_NULL(name));
     jclass cls = jni->FindClass(name);
     if (jni->ExceptionCheck() == JNI_TRUE) {
         jni->ExceptionClear();
+        JDWP_TRACE_DATA("IsArgValid: unknown class name: index=" << index <<
", class=" << JDWP_CHECK_NULL(name));
+        return JNI_FALSE;
+    }
+    if (!jni->IsInstanceOf(value.value.l, cls)) {
+        JDWP_TRACE_DATA("IsArgValid: unmatched class: index=" << index << ",
class=" << JDWP_CHECK_NULL(name));
         return JNI_FALSE;
     }
-    JDWP_TRACE_CMD("IsArgValid: class=" << cls);
-    return jni->IsInstanceOf(value.value.l, cls);
+    JDWP_TRACE_DATA("IsArgValid: matched class: index=" << index << ", class="
<< JDWP_CHECK_NULL(name));
+    return JNI_TRUE;
 }

Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp?view=diff&rev=548713&r1=548712&r2=548713
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp
(original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/RequestManager.cpp
Tue Jun 19 05:58:41 2007
@@ -1379,6 +1379,45 @@
         << ',' << method << ',' << was_popped_by_exception <<
')');
 
     try {
+
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_EVENT)) {
+            jvmtiError err;
+            EventInfo eInfo;
+            memset(&eInfo, 0, sizeof(eInfo));
+            eInfo.kind = JDWP_EVENT_METHOD_EXIT;
+            eInfo.thread = thread;
+        
+            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);
+
+            char* name = 0;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetMethodName(eInfo.method, &name, 0,
0));
+            JDWP_TRACE_EVENT("FRAME_POP event:"
+                << " class=" << JDWP_CHECK_NULL(eInfo.signature) 
+                << " method=" << JDWP_CHECK_NULL(name)
+                << " loc=" << eInfo.location
+                << " by_exception=" << was_popped_by_exception);
+        }
+#endif // NDEBUG
+
         StepRequest* step = GetRequestManager().FindStepRequest(jni, thread);
         if (step != 0) {
             step->OnFramePop(jni);



Mime
View raw message