Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 60487 invoked from network); 28 Nov 2006 17:51:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Nov 2006 17:51:09 -0000 Received: (qmail 51992 invoked by uid 500); 28 Nov 2006 17:51:18 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 51966 invoked by uid 500); 28 Nov 2006 17:51:18 -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 51957 invoked by uid 99); 28 Nov 2006 17:51:18 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2006 09:51:18 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2006 09:51:04 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 3CED51A9859; Tue, 28 Nov 2006 09:49:59 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r480141 [6/38] - in /harmony/enhanced/jdktools/trunk/modules/jpda: ./ doc/ doc/images/ make/ src/ src/common/ src/common/other/ src/common/other/jpda/ src/common/other/jpda/jdwp/ src/common/other/jpda/jdwp/agent/ src/common/other/jpda/jdwp/... Date: Tue, 28 Nov 2006 17:49:31 -0000 To: commits@harmony.apache.org From: geirm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061128174959.3CED51A9859@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ReferenceType.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ReferenceType.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ReferenceType.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ReferenceType.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,355 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Anatoly F. Bondarenko + * @version $Revision: 1.5.2.1 $ + */ + +/** + * @file + * ReferenceType.h + * + */ + +#ifndef _REFERENCE_TYPE_H_ +#define _REFERENCE_TYPE_H_ + +#include "AgentException.h" +#include "CommandHandler.h" + +namespace jdwp { + + /** + * The namespace includes declaration of the classes implementing commands + * from the ReferenceType command set. + */ + namespace ReferenceType { + + // ========================================================================= + /** + * The class implements the Signature (1) command and + * it is the base class for the SignatureWithGeneric (13) + * command, both from the ReferenceType command set. + */ + class SignatureHandler : public SyncCommandHandler { + public: + + /** + * A constructor. + */ + SignatureHandler() { m_withGeneric = false; } + + protected: + + /** + * Executes the Signature JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + protected: + + /** + * The field defines if it is the Signature (1) command or + * the SignatureWithGeneric (13) command. + */ + bool m_withGeneric; + + }; // SignatureHandler class + + // ========================================================================= + /** + * The class implements the ClassLoader (2) + * command from the ReferenceType command set. + */ + class ClassLoaderHandler : public SyncCommandHandler { + protected: + + /** + * Executes the ClassLoader JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // ClassLoaderHandler class + + // ========================================================================= + /** + * The class implements the Modifiers (3) + * command from the ReferenceType command set. + */ + class ModifiersHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Modifiers JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer. + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // ModifiersHandler class + + // ========================================================================= + /** + * The class implements the Fields (4) command and + * it is the base class for the FieldsWithGeneric (14) + * command, both from the ReferenceType command set. + */ + class FieldsHandler : public SyncCommandHandler { + public: + + /** + * A constructor. + */ + FieldsHandler() { m_withGeneric = false; } + + protected: + + /** + * Executes the Fields JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + protected: + /** + * The field defines if it is the Fields (4) command or + * the FieldsWithGeneric (14) command. + */ + bool m_withGeneric; + }; // FieldsHandler class + + // ========================================================================= + /** + * The class implements the Methods (5) command and + * it is the base class for the MethodsWithGeneric (15) + * command, both from the ReferenceType command set. + */ + class MethodsHandler : public SyncCommandHandler { + public: + + /** + * A constructor. + */ + MethodsHandler() { m_withGeneric = false; } + + protected: + + /** + * Executes the Methods JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer. + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + protected: + /** + * The field defines if it is the Methods (5) command or + * the MethodsWithGeneric (15) command. + */ + bool m_withGeneric; + }; // MethodsHandler class + + // ========================================================================= + /** + * The class implements the GetValues (6) + * command from the ReferenceType command set. + */ + class GetValuesHandler : public SyncCommandHandler { + protected: + + /** + * Executes the GetValues JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // GetValuesHandler class + + // ========================================================================= + /** + * The class implements the SourceFile (7) + * command from the ReferenceType command set. + */ + class SourceFileHandler : public SyncCommandHandler { + protected: + + /** + * Executes the SourceFile JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer. + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // SourceFileHandler class + + // ========================================================================= + /** + * The class implements the NestedTypes (8) + * command from the ReferenceType command set. + */ + class NestedTypesHandler : public SyncCommandHandler { + protected: + + /** + * Executes the NestedTypes JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // NestedTypesHandler class + + // ========================================================================= + /** + * The class implements the Status (9) command from the + * ReferenceType command set. + */ + class StatusHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Status JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // StatusHandler class + + // ========================================================================= + /** + * The class implements the Interfaces (10) + * command from the ReferenceType command set. + */ + class InterfacesHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Interfaces JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // InterfacesHandler class + + // ========================================================================= + /** + * The class implements the ClassObject (11) + * command from the ReferenceType command set. + */ + class ClassObjectHandler : public SyncCommandHandler { + protected: + + /** + * Executes the ClassObject JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer. + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // ClassObjectHandler class + + // ========================================================================= + /** + * The class implements the SourceDebugExtension (12) + * command from the ReferenceType command set. + */ + class SourceDebugExtensionHandler : public SyncCommandHandler { + protected: + + /** + * Executes the SourceDebugExtension JDWP command for the + * ReferenceType command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; // SourceDebugExtensionHandler class + + // ========================================================================= + /** + * The class implements the SignatureWithGeneric (13) + * command from the ReferenceType command set. + */ + class SignatureWithGenericHandler : public SignatureHandler { + public: + + /** + * A constructor. + */ + SignatureWithGenericHandler() { m_withGeneric = true; } + + }; // SignatureWithGenericHandler class + + // ========================================================================= + /** + * The class implements the FieldsWithGeneric (14) + * command from the ReferenceType command set. + */ + class FieldsWithGenericHandler : public FieldsHandler { + public: + + /** + * A constructor. + */ + FieldsWithGenericHandler() { m_withGeneric = true; } + + }; // FieldsWithGenericHandler class + + // ========================================================================= + /** + * The class implements the MethodsWithGeneric (15) + * command from the ReferenceType command set. + */ + class MethodsWithGenericHandler : public MethodsHandler { + public: + + /** + * A constructor. + */ + MethodsWithGenericHandler() { m_withGeneric = true; } + + }; // MethodsWithGenericHandler class + + // ========================================================================= + + } // ReferenceType namespace + +} // jdwp namesoace + +#endif //_REFERENCE_TYPE_H_ Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ReferenceType.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.cpp?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.cpp (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.cpp Tue Nov 28 09:49:08 2006 @@ -0,0 +1,395 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Viacheslav G. Rybalov + * @version $Revision: 1.15.2.2 $ + */ +#include "StackFrame.h" +#include "PacketParser.h" +#include "ClassManager.h" +#include "ThreadManager.h" + +using namespace jdwp; +using namespace StackFrame; + +void +StackFrame::GetValuesHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + 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); + + if (thread == 0) { + throw AgentException(JDWP_ERROR_INVALID_THREAD); + } + if (slots < 0) { + throw AgentException(JDWP_ERROR_ILLEGAL_ARGUMENT); + } + + m_cmdParser->reply.WriteInt(slots); + for (int i = 0; i < slots; i++) { + jint slot = m_cmdParser->command.ReadInt(); + jdwpTag sigbyte = static_cast(m_cmdParser->command.ReadByte()); + jvmtiError err = JVMTI_ERROR_NONE; + jvalue resValue; + switch (sigbyte) { + case JDWP_TAG_BOOLEAN: + case JDWP_TAG_BYTE: + case JDWP_TAG_CHAR: + case JDWP_TAG_SHORT: + case JDWP_TAG_INT: + jint ivalue; + JVMTI_TRACE(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); + break; + case JDWP_TAG_BYTE: + resValue.b = static_cast(ivalue); + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", value=(byte)" << resValue.b); + break; + case JDWP_TAG_CHAR: + resValue.c = static_cast(ivalue); + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", value=(char)" << resValue.c); + break; + case JDWP_TAG_SHORT: + resValue.s = static_cast(ivalue); + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", value=(short)" << resValue.s); + break; + case JDWP_TAG_INT: + resValue.i = ivalue; + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", value=(int)" << 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)); + if (err != JVMTI_ERROR_NONE) { + break; + } + resValue.j = lvalue; + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", value=(long)" << 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)); + if (err != JVMTI_ERROR_NONE) { + break; + } + resValue.f = fvalue; + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", value=(float)" << 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)); + if (err != JVMTI_ERROR_NONE) { + break; + } + resValue.d = dvalue; + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", value=(double)" << resValue.d); + m_cmdParser->reply.WriteValue(jni, sigbyte, resValue); + break; + case JDWP_TAG_OBJECT: + case JDWP_TAG_ARRAY: + case JDWP_TAG_STRING: + case JDWP_TAG_THREAD: + case JDWP_TAG_THREAD_GROUP: + case JDWP_TAG_CLASS_LOADER: + case JDWP_TAG_CLASS_OBJECT: { + jobject ovalue; + JVMTI_TRACE(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); + } + resValue.l = ovalue; + JDWP_TRACE_DATA("GetValues: slot#=" << i + << ", tag=" << tag + << ", value=(object)" << resValue.l); + m_cmdParser->reply.WriteValue(jni, tag, resValue); + break; + } + default: + JDWP_TRACE_DATA("GetValues: bad slot tag: slot#=" << i + << ", tag=" << sigbyte); + throw AgentException(JDWP_ERROR_INVALID_TAG); + } + if (err != JVMTI_ERROR_NONE) { + jdwpError error; + if (err == JVMTI_ERROR_TYPE_MISMATCH) { + error = JDWP_ERROR_INVALID_TAG; + } else if (err == JVMTI_ERROR_OPAQUE_FRAME) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) { + error = JDWP_ERROR_INVALID_THREAD; + } else if (err == JVMTI_ERROR_ILLEGAL_ARGUMENT) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else if (err == JVMTI_ERROR_NO_MORE_FRAMES) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else { + error = (jdwpError)err; + } + throw AgentException(error); + } + } +} + +void +StackFrame::SetValuesHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + 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); + + if (thread == 0) { + throw AgentException(JDWP_ERROR_INVALID_THREAD); + } + if (slotValues < 0) { + throw AgentException(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); +// jdwpTag sigbyte = taggedValue.tag; + jvmtiError err = JVMTI_ERROR_NONE; + switch (taggedValue.tag) { + case JDWP_TAG_BOOLEAN: + case JDWP_TAG_BYTE: + case JDWP_TAG_CHAR: + case JDWP_TAG_SHORT: + case JDWP_TAG_INT: + jint ivalue; + switch (taggedValue.tag) { + case JDWP_TAG_BOOLEAN: + ivalue = static_cast(taggedValue.value.z); + JDWP_TRACE_DATA("SetValues: slot#=" << i + << ", value=(boolean)" << 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); + break; + case JDWP_TAG_CHAR: + ivalue = static_cast(taggedValue.value.c); + JDWP_TRACE_DATA("SetValues: slot#=" << i + << ", value=(char)" << 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); + break; + case JDWP_TAG_INT: + ivalue = taggedValue.value.i; + JDWP_TRACE_DATA("SetValues: slot#=" << i + << ", value=(int)" << taggedValue.value.i); + break; + } + JVMTI_TRACE(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)); + 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)); + 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)); + break; + } + case JDWP_TAG_OBJECT: + case JDWP_TAG_ARRAY: + case JDWP_TAG_STRING: + case JDWP_TAG_THREAD: + case JDWP_TAG_THREAD_GROUP: + 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)); + break; + } + default: + JDWP_TRACE_DATA("SetValues: bad value tag: slot#=" << i + << ", tag=" << taggedValue.tag); + throw AgentException(JDWP_ERROR_INVALID_TAG); + } + if (err != JVMTI_ERROR_NONE) { + jdwpError error; + if (err == JVMTI_ERROR_TYPE_MISMATCH) { + error = JDWP_ERROR_INVALID_TAG; + } else if (err == JVMTI_ERROR_OPAQUE_FRAME) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) { + error = JDWP_ERROR_INVALID_THREAD; + } else if (err == JVMTI_ERROR_ILLEGAL_ARGUMENT) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else if (err == JVMTI_ERROR_NO_MORE_FRAMES) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else { + error = (jdwpError)err; + } + throw AgentException(error); + } + } +} + +void +StackFrame::ThisObjectHandler::CheckErr(jvmtiError err) throw(AgentException) +{ + if (err != JVMTI_ERROR_NONE) { + jdwpError error; + if (err == JVMTI_ERROR_OPAQUE_FRAME) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else if (err == JVMTI_ERROR_THREAD_NOT_ALIVE) { + error = JDWP_ERROR_INVALID_THREAD; + } else if (err == JVMTI_ERROR_ILLEGAL_ARGUMENT) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else if (err == JVMTI_ERROR_NO_MORE_FRAMES) { + error = JDWP_ERROR_INVALID_FRAMEID; + } else { + error = (jdwpError)err; + } + throw AgentException(error); + } +} + +void +StackFrame::ThisObjectHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jthread thread = m_cmdParser->command.ReadThreadID(jni); + + if (thread == 0) { + throw AgentException(JDWP_ERROR_INVALID_THREAD); + } + 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); + + jvmtiError err; + jint allCount; + JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameCount(thread, &allCount)); + CheckErr(err); + JDWP_ASSERT(allCount > 0); + + jvmtiFrameInfo* frames = static_cast + (GetMemoryManager().Allocate(allCount * sizeof(jvmtiFrameInfo) JDWP_FILE_LINE)); + AgentAutoFree af(frames JDWP_FILE_LINE); + + jint count; + JVMTI_TRACE(err, GetJvmtiEnv()->GetStackTrace(thread, 0, allCount, frames, &count)); + CheckErr(err); + JDWP_ASSERT(count <= allCount); + JDWP_ASSERT(frame <= count); + + jvmtiFrameInfo& frameInfo = frames[frame]; + + jint modifiers; + JVMTI_TRACE(err, GetJvmtiEnv()->GetMethodModifiers(frameInfo.method, &modifiers)); + CheckErr(err); + + 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)); + resValue.l = 0; + m_cmdParser->reply.WriteValue(jni, JDWP_TAG_OBJECT, resValue); + return; + } + + jobject ovalue = 0; + JVMTI_TRACE(err, GetJvmtiEnv()->GetLocalObject(thread, frame, 0, &ovalue)); + CheckErr(err); + JDWP_ASSERT(ovalue != 0); + + jdwpTag tag = GetClassManager().GetJdwpTag(jni, ovalue); + resValue.l = ovalue; + + JDWP_TRACE_DATA("ThisObject: send: tag=" << tag + << ", object=" << resValue.l); + m_cmdParser->reply.WriteValue(jni, tag, resValue); +} + +void +StackFrame::PopFramesHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jdwpCapabilities caps = GetCapabilities(); + if (caps.canPopFrames != 1) { + throw AgentException(JDWP_ERROR_NOT_IMPLEMENTED); + } + + jthread thread = m_cmdParser->command.ReadThreadID(jni); + if (thread == 0) { + throw AgentException(JDWP_ERROR_INVALID_THREAD); + } + + jint frame = m_cmdParser->command.ReadFrameID(jni); + jint framesToPop = frame + 1; + + JDWP_TRACE_DATA("PopFrames: received: threadID=" << thread + << ", framesToPop=" << framesToPop); + + GetThreadManager().PerformPopFrames(jni, framesToPop, thread); +} Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,118 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Viacheslav G. Rybalov + * @version $Revision: 1.4.2.1 $ + */ + +/** + * @file + * StackFrame.h + * + */ + +#ifndef _STACKFRAME_H_ +#define _STACKFRAME_H_ + +#include "AgentException.h" +#include "CommandHandler.h" + +namespace jdwp { + + /** + * The namespace includes declaration of the classes implementing commands + * from the StackFrame command set. + */ + namespace StackFrame { + + /** + * The class implements the GetValues command from the + * StackFrame command set. + */ + class GetValuesHandler : public SyncCommandHandler { + protected: + + /** + * Executes the GetValues JDWP command for the + * StackFrame command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//GetValuesHandler + + /** + * The class implements the SetValues command from the + * StackFrame command set. + */ + class SetValuesHandler : public SyncCommandHandler { + protected: + + /** + * Executes the SetValues JDWP command for the + * StackFrame command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//SetValuesHandler + + /** + * The class implements the ThisObject command from the + * StackFrame command set. + */ + class ThisObjectHandler : public SyncCommandHandler { + protected: + + /** + * Executes the ThisObject JDWP command for the + * StackFrame command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + private: + void CheckErr(jvmtiError err) throw(AgentException); + };//ThisObjectHandler + + /** + * The class implements the PopFrames command from the + * StackFrame command set. + */ + class PopFramesHandler : public SyncCommandHandler { + protected: + + /** + * Executes the PopFrames JDWP command for the + * StackFrame command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//PopFramesHandler + + } // StackFrame + +} //jdwp + +#endif //_STACKFRAME_H_ Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StackFrame.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.cpp?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.cpp (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.cpp Tue Nov 28 09:49:08 2006 @@ -0,0 +1,58 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Anton V. Karnachuk + * @version $Revision: 1.9 $ + */ +#include "StringReference.h" +#include "PacketParser.h" +#include "ClassManager.h" + +using namespace jdwp; +using namespace StringReference; + +//----------------------------------------------------------------------------- +// StringReference ----------------------------------------------------------------- + +void +StringReference::ValueHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + + //INVALID_OBJECT can be thrown below + jstring stringObject = m_cmdParser->command.ReadStringID(jni); + JDWP_TRACE_DATA("Value: received: stringID=" << stringObject); + + // get length of the string + jsize len = jni->GetStringLength(stringObject); + jsize utfLen = jni->GetStringUTFLength(stringObject); + + // allocate memory for getting string value + char* p_string = reinterpret_cast(GetMemoryManager().Allocate(utfLen + 1 JDWP_FILE_LINE)); + // create auto-free pointer for p_string + AgentAutoFree autoFree_p_string(p_string JDWP_FILE_LINE); + + // obtain the string's value + jni->GetStringUTFRegion(stringObject, 0, len, p_string); + AgentBase::GetClassManager().CheckOnException(jni); + + JDWP_TRACE_DATA("Value: send: utfLen=" << utfLen + << ", string=" << JDWP_CHECK_NULL(p_string)); + + // write string to the reply + m_cmdParser->reply.WriteString(p_string, utfLen); +} Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,75 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Anton V. Karnachuk + * @version $Revision: 1.5.2.1 $ + */ + +/** + * @file + * StringReference.h + * + */ + +#ifndef _STRING_REFERENCE_H_ +#define _STRING_REFERENCE_H_ + +#include "AgentException.h" +#include "CommandHandler.h" + +namespace jdwp { + + /** + * The namespace includes declaration of the classes implementing commands + * from the StringReference command set. + */ + namespace StringReference { + + /** + * The class implements the Superclass command from the + * StringReference command set. + */ + class ValueHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Value JDWP command for the + * StringReference command set. + * + * @param jni - the JNI interface pointer + * + * @exception If packet data integrity gets broken, + * InternalErrorException is thrown. + * @exception If the system runs out of memory, + * OutOfMemoryException is thrown. + * + * following @exception The following implementations of the given interface + * may throw AgentException: + * INVALID_STRING, + * INVALID_OBJECT, VM_DEAD. + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + }; //ValueHandler + + }; // StringReference + +} //jdwp + +#endif //_STRING_REFERENCE_H_ Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/StringReference.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.cpp?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.cpp (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.cpp Tue Nov 28 09:49:08 2006 @@ -0,0 +1,180 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Vitaly A. Provodin + * @version $Revision: 1.11 $ + */ +#include "ThreadGroupReference.h" +#include "VirtualMachine.h" + +#include "PacketParser.h" +#include "ThreadManager.h" +#include "Log.h" + +using namespace jdwp; +using namespace ThreadGroupReference; + +//----------------------------------------------------------------------------- +//NameHandler------------------------------------------------------------------ + +void +ThreadGroupReference::NameHandler::Execute(JNIEnv *jni) throw (AgentException) +{ + jvmtiThreadGroupInfo info; + info.name = 0; + + jthreadGroup threadGroupID = m_cmdParser->command.ReadThreadGroupID(jni); + JDWP_TRACE_DATA("Name: received: threadGroupID=" << threadGroupID); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupInfo(threadGroupID, &info)); + + JvmtiAutoFree dobj(info.name); + + JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + JDWP_TRACE_DATA("Name: send: name=" << info.name); + m_cmdParser->reply.WriteString(info.name); +} + +//----------------------------------------------------------------------------- +//ParentHandler---------------------------------------------------------------- + +void +ThreadGroupReference::ParentHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jvmtiThreadGroupInfo info; + info.name = 0; + + jthreadGroup threadGroupID = m_cmdParser->command.ReadThreadGroupID(jni); + JDWP_TRACE_DATA("Parent: received: threadGroupID=" << threadGroupID); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupInfo(threadGroupID, &info)); + + JvmtiAutoFree dobj(info.name); + + JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + JDWP_TRACE_DATA("Parent: send: name=" << info.name << ", parent=" << info.parent); + m_cmdParser->reply.WriteThreadGroupID(jni, info.parent); +} + +//----------------------------------------------------------------------------- +//ChildrenHandler-------------------------------------------------------------- + +void +ThreadGroupReference::ChildrenHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jint totalThreadCount, threadCount = 0; + jint groupCount; + jthread* threads = 0; + jthreadGroup* groups = 0; + + jthreadGroup threadGroupID = m_cmdParser->command.ReadThreadGroupID(jni); + JDWP_TRACE_DATA("Children: received: threadGroupID=" << threadGroupID); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupChildren(threadGroupID, + &totalThreadCount, &threads, &groupCount, &groups)); + + JvmtiAutoFree dobjt(threads); + JvmtiAutoFree dobjg(groups); + + JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + ThreadManager& thrdMgr = GetThreadManager(); + + JDWP_TRACE_DATA("Children: threadGroupID=" << threadGroupID + << ", totalThreadCount=" << totalThreadCount + << ", threads=" << threads + << ", groupCount=" << groupCount + << ", groups=" << groups); + + int i; + + // filter out agent threads + for (i = 0; i < totalThreadCount; i++) { +#ifndef NDEBUG + if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { + jvmtiThreadInfo info; + info.name = 0; + JVMTI_TRACE(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]))); + } +#endif + if (!thrdMgr.IsAgentThread(jni, threads[i])) { + threads[threadCount] = threads[i]; + threadCount++; + } + } + + m_cmdParser->reply.WriteInt(threadCount); + for (i = 0; i < threadCount; i++) { + m_cmdParser->reply.WriteThreadID(jni, threads[i]); + } + + m_cmdParser->reply.WriteInt(groupCount); + for (i = 0; i < groupCount; i++) { + m_cmdParser->reply.WriteThreadGroupID(jni, groups[i]); + } + +#ifndef NDEBUG + if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { + int i; + JDWP_TRACE_DATA("Clildren: send: threadCount=" << threadCount + << ", groupCount=" << groupCount); + + for (i = 0; i < threadCount; i++) { + jvmtiThreadInfo info; + info.name = 0; + JVMTI_TRACE(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)); + } + + for (i = 0; i < groupCount; i++) { + jvmtiThreadGroupInfo info; + info.name = 0; + JVMTI_TRACE(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)); + } + } +#endif +} + +//----------------------------------------------------------------------------- Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,100 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Vitaly A. Provodin + * @version $Revision: 1.4.2.1 $ + */ + +/** + * @file + * ThreadGroupReference.h + * + */ + +#ifndef _THREAD_GROUP_REFERENCE_H_ +#define _THREAD_GROUP_REFERENCE_H_ + +#include "AgentException.h" +#include "CommandHandler.h" + +namespace jdwp { + + /** + * The namespace includes the declaration of the classes implementing + * commands from the ThreadGroupReference command set. + */ + namespace ThreadGroupReference { + + /** + * The class implements the Name command from the + * ThreadGroupReference command set. + */ + class NameHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Name JDWP command for the + * ThreadGroupReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//NameHandler + + /** + * The class implements the Parent command from the + * ThreadGroupReference command set. + */ + class ParentHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Parent JDWP command for the + * ThreadGroupReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//ParentHandler + + /** + * The class implements the Children command from the + * ThreadGroupReference command set. + */ + class ChildrenHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Children JDWP command for the + * ThreadGroupReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//ChildrenHandler + + }//ThreadGroupReference + +}//jdwp + +#endif //_THREAD_GROUP_REFERENCE_H_ + Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadGroupReference.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.cpp?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.cpp (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.cpp Tue Nov 28 09:49:08 2006 @@ -0,0 +1,373 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Vitaly A. Provodin + * @version $Revision: 1.16.2.2 $ + */ +#include "ThreadReference.h" +#include "PacketParser.h" +#include "ThreadManager.h" +#include "VirtualMachine.h" +#include "MemoryManager.h" +#include "ClassManager.h" + +using namespace jdwp; +using namespace ThreadReference; + +//----------------------------------------------------------------------------- +//NameHandler------------------------------------------------------------------ + +void +ThreadReference::NameHandler::Execute(JNIEnv *jni) throw (AgentException) +{ + jvmtiThreadInfo info; + info.name = 0; + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + JDWP_TRACE_DATA("Name: received: threadID=" << thrd); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thrd, &info)); + JvmtiAutoFree destroyer(info.name); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + JDWP_TRACE_DATA("Name: send: name=" << JDWP_CHECK_NULL(info.name)); + m_cmdParser->reply.WriteString(info.name); +} + +//----------------------------------------------------------------------------- +//SuspendHandler---------------------------------------------------------------- + +void +ThreadReference::SuspendHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + + JDWP_TRACE_DATA("Suspend: suspend: threadID=" << thrd); + GetThreadManager().Suspend(jni, thrd); +} + +//----------------------------------------------------------------------------- +//ResumeHandler---------------------------------------------------------------- + +void +ThreadReference::ResumeHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + + JDWP_TRACE_DATA("Resume: resume: threadID=" << thrd); + GetThreadManager().Resume(jni, thrd); +} + +//----------------------------------------------------------------------------- +//StatusHandler---------------------------------------------------------------- + +void +ThreadReference::StatusHandler::Execute(JNIEnv *jni) throw (AgentException) +{ + jint thread_state; + + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + JDWP_TRACE_DATA("Status: received: threadID=" << thrd); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadState(thrd, &thread_state)); + JDWP_TRACE_DATA("Status: threadState=" << hex << thread_state); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + jint ret_value; + jint const THREAD_STATE_SLEEPING = + JVMTI_THREAD_STATE_SLEEPING | JVMTI_THREAD_STATE_ALIVE; + + if ( (thread_state & THREAD_STATE_SLEEPING) == THREAD_STATE_SLEEPING ) { + ret_value = JDWP_THREAD_STATUS_SLEEPING; + } else { + switch (thread_state & JVMTI_JAVA_LANG_THREAD_STATE_MASK) + { + case JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED: + ret_value = JDWP_THREAD_STATUS_ZOMBIE; + break; + case JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE: + ret_value = JDWP_THREAD_STATUS_RUNNING; + break; + case JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED: + ret_value = JDWP_THREAD_STATUS_MONITOR; + break; + case JVMTI_JAVA_LANG_THREAD_STATE_WAITING: + case JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING: + ret_value = JDWP_THREAD_STATUS_WAIT; + break; + default: + JDWP_TRACE_DATA("Status: bad Java thread state: " + << hex << thread_state); + throw InternalErrorException(); + } + } + m_cmdParser->reply.WriteInt(ret_value); + if (thread_state & JVMTI_THREAD_STATE_SUSPENDED) + m_cmdParser->reply.WriteInt(JDWP_SUSPEND_STATUS_SUSPENDED); + else + m_cmdParser->reply.WriteInt(0); + JDWP_TRACE_DATA("Status: send: status=" << ret_value); +} + +//----------------------------------------------------------------------------- +//ThreadGroupHandler----------------------------------------------------------- + +void +ThreadReference::ThreadGroupHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jvmtiThreadInfo info; + info.name = 0; + + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + JDWP_TRACE_DATA("ThreadGroup: received: threadID=" << thrd); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thrd, &info)); + JvmtiAutoFree destroyer(info.name); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + JDWP_TRACE_DATA("ThreadGroup: send: threadGroupID=" << info.thread_group); + m_cmdParser->reply.WriteThreadGroupID(jni, info.thread_group); +} + +//----------------------------------------------------------------------------- +//FramesHandler---------------------------------------------------------------- + +void +ThreadReference::FramesHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jvmtiEnv *jvmti = GetJvmtiEnv(); + + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + + if (!GetThreadManager().IsSuspended(thrd)) + throw AgentException(JVMTI_ERROR_THREAD_NOT_SUSPENDED); + + jint startFrame = m_cmdParser->command.ReadInt(); + jint length = m_cmdParser->command.ReadInt(); + JDWP_TRACE_DATA("Frames: received: threadID=" << thrd + << ", startFrame=" << startFrame + << ", length=" << length); + + jint frameCount; + jvmtiError err; + JVMTI_TRACE(err, jvmti->GetFrameCount(thrd, &frameCount)); + + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + if (length == -1) { + length = frameCount - startFrame; + } + + if (length == 0) { + JDWP_TRACE_DATA("Frames: frameCount=" << frameCount + << ", startFrame=" << startFrame + << ", length=" << length); + m_cmdParser->reply.WriteInt(0); + return; + } + + if (startFrame >= frameCount || startFrame < 0) + throw AgentException(JDWP_ERROR_INVALID_INDEX); + + jint maxFrame = startFrame + length; + if ( (length < 0) || (maxFrame > frameCount) ) { + throw AgentException(JDWP_ERROR_INVALID_LENGTH); + } + + jvmtiFrameInfo *frame_buffer = + reinterpret_cast(GetMemoryManager().Allocate( + sizeof(jvmtiFrameInfo)*frameCount JDWP_FILE_LINE)); + AgentAutoFree destroyer(frame_buffer JDWP_FILE_LINE); + + jint count; + JVMTI_TRACE(err, jvmti->GetStackTrace(thrd, 0, frameCount, + frame_buffer, &count)); + if (err != JVMTI_ERROR_NONE) { + throw AgentException(err); + } + JDWP_ASSERT(count == frameCount); + + m_cmdParser->reply.WriteInt(length); + + JDWP_TRACE_DATA("Frames: frameCount=" << frameCount + << ", startFrame=" << startFrame + << ", length=" << length + << ", maxFrame=" << maxFrame); + + jclass declaring_class; + jdwpTypeTag typeTag; + + for (jint j = startFrame; j < maxFrame; j++) { + m_cmdParser->reply.WriteFrameID(jni, thrd, j, frameCount); + + JVMTI_TRACE(err, jvmti->GetMethodDeclaringClass(frame_buffer[j].method, + &declaring_class)); + if (err != JVMTI_ERROR_NONE) { + throw AgentException(err); + } + + typeTag = GetClassManager().GetJdwpTypeTag(declaring_class); + +#ifndef NDEBUG + if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) { + jvmtiThreadInfo info; + JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thrd, &info)); + JDWP_TRACE_DATA("Frames: send: frame#=" << j + << ", threadName=" << info.name + << ", loc=" << frame_buffer[j].location + << ", methodID=" << frame_buffer[j].method + << ", classID=" << declaring_class + << ", typeTag=" << typeTag); + } +#endif + + m_cmdParser->reply.WriteLocation(jni, typeTag, + declaring_class, frame_buffer[j].method, + frame_buffer[j].location); + } +} + +//----------------------------------------------------------------------------- +//FrameCountHandler------------------------------------------------------------ + +void +ThreadReference::FrameCountHandler::Execute(JNIEnv *jni) throw (AgentException) +{ + jint count; + + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + JDWP_TRACE_DATA("FrameCount: received: threadID=" << thrd); + + if (!GetThreadManager().IsSuspended(thrd)) + throw AgentException(JVMTI_ERROR_THREAD_NOT_SUSPENDED); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameCount(thrd, &count)); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + m_cmdParser->reply.WriteInt(count); + JDWP_TRACE_DATA("FrameCount: send: count=" << count); +} + +//----------------------------------------------------------------------------- +//OwnedMonitorsHandler--------------------------------------------------------- + +void +ThreadReference::OwnedMonitorsHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jint count; + jobject* owned_monitors = 0; + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + JDWP_TRACE_DATA("OwnedMonitors: received: threadID=" << thrd); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetOwnedMonitorInfo(thrd, &count, + &owned_monitors)); + JvmtiAutoFree destroyer(owned_monitors); + + JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + JDWP_TRACE_DATA("OwnedMonitors: send: monitors=" << count); + m_cmdParser->reply.WriteInt(count); + for (int i = 0; i < count; i++) + { + JDWP_TRACE_DATA("OwnedMonitors: send: monitor#=" << i + << ", objectID=" << owned_monitors[i]); + m_cmdParser->reply.WriteTaggedObjectID(jni, owned_monitors[i]); + } +} + +//----------------------------------------------------------------------------- +//OwnedMonitorsHandler--------------------------------------------------------- + +void +ThreadReference::CurrentContendedMonitorHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jobject monitor; + jthread thrd = m_cmdParser->command.ReadThreadID(jni);\ + JDWP_TRACE_DATA("CurrentContendedMonitor: received: threadID=" << thrd); + + jvmtiError err; + JVMTI_TRACE(err, GetJvmtiEnv()->GetCurrentContendedMonitor(thrd, &monitor)); + + JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER); + + if (err != JVMTI_ERROR_NONE) + throw AgentException(err); + + JDWP_TRACE_DATA("CurrentContendedMonitor: send: monitor=" << monitor); + m_cmdParser->reply.WriteTaggedObjectID(jni, monitor); +} + +//----------------------------------------------------------------------------- +//StopHandler------------------------------------------------------------------ + +void +ThreadReference::StopHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + jobject excp = m_cmdParser->command.ReadObjectID(jni); + + JDWP_TRACE_DATA("Stop: stop: threadID=" << thrd + << ", throwableID=" << excp); + GetThreadManager().Stop(jni, thrd, excp); +} + +//----------------------------------------------------------------------------- +//InterruptHandler------------------------------------------------------------- + +void +ThreadReference::InterruptHandler::Execute(JNIEnv *jni) throw(AgentException) +{ + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + + JDWP_TRACE_DATA("Interrupt: interrupt: threadID=" << thrd); + GetThreadManager().Interrupt(jni, thrd); +} + +//----------------------------------------------------------------------------- +//SuspendCountHandler---------------------------------------------------------- + +void +ThreadReference::SuspendCountHandler::Execute(JNIEnv *jni) + throw (AgentException) +{ + jthread thrd = m_cmdParser->command.ReadThreadID(jni); + JDWP_TRACE_DATA("SuspendCount: received: threadID=" << thrd); + jint count = GetThreadManager().GetSuspendCount(jni, thrd); + + JDWP_TRACE_DATA("SuspendCount: send: count=" << count); + m_cmdParser->reply.WriteInt(count); +} + +//----------------------------------------------------------------------------- Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,252 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Vitaly A. Provodin + * @version $Revision: 1.4.2.1 $ + */ + +/** + * @file + * ThreadReference.h + * + */ + +#ifndef _THREAD_REFERENCE_H_ +#define _THREAD_REFERENCE_H_ + +#include "AgentException.h" +#include "CommandHandler.h" + +namespace jdwp { + + /** + * The namespace includes declaration of the classes implementing commands + * from the ThreadReference command set. + */ + namespace ThreadReference { + + /** + * The class implements the Name command from the + * ThreadReference command set. + */ + class NameHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Name JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//NameHandler + + /** + * The class implements the Suspend command from the + * ThreadReference command set. + */ + class SuspendHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Suspend JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//SuspendHandler + + /** + * The class implements the Resume command from the + * ThreadReference command set. + */ + class ResumeHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Resume JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//ResumeHandler + + /** + * The class implements the Status command from the + * ThreadReference command set. + */ + class StatusHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Status JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//StatusHandler + + /** + * The class implements the ThreadGroup command from the + * ThreadReference command set. + */ + class ThreadGroupHandler : public SyncCommandHandler { + protected: + + /** + * Executes the ThreadGroup JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//ThreadGroupHandler + + /** + * The class implements the Frames command from the + * ThreadReference command set. + */ + class FramesHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Frames JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//FramesHandler + + /** + * The class implements the FrameCount command from the + * ThreadReference command set. + */ + class FrameCountHandler : public SyncCommandHandler { + protected: + + /** + * Executes the FrameCount JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//FrameCountHandler + + /** + * The class implements the OwnedMonitors command from the + * ThreadReference command set. + */ + class OwnedMonitorsHandler : public SyncCommandHandler { + protected: + + /** + * Executes the OwnedMonitors JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//OwnedMonitorsHandler + + /** + * The class implements the CurrentContendedMonitor command from the + * ThreadReference command set. + */ + class CurrentContendedMonitorHandler : public SyncCommandHandler { + protected: + + /** + * Executes the CurrentContendedMonitor JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//CurrentContendedMonitorHandler + + /** + * The class implements the Stop command from the + * ThreadReference command set. + */ + class StopHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Stop JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//StopHandler + + /** + * The class implements the Interrupt command from the + * ThreadReference command set. + */ + class InterruptHandler : public SyncCommandHandler { + protected: + + /** + * Executes the Interrupt JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//InterruptHandler + + /** + * The class implements the SuspendCount command from the + * ThreadReference command set. + */ + class SuspendCountHandler : public SyncCommandHandler { + protected: + + /** + * Executes the SuspendCount JDWP command for the + * ThreadReference command set. + * + * @param jni - the JNI interface pointer + */ + virtual void Execute(JNIEnv *jni) throw(AgentException); + + };//SuspendCountHandler + + }//ThreadReference + +}//jdwp + +#endif //_THREAD_REFERENCE_H_ Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/commands/ThreadReference.h ------------------------------------------------------------------------------ svn:eol-style = native