Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 25577 invoked from network); 16 Jul 2009 15:57:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Jul 2009 15:57:07 -0000 Received: (qmail 8554 invoked by uid 500); 16 Jul 2009 15:58:12 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 8530 invoked by uid 500); 16 Jul 2009 15:58:12 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 8521 invoked by uid 99); 16 Jul 2009 15:58:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jul 2009 15:58:12 +0000 X-ASF-Spam-Status: No, hits=-1996.5 required=10.0 tests=ALL_TRUSTED,URIBL_BLACK X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jul 2009 15:58:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 26420238898D; Thu, 16 Jul 2009 15:57:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r794726 [4/15] - in /harmony/enhanced/jdktools/branches/java6/modules/jpda: ./ src/main/native/include/ src/main/native/jdwp/common/agent/commands/ src/main/native/jdwp/common/agent/core/ src/main/native/jdwp/common/generic/ src/main/native... Date: Thu, 16 Jul 2009 15:57:41 -0000 To: commits@harmony.apache.org From: odeakin@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090716155747.26420238898D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp Thu Jul 16 15:57:37 2009 @@ -15,16 +15,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Anatoly F. Bondarenko - * @version $Revision: 1.18.2.1 $ - */ #include "ReferenceType.h" #include "PacketParser.h" #include "ClassManager.h" #include "CallBacks.h" -#include +#include "ExceptionManager.h" + +#include +#include using namespace jdwp; using namespace ReferenceType; @@ -33,13 +31,13 @@ //------------------------------------------------------------------------------ //SignatureFileHandler(1)---------------------------------------------------------- -void -ReferenceType::SignatureHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::SignatureHandler::Execute(JNIEnv *jni) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT - JDWP_TRACE_DATA("Signature: received: refTypeID=" << jvmClass); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Signature: received: refTypeID=%p", jvmClass)); char* classSignature = 0; char* classGenericSignature = 0; @@ -50,12 +48,14 @@ } jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &classSignature, genericSignaturePtr)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeSignature(classSignature); @@ -69,16 +69,16 @@ m_cmdParser->reply.WriteString(""); } } - JDWP_TRACE_DATA("Signature: send: classSignature=" << JDWP_CHECK_NULL(classSignature) - << ", classGenericSignature=" << JDWP_CHECK_NULL(classGenericSignature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Signature: send: classSignature=%s, classGenericSignature=%s", JDWP_CHECK_NULL(classSignature), JDWP_CHECK_NULL(classGenericSignature))); + return JDWP_ERROR_NONE; } // SignatureHandler::Execute() //------------------------------------------------------------------------------ //ClassLoaderHandler(2)---------------------------------------------------------- -void -ReferenceType::ClassLoaderHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::ClassLoaderHandler::Execute(JNIEnv *jni) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -87,21 +87,22 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("ClassLoader: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassLoader: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif jobject jvmClassLoader; jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassLoader(jvmClass, &jvmClassLoader)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassLoader(jvmClass, &jvmClassLoader)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } // if GetClassLoader() returns NULL value for jvmClassLoader // consider it as the class loader for the jvmClass is the system class @@ -109,15 +110,16 @@ // to JDWP_OBJECT_ID_NULL value. m_cmdParser->reply.WriteObjectID(jni, jvmClassLoader); - JDWP_TRACE_DATA("ClassLoader: send: classLoaderID=" << jvmClassLoader); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassLoader: send: classLoaderID=%p", jvmClassLoader)); + return JDWP_ERROR_NONE; } // ClassLoaderHandler::Execute() //------------------------------------------------------------------------------ //ModifiersHandler(3)---------------------------------------------------------- -void -ReferenceType::ModifiersHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::ModifiersHandler::Execute(JNIEnv *jni) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -126,32 +128,34 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("Modifiers: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Modifiers: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif jint jvmClassModifiers; jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassModifiers(jvmClass, + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassModifiers(jvmClass, &jvmClassModifiers)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } m_cmdParser->reply.WriteInt(jvmClassModifiers); - JDWP_TRACE_DATA("Modifiers: send: modBits=" << hex << jvmClassModifiers); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Modifiers: send: modBits=%x", jvmClassModifiers)); + return JDWP_ERROR_NONE; } // ModifiersHandler::Execute() //------------------------------------------------------------------------------ //FieldsHandler(4,14)---------------------------------------------------------- -void -ReferenceType::FieldsHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::FieldsHandler::Execute(JNIEnv *jni) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -160,10 +164,9 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("Fields: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Fields: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif @@ -172,17 +175,19 @@ jint fieldsCount = 0; jfieldID* fields = 0; jvmtiError err; - JVMTI_TRACE(err, jvmti->GetClassFields(jvmClass, &fieldsCount, &fields)); + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassFields(jvmClass, &fieldsCount, &fields)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_CLASS_NOT_PREPARED, JVMTI_ERROR_INVALID_CLASS // JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeFields(fields); m_cmdParser->reply.WriteInt(fieldsCount); - JDWP_TRACE_DATA("Fields: fieldCount=" << fieldsCount); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Fields: fieldCount=%d", fieldsCount)); for (int i = 0; i < fieldsCount; i++) { jfieldID jvmFieldID = fields[i]; m_cmdParser->reply.WriteFieldID(jni, jvmFieldID); @@ -195,12 +200,14 @@ genericSignaturePtr = &genericSignature; } - JVMTI_TRACE(err, jvmti->GetFieldName(jvmClass, jvmFieldID, &fieldName, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetFieldName(jvmClass, jvmFieldID, &fieldName, &fieldSignature, genericSignaturePtr)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_INVALID_FIELDID - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeFieldName(fieldName); @@ -220,18 +227,20 @@ } jint fieldModifiers; - JVMTI_TRACE(err, jvmti->GetFieldModifiers(jvmClass, jvmFieldID, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetFieldModifiers(jvmClass, jvmFieldID, &fieldModifiers)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_INVALID_FIELDID, // JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } jint fieldSyntheticFlag = 0xf0000000; jboolean isFieldSynthetic; - JVMTI_TRACE(err, jvmti->IsFieldSynthetic(jvmClass, jvmFieldID, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->IsFieldSynthetic(jvmClass, jvmFieldID, &isFieldSynthetic)); if (err != JVMTI_ERROR_NONE) { @@ -240,7 +249,9 @@ if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY) { fieldSyntheticFlag = 0; } else { - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } } else { if ( ! isFieldSynthetic ) { @@ -250,21 +261,19 @@ fieldModifiers = fieldModifiers | fieldSyntheticFlag; m_cmdParser->reply.WriteInt(fieldModifiers); - JDWP_TRACE_DATA("Fields: send: field#=" << i - << ", fieldsName=" << JDWP_CHECK_NULL(fieldName) - << ", fieldSignature=" << JDWP_CHECK_NULL(fieldSignature) - << ", genericSignature=" << JDWP_CHECK_NULL(genericSignature) - << ", fieldModifiers=" << hex << fieldModifiers); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Fields: send: field#=%d, fieldsName=%s, fieldSignature=%s, genericSignature=%s, fieldModifiers=%x", + i, JDWP_CHECK_NULL(fieldName), JDWP_CHECK_NULL(fieldSignature), JDWP_CHECK_NULL(genericSignature), fieldModifiers)); } // for (int i = 0; i < fieldsCount; i++) + return JDWP_ERROR_NONE; } // FieldsHandler::Execute() //------------------------------------------------------------------------------ //MethodsHandler(5,15)---------------------------------------------------------- -void -ReferenceType::MethodsHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::MethodsHandler::Execute(JNIEnv *jni) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -273,10 +282,9 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("Methods: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Methods: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif jvmtiEnv* jvmti = AgentBase::GetJvmtiEnv(); @@ -284,17 +292,19 @@ jint methodsCount = 0; jmethodID* methods = 0; jvmtiError err; - JVMTI_TRACE(err, jvmti->GetClassMethods(jvmClass, &methodsCount, &methods)); + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassMethods(jvmClass, &methodsCount, &methods)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_CLASS_NOT_PREPARED, JVMTI_ERROR_INVALID_CLASS, // JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeFields(methods); m_cmdParser->reply.WriteInt(methodsCount); - JDWP_TRACE_DATA("Methods: methodCount=" << methodsCount); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Methods: methodsCount=%d", methodsCount)); for (int i = 0; i < methodsCount; i++) { jmethodID jvmMethodID = methods[i]; @@ -308,12 +318,14 @@ genericSignaturePtr = &genericSignature; } - JVMTI_TRACE(err, jvmti->GetMethodName(jvmMethodID, &methodName, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetMethodName(jvmMethodID, &methodName, &methodSignature, genericSignaturePtr)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_METHODID - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeFieldName(methodName); JvmtiAutoFree autoFreeMethodSignature(methodSignature); @@ -332,16 +344,18 @@ } jint methodModifiers; - JVMTI_TRACE(err, jvmti->GetMethodModifiers(jvmMethodID, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetMethodModifiers(jvmMethodID, &methodModifiers)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_METHODID, JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } jint methodSyntheticFlag = 0xf0000000; jboolean isMethodSynthetic; - JVMTI_TRACE(err, jvmti->IsMethodSynthetic(jvmMethodID, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->IsMethodSynthetic(jvmMethodID, &isMethodSynthetic)); if (err == JVMTI_ERROR_MUST_POSSESS_CAPABILITY) { @@ -349,7 +363,9 @@ } else { if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_METHODID, JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } if ( ! isMethodSynthetic ) { methodSyntheticFlag = 0; @@ -358,21 +374,19 @@ methodModifiers = methodModifiers | methodSyntheticFlag; m_cmdParser->reply.WriteInt(methodModifiers); - JDWP_TRACE_DATA("Methods: send: method#="<< i - << ", methodName=" << JDWP_CHECK_NULL(methodName) - << ", methodSignature=" << JDWP_CHECK_NULL(methodSignature) - << ", genericSignature=" << JDWP_CHECK_NULL(genericSignature) - << ", methodModifiers=" << hex << methodModifiers); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Methods: send: method#=%d, methodName=%s, methodSignature=%s, genericSignature=%s, methodModifiers=%x", + i, JDWP_CHECK_NULL(methodName), JDWP_CHECK_NULL(methodSignature), JDWP_CHECK_NULL(genericSignature), methodModifiers)); } // for (int i = 0; i < methodsCount; i++) + return JDWP_ERROR_NONE; } // MethodsHandler::Execute() //------------------------------------------------------------------------------ //GetValuesHandler(6)----------------------------------------------------------- -void -ReferenceType::GetValuesHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::GetValuesHandler::Execute(JNIEnv *jni) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -384,11 +398,10 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("GetValues: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature) - << ", fields=" << fieldsNumber); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: received: refTypeID=%p, classSignature=%s, fields=%d", + jvmClass, JDWP_CHECK_NULL(signature), fieldsNumber)); } #endif @@ -405,41 +418,51 @@ // taking into account inheritance jvmtiError err; jclass declaringClass; - JVMTI_TRACE(err, jvmti->GetFieldDeclaringClass(jvmClass, jvmFieldID, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetFieldDeclaringClass(jvmClass, jvmFieldID, &declaringClass)); if (err != JVMTI_ERROR_NONE) { - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } if ( jni->IsAssignableFrom(jvmClass, declaringClass) == JNI_FALSE ) { // given field does not belong to passed jvmClass - throw AgentException(JDWP_ERROR_INVALID_FIELDID); + AgentException e(JDWP_ERROR_INVALID_FIELDID); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_FIELDID; } jint fieldModifiers; - JVMTI_TRACE(err, jvmti->GetFieldModifiers(jvmClass, jvmFieldID, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetFieldModifiers(jvmClass, jvmFieldID, &fieldModifiers)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_INVALID_FIELDID, // JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } if ( (fieldModifiers & 0x0008) == 0 ) { // ACC_STATIC_FLAG = 0x0008; // given field is not static - throw AgentException(JDWP_ERROR_INVALID_FIELDID); + AgentException e(JDWP_ERROR_INVALID_FIELDID); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_FIELDID; } char* fieldName = 0; char* fieldSignature = 0; - JVMTI_TRACE(err, jvmti->GetFieldName(jvmClass, jvmFieldID, + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetFieldName(jvmClass, jvmFieldID, &fieldName, &fieldSignature, 0)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_INVALID_FIELDID - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeFieldName(fieldName); JvmtiAutoFree autoFreeFieldSignature(fieldSignature); @@ -487,26 +510,26 @@ fieldValue.l = jobj; break; default: - JDWP_TRACE_DATA("GetValues: unknown field signature: " - << JDWP_CHECK_NULL(fieldSignature)); - throw InternalErrorException(); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: unknown field signature: %s", JDWP_CHECK_NULL(fieldSignature))); + AgentException e(JDWP_ERROR_INTERNAL); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INTERNAL; } m_cmdParser->reply.WriteValue(jni, fieldValueTag, fieldValue); - JDWP_TRACE_DATA("GetValues: send: field#=" << i - << ", fieldName=" << JDWP_CHECK_NULL(fieldName) - << ", fieldSignature=" << JDWP_CHECK_NULL(fieldSignature) - << ", fieldValueTag=" << fieldValueTag); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: send: field#=%d, fieldName=%s, fieldSignature=%s, fieldValueTag=%d", + i, JDWP_CHECK_NULL(fieldName), JDWP_CHECK_NULL(fieldSignature), fieldValueTag)); } // for (int i = 0; i < fieldsNumber; i++) { + return JDWP_ERROR_NONE; } // GetValuesHandler::Execute() //------------------------------------------------------------------------------ //SourceFileHandler(7)---------------------------------------------------------- -void -ReferenceType::SourceFileHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::SourceFileHandler::Execute(JNIEnv *jni) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -515,27 +538,29 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("SourceFile: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SourceFile: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif char* sourceFileName = 0; jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetSourceFileName(jvmClass, + JVMTI_TRACE(LOG_DEBUG, 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); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeFieldName(sourceFileName); m_cmdParser->reply.WriteString(sourceFileName); - JDWP_TRACE_DATA("SourceFile: send: sourceFile=" << JDWP_CHECK_NULL(sourceFileName)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SourceFile: send: sourceFile=%s", JDWP_CHECK_NULL(sourceFileName))); + return JDWP_ERROR_NONE; } // SourceFileHandler::Execute() //------------------------------------------------------------------------------ @@ -554,9 +579,8 @@ // A nested interface is any interface whose declaration occurs within the body // of another class or interface -void +int ReferenceType::NestedTypesHandler::Execute(JNIEnv *jni) - throw (AgentException) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -565,10 +589,9 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("NestedTypes: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "NestedTypes: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif char* jvmClassSignature = 0; @@ -576,22 +599,29 @@ jvmtiEnv* jvmti = AgentBase::GetJvmtiEnv(); jvmtiError err; - JVMTI_TRACE(err, jvmti->GetClassSignature(jvmClass, &jvmClassSignature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassSignature(jvmClass, &jvmClassSignature, 0)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeSignature(jvmClassSignature); size_t jvmClassSignatureLength = strlen(jvmClassSignature); jint allClassesCount = 0; jclass* allClasses = 0; - JVMTI_TRACE(err, jvmti->GetLoadedClasses(&allClassesCount, &allClasses)); + + AgentBase::GetJniEnv()->PushLocalFrame(100); + + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetLoadedClasses(&allClassesCount, &allClasses)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeAllClasses(allClasses); @@ -622,11 +652,13 @@ jclass klass = allClasses[allClassesIndex]; char* klassSignature = 0; - JVMTI_TRACE(err, jvmti->GetClassSignature(klass, &klassSignature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassSignature(klass, &klassSignature, 0)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeKlassSignature(klassSignature); @@ -641,7 +673,8 @@ != 0 ) { continue; } - char* firstCharPtr = strchr(klassSignature, nestedClassSign); + // note: + char* firstCharPtr = strchr((klassSignature + jvmClassSignatureLength - 1), nestedClassSign); if ( firstCharPtr == NULL ) { // klass is not nested in jvmClass continue; @@ -663,7 +696,7 @@ // form reply data for all found out classes nested directly in given jvmClass m_cmdParser->reply.WriteInt(nestedTypesCount); - JDWP_TRACE_DATA("NestedTypes: nestedTypes=" << nestedTypesCount); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "NestedTypes: nestedTypes=%d", nestedTypesCount)); for (int nestedClassesIndex = 0; nestedClassesIndex < nestedTypesCount; nestedClassesIndex++) { jclass nestedClass = allClasses[nestedClassesIndex]; @@ -672,30 +705,31 @@ // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_NULL_POINTER refTypeTag = JDWP_TYPE_TAG_INTERFACE; } - m_cmdParser->reply.WriteByte(refTypeTag); + m_cmdParser->reply.WriteByte((jbyte)refTypeTag); m_cmdParser->reply.WriteReferenceTypeID(jni, nestedClass); // can be: OutOfMemoryException, InternalErrorException, #ifndef NDEBUG if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, jvmti->GetClassSignature(nestedClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassSignature(nestedClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("NestedTypes: send: nestedClass#" << nestedClassesIndex - << ", typeTag=" << refTypeTag - << ", nestedClassID=" << nestedClass - << ", signature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "NestedTypes: send: nestedClass#%d, typeTag=%d, nestedClassID=%p, signature=%s", + nestedClassesIndex, refTypeTag, nestedClass, JDWP_CHECK_NULL(signature))); } #endif } + AgentBase::GetJniEnv()->PopLocalFrame(NULL); + + return JDWP_ERROR_NONE; } // NestedTypesHandler::Execute() //------------------------------------------------------------------------------ //StatusHandler(9)-------------------------------------------------------------- -void -ReferenceType::StatusHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ReferenceType::StatusHandler::Execute(JNIEnv *jni) { jint status; @@ -706,19 +740,20 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(klass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(klass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("Status: received: refTypeID=" << klass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Status: received: refTypeID=%p, classSignature=%s", klass, JDWP_CHECK_NULL(signature))); } #endif jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassStatus(klass, &status)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassStatus(klass, &status)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } if (status == JVMTI_CLASS_STATUS_ARRAY) { @@ -729,16 +764,16 @@ } } m_cmdParser->reply.WriteInt(status); - JDWP_TRACE_DATA("Status: send: status=" << status); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Status: send: status=%d", status)); + return JDWP_ERROR_NONE; } // StatusHandler::Execute() //------------------------------------------------------------------------------ //InterfacesHandler(10)--------------------------------------------------------- -void +int ReferenceType::InterfacesHandler::Execute(JNIEnv *jni) - throw (AgentException) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -747,51 +782,51 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("Interfaces: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Interfaces: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif jint interfacesCount = 0; jclass* interfaces; jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetImplementedInterfaces(jvmClass, + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetImplementedInterfaces(jvmClass, &interfacesCount, &interfaces)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_CLASS_NOT_PREPARED, JVMTI_ERROR_INVALID_CLASS, // JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeInterfaces(interfaces); m_cmdParser->reply.WriteInt(interfacesCount); - JDWP_TRACE_DATA("Interfaces: interfaces=" << interfacesCount); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Interfaces: interfaces=%d", interfacesCount)); for (int i = 0; i < interfacesCount; i++) { m_cmdParser->reply.WriteReferenceTypeID(jni, interfaces[i]); #ifndef NDEBUG if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(interfaces[i], &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(interfaces[i], &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("Interfaces: interface#" << i - << ", interfaceID=" << interfaces[i] - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Interfaces: interface#%d, interfaceID=%p, classSignature=%s", + i, interfaces[i], JDWP_CHECK_NULL(signature))); } #endif } + return JDWP_ERROR_NONE; } // InterfacesHandler::Execute() //------------------------------------------------------------------------------ //ClassObjectHandler(11)-------------------------------------------------------- -void +int ReferenceType::ClassObjectHandler::Execute(JNIEnv *jni) - throw (AgentException) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -800,24 +835,22 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("ClassObject: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)) + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassObject: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif m_cmdParser->reply.WriteObjectID(jni, jvmClass); - JDWP_TRACE_DATA("ClassObject: send: objectID=" << jvmClass); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassObject: send: objectID=%p", jvmClass)); - + return JDWP_ERROR_NONE; } // ClassObjectHandler::Execute() //------------------------------------------------------------------------------ //SourceDebugExtensionHandler(12)----------------------------------------------- -void +int ReferenceType::SourceDebugExtensionHandler::Execute(JNIEnv *jni) - throw (AgentException) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -826,28 +859,29 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("SourceDebugExtension: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SourceDebugExtension: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif char* sourceDebugExtension = 0; jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetSourceDebugExtension(jvmClass, + JVMTI_TRACE(LOG_DEBUG, 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 - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } JvmtiAutoFree autoFreeDebugExtension(sourceDebugExtension); m_cmdParser->reply.WriteString(sourceDebugExtension); - JDWP_TRACE_DATA("SourceDebugExtension: send: sourceDebugExtension=" - << JDWP_CHECK_NULL(sourceDebugExtension)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SourceDebugExtension: send: sourceDebugExtension=%s", JDWP_CHECK_NULL(sourceDebugExtension))); + return JDWP_ERROR_NONE; } // SourceDebugExtensionHandler::Execute() // New commands for Java 6 @@ -855,9 +889,8 @@ //------------------------------------------------------------------------------ // InstancesHandler(16)----------------------------------------------- -void +int ReferenceType::InstancesHandler::Execute(JNIEnv *jni) - throw (AgentException) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -866,50 +899,55 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("SourceDebugExtension: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Instances: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif jint maxInstances = m_cmdParser->command.ReadInt(); if(maxInstances < 0) { - throw AgentException(JDWP_ERROR_ILLEGAL_ARGUMENT); + AgentException e(JDWP_ERROR_ILLEGAL_ARGUMENT); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_ILLEGAL_ARGUMENT; } jvmtiHeapCallbacks hcbs; memset(&hcbs, 0, sizeof(hcbs)); hcbs.heap_iteration_callback = NULL; hcbs.heap_reference_callback = &HeapReferenceCallback; - hcbs.primitive_field_callback = &PrimitiveFieldCallback; - hcbs.array_primitive_value_callback = &ArrayPrimitiveValueCallback; - hcbs.string_primitive_value_callback = &StringPrimitiveValueCallback; + hcbs.primitive_field_callback = NULL; + hcbs.array_primitive_value_callback = NULL; + hcbs.string_primitive_value_callback = NULL; jvmtiError err; //This tag is used to mark instance that is reachable for garbage collection purpose const jlong tag_value = 0xfffff; //It initiates a traversal over the objects that are directly and indirectly reachable from the heap roots. - JVMTI_TRACE(err, GetJvmtiEnv()->FollowReferences(0, jvmClass, NULL, + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->FollowReferences(0, jvmClass, NULL, &hcbs, &tag_value)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_INVALID_CLASS // JVMTI_ERROR_INVALID_OBJECT, JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } const jlong tags[1] = {tag_value}; jint reachableInstancesNum = 0; jobject * pResultObjects = 0; // Return the instances that have been marked expectd tag_value tag. - JVMTI_TRACE(err, GetJvmtiEnv()->GetObjectsWithTags(1, tags, &reachableInstancesNum, + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetObjectsWithTags(1, tags, &reachableInstancesNum, &pResultObjects, NULL)); JvmtiAutoFree afResultObjects(pResultObjects); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_ILLEGAL_ARGUMENT // JVMTI_ERROR_ILLEGAL_ARGUMENT, JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } jint returnInstancesNum; @@ -926,21 +964,41 @@ // Compose reply package m_cmdParser->reply.WriteInt(returnInstancesNum); - JDWP_TRACE_DATA("Instances: return instances number:" << returnInstancesNum); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Instances: return instances number: %d", returnInstancesNum)); for(int i = 0; i < returnInstancesNum; i++) { m_cmdParser->reply.WriteTaggedObjectID(jni, pResultObjects[i]); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetTag(pResultObjects[i], 0)); + jni->DeleteLocalRef(pResultObjects[i]); + if (err != JVMTI_ERROR_NONE) { + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; + } } - JDWP_TRACE_DATA("Instances: tagged-objectID returned."); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Instances: tagged-objectID returned.")); + + // Tags for those instances which are not returned should also be set back to 0 + if(returnInstancesNum < reachableInstancesNum) { + for(int i = returnInstancesNum; i < reachableInstancesNum; i++) { + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetTag(pResultObjects[i], 0)); + jni->DeleteLocalRef(pResultObjects[i]); + if (err != JVMTI_ERROR_NONE) { + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; + } + } + } + return JDWP_ERROR_NONE; } //------------------------------------------------------------------------------ // ClassFileVersionHandler(17)----------------------------------------------- -void +int ReferenceType::ClassFileVersionHandler::Execute(JNIEnv *jni) - throw (AgentException) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -949,40 +1007,39 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("SourceDebugExtension: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassFileVersion: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif jint minorVersion = -1; jint majorVersion = -1; jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassVersionNumbers(jvmClass, &minorVersion, &majorVersion)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassVersionNumbers(jvmClass, &minorVersion, &majorVersion)); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_ABSENT_INFORMATION, JVMTI_ERROR_INVALID_CLASS, // JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } m_cmdParser->reply.WriteInt(majorVersion); - JDWP_TRACE_DATA("ClassFileVersion: send: majorVersion=" - << majorVersion); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassFileVersion: send: majorVersion=%d", majorVersion)); m_cmdParser->reply.WriteInt(minorVersion); - JDWP_TRACE_DATA("ClassFileVersion: send: minorVersion=" - << minorVersion); - + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassFileVersion: send: minorVersion=%d", minorVersion)); + + return JDWP_ERROR_NONE; } //------------------------------------------------------------------------------ // ConstantPoolHandler(18)----------------------------------------------- -void +int ReferenceType::ConstantPoolHandler::Execute(JNIEnv *jni) - throw (AgentException) { jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni); // Can be: InternalErrorException, OutOfMemoryException, @@ -991,10 +1048,9 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiError err; char* signature = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0)); JvmtiAutoFree afcs(signature); - JDWP_TRACE_DATA("SourceDebugExtension: received: refTypeID=" << jvmClass - << ", classSignature=" << JDWP_CHECK_NULL(signature)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ConstantPool: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature))); } #endif jvmtiError err; @@ -1002,27 +1058,27 @@ jint bytes = 0; unsigned char* cpbytes = 0; // Return the raw bytes of the constant pool - JVMTI_TRACE(err, GetJvmtiEnv()->GetConstantPool(jvmClass, &count, &bytes, &cpbytes)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetConstantPool(jvmClass, &count, &bytes, &cpbytes)); JvmtiAutoFree afCpbytes(cpbytes); if (err != JVMTI_ERROR_NONE) { // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_ABSENT_INFORMATION // JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_INVALID_OBJECT // JVMTI_ERROR_NULL_POINTER - throw AgentException(err); + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; } m_cmdParser->reply.WriteInt(count); - JDWP_TRACE_DATA("ConstantPool: send: count=" - << count); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ConstantPool: send: count=%d", count)); m_cmdParser->reply.WriteInt(bytes); - JDWP_TRACE_DATA("ConstantPool: send: bytes=" - << bytes); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ConstantPool: send: bytes=%d", bytes)); for (int i = 0; i < bytes; i++) { m_cmdParser->reply.WriteByte(cpbytes[i]); } + return JDWP_ERROR_NONE; } - Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h Thu Jul 16 15:57:37 2009 @@ -17,11 +17,6 @@ */ /** - * @author Anatoly F. Bondarenko - * @version $Revision: 1.5.2.1 $ - */ - -/** * @file * ReferenceType.h * @@ -63,7 +58,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); protected: @@ -89,7 +84,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // ClassLoaderHandler class @@ -107,7 +102,7 @@ * * @param jni - the JNI interface pointer. */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // ModifiersHandler class @@ -133,7 +128,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); protected: /** @@ -165,7 +160,7 @@ * * @param jni - the JNI interface pointer. */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); protected: /** @@ -189,7 +184,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // GetValuesHandler class @@ -207,7 +202,7 @@ * * @param jni - the JNI interface pointer. */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // SourceFileHandler class @@ -225,7 +220,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // NestedTypesHandler class @@ -243,7 +238,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // StatusHandler class @@ -261,7 +256,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // InterfacesHandler class @@ -279,7 +274,7 @@ * * @param jni - the JNI interface pointer. */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // ClassObjectHandler class @@ -297,7 +292,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; // SourceDebugExtensionHandler class @@ -361,7 +356,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni) ; };// InstancesHandler class // ========================================================================= @@ -378,7 +373,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni) ; };// ClassFileVersionHandler class // ========================================================================= @@ -395,7 +390,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); };//ConstantPoolHandler class // ========================================================================= Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.cpp?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.cpp (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.cpp Thu Jul 16 15:57:37 2009 @@ -15,35 +15,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Viacheslav G. Rybalov - * @version $Revision: 1.15.2.2 $ - */ #include "StackFrame.h" #include "PacketParser.h" #include "ClassManager.h" #include "ThreadManager.h" +#include "ExceptionManager.h" using namespace jdwp; using namespace StackFrame; -void -StackFrame::GetValuesHandler::Execute(JNIEnv *jni) throw(AgentException) +int +StackFrame::GetValuesHandler::Execute(JNIEnv *jni) { jthread thread = m_cmdParser->command.ReadThreadID(jni); jint frame = m_cmdParser->command.ReadFrameID(jni); jint slots = m_cmdParser->command.ReadInt(); - JDWP_TRACE_DATA("GetValues: received: frameID=" << frame - << ", threadID=" << thread - << ", slots=" << slots); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: received: frameID=%d, threadID=%p, slots=%d", frame, thread, slots)); if (thread == 0) { - throw AgentException(JDWP_ERROR_INVALID_THREAD); + AgentException e(JDWP_ERROR_INVALID_THREAD); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_THREAD; } if (slots < 0) { - throw AgentException(JDWP_ERROR_ILLEGAL_ARGUMENT); + AgentException e(JDWP_ERROR_ILLEGAL_ARGUMENT); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_ILLEGAL_ARGUMENT; } m_cmdParser->reply.WriteInt(slots); @@ -59,70 +57,62 @@ case JDWP_TAG_SHORT: case JDWP_TAG_INT: jint ivalue; - JVMTI_TRACE(err, GetJvmtiEnv()->GetLocalInt(thread, frame, slot, &ivalue)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetLocalInt(thread, frame, slot, &ivalue)); if (err != JVMTI_ERROR_NONE) { break; } switch (sigbyte) { case JDWP_TAG_BOOLEAN: resValue.z = static_cast(ivalue); - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(boolean)" << resValue.z); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(boolean)%d", i, resValue.z)); break; case JDWP_TAG_BYTE: resValue.b = static_cast(ivalue); - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(byte)" << resValue.b); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(byte)%d", i, resValue.b)); break; case JDWP_TAG_CHAR: resValue.c = static_cast(ivalue); - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(char)" << resValue.c); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(char)%d", i, resValue.c)); break; case JDWP_TAG_SHORT: resValue.s = static_cast(ivalue); - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(short)" << resValue.s); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(short)%d", i, resValue.s)); break; case JDWP_TAG_INT: resValue.i = ivalue; - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(int)" << resValue.i); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(int)%d", i, resValue.i)); break; } m_cmdParser->reply.WriteValue(jni, sigbyte, resValue); break; case JDWP_TAG_LONG: jlong lvalue; - JVMTI_TRACE(err, GetJvmtiEnv()->GetLocalLong(thread, frame, slot, &lvalue)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetLocalLong(thread, frame, slot, &lvalue)); if (err != JVMTI_ERROR_NONE) { break; } resValue.j = lvalue; - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(long)" << resValue.j); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(long)%lld", i, resValue.j)); m_cmdParser->reply.WriteValue(jni, sigbyte, resValue); break; case JDWP_TAG_FLOAT: jfloat fvalue; - JVMTI_TRACE(err, GetJvmtiEnv()->GetLocalFloat(thread, frame, slot, &fvalue)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetLocalFloat(thread, frame, slot, &fvalue)); if (err != JVMTI_ERROR_NONE) { break; } resValue.f = fvalue; - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(float)" << resValue.f); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(float)%f", i, resValue.f)); m_cmdParser->reply.WriteValue(jni, sigbyte, resValue); break; case JDWP_TAG_DOUBLE: jdouble dvalue; - JVMTI_TRACE(err, GetJvmtiEnv()->GetLocalDouble(thread, frame, slot, &dvalue)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetLocalDouble(thread, frame, slot, &dvalue)); if (err != JVMTI_ERROR_NONE) { break; } resValue.d = dvalue; - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", value=(double)" << resValue.d); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, value(double)%Lf", i, resValue.d)); m_cmdParser->reply.WriteValue(jni, sigbyte, resValue); break; case JDWP_TAG_OBJECT: @@ -133,25 +123,27 @@ case JDWP_TAG_CLASS_LOADER: case JDWP_TAG_CLASS_OBJECT: { jobject ovalue; - JVMTI_TRACE(err, GetJvmtiEnv()->GetLocalObject(thread, frame, slot, &ovalue)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetLocalObject(thread, frame, slot, &ovalue)); if (err != JVMTI_ERROR_NONE) { break; } jdwpTag tag = GetClassManager().GetJdwpTag(jni, ovalue); - if ((sigbyte != JDWP_TAG_OBJECT) && (sigbyte != tag)) { - throw AgentException(JDWP_ERROR_INVALID_TAG); + if ((sigbyte != JDWP_TAG_OBJECT) && (sigbyte != tag) && ovalue != 0) { + AgentException e(JDWP_ERROR_INVALID_TAG); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_TAG; } resValue.l = ovalue; - JDWP_TRACE_DATA("GetValues: slot#=" << i - << ", tag=" << tag - << ", value=(object)" << resValue.l); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: slot#=%d, tag=%d, value(object)=%p", i, tag, resValue.l)); m_cmdParser->reply.WriteValue(jni, tag, resValue); + jni->DeleteLocalRef(ovalue); break; } default: - JDWP_TRACE_DATA("GetValues: bad slot tag: slot#=" << i - << ", tag=" << sigbyte); - throw AgentException(JDWP_ERROR_INVALID_TAG); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "GetValues: bad slot tag: slot#=%d, tag=%d", i, sigbyte)); + AgentException e(JDWP_ERROR_INVALID_TAG); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_TAG; } if (err != JVMTI_ERROR_NONE) { jdwpError error; @@ -168,33 +160,39 @@ } else { error = (jdwpError)err; } - throw AgentException(error); + AgentException e(error); + JDWP_SET_EXCEPTION(e); + return error; } } + + return JDWP_ERROR_NONE; } -void -StackFrame::SetValuesHandler::Execute(JNIEnv *jni) throw(AgentException) +int +StackFrame::SetValuesHandler::Execute(JNIEnv *jni) { jthread thread = m_cmdParser->command.ReadThreadID(jni); jint frame = m_cmdParser->command.ReadFrameID(jni); jint slotValues = m_cmdParser->command.ReadInt(); - JDWP_TRACE_DATA("SetValues: received: frameID=" << frame - << ", threadID=" << thread - << ", slots=" << slotValues); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: received: frameID=%d, threadId=%p, slots=%d", frame, thread, slotValues)); if (thread == 0) { - throw AgentException(JDWP_ERROR_INVALID_THREAD); + AgentException e(JDWP_ERROR_INVALID_THREAD); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_THREAD; } if (slotValues < 0) { - throw AgentException(JDWP_ERROR_ILLEGAL_ARGUMENT); + AgentException e(JDWP_ERROR_ILLEGAL_ARGUMENT); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_ILLEGAL_ARGUMENT; } for (int i = 0; i < slotValues; i++) { jint slot = m_cmdParser->command.ReadInt(); jdwpTaggedValue taggedValue = m_cmdParser->command.ReadValue(jni); - JDWP_TRACE_DATA("SetValues: slot#" << i << ": taggedValue=" << taggedValue.tag); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#%d: taggedValue=%d", i, taggedValue.tag)); // jdwpTag sigbyte = taggedValue.tag; jvmtiError err = JVMTI_ERROR_NONE; switch (taggedValue.tag) { @@ -207,51 +205,43 @@ switch (taggedValue.tag) { case JDWP_TAG_BOOLEAN: ivalue = static_cast(taggedValue.value.z); - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(boolean)" << taggedValue.value.z); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(boolean)%d", i, taggedValue.value.z)); break; case JDWP_TAG_BYTE: ivalue = static_cast(taggedValue.value.b); - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(byte)" << taggedValue.value.b); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(byte)%d", i, taggedValue.value.b)); break; case JDWP_TAG_CHAR: ivalue = static_cast(taggedValue.value.c); - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(char)" << taggedValue.value.c); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(char)%d", i, taggedValue.value.c)); break; case JDWP_TAG_SHORT: ivalue = static_cast(taggedValue.value.s); - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(short)" << taggedValue.value.s); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(short)%d", i, taggedValue.value.s)); break; case JDWP_TAG_INT: ivalue = taggedValue.value.i; - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(int)" << taggedValue.value.i); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(int)%d", i, taggedValue.value.i)); break; } - JVMTI_TRACE(err, GetJvmtiEnv()->SetLocalInt(thread, frame, slot, ivalue)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetLocalInt(thread, frame, slot, ivalue)); break; case JDWP_TAG_LONG: { jlong lvalue = taggedValue.value.j; - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(long)" << taggedValue.value.j); - JVMTI_TRACE(err, GetJvmtiEnv()->SetLocalLong(thread, frame, slot, lvalue)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(long)%lld", i, taggedValue.value.j)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetLocalLong(thread, frame, slot, lvalue)); break; } case JDWP_TAG_FLOAT: { jfloat fvalue = taggedValue.value.f; - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(float)" << taggedValue.value.f); - JVMTI_TRACE(err, GetJvmtiEnv()->SetLocalFloat(thread, frame, slot, fvalue)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(float)%f", i, taggedValue.value.f)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetLocalFloat(thread, frame, slot, fvalue)); break; } case JDWP_TAG_DOUBLE: { jdouble dvalue = taggedValue.value.d; - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(double)" << taggedValue.value.d); - JVMTI_TRACE(err, GetJvmtiEnv()->SetLocalDouble(thread, frame, slot, dvalue)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(double)%Lf", i, taggedValue.value.d)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetLocalDouble(thread, frame, slot, dvalue)); break; } case JDWP_TAG_OBJECT: @@ -262,15 +252,15 @@ case JDWP_TAG_CLASS_LOADER: case JDWP_TAG_CLASS_OBJECT: { jobject ovalue = taggedValue.value.l; - JDWP_TRACE_DATA("SetValues: slot#=" << i - << ", value=(object)" << taggedValue.value.l); - JVMTI_TRACE(err, GetJvmtiEnv()->SetLocalObject(thread, frame, slot, ovalue)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: slot#=%d, value=(object)%p", i, taggedValue.value.l)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetLocalObject(thread, frame, slot, ovalue)); break; } default: - JDWP_TRACE_DATA("SetValues: bad value tag: slot#=" << i - << ", tag=" << taggedValue.tag); - throw AgentException(JDWP_ERROR_INVALID_TAG); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SetValues: bad value tag: slot#=%d, tag=%d", i, taggedValue.tag)); + AgentException e(JDWP_ERROR_INVALID_TAG); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_TAG; } if (err != JVMTI_ERROR_NONE) { jdwpError error; @@ -287,13 +277,17 @@ } else { error = (jdwpError)err; } - throw AgentException(error); + AgentException e(error); + JDWP_SET_EXCEPTION(e); + return error; } } + + return JDWP_ERROR_NONE; } -void -StackFrame::ThisObjectHandler::CheckErr(jvmtiError err) throw(AgentException) +int +StackFrame::ThisObjectHandler::CheckErr(jvmtiError err) { if (err != JVMTI_ERROR_NONE) { jdwpError error; @@ -308,29 +302,38 @@ } else { error = (jdwpError)err; } - throw AgentException(error); + AgentException e(error); + JDWP_SET_EXCEPTION(e); + return error; } + return JDWP_ERROR_NONE; } -void -StackFrame::ThisObjectHandler::Execute(JNIEnv *jni) throw(AgentException) +int +StackFrame::ThisObjectHandler::Execute(JNIEnv *jni) { jthread thread = m_cmdParser->command.ReadThreadID(jni); if (thread == 0) { - throw AgentException(JDWP_ERROR_INVALID_THREAD); + AgentException e(JDWP_ERROR_INVALID_THREAD); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_THREAD; + } + if (!GetThreadManager().IsSuspended(thread)){ + AgentException e(JVMTI_ERROR_THREAD_NOT_SUSPENDED); + JDWP_SET_EXCEPTION(e); + return JVMTI_ERROR_THREAD_NOT_SUSPENDED; } - if (!GetThreadManager().IsSuspended(thread)) - throw AgentException(JVMTI_ERROR_THREAD_NOT_SUSPENDED); jint frame = m_cmdParser->command.ReadFrameID(jni); // frame == depth - JDWP_TRACE_DATA("ThisObject: received: threadID=" << thread - << ", frameID=" << frame); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ThisObject: received: threadID=%p, frameID=%d", thread, frame)); jvmtiError err; + int ret; jint allCount; - JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameCount(thread, &allCount)); - CheckErr(err); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetFrameCount(thread, &allCount)); + ret = CheckErr(err); + JDWP_CHECK_RETURN(ret); JDWP_ASSERT(allCount > 0); jvmtiFrameInfo* frames = static_cast @@ -338,59 +341,67 @@ AgentAutoFree af(frames JDWP_FILE_LINE); jint count; - JVMTI_TRACE(err, GetJvmtiEnv()->GetStackTrace(thread, 0, allCount, frames, &count)); - CheckErr(err); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetStackTrace(thread, 0, allCount, frames, &count)); + ret = CheckErr(err); + JDWP_CHECK_RETURN(ret); JDWP_ASSERT(count <= allCount); JDWP_ASSERT(frame <= count); jvmtiFrameInfo& frameInfo = frames[frame]; jint modifiers; - JVMTI_TRACE(err, GetJvmtiEnv()->GetMethodModifiers(frameInfo.method, &modifiers)); - CheckErr(err); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetMethodModifiers(frameInfo.method, &modifiers)); + ret = CheckErr(err); + JDWP_CHECK_RETURN(ret); jvalue resValue; if ((modifiers & (ACC_STATIC | ACC_NATIVE)) != 0) { - JDWP_TRACE_DATA("ThisObject: null this for method: " - << "modifiers=" << hex << modifiers - << ", static=" << hex << (modifiers & ACC_STATIC) - << ", native=" << hex << (modifiers & ACC_NATIVE)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ThisObject: null this for method: modifiers=%x, static=%x, native=%x", + modifiers, (modifiers & ACC_STATIC), (modifiers & ACC_NATIVE))); resValue.l = 0; m_cmdParser->reply.WriteValue(jni, JDWP_TAG_OBJECT, resValue); - return; + return JDWP_ERROR_NONE; } jobject ovalue = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetLocalObject(thread, frame, 0, &ovalue)); - CheckErr(err); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetLocalObject(thread, frame, 0, &ovalue)); + ret = CheckErr(err); + JDWP_CHECK_RETURN(ret); JDWP_ASSERT(ovalue != 0); jdwpTag tag = GetClassManager().GetJdwpTag(jni, ovalue); resValue.l = ovalue; - JDWP_TRACE_DATA("ThisObject: send: tag=" << tag - << ", object=" << resValue.l); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ThisObject: send: tag=%d, object=%p", tag, resValue.l)); m_cmdParser->reply.WriteValue(jni, tag, resValue); + + return JDWP_ERROR_NONE; } -void -StackFrame::PopFramesHandler::Execute(JNIEnv *jni) throw(AgentException) +int +StackFrame::PopFramesHandler::Execute(JNIEnv *jni) { jdwpCapabilities caps = GetCapabilities(); if (caps.canPopFrames != 1) { - throw AgentException(JDWP_ERROR_NOT_IMPLEMENTED); + AgentException e(JDWP_ERROR_NOT_IMPLEMENTED); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_NOT_IMPLEMENTED; } jthread thread = m_cmdParser->command.ReadThreadID(jni); if (thread == 0) { - throw AgentException(JDWP_ERROR_INVALID_THREAD); + AgentException e(JDWP_ERROR_INVALID_THREAD); + JDWP_SET_EXCEPTION(e); + return JDWP_ERROR_INVALID_THREAD; } jint frame = m_cmdParser->command.ReadFrameID(jni); jint framesToPop = frame + 1; - JDWP_TRACE_DATA("PopFrames: received: threadID=" << thread - << ", framesToPop=" << framesToPop); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "PopFrames: received: threadID=%p, framesToPop=%d", thread, framesToPop)); + + int ret = GetThreadManager().PerformPopFrames(jni, framesToPop, thread); + JDWP_CHECK_RETURN(ret); - GetThreadManager().PerformPopFrames(jni, framesToPop, thread); + return JDWP_ERROR_NONE; } Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.h?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.h (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StackFrame.h Thu Jul 16 15:57:37 2009 @@ -15,12 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Viacheslav G. Rybalov - * @version $Revision: 1.4.2.1 $ - */ - /** * @file * StackFrame.h @@ -54,7 +48,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); };//GetValuesHandler @@ -71,7 +65,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); };//SetValuesHandler @@ -88,10 +82,10 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); private: - void CheckErr(jvmtiError err) throw(AgentException); + int CheckErr(jvmtiError err); };//ThisObjectHandler /** @@ -107,7 +101,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); };//PopFramesHandler Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.cpp?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.cpp (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.cpp Thu Jul 16 15:57:37 2009 @@ -15,14 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Anton V. Karnachuk - * @version $Revision: 1.9 $ - */ #include "StringReference.h" #include "PacketParser.h" #include "ClassManager.h" +#include "ExceptionManager.h" + using namespace jdwp; using namespace StringReference; @@ -30,13 +27,13 @@ //----------------------------------------------------------------------------- // StringReference ----------------------------------------------------------------- -void -StringReference::ValueHandler::Execute(JNIEnv *jni) throw(AgentException) +int +StringReference::ValueHandler::Execute(JNIEnv *jni) { //INVALID_OBJECT can be thrown below jstring stringObject = m_cmdParser->command.ReadStringID(jni); - JDWP_TRACE_DATA("Value: received: stringID=" << stringObject); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Value: received: stringID=%p", stringObject)); // get length of the string jsize len = jni->GetStringLength(stringObject); @@ -51,9 +48,10 @@ jni->GetStringUTFRegion(stringObject, 0, len, p_string); AgentBase::GetClassManager().CheckOnException(jni); - JDWP_TRACE_DATA("Value: send: utfLen=" << utfLen - << ", string=" << JDWP_CHECK_NULL(p_string)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Value: send: utfLen=%d, string=%s", utfLen, JDWP_CHECK_NULL(p_string))); // write string to the reply m_cmdParser->reply.WriteString(p_string, utfLen); + + return JDWP_ERROR_NONE; } Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.h?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.h (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/StringReference.h Thu Jul 16 15:57:37 2009 @@ -15,12 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Anton V. Karnachuk - * @version $Revision: 1.5.2.1 $ - */ - /** * @file * StringReference.h @@ -64,7 +58,7 @@ * INVALID_STRING, * INVALID_OBJECT, VM_DEAD. */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni); }; //ValueHandler Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.cpp?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.cpp (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.cpp Thu Jul 16 15:57:37 2009 @@ -15,17 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Vitaly A. Provodin - * @version $Revision: 1.11 $ - */ #include "ThreadGroupReference.h" #include "VirtualMachine.h" #include "PacketParser.h" #include "ThreadManager.h" #include "Log.h" +#include "ExceptionManager.h" using namespace jdwp; using namespace ThreadGroupReference; @@ -33,60 +29,70 @@ //----------------------------------------------------------------------------- //NameHandler------------------------------------------------------------------ -void -ThreadGroupReference::NameHandler::Execute(JNIEnv *jni) throw (AgentException) +int +ThreadGroupReference::NameHandler::Execute(JNIEnv *jni) { jvmtiThreadGroupInfo info; info.name = 0; jthreadGroup threadGroupID = m_cmdParser->command.ReadThreadGroupID(jni); - JDWP_TRACE_DATA("Name: received: threadGroupID=" << threadGroupID); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Name: received: threadGroupID=%p", threadGroupID)); jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupInfo(threadGroupID, &info)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadGroupInfo(threadGroupID, &info)); JvmtiAutoFree dobj(info.name); JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); - if (err != JVMTI_ERROR_NONE) - throw AgentException(err); + if (err != JVMTI_ERROR_NONE) { + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; + } - JDWP_TRACE_DATA("Name: send: name=" << info.name); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Name: send: name=%s", info.name)); m_cmdParser->reply.WriteString(info.name); + + return JDWP_ERROR_NONE; } //----------------------------------------------------------------------------- //ParentHandler---------------------------------------------------------------- -void -ThreadGroupReference::ParentHandler::Execute(JNIEnv *jni) throw(AgentException) +int +ThreadGroupReference::ParentHandler::Execute(JNIEnv *jni) { jvmtiThreadGroupInfo info; info.name = 0; jthreadGroup threadGroupID = m_cmdParser->command.ReadThreadGroupID(jni); - JDWP_TRACE_DATA("Parent: received: threadGroupID=" << threadGroupID); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Parent: received: threadGroupID=%p", threadGroupID)); jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupInfo(threadGroupID, &info)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadGroupInfo(threadGroupID, &info)); JvmtiAutoFree dobj(info.name); JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); - if (err != JVMTI_ERROR_NONE) - throw AgentException(err); + if (err != JVMTI_ERROR_NONE){ + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; + } - JDWP_TRACE_DATA("Parent: send: name=" << info.name << ", parent=" << info.parent); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Parent: send: name=%s, parent=%p", info.name, info.parent)); m_cmdParser->reply.WriteThreadGroupID(jni, info.parent); + + return JDWP_ERROR_NONE; } //----------------------------------------------------------------------------- //ChildrenHandler-------------------------------------------------------------- -void -ThreadGroupReference::ChildrenHandler::Execute(JNIEnv *jni) throw(AgentException) +int +ThreadGroupReference::ChildrenHandler::Execute(JNIEnv *jni) { jint totalThreadCount, threadCount = 0; jint groupCount; @@ -94,10 +100,10 @@ jthreadGroup* groups = 0; jthreadGroup threadGroupID = m_cmdParser->command.ReadThreadGroupID(jni); - JDWP_TRACE_DATA("Children: received: threadGroupID=" << threadGroupID); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Children: received: threadGroupID=%p", threadGroupID)); jvmtiError err; - JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupChildren(threadGroupID, + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadGroupChildren(threadGroupID, &totalThreadCount, &threads, &groupCount, &groups)); JvmtiAutoFree dobjt(threads); @@ -105,16 +111,16 @@ JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); - if (err != JVMTI_ERROR_NONE) - throw AgentException(err); + if (err != JVMTI_ERROR_NONE){ + AgentException e(err); + JDWP_SET_EXCEPTION(e); + return err; + } ThreadManager& thrdMgr = GetThreadManager(); - JDWP_TRACE_DATA("Children: threadGroupID=" << threadGroupID - << ", totalThreadCount=" << totalThreadCount - << ", threads=" << threads - << ", groupCount=" << groupCount - << ", groups=" << groups); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Children: threadGroupID=%p, totalThreadCount=%d, thread=%p, groupCount=%d, groups=%p", + threadGroupID, totalThreadCount, threads, groupCount, groups)); int i; @@ -124,11 +130,10 @@ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { jvmtiThreadInfo info; info.name = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(threads[i], &info)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadInfo(threads[i], &info)); JvmtiAutoFree jafInfoName(info.name); - JDWP_TRACE_DATA("Children: thread#=" << i - << ", name= " << JDWP_CHECK_NULL(info.name) - << ", isAgent=" << (thrdMgr.IsAgentThread(jni, threads[i]))); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Children: thread#=%d, name=%s, isAgent=%s", + i, JDWP_CHECK_NULL(info.name), ((thrdMgr.IsAgentThread(jni, threads[i]))?"TRUE":"FALSE"))); } #endif if (!thrdMgr.IsAgentThread(jni, threads[i])) { @@ -150,32 +155,29 @@ #ifndef NDEBUG if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { int i; - JDWP_TRACE_DATA("Clildren: send: threadCount=" << threadCount - << ", groupCount=" << groupCount); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Clildren: send: threadCount=%d, groupCount=%d", threadCount, groupCount)); for (i = 0; i < threadCount; i++) { jvmtiThreadInfo info; info.name = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(threads[i], &info)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadInfo(threads[i], &info)); JvmtiAutoFree jafInfoName(info.name); - JDWP_TRACE_DATA("Clildren: send: thread#=" << i - << ", threadID=" << threads[i] - << ", name=" << JDWP_CHECK_NULL(info.name)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Clildren: send: thread#=%d, threadID=%p, name=%s", i, threads[i], JDWP_CHECK_NULL(info.name))); } for (i = 0; i < groupCount; i++) { jvmtiThreadGroupInfo info; info.name = 0; - JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupInfo(groups[i], &info)); + JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadGroupInfo(groups[i], &info)); JvmtiAutoFree jafInfoName(info.name); - JDWP_TRACE_DATA("Clildren: send: group#" << i - << ", groupID=" << groups[i] - << ", name=" << JDWP_CHECK_NULL(info.name)); + JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Clildren: send: group#%d, groupID=%p, name=%s", i, groups[i], JDWP_CHECK_NULL(info.name))); } } #endif + + return JDWP_ERROR_NONE; } //----------------------------------------------------------------------------- Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.h?rev=794726&r1=794725&r2=794726&view=diff ============================================================================== --- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.h (original) +++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadGroupReference.h Thu Jul 16 15:57:37 2009 @@ -15,12 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * @author Vitaly A. Provodin - * @version $Revision: 1.4.2.1 $ - */ - /** * @file * ThreadGroupReference.h @@ -54,7 +48,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni) ; };//NameHandler @@ -71,7 +65,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni) ; };//ParentHandler @@ -88,7 +82,7 @@ * * @param jni - the JNI interface pointer */ - virtual void Execute(JNIEnv *jni) throw(AgentException); + virtual int Execute(JNIEnv *jni) ; };//ChildrenHandler