harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r480141 [8/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 GMT
Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.cpp?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.cpp (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.cpp Tue Nov 28 09:49:08 2006
@@ -0,0 +1,333 @@
+/*
+ * 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 Pavel N. Vyssotski
+ * @version $Revision: 1.10 $
+ */
+// AgentEventRequest.cpp
+
+#include "AgentEventRequest.h"
+#include "RequestManager.h"
+#include "Log.h"
+
+using namespace jdwp;
+
+AgentEventRequest::AgentEventRequest(jdwpEventKind kind,
+        jdwpSuspendPolicy suspend, jint modCount)
+    throw(AgentException)
+{
+    m_requestId = 0;
+    m_eventKind = kind;
+    m_suspendPolicy = suspend;
+    m_modifierCount = modCount;
+    m_modifiers = 0;
+    m_isExpired = false;
+    if (modCount != 0) {
+        m_modifiers = reinterpret_cast<RequestModifier**>
+            (GetMemoryManager().Allocate(sizeof(RequestModifier*)*modCount JDWP_FILE_LINE));
+        memset(m_modifiers, 0, sizeof(RequestModifier*)*modCount);
+    }
+}
+
+AgentEventRequest::~AgentEventRequest() throw()
+{
+    for (jint i = 0; i < m_modifierCount; i++) {
+        delete m_modifiers[i];
+    }
+    if (m_modifiers != 0) {
+        GetMemoryManager().Free(m_modifiers JDWP_FILE_LINE);
+    }
+}
+
+bool AgentEventRequest::ApplyModifiers(JNIEnv *jni, EventInfo &eInfo)
+    throw(AgentException)
+{
+    for (jint i = 0; i < m_modifierCount; i++) {
+        if (!m_modifiers[i]->Apply(jni, eInfo)) {
+            return false;
+        }
+        if ((m_modifiers[i])->GetKind() == JDWP_MODIFIER_COUNT) {
+            // once the count reaches 0, the event becomes expired
+            m_isExpired = true;
+        }
+    }
+    return true;
+}
+
+jthread AgentEventRequest::GetThread() const throw()
+{
+    for (jint i = 0; i < m_modifierCount; i++) {
+        if ((m_modifiers[i])->GetKind() == JDWP_MODIFIER_THREAD_ONLY) {
+            return (reinterpret_cast<ThreadOnlyModifier*>
+                (m_modifiers[i]))->GetThread();
+        }
+    }
+    return 0;
+}
+
+FieldOnlyModifier* AgentEventRequest::GetField() const throw()
+{
+    for (jint i = 0; i < m_modifierCount; i++) {
+        if ((m_modifiers[i])->GetKind() == JDWP_MODIFIER_FIELD_ONLY) {
+            return reinterpret_cast<FieldOnlyModifier*>(m_modifiers[i]);
+        }
+    }
+    return 0;
+}
+
+LocationOnlyModifier* AgentEventRequest::GetLocation() const throw()
+{
+    for (jint i = 0; i < m_modifierCount; i++) {
+        if ((m_modifiers[i])->GetKind() == JDWP_MODIFIER_LOCATION_ONLY) {
+            return reinterpret_cast<LocationOnlyModifier*>(m_modifiers[i]);
+        }
+    }
+    return 0;
+}
+
+
+//-----------------------------------------------------------------------------
+// StepRequest
+//-----------------------------------------------------------------------------
+
+StepRequest::~StepRequest() throw()
+{
+    ControlSingleStep(false);
+    JNIEnv *jni = GetJniEnv();
+    if (m_framePopRequest != 0) {
+        GetRequestManager().DeleteRequest(jni, m_framePopRequest);
+    }
+    if (m_methodEntryRequest != 0) {
+        GetRequestManager().DeleteRequest(jni, m_methodEntryRequest);
+    }
+    jni->DeleteGlobalRef(m_thread);
+}
+
+jint StepRequest::GetCurrentLine() throw()
+{
+    jint lineNumber = -1;
+    if (m_size == JDWP_STEP_LINE) {
+        jmethodID method;
+        jlocation location;
+        jvmtiError err;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameLocation(m_thread, 0,
+            &method, &location));
+        if (err == JVMTI_ERROR_NONE && location != -1) {
+            jint cnt;
+            jvmtiLineNumberEntry* table = 0;
+            JVMTI_TRACE(err, GetJvmtiEnv()->GetLineNumberTable(method,
+                &cnt, &table));
+            JvmtiAutoFree jafTable(table);
+            if (err == JVMTI_ERROR_NONE && cnt > 0) {
+                jint i = 1;
+                while (i < cnt && location >= table[i].start_location) {
+                    i++;
+                }
+                lineNumber = table[i-1].line_number;
+            }
+        }
+    }
+    return lineNumber;
+}
+
+void StepRequest::ControlSingleStep(bool enable) throw()
+{
+    JDWP_TRACE_EVENT("control Step: "<< (enable ? "on" : "off")
+        << ", thread=" << m_thread);
+    jvmtiError err;
+    JVMTI_TRACE(err, GetJvmtiEnv()->SetEventNotificationMode(
+        (enable) ? JVMTI_ENABLE : JVMTI_DISABLE,
+        JVMTI_EVENT_SINGLE_STEP, m_thread));
+    m_isActive = enable;
+}
+
+void StepRequest::Restore() throw(AgentException) {
+    JDWP_TRACE_EVENT("Restore stepRequest: " << (m_isActive ? "on" : "off"));
+    jvmtiError err;
+    JVMTI_TRACE(err, GetJvmtiEnv()->SetEventNotificationMode(
+        (m_isActive) ? JVMTI_ENABLE : JVMTI_DISABLE,
+        JVMTI_EVENT_SINGLE_STEP, m_thread));
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+}
+
+bool StepRequest::IsClassApplicable(JNIEnv* jni, EventInfo &eInfo) throw()
+{
+    for (jint i = 0; i < m_modifierCount; i++) {
+        switch ((m_modifiers[i])->GetKind()) {
+        case JDWP_MODIFIER_CLASS_ONLY:
+        case JDWP_MODIFIER_CLASS_MATCH:
+        case JDWP_MODIFIER_CLASS_EXCLUDE:
+            if (!m_modifiers[i]->Apply(jni, eInfo)) {
+                return false;
+            }
+            break;
+        case JDWP_MODIFIER_COUNT:
+            return true;
+        default:
+            break;
+        }
+    }
+    return true;
+}
+
+void StepRequest::OnFramePop(JNIEnv *jni)
+    throw(AgentException)
+{
+    JDWP_ASSERT(m_framePopRequest != 0);
+
+    jint currentCount;
+    jvmtiError err;
+    JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameCount(m_thread, &currentCount));
+    if (err != JVMTI_ERROR_NONE) {
+        currentCount = -1;
+    }
+
+    if (m_depth == JDWP_STEP_OVER ||
+        (m_depth == JDWP_STEP_OUT && currentCount <= m_frameCount) ||
+        (m_methodEntryRequest != 0 && currentCount-1 <= m_frameCount))
+    {
+        ControlSingleStep(true);
+        if (m_methodEntryRequest != 0) {
+            GetRequestManager().DeleteRequest(jni, m_methodEntryRequest);
+            m_methodEntryRequest = 0;
+        }
+    }
+}
+
+void StepRequest::OnMethodEntry(JNIEnv *jni, EventInfo &eInfo)
+    throw(AgentException)
+{
+    JDWP_ASSERT(m_methodEntryRequest != 0);
+    JDWP_ASSERT(m_depth == JDWP_STEP_INTO);
+
+    if ((m_size == JDWP_STEP_MIN || GetCurrentLine() != -1) &&
+        IsClassApplicable(jni, eInfo))
+    {
+        ControlSingleStep(true);
+        m_methodEntryRequest->SetExpired(true);
+        m_methodEntryRequest = 0;
+    }
+}
+
+void StepRequest::Init(JNIEnv *jni, jthread thread, jint size, jint depth)
+    throw(AgentException)
+{
+    m_thread = jni->NewGlobalRef(thread);
+    if (m_thread == 0) {
+        throw OutOfMemoryException();
+    }
+    m_size = size;
+    m_depth = depth;
+
+    if (m_depth != JDWP_STEP_INTO || m_size != JDWP_STEP_MIN) {
+        jvmtiError err;
+        JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameCount(m_thread, &m_frameCount));
+        if (err != JVMTI_ERROR_NONE) {
+            m_frameCount = -1;
+        }
+        if (m_size == JDWP_STEP_LINE) {
+            m_lineNumber = GetCurrentLine();
+        }
+    }
+
+    if (m_depth == JDWP_STEP_INTO || m_frameCount > 0) {
+        // add internal FramePop event request for the thread
+        m_framePopRequest =
+            new AgentEventRequest(JDWP_EVENT_FRAME_POP, JDWP_SUSPEND_NONE, 1);
+        m_framePopRequest->AddModifier(new ThreadOnlyModifier(jni, thread), 0);
+        GetRequestManager().AddInternalRequest(jni, m_framePopRequest);
+        jvmtiError err;
+        JVMTI_TRACE(err, GetJvmtiEnv()->NotifyFramePop(m_thread, 0));
+        if (err == JVMTI_ERROR_OPAQUE_FRAME) {
+            m_isNative = true;
+        }
+    }
+
+    if (m_depth == JDWP_STEP_INTO ||
+        (m_depth == JDWP_STEP_OUT && m_frameCount > 0 && m_isNative) ||
+        (m_depth == JDWP_STEP_OVER && m_frameCount > 0 &&
+         (m_size == JDWP_STEP_MIN || m_isNative || m_lineNumber != -1)))
+    {
+        ControlSingleStep(true);
+    }
+
+    JDWP_TRACE_EVENT("step start: size=" << m_size << "(depth=" << m_depth
+        << ", frame=" << m_frameCount << ", line=" << m_lineNumber);
+}
+
+bool StepRequest::ApplyModifiers(JNIEnv *jni, EventInfo &eInfo)
+    throw(AgentException)
+{
+    JDWP_ASSERT(eInfo.thread != 0);
+
+    if (JNI_FALSE == jni->IsSameObject(eInfo.thread, m_thread)) {
+        return false;
+    }
+
+    jint currentCount = 0;
+    jvmtiError err;
+    JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameCount(m_thread, &currentCount));
+    if (err != JVMTI_ERROR_NONE) {
+        return false;
+    }
+
+    jint currentLine = 0;
+    if (m_size == JDWP_STEP_LINE) {
+        currentLine = GetCurrentLine();
+    }
+
+    if (currentCount < m_frameCount) {
+        // method exit
+    } else if (currentCount > m_frameCount) {
+        // method entry
+        if (m_depth != JDWP_STEP_INTO || !IsClassApplicable(jni, eInfo)) {
+            ControlSingleStep(false);
+            if (m_depth == JDWP_STEP_INTO) {
+                // add internal MethodEntry event request for the thread
+                m_methodEntryRequest = new AgentEventRequest(
+                    JDWP_EVENT_METHOD_ENTRY, JDWP_SUSPEND_NONE, 1);
+                m_methodEntryRequest->AddModifier(
+                    new ThreadOnlyModifier(jni, m_thread), 0);
+                GetRequestManager().AddInternalRequest(
+                    jni, m_methodEntryRequest);
+            }
+            JVMTI_TRACE(err, GetJvmtiEnv()->NotifyFramePop(m_thread, 0));
+            if (err == JVMTI_ERROR_OPAQUE_FRAME) {
+                m_isNative = true;
+            }
+            return false;
+        }
+    } else { // currentCount == m_frameCount
+        // check against line
+        if (m_size == JDWP_STEP_LINE && currentLine == m_lineNumber) {
+            return false;
+        }
+    }
+
+    if (m_size == JDWP_STEP_LINE && currentLine == -1) {
+        return false;
+    }
+
+    m_frameCount = currentCount;
+    m_lineNumber = currentLine;
+
+    JDWP_TRACE_EVENT("step: frame=" << m_frameCount << "(line=" << m_lineNumber);
+    return AgentEventRequest::ApplyModifiers(jni, eInfo);
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.h?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.h (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.h Tue Nov 28 09:49:08 2006
@@ -0,0 +1,289 @@
+/*
+ * 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 Pavel N. Vyssotski
+ * @version $Revision: 1.7.2.1 $
+ */
+
+/**
+ * @file
+ * AgentEventRequest.h
+ *
+ */
+
+#ifndef _AGENT_EVENT_REQUEST_H_
+#define _AGENT_EVENT_REQUEST_H_
+
+#include "AgentBase.h"
+#include "RequestModifier.h"
+
+namespace jdwp {
+
+    /**
+     * The class is a container for the information about a certain event 
+     * request.
+     * It includes event kind, request ID, suspend policy and event modifiers.
+     */
+    class AgentEventRequest : public AgentBase {
+
+    public:
+
+        /**
+         * A constructor.
+         *
+         * @param kind     - event kind
+         * @param suspend  - suspend policy
+         * @param modCount - number of modifiers
+         */
+        AgentEventRequest(
+            jdwpEventKind kind,
+            jdwpSuspendPolicy suspend,
+            jint modCount = 0
+        ) throw(AgentException);
+
+        /**
+         * A destructor.
+         */
+        virtual ~AgentEventRequest() throw();
+
+        /**
+         * Assigns request ID.
+         *
+         * @param id - request ID
+         */
+        void SetRequestId(RequestID id) throw() { m_requestId = id; }
+
+        /**
+         * Assigns expiration flag of the event request.
+         *
+         * @param flag - expire flag
+         */
+        void SetExpired(bool flag) throw() { m_isExpired = flag; }
+
+        /**
+         * Assigns a new modifier at the given location in the list of modifiers.
+         *
+         * @param modifier - pointer to modifier
+         * @param i        - index of place in the array of modifiers
+         */
+        virtual void AddModifier(RequestModifier* modifier, jint i) throw() {
+            JDWP_ASSERT(i < m_modifierCount);
+            m_modifiers[i] = modifier;
+        }
+
+        /**
+         * Returns request ID.
+         */
+        RequestID GetRequestId() const throw() {
+            return m_requestId;
+        }
+
+        /**
+         * Returns event kind of this request.
+         */
+        jdwpEventKind GetEventKind() const throw() {
+            return m_eventKind;
+        }
+
+        /**
+         * Returns suspend policy of this request.
+         */
+        jdwpSuspendPolicy GetSuspendPolicy() const throw() {
+            return m_suspendPolicy;
+        }
+
+        /**
+         * Returns number of modifiers of this event request.
+         */
+        jint GetModifierCount() const throw() {
+            return m_modifierCount;
+        }
+
+        /**
+         * Returns whether this event request is expired.
+         */
+        bool IsExpired() const throw() {
+            return m_isExpired;
+        }
+
+        /**
+         * Compares ID of this request with the given ID.
+         *
+         * @param id - value to compare with
+         */
+        bool operator == (const RequestID id) const {
+            return m_requestId == id;
+        }
+
+        /**
+         * Applies accompanied modifiers for filtering this event.
+         *
+         * @param jni   - the JNI interface pointer
+         * @param eInfo - event information
+         */
+        virtual bool ApplyModifiers(JNIEnv* jni, EventInfo &eInfo)
+            throw(AgentException);
+
+        /**
+         * Gets the Java thread from the corresponding ThreadOnly modifier.
+         */
+        virtual jthread GetThread() const throw();
+
+        /**
+         * Gets the FieldOnly modifier from the saved list of modifiers.
+         */
+        FieldOnlyModifier* GetField() const throw();
+
+        /**
+         * Gets the LocationOnly modifier from the saved list of modifiers.
+         */
+        LocationOnlyModifier* GetLocation() const throw();
+
+    protected:
+
+        bool m_isExpired;
+        jint m_modifierCount;
+        RequestModifier** m_modifiers;
+
+    private:
+
+        RequestID m_requestId;
+        jdwpEventKind m_eventKind;
+        jdwpSuspendPolicy m_suspendPolicy;
+
+    };
+
+    /**
+     * The class implements step event request that handles single step
+     * events generated by target VM.
+     */
+    class StepRequest : public AgentEventRequest {
+
+    public:
+
+        /**
+         * A constructor.
+         *
+         * @param suspend  - suspend policy
+         * @param modCount - number of modifiers
+         */
+        StepRequest(jdwpSuspendPolicy suspend, jint modCount)
+          throw(AgentException) :
+            AgentEventRequest(JDWP_EVENT_SINGLE_STEP, suspend, modCount),
+            m_thread(0),
+            m_size(0),
+            m_depth(0),
+            m_frameCount(0),
+            m_lineNumber(0),
+            m_isNative(false),
+            m_isActive(false),
+            m_framePopRequest(0),
+            m_methodEntryRequest(0)
+        { JDWP_ASSERT(modCount > 0); }
+
+        /**
+         * A destructor.
+         */
+        ~StepRequest() throw();
+
+        /**
+         * Handles step on frame pop event.
+         *
+         * @param jni - the JNI interface pointer
+         */
+        void OnFramePop(JNIEnv *jni) throw(AgentException);
+
+        /**
+         * Handles step on method-entry event.
+         *
+         * @param jni   - the JNI interface pointer
+         * @param eInfo - event information
+         */
+        void OnMethodEntry(JNIEnv *jni, EventInfo &eInfo)
+            throw(AgentException);
+
+        /**
+         * Initializes step event request.
+         * @param jni    - the JNI interface pointer
+         * @param thread - step thread
+         * @param size   - step size
+         * @param depth  - step depth
+         */
+        void Init(JNIEnv* jni, jthread thread, jint size, jint depth)
+            throw(AgentException);
+
+        /**
+         * Applies accompanied modifiers for filtering the given event.
+         */
+        bool ApplyModifiers(JNIEnv* jni, EventInfo &eInfo)
+            throw(AgentException);
+
+        /**
+         * Gets the associated Java thread.
+         */
+        jthread GetThread() const throw() {
+            return m_thread;
+        }
+
+        /**
+         * Restores a step request after a PopFrame process.
+         *
+         * @exception AgentException is thrown, if any error occurs.
+         */
+        void Restore() throw(AgentException);
+
+    private:
+
+        /**
+         * Gets current line of the current step location.
+         *
+         * @return Java integer (jint).
+         */
+        jint GetCurrentLine() throw();
+
+        /**
+         * Enables or disables single step event generation in the target VM.
+         *
+         * @param enable - boolean value for the step event notification mode
+         */
+        void ControlSingleStep(bool enable) throw();
+
+        /**
+         * Checks whether at least one modifier can be applied.
+         *
+         * @param jni   - the JNI interface pointer
+         * @param eInfo - event-request descriptor
+         */
+        bool IsClassApplicable(JNIEnv* jni, EventInfo &eInfo) throw();
+
+        jthread m_thread;
+        jint m_size;
+        jint m_depth;
+        jint m_frameCount;
+        jint m_lineNumber;
+        bool m_isNative;
+        bool m_isActive;
+        AgentEventRequest* m_framePopRequest;
+        AgentEventRequest* m_methodEntryRequest;
+
+    };
+
+}
+
+#endif // _AGENT_EVENT_REQUEST_H_

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentEventRequest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentException.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentException.h?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentException.h (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentException.h Tue Nov 28 09:49:08 2006
@@ -0,0 +1,231 @@
+/*
+ * 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 Pavel N. Vyssotski
+ * @version $Revision: 1.5.2.1 $
+ */
+
+/**
+ * @file
+ * AgentException.h
+ *
+ */
+
+#ifndef _AGENT_EXCEPTION_H_
+#define _AGENT_EXCEPTION_H_
+
+#include <exception>
+
+#include "jdwp.h"
+#include "jvmti.h"
+#include "jdwpTransport.h"
+
+namespace jdwp {
+
+    using namespace std;
+
+    /**
+     * The base of all agent exceptions.
+     */
+    class AgentException : public exception {
+
+    public:
+
+        /**
+         * A constructor.
+         *
+         * @param err - JDWP error code
+         */
+        AgentException(jdwpError err) throw() {
+            m_error = err;
+        }
+
+        /**
+         * A constructor.
+         *
+         * @param err - JVMTI error code
+         */
+        AgentException(jvmtiError err) throw() {
+            m_error = (jdwpError)err;
+        }
+
+        /**
+         * Returns the exception name.
+         */
+        virtual const char* what() const throw() { return "AgentException"; }
+
+        /**
+         * Returns JDWP error code.
+         */
+        jdwpError ErrCode() const throw() {
+            return m_error;
+        }
+
+    private:
+        jdwpError m_error;
+    };
+
+    /**
+     * Out of memory exception thrown in case of JVMTI failures
+     * of memory or reference allocation.
+     */
+    class OutOfMemoryException : public AgentException {
+
+    public:
+
+        /**
+         * A constructor.
+         */
+        OutOfMemoryException() throw() :
+            AgentException(JDWP_ERROR_OUT_OF_MEMORY) { }
+
+        /**
+         * Returns the given exception name.
+         */
+        const char* what() const throw() {
+            return "JDWP_ERROR_OUT_OF_MEMORY";
+        }
+    };
+
+    /**
+     * Exception caused by invalid internal state, checking or parameter 
+     * validation.
+     */
+    class InternalErrorException : public AgentException {
+
+    public:
+
+        /**
+         * A constructor.
+         */
+        InternalErrorException() throw() :
+            AgentException(JDWP_ERROR_INTERNAL) { }
+
+        /**
+         * Returns the given exception name.
+         */
+        const char* what() const throw() {
+            return "JDWP_ERROR_INTERNAL";
+        }
+    };
+
+    /**
+     * Exception thrown by unrealized method or function.
+     */
+    class NotImplementedException : public AgentException {
+
+    public:
+
+        /**
+         * A constructor.
+         */
+        NotImplementedException() throw() :
+            AgentException(JDWP_ERROR_NOT_IMPLEMENTED) { }
+
+        /**
+         * Returns the given exception name.
+         */
+        const char* what() const throw() {
+            return "JDWP_ERROR_NOT_IMPLEMENTED";
+        }
+    };
+
+    /**
+     * Exception caused by the parameter validation failure.
+     */
+    class IllegalArgumentException : public AgentException {
+
+    public:
+
+        /**
+         * A constructor.
+         */
+        IllegalArgumentException() throw() :
+            AgentException(JDWP_ERROR_ILLEGAL_ARGUMENT) { }
+
+        /**
+         * Returns the given exception name.
+         */
+        const char* what() const throw() {
+            return "JDWP_ERROR_ILLEGAL_ARGUMENT";
+        }
+    };
+
+    /**
+     * Exception caused by invalid index value or out-of-range index.
+     */
+    class InvalidIndexException : public AgentException {
+
+    public:
+
+        /**
+         * A constructor.
+         */
+        InvalidIndexException() throw() :
+            AgentException(JDWP_ERROR_INVALID_INDEX) { }
+
+        /**
+         * Returns the given exception name.
+         */
+        const char* what() const throw() {
+            return "JDWP_ERROR_INVALID_INDEX";
+        }
+    };
+
+    /**
+     * Exception caused by failures in agent-transport layer.
+     */
+    class TransportException : public AgentException {
+
+    public:
+
+        /**
+         * A constructor.
+         *
+         * @param err            - JDWP error code
+         * @param transportError - transport error code
+         */
+        TransportException(jdwpError err = JDWP_ERROR_TRANSPORT_INIT, 
+                jdwpTransportError transportError = JDWPTRANSPORT_ERROR_NONE) 
+                throw() : AgentException(err) 
+        {
+            this->m_transportError = transportError;
+        }
+
+        /**
+         * Returns transport-error code.
+         */
+        jdwpTransportError TransportErrorCode() const throw() {
+            return m_transportError;
+        }
+
+        /**
+         * Returns the given exception name.
+         */
+        const char* what() const throw() {
+            return "TransportException";
+        }
+
+    private:
+        jdwpTransportError m_transportError;
+    };
+
+}
+
+#endif // _AGENT_EXCEPTION_H_

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentException.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.cpp?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.cpp (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.cpp Tue Nov 28 09:49:08 2006
@@ -0,0 +1,87 @@
+/*
+ * 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 Pavel N. Vyssotski
+ * @version $Revision: 1.8 $
+ */
+// AgentMonitor.cpp
+
+#include "AgentMonitor.h"
+#include "jvmti.h"
+
+using namespace jdwp;
+
+AgentMonitor::AgentMonitor(const char* name) throw(AgentException) {
+    jvmtiError err;
+    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->CreateRawMonitor(name, &m_monitor));
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+}
+
+AgentMonitor::~AgentMonitor() throw(AgentException) {
+    jvmtiError err;
+    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->DestroyRawMonitor(m_monitor));
+    // check for error only in debug mode
+    JDWP_ASSERT(err==JVMTI_ERROR_NONE);
+}
+
+void AgentMonitor::Enter() const throw(AgentException) {
+    jvmtiError err;
+//    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorEnter(m_monitor));
+    err = AgentBase::GetJvmtiEnv()->RawMonitorEnter(m_monitor);
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+}
+
+void AgentMonitor::Wait(jlong timeout) const throw(AgentException) {
+    jvmtiError err;
+    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorWait(m_monitor, timeout));
+//    err = AgentBase::GetJvmtiEnv()->RawMonitorWait(m_monitor, timeout);
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+}
+
+void AgentMonitor::Notify() const throw(AgentException) {
+    jvmtiError err;
+    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorNotify(m_monitor));
+//    err = AgentBase::GetJvmtiEnv()->RawMonitorNotify(m_monitor);
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+}
+
+void AgentMonitor::NotifyAll() const throw(AgentException) {
+    jvmtiError err;
+    JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorNotifyAll(m_monitor));
+//    err = AgentBase::GetJvmtiEnv()->RawMonitorNotifyAll(m_monitor);
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+}
+
+void AgentMonitor::Exit() const throw(AgentException) {
+    jvmtiError err;
+    //JVMTI_TRACE(err, AgentBase::GetJvmtiEnv()->RawMonitorExit(m_monitor));
+    err = AgentBase::GetJvmtiEnv()->RawMonitorExit(m_monitor);
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.h?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.h (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.h Tue Nov 28 09:49:08 2006
@@ -0,0 +1,139 @@
+/*
+ * 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 Pavel N. Vyssotski
+ * @version $Revision: 1.6.2.1 $
+ */
+
+/**
+ * @file
+ * AgentMonitor.h
+ *
+ */
+
+#ifndef _AGENT_MONITOR_H_
+#define _AGENT_MONITOR_H_
+
+#include "AgentBase.h"
+#include "Log.h"
+
+#include "jvmti.h"
+
+namespace jdwp {
+
+    /**
+     * The class provides wrapping for the JVMTI raw monitor.
+     * The raw monitor ID is stored in <code>AgentMonitor</code> and safely
+     * manipulated in the <code>AgentMonitor</code> methods. The raw monitor ID is
+     * created in ctor and automatically destroyed in dtor.
+     */
+    class AgentMonitor : public AgentBase {
+
+    public:
+
+        /**
+         * Constructs the JVMTI raw monitor.
+         *
+         * @param name - monitor name
+         */
+        AgentMonitor(const char* name) throw(AgentException);
+
+        /**
+         * Destructs the JVMTI raw monitor.
+         */
+        ~AgentMonitor() throw(AgentException);
+
+        /**
+         * Locks the JVMTI raw monitor.
+         */
+        void Enter() const throw(AgentException);
+
+        /**
+         * Suspends the current thread for the given time-out.
+         *
+         * @param timeout - wait time-out
+         */
+        void Wait(jlong timeout = 0) const throw(AgentException);
+
+        /**
+         * Notifies the suspended thread waiting on the given monitor.
+         */
+        void Notify() const throw(AgentException);
+
+        /**
+         * Notifies all suspended threads waiting on the given monitor.
+         */
+        void NotifyAll() const throw(AgentException);
+
+        /**
+         * Unlocks the JVMTI raw monitor.
+         */
+        void Exit() const throw(AgentException);
+
+    private:
+        jrawMonitorID m_monitor;
+    };
+
+    /**
+     * The class provides automatic <code>AgentMonitor<code> locking/unlocking.
+     * The monitor stored in a reference is locked in the 
+     * <code>MonitorAutoLock</code> ctor and is automatically unlocked
+     * in the dtor.
+     */
+    class MonitorAutoLock : public AgentBase {
+
+    public:
+
+        /**
+         * The constructor locks the agent monitor.
+         *
+         * @param monitor - agent monitor
+         */
+        MonitorAutoLock(AgentMonitor &monitor
+            JDWP_FILE_LINE_PAR) : m_lock(monitor) JDWP_FILE_LINE_INI {
+            JDWP_TRACE_EX(LOG_KIND_MON, m_file, m_line, "Enter: " << &m_lock);
+            m_lock.Enter();
+        }
+
+        /**
+         * The constructor locks the agent monitor.
+         *
+         * @param monitor - agent monitor
+         */
+        MonitorAutoLock(AgentMonitor *monitor
+            JDWP_FILE_LINE_PAR) : m_lock(*monitor) JDWP_FILE_LINE_INI {
+            JDWP_TRACE_EX(LOG_KIND_MON, m_file, m_line, "Enter: " << &m_lock);
+            m_lock.Enter();
+        }
+
+        /**
+         * The destructor unlocks the agent monitor.
+         */
+        ~MonitorAutoLock() {
+            JDWP_TRACE_EX(LOG_KIND_MON, m_file, m_line, "Exit : " << &m_lock);
+            m_lock.Exit();
+        }
+
+    private:
+        JDWP_FILE_LINE_DECL;
+        AgentMonitor &m_lock;
+    };
+}
+
+#endif // _AGENT_MONITOR_H_

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/AgentMonitor.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.cpp?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.cpp (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.cpp Tue Nov 28 09:49:08 2006
@@ -0,0 +1,352 @@
+/*
+ * 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 Pavel N. Vyssotski
+ * @version $Revision: 1.13 $
+ */
+// ClassManager.cpp
+
+#include "jni.h"
+
+#include "ClassManager.h"
+#include "Log.h"
+
+using namespace jdwp;
+
+ClassManager::ClassManager() throw()
+{
+    m_classClass = 0;
+    m_threadClass = 0;
+    m_threadGroupClass = 0;
+    m_stringClass = 0;
+    m_classLoaderClass = 0;
+    m_OOMEClass = 0;
+    m_systemClass = 0;
+}
+
+void ClassManager::Init(JNIEnv *jni) throw(AgentException)
+{
+    JDWP_TRACE_ENTRY("Init(" << jni << ')');
+    
+    m_stringClass = jni->FindClass("java/lang/String");
+    if (m_stringClass == 0) {
+        JDWP_INFO("Class not found: java.lang.String");
+        throw InternalErrorException();
+    }
+    m_stringClass = static_cast<jclass>(jni->NewGlobalRef(m_stringClass));
+
+    m_classClass = jni->FindClass("java/lang/Class");
+    if (m_classClass == 0) {
+        JDWP_INFO("Class not found: java.lang.Class");
+        throw InternalErrorException();
+    }
+    m_classClass = static_cast<jclass>(jni->NewGlobalRef(m_classClass));
+
+    m_threadClass = jni->FindClass("java/lang/Thread");
+    if (m_threadClass == 0) {
+        JDWP_INFO("Class not found: java.lang.Thread");
+        throw InternalErrorException();
+    }
+    m_threadClass = static_cast<jclass>(jni->NewGlobalRef(m_threadClass));
+
+    m_threadGroupClass = jni->FindClass("java/lang/ThreadGroup");
+    if (m_threadGroupClass == 0) {
+        JDWP_INFO("Class not found: java.lang.ThreadGroup");
+        throw InternalErrorException();
+    }
+    m_threadGroupClass =
+        static_cast<jclass>(jni->NewGlobalRef(m_threadGroupClass));
+
+    m_classLoaderClass = jni->FindClass("java/lang/ClassLoader");
+    if (m_classLoaderClass== 0) {
+        JDWP_INFO("Class not found: java.lang.ClassLoader");
+        throw InternalErrorException();
+    }
+    m_classLoaderClass =
+        static_cast<jclass>(jni->NewGlobalRef(m_classLoaderClass));
+
+    m_OOMEClass = jni->FindClass("java/lang/OutOfMemoryError");
+    if (m_OOMEClass == 0) {
+        JDWP_INFO("Class not found: java.lang.OutOfMemoryError");
+        throw InternalErrorException();
+    }
+    m_OOMEClass = static_cast<jclass>(jni->NewGlobalRef(m_OOMEClass));
+
+    m_systemClass = jni->FindClass("java/lang/System");
+    if (m_systemClass == 0) {
+        JDWP_INFO("Class not found: java.lang.System");
+        throw InternalErrorException();
+    }
+    m_systemClass = static_cast<jclass>(jni->NewGlobalRef(m_systemClass));
+}
+
+void ClassManager::Clean(JNIEnv *jni) throw()
+{
+    JDWP_TRACE_ENTRY("Clean(" << jni << ')');
+
+    if (m_classClass != 0)
+        jni->DeleteGlobalRef(m_classClass);
+    if (m_threadClass != 0)
+        jni->DeleteGlobalRef(m_threadClass);
+    if (m_threadGroupClass != 0)
+        jni->DeleteGlobalRef(m_threadGroupClass);
+    if (m_stringClass != 0)
+        jni->DeleteGlobalRef(m_stringClass);
+    if (m_classLoaderClass != 0)
+        jni->DeleteGlobalRef(m_classLoaderClass);
+    if (m_OOMEClass != 0)
+        jni->DeleteGlobalRef(m_OOMEClass);
+    if (m_systemClass != 0)
+        jni->DeleteGlobalRef(m_systemClass);
+}
+
+void ClassManager::CheckOnException(JNIEnv *jni) const throw(AgentException)
+{
+    jthrowable exception = jni->ExceptionOccurred();
+    if (exception != 0) {
+        jni->ExceptionClear();
+        if (jni->IsInstanceOf(exception, m_OOMEClass) == JNI_TRUE) {
+            throw OutOfMemoryException();
+        } else {
+            throw InternalErrorException();
+        }
+    }
+}
+
+// returnValue must be freed via GetMemoryManager().Free()
+// returnValue = 0, if there is no property with that name
+char* ClassManager::GetProperty(JNIEnv *jni, const char *str) const
+    throw(AgentException)
+{
+    jmethodID mid = jni->GetStaticMethodID(m_systemClass,
+        "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
+    if (mid == 0) {
+        JDWP_INFO("Method not found: java.lang.System.getProperty(String)");
+        throw InternalErrorException();
+    }
+
+    jstring key = jni->NewStringUTF(str);
+    CheckOnException(jni);
+
+    jstring value = static_cast<jstring>
+        (jni->CallStaticObjectMethod(m_systemClass, mid, key));
+    CheckOnException(jni);
+
+    char *returnValue = 0;
+    if (value != 0) {
+        jsize len = jni->GetStringUTFLength(value);
+        returnValue = reinterpret_cast<char*>
+            (AgentBase::GetMemoryManager().Allocate(len + 1 JDWP_FILE_LINE));
+        jni->GetStringUTFRegion(value, 0, jni->GetStringLength(value),
+            returnValue);
+    }
+
+    return returnValue;
+}
+
+// returnValue must be freed via GetMemoryManager().Free()
+char* ClassManager::GetClassName(const char *signature) const throw(AgentException)
+{
+    if (signature == 0)
+        return 0;
+
+    const size_t len = strlen(signature);
+    char *returnValue = reinterpret_cast<char*>
+        (AgentBase::GetMemoryManager().Allocate(len + 1 JDWP_FILE_LINE));
+
+    bool arrayFlag = (signature[0] == '[');
+    size_t j = 0;
+    for (size_t i = 0; i < len; i++) {
+        char c = signature[i];
+        if (c == '/') {
+             returnValue[j++] = '.';
+        } else if (c == 'L') {
+             if (arrayFlag) {
+                 returnValue[j++] = c;
+             }
+        } else if (c == ';') {
+             if (arrayFlag) {
+                 returnValue[j++] = c;
+             }
+             break;
+        } else {
+             returnValue[j++] = c;
+        }
+    }
+    returnValue[j] = '\0';
+
+    return returnValue;
+}
+
+jclass ClassManager::GetClassForName(JNIEnv *jni,
+    const char *name, jobject loader) const throw(AgentException)
+{
+    JDWP_TRACE_ENTRY("GetClassForName(" << jni << ',' << name << ',' << loader << ')');
+
+    jmethodID mid = jni->GetStaticMethodID(m_classClass, "forName",
+        "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;");
+    CheckOnException(jni);
+    if (mid == 0) {
+        JDWP_INFO("Method not found: java.lang.Class.forName(String,boolean,ClassLoader)");
+        throw InternalErrorException();
+    }
+
+    jstring clsName = jni->NewStringUTF(name);
+    CheckOnException(jni);
+
+    jclass cls = static_cast<jclass>
+        (jni->CallStaticObjectMethod(m_classClass, mid, clsName, JNI_TRUE, loader));
+    CheckOnException(jni);
+
+    return cls;
+}
+
+jboolean ClassManager::IsArray(JNIEnv *jni, jobject object) const
+    throw(AgentException)
+{
+    jboolean isArray;
+    jclass cls = jni->GetObjectClass(object);
+    jvmtiError err;
+    JVMTI_TRACE(err, GetJvmtiEnv()->IsArrayClass(cls, &isArray));
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+    return isArray;
+}
+
+jdwpTag ClassManager::GetJdwpTag(JNIEnv *jni, jobject object) const
+    throw(AgentException)
+{
+    if (object == 0) {
+        return JDWP_TAG_OBJECT;
+    } else if (IsString(jni, object) == JNI_TRUE) {
+        return JDWP_TAG_STRING;
+    } else if (IsThread(jni, object) == JNI_TRUE) {
+        return JDWP_TAG_THREAD;
+    } else if (IsThreadGroup(jni, object) == JNI_TRUE) {
+        return JDWP_TAG_THREAD_GROUP;
+    } else if (IsClassLoader(jni, object) == JNI_TRUE) {
+        return JDWP_TAG_CLASS_LOADER;
+    } else if (IsClass(jni, object) == JNI_TRUE) {
+        return JDWP_TAG_CLASS_OBJECT;
+    } else if (IsArray(jni, object) == JNI_TRUE) {
+        return JDWP_TAG_ARRAY;
+    } else {
+        return JDWP_TAG_OBJECT;
+    }
+}
+
+jdwpTag ClassManager::GetJdwpTagFromSignature(const char* signature) const
+throw ()
+{
+    switch ( signature[0] ) {
+        case 'Z': return JDWP_TAG_BOOLEAN;
+        case 'B': return JDWP_TAG_BYTE;
+        case 'C': return JDWP_TAG_CHAR;
+        case 'S': return JDWP_TAG_SHORT;
+        case 'I': return JDWP_TAG_INT;
+        case 'J': return JDWP_TAG_LONG;
+        case 'F': return JDWP_TAG_FLOAT;
+        case 'D': return JDWP_TAG_DOUBLE;
+        case 'L': return JDWP_TAG_OBJECT;
+        case '[': return JDWP_TAG_ARRAY;
+    }
+    return JDWP_TAG_NONE;
+} // GetJdwpTagFromSignature() 
+
+jboolean ClassManager::IsArrayType(jclass klass) const
+    throw(AgentException)
+{
+    jboolean flag;
+    jvmtiError err;
+    JVMTI_TRACE(err, GetJvmtiEnv()->IsArrayClass(klass, &flag));
+
+    if (err != JVMTI_ERROR_NONE)
+        throw AgentException(err);
+
+    return flag;
+}
+
+jboolean ClassManager::IsInterfaceType(jclass klass) const
+    throw(AgentException)
+{
+    jboolean flag;
+    jvmtiError err;
+    JVMTI_TRACE(err, GetJvmtiEnv()->IsInterface(klass, &flag));
+
+    if (err != JVMTI_ERROR_NONE)
+        throw AgentException(err);
+
+    return flag;
+}
+
+jdwpTypeTag ClassManager::GetJdwpTypeTag(jclass klass) const
+    throw (AgentException)
+{
+    if ( IsInterfaceType(klass) == JNI_TRUE )
+        return JDWP_TYPE_TAG_INTERFACE;
+
+    else if ( IsArrayType(klass) )
+        return JDWP_TYPE_TAG_ARRAY;
+
+    return JDWP_TYPE_TAG_CLASS;
+}
+
+jboolean ClassManager::IsObjectValueFitsFieldType
+    (JNIEnv *jni, jobject objectValue, const char* fieldSignature) const 
+    throw(AgentException)
+{
+    if ( objectValue == 0 ) {
+        return true;
+    }
+
+    jint classCount = 0;
+    jclass* classes = 0;
+
+    jvmtiEnv* jvmti = AgentBase::GetJvmtiEnv();
+
+    jvmtiError err;
+    JVMTI_TRACE(err, jvmti->GetLoadedClasses(&classCount, &classes));
+    JvmtiAutoFree classesAutoFree(classes);
+
+    if (err != JVMTI_ERROR_NONE) {
+        throw AgentException(err);
+    }
+
+    int i;
+    jclass fieldTypeClass = 0;
+    for (i = 0; i < classCount; i++) {
+        char* classSignature = 0;
+
+        JVMTI_TRACE(err, jvmti->GetClassSignature(classes[i], &classSignature, 0));
+        JvmtiAutoFree classSignatureAutoFree(classSignature);
+
+        if (err != JVMTI_ERROR_NONE) {
+            throw AgentException(err);
+        }
+
+        if ( strcmp(fieldSignature, classSignature) == 0 ) {
+            fieldTypeClass = classes[i];
+            break;
+        }
+    }
+    if ( fieldTypeClass == 0 ) {
+        throw AgentException(JDWP_ERROR_INVALID_FIELDID);
+    }
+    return  jni->IsInstanceOf(objectValue, fieldTypeClass);
+}

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.h?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.h (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.h Tue Nov 28 09:49:08 2006
@@ -0,0 +1,352 @@
+/*
+ * 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 Pavel N. Vyssotski
+ * @version $Revision: 1.10.2.1 $
+ */
+
+/**
+ * @file
+ * ClassManager.h
+ *
+ * Provides access to certain standard Java classes.
+ */
+
+#ifndef _CLASS_MANAGER_H_
+#define _CLASS_MANAGER_H_
+
+#include "AgentBase.h"
+
+namespace jdwp {
+
+    /**
+     * The class provides access to certain standard Java classes.
+     */
+    class ClassManager : public AgentBase {
+
+    public:
+
+        /**
+         * A constructor.
+         */
+        ClassManager() throw();
+
+        /**
+         * A destructor.
+         */
+        ~ClassManager() throw() {}
+
+        /**
+         * Initializes the class manager.
+         * Creates instances of the standard java classes: 
+         * <code>java.lang.String</code>, <code>java.lang.Class</code>,
+         * <code>java.lang.Thread</code>, <code>java.lang.ThreadGroup</code>,
+         * <code>java.lang.ClassLoader</code>, <code>java.lang.OutOfMemoryError</code> 
+         * and <code>java.lang.System</code>.
+         *
+         * @param jni - the JNI interface pointer
+         */
+        void Init(JNIEnv *jni) throw(AgentException);
+
+        /**
+         * Cleanups the class manager.
+         *
+         * @param jni - the JNI interface pointer
+         */
+        void Clean(JNIEnv *jni) throw();
+
+        /**
+         * Resets the class manager.
+         *
+         * @param jni - the JNI interface pointer
+         */
+        void Reset(JNIEnv *jni) throw() { }
+
+        /**
+         * Gets an instance of the <code>java.lang.Class</code> class.
+         *
+         * @return Returns  the <code>java.lang.Class</code> jclass.
+         */
+        jclass GetClassClass() const throw() {
+            return m_classClass;
+        }
+
+        /**
+         * Gets an instance of the <code>java.lang.Thread</code> class.
+         *
+         * @return Returns the <code>java.lang.Thread</code> jclass.
+         */
+        jclass GetThreadClass() const throw() {
+            return m_threadClass;
+        }
+
+        /**
+         * Gets an instance of the <code>java.lang.ThreadGroup</code> class.
+         *
+         * @return Returns the <code>java.lang.ThreadGroup</code> jclass.
+         */
+        jclass GetThreadGroupClass() const throw() {
+            return m_threadGroupClass;
+        }
+
+        /**
+         * Gets an instance of the <code>java.lang.String</code> class.
+         *
+         * @return Returns the <code>java.lang.String</code> jclass.
+         */
+        jclass GetStringClass() const throw() {
+            return m_stringClass;
+        }
+
+        /**
+         * Gets an instance of  the <code>java.lang.ClassLoader</code> class.
+         * 
+         * @return Returns the <code>java.lang.ClassLoader</code> jclass.
+         */
+        jclass GetClassLoaderClass() const throw() {
+            return m_classLoaderClass;
+        }
+
+        /**
+         * Gets an instance of the <code>java.lang.OutOfMemoryError</code> class.
+         *
+         * @return Returns the <code>java.lang.OutOfMemoryError</code> jclass.
+         */
+        jclass GetOOMEClass() const throw() {
+            return m_OOMEClass;
+        }
+
+        /**
+         * Gets an instance of the <code>java.lang.System</code> class.
+         *
+         * @return Returns the <code>java.lang.System</code> jclass.
+         */
+        jclass GetSystemClass() const throw() {
+            return m_systemClass;
+        }
+
+        /**
+         * Checks whether an exception has occurred in the target VM
+         * and whether VM has translated it to <code>AgentException</code>.
+         *
+         * @param jni - the JNI interface pointer
+         */
+        void CheckOnException(JNIEnv *jni) const throw(AgentException);
+
+        /**
+         * Returns system property from the Java class <code>java.lang.System</code> 
+         * using the <code>getProperty</code> method.
+         *
+         * @param jni - the JNI interface pointer
+         * @param str - the name of the property.
+         *
+         * Free the returned value via <code>GetMemoryManager().Free().</code>
+         * If no property exists with that name, the returned value is 0.
+         *
+         * @return Returns - the Java system property.
+         */
+        char* GetProperty(JNIEnv *jni, const char *str) const
+            throw(AgentException);
+
+        /**
+         * Returns the class name corresponding to the given signature.
+         *
+         * @param signature - the class signature.
+         *
+         * Free the returned value via <code>GetMemoryManager().Free().</code>
+         *
+         * @return Returns the class name corresponding to the given signature.
+         */
+        char* GetClassName(const char *signature) const throw(AgentException);
+
+        /**
+         * Gets the Java class corresponding to the given name.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param name   - the class name
+         * @param loader - the class loader
+         *
+         * @return Returns the Java class for the given name.
+         */
+        jclass GetClassForName(JNIEnv *jni, const char *name, jobject loader) const
+            throw(AgentException);
+
+        /**
+         * Checks whether the given object is the instance of the 
+         * <code>java.lang.Class</code> class.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param object - the Java object
+         *
+         * @return <code>TRUE</code> if the object is the instance of 
+         *         <code>java.lang.Class</code>, otherwise <code>FALSE</code>.
+         */
+        jboolean IsClass(JNIEnv *jni, jobject object) const throw() {
+            return jni->IsInstanceOf(object, m_classClass);
+        }
+
+        /**
+         * Checks whether the given object is the instance of the 
+         * <code>java.lang.Thread</code> class.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param object - the Java object
+         *
+         * @return <code>TRUE</code> if the object is the instance of 
+         *         <code>java.lang.Thread</code>, otherwise <code>FALSE</code>.
+         */
+        jboolean IsThread(JNIEnv *jni, jobject object) const throw() {
+            return jni->IsInstanceOf(object, m_threadClass);
+        }
+
+        /**
+         * Checks whether the given object is the instance of the 
+         * <code>java.lang.ThreadGroup</code> class.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param object - the Java object
+         *
+         * @return <code>TRUE</code> if the object is the instance of 
+         *         <code>java.lang.ThreadGroup</code>, otherwise <code>FALSE</code>.
+         */
+        jboolean IsThreadGroup(JNIEnv *jni, jobject object) const throw() {
+            return jni->IsInstanceOf(object, m_threadGroupClass);
+        }
+
+        /**
+         * Checks whether the given object is the instance of the 
+         * <code>java.lang.String</code> class.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param object - the Java object
+         *
+         * @return <code>TRUE</code> if the object is the instance of 
+         *         <code>java.lang.String</code>, otherwise <code>FALSE</code>.
+         */
+        jboolean IsString(JNIEnv *jni, jobject object) const throw() {
+            return jni->IsInstanceOf(object, m_stringClass);
+        }
+
+        /**
+         * Checks whether the given object is the instance of the 
+         * <code>java.lang.ClassLoader</code> class.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param object - the Java object
+         *
+         * @return <code>TRUE<code> if the object is the instance of 
+         *         <code>java.lang.ClassLoader</code>, otherwise <code>FALSE</code>.
+         */
+        jboolean IsClassLoader(JNIEnv *jni, jobject object) const throw() {
+            return jni->IsInstanceOf(object, m_classLoaderClass);
+        }
+
+        /**
+         * Checks whether the given object is the Java array.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param object - the Java object
+         *
+         * @return <code>TRUE</code> if the object is the array, 
+         *         otherwise <code>FALSE</code>.
+         */
+        jboolean IsArray(JNIEnv *jni, jobject object) const
+            throw(AgentException);
+
+        /**
+         * Gets the JDWP tag of the given Java object.
+         *
+         * @param jni    - the JNI interface pointer
+         * @param object - the Java object
+         *
+         * @return Returns the JDWP tag of the Java object.
+         */
+        jdwpTag GetJdwpTag(JNIEnv *jni, jobject object) const
+            throw(AgentException);
+
+        /** 
+         * Gets jdwpTag indicated by the specified signature.
+         *
+         * @param signature - the JNI-style signature for a certain component
+         *                    encoding the type information according to the 
+         *                    JNI documentation
+         *
+         * @return Returns the JDWP tag corresponding to the passed signature,
+         *         such as JDWP_TAG_BYTE, JDWP_TAG_OBJECT and so on, or 
+         *         JDWP_TAG_NONE, if the passed signature is incorrect.
+         */
+        jdwpTag GetJdwpTagFromSignature(const char* signature) const throw();
+
+        /**
+         * Checks whether the given class is the Java array.
+         *
+         * @param klass - the Java class
+         *
+         * @return <code>TRUE</code> if the given class is the array, 
+         *         otherwise <code>FALSE</code>.
+         */
+        jboolean IsArrayType(jclass klass) const throw(AgentException);
+
+        /**
+         * Checks whether the given class is the Java interface.
+         *
+         * @param klass - the Java class
+         *
+         * @return <code>TRUE</code> if the given class is the interface, 
+         *         otherwise <code>FALSE</code>.
+         */
+        jboolean IsInterfaceType(jclass klass) const throw(AgentException);
+
+        /**
+         * Gets the JDWP type tag of the given Java class.
+         *
+         * @param klass - the Java class
+         *
+         * @return Returns the JDWP type tag of the Java class.
+         */
+        jdwpTypeTag GetJdwpTypeTag(jclass klass) const
+            throw (AgentException);
+
+        /**
+         * Checks the given object value.
+         *
+         * @param jni            - the JNI interface pointer
+         * @param objectValue    - the Java object
+         * @param fieldSignature - the signature of the field type
+         *
+         * @return <code>TRUE</code> if the given value fits the field type.
+         */
+        jboolean IsObjectValueFitsFieldType(JNIEnv *jni, jobject objectValue, const char* fieldSignature)
+            const throw(AgentException);
+
+    private:
+
+        jclass m_classClass;
+        jclass m_threadClass;
+        jclass m_threadGroupClass;
+        jclass m_stringClass;
+        jclass m_classLoaderClass;
+        jclass m_OOMEClass;
+        jclass m_systemClass;
+
+    };
+
+}
+
+#endif // _CLASS_MANAGER_H_

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/ClassManager.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/CommandDispatcher.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/CommandDispatcher.cpp?view=auto&rev=480141
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/CommandDispatcher.cpp (added)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/CommandDispatcher.cpp Tue Nov 28 09:49:08 2006
@@ -0,0 +1,807 @@
+/*
+ * 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.15 $
+ */
+#include "CommandDispatcher.h"
+#include "PacketParser.h"
+#include "TransportManager.h"
+
+#include "CommandHandler.h"
+
+#include "EventRequest.h"
+#include "Method.h"
+#include "ObjectReference.h"
+#include "ReferenceType.h"
+#include "ThreadGroupReference.h"
+#include "ThreadReference.h"
+#include "ThreadGroupReference.h"
+#include "ArrayReference.h"
+#include "EventRequest.h"
+#include "ClassType.h"
+#include "StringReference.h"
+#include "VirtualMachine.h"
+#include "ArrayType.h"
+#include "ClassLoaderReference.h"
+#include "ClassObjectReference.h"
+#include "StackFrame.h"
+
+using namespace jdwp;
+
+//-----------------------------------------------------------------------------
+void removeSynchronousHandler(CommandHandler *handler)
+{
+//    JDWP_TRACE_ENTRY("removeSynchronousHandler(" << handler << ')');
+
+    if (handler == 0)
+        return;
+
+    if (handler->IsSynchronous())
+    {
+#ifndef NDEBUG
+        if (JDWP_TRACE_ENABLED(LOG_KIND_CMD)) {
+            jdwpCommandSet cmdSet = handler->GetCommandParser()->command.GetCommandSet();
+            jdwpCommand cmdKind = handler->GetCommandParser()->command.GetCommand();
+            JDWP_TRACE_CMD("Remove handler: "
+                << CommandDispatcher::GetCommandSetName(cmdSet) << "/"
+                << CommandDispatcher::GetCommandName(cmdSet, cmdKind)
+                << "[" << cmdSet << "/" << cmdKind << "]");
+        }
+#endif
+        delete handler;
+    }
+}
+//-----------------------------------------------------------------------------
+
+void CommandDispatcher::ExecCommand(JNIEnv* jni, CommandParser *cmdParser)
+    throw (AgentException)
+{
+    JDWP_TRACE_ENTRY("ExecCommand(" << jni << ',' << cmdParser << ')');
+
+    CommandHandler *handler = 0;
+    bool isSynchronous = false;
+    jdwpError err = JDWP_ERROR_NONE;
+
+    jdwpCommandSet cmdSet = cmdParser->command.GetCommandSet();
+    jdwpCommand cmdKind = cmdParser->command.GetCommand();
+
+    try
+    {
+        if (IsDead())
+            throw AgentException(JDWP_ERROR_VM_DEAD);
+
+        JDWP_TRACE_CMD("Create handler: "
+            << GetCommandSetName(cmdSet) << "/"
+            << GetCommandName(cmdSet, cmdKind)
+            << "[" << cmdSet << "/" << cmdKind << "]");
+        handler = CreateCommandHandler(cmdSet, cmdKind);
+        isSynchronous = handler->IsSynchronous();
+
+        handler->Run(jni, cmdParser);
+    }
+    catch (const TransportException &e)
+    {
+        if (isSynchronous) {
+            removeSynchronousHandler(handler);
+        }
+        throw e;
+    }
+    catch (const AgentException &e)
+    {
+        if (isSynchronous) {
+            removeSynchronousHandler(handler);
+        }
+        err = e.ErrCode();
+        cmdParser->reply.SetError(err);
+    }
+    
+    if (isSynchronous) {
+        removeSynchronousHandler(handler);
+    }
+
+    if (err != JDWP_ERROR_NONE)
+        cmdParser->WriteReply(jni);
+
+    //when command is executed asynchronously,
+    //memory is released by AsyncCommandHandler::StartExecution()
+}
+
+//-----------------------------------------------------------------------------
+
+CommandHandler*
+CommandDispatcher::CreateCommandHandler(jdwpCommandSet cmdSet, jdwpCommand cmdKind)
+    throw (NotImplementedException, OutOfMemoryException)
+{
+    JDWP_TRACE_ENTRY("CreateCommandHandler(" << cmdSet << ',' << cmdKind << ')');
+
+    switch (cmdSet)
+    {
+    //JDWP_COMMAND_SET_VIRTUAL_MACHINE-------------------------------------
+    case JDWP_COMMAND_SET_VIRTUAL_MACHINE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_VM_VERSION :
+            return new VirtualMachine::VersionHandler();
+
+        case JDWP_COMMAND_VM_CLASSES_BY_SIGNATURE:
+            return new VirtualMachine::ClassesBySignatureHandler();
+
+        case JDWP_COMMAND_VM_ALL_CLASSES :
+            return new VirtualMachine::AllClassesHandler();
+
+        case JDWP_COMMAND_VM_ALL_THREADS:
+            return new VirtualMachine::AllThreadsHandler();
+
+        case JDWP_COMMAND_VM_TOP_LEVEL_THREAD_GROUPS:
+            return new VirtualMachine::TopLevelThreadGroupsHandler();
+
+        case JDWP_COMMAND_VM_DISPOSE:
+            return new VirtualMachine::DisposeHandler();
+        
+        case JDWP_COMMAND_VM_ID_SIZES:
+            return new VirtualMachine::IDSizesHandler();
+
+        case JDWP_COMMAND_VM_SUSPEND:
+            return new VirtualMachine::SuspendHandler();
+
+        case JDWP_COMMAND_VM_RESUME:
+            return new VirtualMachine::ResumeHandler();
+
+        case JDWP_COMMAND_VM_EXIT:
+            return new VirtualMachine::ExitHandler();
+
+        case JDWP_COMMAND_VM_CREATE_STRING:
+            return new VirtualMachine::CreateStringHandler();
+
+        case JDWP_COMMAND_VM_CAPABILITIES:
+            return new VirtualMachine::CapabilitiesHandler();
+
+        case JDWP_COMMAND_VM_CLASS_PATHS:
+            return new VirtualMachine::ClassPathsHandler();
+
+        case JDWP_COMMAND_VM_DISPOSE_OBJECTS:
+            return new VirtualMachine::DisposeObjectsHandler();
+
+        case JDWP_COMMAND_VM_HOLD_EVENTS:
+            return new VirtualMachine::HoldEventsHandler();
+
+        case JDWP_COMMAND_VM_RELEASE_EVENTS:
+            return new VirtualMachine::ReleaseEventsHandler();
+
+        case JDWP_COMMAND_VM_CAPABILITIES_NEW:
+            return new VirtualMachine::CapabilitiesNewHandler();
+
+        case JDWP_COMMAND_VM_REDEFINE_CLASSES:
+            return new VirtualMachine::RedefineClassesHandler();
+
+        case JDWP_COMMAND_VM_SET_DEFAULT_STRATUM:
+            return new VirtualMachine::SetDefaultStratumHandler();
+
+        case JDWP_COMMAND_VM_ALL_CLASSES_WITH_GENERIC:
+            return new VirtualMachine::AllClassesWithGenericHandler();
+
+        }//JDWP_COMMAND_SET_VIRTUAL_MACHINE
+        break;
+
+    //JDWP_COMMAND_SET_REFERENCE_TYPE--------------------------------------
+    case JDWP_COMMAND_SET_REFERENCE_TYPE:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_RT_SIGNATURE:
+            return new ReferenceType::SignatureHandler();
+
+        case JDWP_COMMAND_RT_CLASS_LOADER:
+            return new ReferenceType::ClassLoaderHandler();
+
+        case JDWP_COMMAND_RT_MODIFIERS:
+            return new ReferenceType::ModifiersHandler();
+
+        case JDWP_COMMAND_RT_FIELDS:
+            return new ReferenceType::FieldsHandler();
+
+        case JDWP_COMMAND_RT_METHODS:
+            return new ReferenceType::MethodsHandler();
+
+        case JDWP_COMMAND_RT_GET_VALUES:
+            return new ReferenceType::GetValuesHandler();
+
+        case JDWP_COMMAND_RT_SOURCE_FILE:
+            return new ReferenceType::SourceFileHandler();
+
+        case JDWP_COMMAND_RT_NESTED_TYPES:
+            return new ReferenceType::NestedTypesHandler();
+
+        case JDWP_COMMAND_RT_STATUS:
+            return new ReferenceType::StatusHandler();
+
+        case JDWP_COMMAND_RT_INTERFACES:
+            return new ReferenceType::InterfacesHandler();
+
+        case JDWP_COMMAND_RT_CLASS_OBJECT:
+            return new ReferenceType::ClassObjectHandler();
+
+        case JDWP_COMMAND_RT_SOURCE_DEBUG_EXTENSION:
+            return new ReferenceType::SourceDebugExtensionHandler();
+
+        case JDWP_COMMAND_RT_SIGNATURE_WITH_GENERIC:
+            return new ReferenceType::SignatureWithGenericHandler();
+
+        case JDWP_COMMAND_RT_FIELDS_WITH_GENERIC:
+            return new ReferenceType::FieldsWithGenericHandler();
+
+        case JDWP_COMMAND_RT_METHODS_WITH_GENERIC:
+            return new ReferenceType::MethodsWithGenericHandler();
+        }//JDWP_COMMAND_SET_REFERENCE_TYPE
+        break;
+
+    //JDWP_COMMAND_SET_METHOD----------------------------------------------
+    case JDWP_COMMAND_SET_METHOD:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_M_LINE_TABLE:
+            return new Method::LineTableHandler();
+        case JDWP_COMMAND_M_VARIABLE_TABLE:
+            return new Method::VariableTableHandler();
+        case JDWP_COMMAND_M_BYTECODES:
+            return new Method::BytecodesHandler();
+        case JDWP_COMMAND_M_OBSOLETE:
+            return new Method::IsObsoleteHandler();
+        case JDWP_COMMAND_M_VARIABLE_TABLE_WITH_GENERIC:
+            return new Method::VariableTableWithGenericHandler();
+        }
+        break;
+
+    //JDWP_COMMAND_SET_OBJECT_REFERENCE------------------------------------
+    case JDWP_COMMAND_SET_OBJECT_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_OR_REFERENCE_TYPE:
+            return new ObjectReference::ReferenceTypeHandler();
+
+        case JDWP_COMMAND_OR_GET_VALUES:
+            return new ObjectReference::GetValuesHandler();
+
+        case JDWP_COMMAND_OR_SET_VALUES:
+            return new ObjectReference::SetValuesHandler();
+
+        case JDWP_COMMAND_OR_MONITOR_INFO:
+            return new ObjectReference::MonitorInfoHandler();
+
+        case JDWP_COMMAND_OR_INVOKE_METHOD:
+            return new ObjectReference::InvokeMethodHandler();
+
+        case JDWP_COMMAND_OR_DISABLE_COLLECTION:
+            return new ObjectReference::DisableCollectionHandler();
+
+        case JDWP_COMMAND_OR_ENABLE_COLLECTION:
+            return new ObjectReference::EnableCollectionHandler();
+
+        case JDWP_COMMAND_OR_IS_COLLECTED:
+            return new ObjectReference::IsCollectedHandler();
+
+        }
+        break;
+
+    //JDWP_COMMAND_SET_THREAD_REFERENCE------------------------------------
+    case JDWP_COMMAND_SET_THREAD_REFERENCE:
+        switch(cmdKind)
+        {
+        case JDWP_COMMAND_TR_NAME:
+            return new ThreadReference::NameHandler();
+
+        case JDWP_COMMAND_TR_SUSPEND:
+            return new ThreadReference::SuspendHandler();
+
+        case JDWP_COMMAND_TR_RESUME:
+            return new ThreadReference::ResumeHandler();
+
+        case JDWP_COMMAND_TR_STATUS:
+            return new ThreadReference::StatusHandler();
+
+        case JDWP_COMMAND_TR_THREAD_GROUP:
+            return new ThreadReference::ThreadGroupHandler();
+
+        case JDWP_COMMAND_TR_FRAMES:
+            return new ThreadReference::FramesHandler();
+
+        case JDWP_COMMAND_TR_FRAME_COUNT:
+            return new ThreadReference::FrameCountHandler();
+
+        case JDWP_COMMAND_TR_OWNED_MONITORS:
+            return new ThreadReference::OwnedMonitorsHandler();
+
+        case JDWP_COMMAND_TR_CURRENT_CONTENDED_MONITOR:
+            return new ThreadReference::CurrentContendedMonitorHandler();
+
+        case JDWP_COMMAND_TR_STOP:
+            return new ThreadReference::StopHandler();
+
+        case JDWP_COMMAND_TR_INTERRUPT:
+            return new ThreadReference::InterruptHandler();
+
+        case JDWP_COMMAND_TR_SUSPEND_COUNT:
+            return new ThreadReference::SuspendCountHandler();
+
+        }//JDWP_COMMAND_SET_THREAD_REFERENCE
+        break;
+
+    case JDWP_COMMAND_SET_THREAD_GROUP_REFERENCE:
+        switch (cmdKind)
+        {
+
+        case JDWP_COMMAND_TGR_NAME:
+            return new ThreadGroupReference::NameHandler();
+
+        case JDWP_COMMAND_TGR_PARENT:
+            return new ThreadGroupReference::ParentHandler();
+
+        case JDWP_COMMAND_TGR_CHILDREN:
+            return new ThreadGroupReference::ChildrenHandler();
+
+        }//JDWP_COMMAND_SET_THREAD_GROUP_REFERENCE
+        break;
+
+    case JDWP_COMMAND_SET_ARRAY_REFERENCE:
+        switch (cmdKind)
+        {
+
+        case JDWP_COMMAND_AR_LENGTH:
+            return new ArrayReference::LengthHandler();
+
+        case JDWP_COMMAND_AR_GET_VALUES:
+            return new ArrayReference::GetValuesHandler();
+
+        case JDWP_COMMAND_AR_SET_VALUES:
+            return new ArrayReference::SetValuesHandler();
+        }
+        break;
+
+    //JDWP_COMMAND_SET_EVENT_REQUEST---------------------------------------
+    case JDWP_COMMAND_SET_EVENT_REQUEST:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_ER_SET:
+            return new EventRequest::SetHandler();
+
+        case JDWP_COMMAND_ER_CLEAR:
+            return new EventRequest::ClearHandler();
+
+        case JDWP_COMMAND_ER_CLEAR_ALL_BREAKPOINTS:
+            return new EventRequest::ClearAllBreakpointsHandler();
+
+        }//JDWP_COMMAND_SET_EVENT_REQUEST
+        break;
+
+    //JDWP_COMMAND_SET_CLASS_TYPE--------------------------------------
+    case JDWP_COMMAND_SET_CLASS_TYPE:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_CT_SUPERCLASS:
+            return new ClassType::SuperClassHandler();
+
+        case JDWP_COMMAND_CT_SET_VALUES:
+            return new ClassType::SetValuesHandler();
+        case JDWP_COMMAND_CT_INVOKE_METHOD:
+            return new ClassType::InvokeMethodHandler();
+
+        case JDWP_COMMAND_CT_NEW_INSTANCE:
+            return new ClassType::NewInstanceHandler();
+
+        }//JDWP_COMMAND_SET_CLASS_TYPE
+        break;
+
+    //JDWP_COMMAND_SET_STRING_REFERENCE--------------------------------------
+    case JDWP_COMMAND_SET_STRING_REFERENCE:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_SR_VALUE:
+            return new StringReference::ValueHandler();
+
+        }//JDWP_COMMAND_SR_VALUE
+        break;
+
+    //JDWP_COMMAND_SET_ARRAY_TYPE--------------------------------------
+    case JDWP_COMMAND_SET_ARRAY_TYPE:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_AT_NEW_INSTANCE:
+            return new ArrayType::NewInstanceHandler();
+
+        }
+        break;
+
+    //JDWP_COMMAND_SET_CLASS_LOADER_REFERENCE--------------------------------------
+    case JDWP_COMMAND_SET_CLASS_LOADER_REFERENCE:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_CLR_VISIBLE_CLASSES:
+            return new ClassLoaderReference::VisibleClassesHandler();
+
+        }
+        break;
+
+    //JDWP_COMMAND_SET_STACK_FRAME--------------------------------------
+    case JDWP_COMMAND_SET_STACK_FRAME:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_SF_GET_VALUES:
+            return new StackFrame::GetValuesHandler();
+
+        case JDWP_COMMAND_SF_SET_VALUES:
+            return new StackFrame::SetValuesHandler();
+
+        case JDWP_COMMAND_SF_THIS_OBJECT:
+            return new StackFrame::ThisObjectHandler();
+
+        case JDWP_COMMAND_SF_POP_FRAME:
+            return new StackFrame::PopFramesHandler();
+
+        }
+        break;
+
+    //JDWP_COMMAND_SET_CLASS_OBJECT_REFERENCE--------------------------------------
+    case JDWP_COMMAND_SET_CLASS_OBJECT_REFERENCE:
+        switch(cmdKind)
+        {
+
+        case JDWP_COMMAND_COR_REFLECTED_TYPE:
+            return new ClassObjectReference::ReflectedTypeHandler();
+
+        }
+        break;
+
+    }//cmdSet
+
+    JDWP_ERROR("command not implemented "
+                        << GetCommandSetName(cmdSet) << "/"
+                        << GetCommandName(cmdSet, cmdKind)
+                        << "[" << cmdSet << "/" << cmdKind << "]");
+
+    throw NotImplementedException();
+
+    // never reached
+    return 0;
+}
+
+//-----------------------------------------------------------------------------
+
+const char*
+CommandDispatcher::GetCommandSetName(jdwpCommandSet cmdSet)
+{
+    switch (cmdSet)
+    {
+    case JDWP_COMMAND_SET_VIRTUAL_MACHINE:
+        return "VIRTUAL_MACHINE";
+    case JDWP_COMMAND_SET_REFERENCE_TYPE:
+        return "REFERENCE_TYPE";
+    case JDWP_COMMAND_SET_CLASS_TYPE:
+        return "CLASS_TYPE";
+    case JDWP_COMMAND_SET_ARRAY_TYPE:
+        return "ARRAY_TYPE";
+    case JDWP_COMMAND_SET_INTERFACE_TYPE:
+        return "INTERFACE_TYPE";
+    case JDWP_COMMAND_SET_METHOD:
+        return "METHOD";
+    case JDWP_COMMAND_SET_FIELD:
+        return "FIELD";
+    case JDWP_COMMAND_SET_OBJECT_REFERENCE:
+        return "OBJECT_REFERENCE";
+    case JDWP_COMMAND_SET_STRING_REFERENCE:
+        return "STRING_REFERENCE";
+    case JDWP_COMMAND_SET_THREAD_REFERENCE:
+        return "THREAD_REFERENCE";
+    case JDWP_COMMAND_SET_THREAD_GROUP_REFERENCE:
+        return "THREAD_GROUP_REFERENCE";
+    case JDWP_COMMAND_SET_ARRAY_REFERENCE:
+        return "ARRAY_REFERENCE";
+    case JDWP_COMMAND_SET_CLASS_LOADER_REFERENCE:
+        return "CLASS_LOADER_REFERENCE";
+    case JDWP_COMMAND_SET_EVENT_REQUEST:
+        return "EVENT_REQUEST";
+    case JDWP_COMMAND_SET_STACK_FRAME:
+        return "STACK_FRAME";
+    case JDWP_COMMAND_SET_CLASS_OBJECT_REFERENCE:
+        return "CLASS_OBJECT_REFERENCE";
+    case JDWP_COMMAND_SET_EVENT:
+        return "EVENT";
+    }//cmdSet
+
+    return "***UNKNOWN COMMAND_SET***";
+}
+
+//-----------------------------------------------------------------------------
+
+const char*
+CommandDispatcher::GetCommandName(jdwpCommandSet cmdSet, jdwpCommand cmdKind)
+{
+    switch (cmdSet)
+    {
+
+    case JDWP_COMMAND_SET_VIRTUAL_MACHINE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_VM_VERSION:
+            return "VERSION";
+        case JDWP_COMMAND_VM_CLASSES_BY_SIGNATURE:
+            return "CLASSES_BY_SIGNATURE";
+        case JDWP_COMMAND_VM_ALL_CLASSES:
+            return "ALL_CLASSES";
+        case JDWP_COMMAND_VM_ALL_THREADS:
+            return "ALL_THREADS";
+        case JDWP_COMMAND_VM_TOP_LEVEL_THREAD_GROUPS:
+            return "TOP_LEVEL_THREAD_GROUPS";
+        case JDWP_COMMAND_VM_DISPOSE:
+            return "DISPOSE";
+        case JDWP_COMMAND_VM_ID_SIZES:
+            return "ID_SIZES";
+        case JDWP_COMMAND_VM_SUSPEND:
+            return "SUSPEND";
+        case JDWP_COMMAND_VM_RESUME:
+            return "RESUME";
+        case JDWP_COMMAND_VM_EXIT:
+            return "EXIT";
+        case JDWP_COMMAND_VM_CREATE_STRING:
+            return "CREATE_STRING";
+        case JDWP_COMMAND_VM_CAPABILITIES:
+            return "CAPABILITIES";
+        case JDWP_COMMAND_VM_CLASS_PATHS:
+            return "CLASS_PATHS";
+        case JDWP_COMMAND_VM_DISPOSE_OBJECTS:
+            return "DISPOSE_OBJECTS";
+        case JDWP_COMMAND_VM_HOLD_EVENTS:
+            return "HOLD_EVENTS";
+        case JDWP_COMMAND_VM_RELEASE_EVENTS:
+            return "RELEASE_EVENTS";
+        case JDWP_COMMAND_VM_CAPABILITIES_NEW:
+            return "CAPABILITIES_NEW";
+        case JDWP_COMMAND_VM_REDEFINE_CLASSES:
+            return "REDEFINE_CLASSES";
+        case JDWP_COMMAND_VM_SET_DEFAULT_STRATUM:
+            return "SET_DEFAULT_STRATUM";
+        case JDWP_COMMAND_VM_ALL_CLASSES_WITH_GENERIC:
+            return "ALL_CLASSES_WITH_GENERIC";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_REFERENCE_TYPE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_RT_SIGNATURE:
+            return "SIGNATURE";
+        case JDWP_COMMAND_RT_CLASS_LOADER:
+            return "CLASS_LOADER";
+        case JDWP_COMMAND_RT_MODIFIERS:
+            return "MODIFIERS";
+        case JDWP_COMMAND_RT_FIELDS:
+            return "FIELDS";
+        case JDWP_COMMAND_RT_METHODS:
+            return "METHODS";
+        case JDWP_COMMAND_RT_GET_VALUES:
+            return "GET_VALUES";
+        case JDWP_COMMAND_RT_SOURCE_FILE:
+            return "SOURCE_FILE";
+        case JDWP_COMMAND_RT_NESTED_TYPES:
+            return "NESTED_TYPES";
+        case JDWP_COMMAND_RT_STATUS:
+            return "STATUS";
+        case JDWP_COMMAND_RT_INTERFACES:
+            return "INTERFACES";
+        case JDWP_COMMAND_RT_CLASS_OBJECT:
+            return "CLASS_OBJECT";
+        case JDWP_COMMAND_RT_SOURCE_DEBUG_EXTENSION:
+            return "SOURCE_DEBUG_EXTENSION";
+        case JDWP_COMMAND_RT_SIGNATURE_WITH_GENERIC:
+            return "SIGNATURE_WITH_GENERIC";
+        case JDWP_COMMAND_RT_FIELDS_WITH_GENERIC:
+            return "FIELDS_WITH_GENERIC";
+        case JDWP_COMMAND_RT_METHODS_WITH_GENERIC:
+            return "METHODS_WITH_GENERIC";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_CLASS_TYPE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_CT_SUPERCLASS:
+            return "SUPERCLASS";
+        case JDWP_COMMAND_CT_SET_VALUES:
+            return "SET_VALUES";
+        case JDWP_COMMAND_CT_INVOKE_METHOD:
+            return "INVOKE_METHOD";
+        case JDWP_COMMAND_CT_NEW_INSTANCE:
+            return "NEW_INSTANCE";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_ARRAY_TYPE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_AT_NEW_INSTANCE:
+            return "NEW_INSTANCE";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_INTERFACE_TYPE:
+        break;
+
+    case JDWP_COMMAND_SET_METHOD:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_M_LINE_TABLE:
+            return "LINE_TABLE";
+        case JDWP_COMMAND_M_VARIABLE_TABLE:
+            return "VARIABLE_TABLE";
+        case JDWP_COMMAND_M_BYTECODES:
+            return "BYTECODES";
+        case JDWP_COMMAND_M_OBSOLETE:
+            return "OBSOLETE";
+        case JDWP_COMMAND_M_VARIABLE_TABLE_WITH_GENERIC:
+            return "VARIABLE_TABLE_WITH_GENERIC";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_FIELD:
+        break;
+
+    case JDWP_COMMAND_SET_OBJECT_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_OR_REFERENCE_TYPE:
+            return "REFERENCE_TYPE";
+        case JDWP_COMMAND_OR_GET_VALUES:
+            return "GET_VALUES";
+        case JDWP_COMMAND_OR_SET_VALUES:
+            return "SET_VALUES";
+        case JDWP_COMMAND_OR_MONITOR_INFO:
+            return "MONITOR_INFO";
+        case JDWP_COMMAND_OR_INVOKE_METHOD:
+            return "INVOKE_METHOD";
+        case JDWP_COMMAND_OR_DISABLE_COLLECTION:
+            return "DISABLE_COLLECTION";
+        case JDWP_COMMAND_OR_ENABLE_COLLECTION:
+            return "ENABLE_COLLECTION";
+        case JDWP_COMMAND_OR_IS_COLLECTED:
+            return "IS_COLLECTED";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_STRING_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_SR_VALUE:
+            return "VALUE";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_THREAD_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_TR_NAME:
+            return "NAME";
+        case JDWP_COMMAND_TR_SUSPEND:
+            return "SUSPEND";
+        case JDWP_COMMAND_TR_RESUME:
+            return "RESUME";
+        case JDWP_COMMAND_TR_STATUS:
+            return "STATUS";
+        case JDWP_COMMAND_TR_THREAD_GROUP:
+            return "THREAD_GROUP";
+        case JDWP_COMMAND_TR_FRAMES:
+            return "FRAMES";
+        case JDWP_COMMAND_TR_FRAME_COUNT:
+            return "FRAME_COUNT";
+        case JDWP_COMMAND_TR_OWNED_MONITORS:
+            return "OWNED_MONITORS";
+        case JDWP_COMMAND_TR_CURRENT_CONTENDED_MONITOR:
+            return "CURRENT_CONTENDED_MONITOR";
+        case JDWP_COMMAND_TR_STOP:
+            return "STOP";
+        case JDWP_COMMAND_TR_INTERRUPT:
+            return "INTERRUPT";
+        case JDWP_COMMAND_TR_SUSPEND_COUNT:
+            return "SUSPEND_COUNT";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_THREAD_GROUP_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_TGR_NAME:
+            return "NAME";
+        case JDWP_COMMAND_TGR_PARENT:
+            return "PARENT";
+        case JDWP_COMMAND_TGR_CHILDREN:
+            return "CHILDREN";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_ARRAY_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_AR_LENGTH:
+            return "LENGTH";
+        case JDWP_COMMAND_AR_GET_VALUES:
+            return "GET_VALUES";
+        case JDWP_COMMAND_AR_SET_VALUES:
+            return "SET_VALUES";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_CLASS_LOADER_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_CLR_VISIBLE_CLASSES:
+            return "VISIBLE_CLASSES";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_EVENT_REQUEST:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_ER_SET:
+            return "SET";
+        case JDWP_COMMAND_ER_CLEAR:
+            return "CLEAR";
+        case JDWP_COMMAND_ER_CLEAR_ALL_BREAKPOINTS:
+            return "CLEAR_ALL_BREAKPOINTS";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_STACK_FRAME:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_SF_GET_VALUES:
+            return "GET_VALUES";
+        case JDWP_COMMAND_SF_SET_VALUES:
+            return "SET_VALUES";
+        case JDWP_COMMAND_SF_THIS_OBJECT:
+            return "THIS_OBJECT";
+        case JDWP_COMMAND_SF_POP_FRAME:
+            return "POP_FRAME";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_CLASS_OBJECT_REFERENCE:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_COR_REFLECTED_TYPE:
+            return "REFLECTED_TYPE";
+        }
+        break;
+
+    case JDWP_COMMAND_SET_EVENT:
+        switch (cmdKind)
+        {
+        case JDWP_COMMAND_E_COMPOSITE:
+            return "COMPOSITE";
+        }
+        break;
+    }//cmdSet
+
+    return "***UNKNOWN COMMAND***";
+}
+
+//-----------------------------------------------------------------------------

Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/CommandDispatcher.cpp
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message