harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r794726 [5/15] - in /harmony/enhanced/jdktools/branches/java6/modules/jpda: ./ src/main/native/include/ src/main/native/jdwp/common/agent/commands/ src/main/native/jdwp/common/agent/core/ src/main/native/jdwp/common/generic/ src/main/native...
Date Thu, 16 Jul 2009 15:57:41 GMT
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp Thu Jul 16 15:57:37 2009
@@ -15,17 +15,14 @@
  *  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"
+#include "ExceptionManager.h"
+
 
 using namespace jdwp;
 using namespace ThreadReference;
@@ -33,66 +30,78 @@
 //-----------------------------------------------------------------------------
 //NameHandler------------------------------------------------------------------
 
-void
-ThreadReference::NameHandler::Execute(JNIEnv *jni) throw (AgentException)
+int
+ThreadReference::NameHandler::Execute(JNIEnv *jni) 
 {
     jvmtiThreadInfo info;
     info.name = 0;
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("Name: received: threadID=" << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Name: received: threadID=%p", thrd));
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thrd, &info));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadInfo(thrd, &info));
     JvmtiAutoFree destroyer(info.name);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
-    JDWP_TRACE_DATA("Name: send: name=" << JDWP_CHECK_NULL(info.name));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Name: send: name=%s", JDWP_CHECK_NULL(info.name)));
     m_cmdParser->reply.WriteString(info.name);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //SuspendHandler----------------------------------------------------------------
 
-void
-ThreadReference::SuspendHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+ThreadReference::SuspendHandler::Execute(JNIEnv *jni) 
 {
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
 
-    JDWP_TRACE_DATA("Suspend: suspend: threadID=" << thrd);
-    GetThreadManager().Suspend(jni, thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Suspend: suspend: threadID=%p", thrd));
+    int ret = GetThreadManager().Suspend(jni, thrd);
+
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
 //ResumeHandler----------------------------------------------------------------
 
-void
-ThreadReference::ResumeHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+ThreadReference::ResumeHandler::Execute(JNIEnv *jni) 
 {
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
 
-    JDWP_TRACE_DATA("Resume: resume: threadID=" << thrd);
-    GetThreadManager().Resume(jni, thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Resume: resume: threadID=%p", thrd));
+    int ret = GetThreadManager().Resume(jni, thrd);
+
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
 //StatusHandler----------------------------------------------------------------
 
-void
-ThreadReference::StatusHandler::Execute(JNIEnv *jni) throw (AgentException)
+int
+ThreadReference::StatusHandler::Execute(JNIEnv *jni) 
 {
     jint thread_state;
 
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("Status: received: threadID=" << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Status: received: threadID=%p", thrd));
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadState(thrd, &thread_state));
-    JDWP_TRACE_DATA("Status: threadState=" << hex << thread_state);
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadState(thrd, &thread_state));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Status: threadState=%x", thread_state));
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     jint ret_value;
     jint const THREAD_STATE_SLEEPING =
@@ -101,7 +110,7 @@
     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)
+        switch (thread_state & (JVMTI_JAVA_LANG_THREAD_STATE_MASK))
         {
         case JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED:
             ret_value = JDWP_THREAD_STATUS_ZOMBIE;
@@ -117,9 +126,10 @@
             ret_value = JDWP_THREAD_STATUS_WAIT;
             break;
         default:
-            JDWP_TRACE_DATA("Status: bad Java thread state: " 
-                << hex << thread_state);
-            throw InternalErrorException();
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Status: bad Java thread state: %x", thread_state));
+            AgentException e(JDWP_ERROR_INTERNAL);
+			JDWP_SET_EXCEPTION(e);
+            return JDWP_ERROR_INTERNAL;
         }
     }
     m_cmdParser->reply.WriteInt(ret_value);
@@ -127,77 +137,91 @@
         m_cmdParser->reply.WriteInt(JDWP_SUSPEND_STATUS_SUSPENDED);
     else
         m_cmdParser->reply.WriteInt(0);
-    JDWP_TRACE_DATA("Status: send: status=" << ret_value);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Status: send: status=%d", ret_value));
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //ThreadGroupHandler-----------------------------------------------------------
 
-void 
-ThreadReference::ThreadGroupHandler::Execute(JNIEnv *jni) throw(AgentException)
+int 
+ThreadReference::ThreadGroupHandler::Execute(JNIEnv *jni) 
 {
     jvmtiThreadInfo info;
     info.name = 0;
 
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("ThreadGroup: received: threadID=" << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ThreadGroup: received: threadID=%p", thrd));
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(thrd, &info));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadInfo(thrd, &info));
     JvmtiAutoFree destroyer(info.name);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
-    JDWP_TRACE_DATA("ThreadGroup: send: threadGroupID=" << info.thread_group);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ThreadGroup: send: threadGroupID=%p", info.thread_group));
     m_cmdParser->reply.WriteThreadGroupID(jni, info.thread_group);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //FramesHandler----------------------------------------------------------------
 
-void
-ThreadReference::FramesHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+ThreadReference::FramesHandler::Execute(JNIEnv *jni)
 {
     jvmtiEnv *jvmti = GetJvmtiEnv();
 
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
     
-    if (!GetThreadManager().IsSuspended(thrd))
-        throw AgentException(JVMTI_ERROR_THREAD_NOT_SUSPENDED);
+    if (!GetThreadManager().IsSuspended(thrd)){
+        AgentException e(JVMTI_ERROR_THREAD_NOT_SUSPENDED);
+		JDWP_SET_EXCEPTION(e);
+        return 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);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Frames: received: threadID=%p, startFrame=%d, length=%d", thrd, startFrame, length));
 
     jint frameCount;
     jvmtiError err;
-    JVMTI_TRACE(err, jvmti->GetFrameCount(thrd, &frameCount));
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetFrameCount(thrd, &frameCount));
 
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     if (length == -1) {
         length = frameCount - startFrame;
     }
 
     if (length == 0) {
-        JDWP_TRACE_DATA("Frames: frameCount=" << frameCount 
-            << ", startFrame=" << startFrame 
-            << ", length=" << length);
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Frames: frameCount=%d, startFrame=%d, length=%d", frameCount, startFrame, length));
         m_cmdParser->reply.WriteInt(0);
-        return;
+        return JDWP_ERROR_NONE;
     }
 
-    if (startFrame >= frameCount || startFrame < 0)
-        throw AgentException(JDWP_ERROR_INVALID_INDEX);
+    if (startFrame >= frameCount || startFrame < 0){
+        AgentException e(JDWP_ERROR_INVALID_INDEX);
+		JDWP_SET_EXCEPTION(e);
+        return JDWP_ERROR_INVALID_INDEX;
+    }
 
     jint maxFrame = startFrame + length;
     if ( (length < 0) || (maxFrame > frameCount) ) {
-        throw AgentException(JDWP_ERROR_INVALID_LENGTH);
+        AgentException e(JDWP_ERROR_INVALID_LENGTH);
+		JDWP_SET_EXCEPTION(e);
+        return JDWP_ERROR_INVALID_LENGTH;
     }
 
     jvmtiFrameInfo *frame_buffer = 
@@ -206,19 +230,18 @@
     AgentAutoFree destroyer(frame_buffer JDWP_FILE_LINE);
 
     jint count;
-    JVMTI_TRACE(err, jvmti->GetStackTrace(thrd, 0, frameCount, 
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetStackTrace(thrd, 0, frameCount, 
                                                  frame_buffer, &count));
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
     }
     JDWP_ASSERT(count == frameCount);
 
     m_cmdParser->reply.WriteInt(length);
 
-    JDWP_TRACE_DATA("Frames: frameCount=" << frameCount 
-        << ", startFrame=" << startFrame 
-        << ", length=" << length 
-        << ", maxFrame=" << maxFrame);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Frames: frameCount=%d, startFrame=%d, length=%d, maxFrame=%d", frameCount, startFrame, length, maxFrame));
 
     jclass declaring_class;
     jdwpTypeTag typeTag;
@@ -226,10 +249,12 @@
     for (jint j = startFrame; j < maxFrame; j++) {
         m_cmdParser->reply.WriteFrameID(jni, thrd, j, frameCount);
 
-        JVMTI_TRACE(err, jvmti->GetMethodDeclaringClass(frame_buffer[j].method,
+        JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetMethodDeclaringClass(frame_buffer[j].method,
             &declaring_class));
         if (err != JVMTI_ERROR_NONE) {
-            throw AgentException(err);
+            AgentException e(err);
+		    JDWP_SET_EXCEPTION(e);
+            return err;
         }
 
         typeTag = GetClassManager().GetJdwpTypeTag(declaring_class);
@@ -237,171 +262,211 @@
 #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);
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadInfo(thrd, &info));
+            JvmtiAutoFree jafInfoName(info.name);
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Frames: send: frame#=%d, threadName=%s, loc=%lld, methodID=%p, classID=%p, typeTag=%d", 
+                            j, info.name, frame_buffer[j].location, frame_buffer[j].method, declaring_class, typeTag));
         }
 #endif
+        
+        jboolean isObsolete;
+        JVMTI_TRACE(LOG_DEBUG, err, jvmti->IsMethodObsolete(frame_buffer[j].method, &isObsolete));
 
-        m_cmdParser->reply.WriteLocation(jni, typeTag,
+        // we should return 0 as the methodID for obsolete method.
+        if(isObsolete) {	 
+            m_cmdParser->reply.WriteLocation(jni, typeTag,
+                        declaring_class, 0,
+                        frame_buffer[j].location);
+        } else {
+            m_cmdParser->reply.WriteLocation(jni, typeTag,
                         declaring_class, frame_buffer[j].method,
                         frame_buffer[j].location);
+        }
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //FrameCountHandler------------------------------------------------------------
 
-void
-ThreadReference::FrameCountHandler::Execute(JNIEnv *jni) throw (AgentException)
+int
+ThreadReference::FrameCountHandler::Execute(JNIEnv *jni) 
 {
     jint count;
 
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("FrameCount: received: threadID=" << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "FrameCount: received: threadID=%p", thrd));
 
-    if (!GetThreadManager().IsSuspended(thrd))
-        throw AgentException(JVMTI_ERROR_THREAD_NOT_SUSPENDED);
+    if (!GetThreadManager().IsSuspended(thrd)){
+        AgentException e(JVMTI_ERROR_THREAD_NOT_SUSPENDED);
+		JDWP_SET_EXCEPTION(e);
+        return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
+    }
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetFrameCount(thrd, &count));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetFrameCount(thrd, &count));
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     m_cmdParser->reply.WriteInt(count);
-    JDWP_TRACE_DATA("FrameCount: send: count=" << count);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "FrameCount: send: count=%d", count));
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //OwnedMonitorsHandler---------------------------------------------------------
 
-void
-ThreadReference::OwnedMonitorsHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+ThreadReference::OwnedMonitorsHandler::Execute(JNIEnv *jni) 
 {
     jint count;
     jobject* owned_monitors = 0;
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("OwnedMonitors: received: threadID=" << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "OwnedMonitors: received: threadID=%p", thrd));
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetOwnedMonitorInfo(thrd, &count,
+    JVMTI_TRACE(LOG_DEBUG, 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);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
-    JDWP_TRACE_DATA("OwnedMonitors: send: monitors=" << count);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "OwnedMonitors: send: monitors=%d", count));
     m_cmdParser->reply.WriteInt(count);
     for (int i = 0; i < count; i++)
     {
-        JDWP_TRACE_DATA("OwnedMonitors: send: monitor#=" << i
-            << ", objectID=" << owned_monitors[i]);
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "OwnedMonitors: send: monitor#=%d, objectID=%p", i, owned_monitors[i]));
         m_cmdParser->reply.WriteTaggedObjectID(jni, owned_monitors[i]);
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //OwnedMonitorsHandler---------------------------------------------------------
 
-void
-ThreadReference::CurrentContendedMonitorHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+ThreadReference::CurrentContendedMonitorHandler::Execute(JNIEnv *jni) 
 {
     jobject monitor;
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);\
-    JDWP_TRACE_DATA("CurrentContendedMonitor: received: threadID=" << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "CurrentContendedMonitor: received: threadID=%p", thrd));
                                                                            
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetCurrentContendedMonitor(thrd, &monitor));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetCurrentContendedMonitor(thrd, &monitor));
 
     JDWP_ASSERT(err != JVMTI_ERROR_NULL_POINTER);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
-    JDWP_TRACE_DATA("CurrentContendedMonitor: send: monitor=" << monitor);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "CurrentContendedMonitor: send: monitor=%p", monitor));
     m_cmdParser->reply.WriteTaggedObjectID(jni, monitor);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //StopHandler------------------------------------------------------------------
 
-void
-ThreadReference::StopHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+ThreadReference::StopHandler::Execute(JNIEnv *jni) 
 {
     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);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Stop: stop: threadID=%p throwableID=%p", thrd, excp));
+    int ret = GetThreadManager().Stop(jni, thrd, excp);
+
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
 //InterruptHandler-------------------------------------------------------------
 
-void
-ThreadReference::InterruptHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+ThreadReference::InterruptHandler::Execute(JNIEnv *jni) 
 {
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
 
-    JDWP_TRACE_DATA("Interrupt: interrupt: threadID=" << thrd);
-    GetThreadManager().Interrupt(jni, thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Interrupt: interrupt: threadID=%p", thrd));
+    int ret = GetThreadManager().Interrupt(jni, thrd);
+
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
 //SuspendCountHandler----------------------------------------------------------
 
-void
+int
 ThreadReference::SuspendCountHandler::Execute(JNIEnv *jni)
-    throw (AgentException)
 {
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("SuspendCount: received: threadID=" << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SuspendCount: received: threadID=%p", thrd));
     jint count = GetThreadManager().GetSuspendCount(jni, thrd);
 
-    JDWP_TRACE_DATA("SuspendCount: send: count=" << count);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "SuspendCount: send: count=%d", count));
     m_cmdParser->reply.WriteInt(count);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //OwnedMonitorsStackDepthInfoHandler-------------------------------------------
 
-void
+int
 ThreadReference::OwnedMonitorsStackDepthInfoHandler::Execute(JNIEnv *jni)
-    throw (AgentException)
 {
     // Read thread id from OwnedMonitorsStackDepthInfoHandler command
+    // Bug fix, if thread id is invalid, error code reply should be returned
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("OwnedMonitorsStackDepthInfo: received: threadID=" << thrd);
-
-    // If the thread is not suspended, throw exception
-    if (!GetThreadManager().IsSuspended(thrd))
-        throw AgentException(JVMTI_ERROR_THREAD_NOT_SUSPENDED);
+    if(thrd == 0){
+        AgentException aex = GetExceptionManager().GetLastException();
+        jdwpError err = aex.ErrCode();
+        AgentException ex(err);
+        JDWP_SET_EXCEPTION(ex);
+        return err;
+	}
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "OwnedMonitorsStackDepthInfo: received: threadID=%p", thrd));
+    
+    // If the thread is not in the suspended list or is terminated,
+    // throw INVALID_THREAD exception or THREAD_NOT_SUSPENDED
+    int ret = GetThreadManager().CheckThreadStatus(jni, thrd);
+    JDWP_CHECK_RETURN(ret);
 
     // Invoke jvmti function to attain the expected monitor data
     jvmtiError err;
     jint count;
     jvmtiMonitorStackDepthInfo* pMonitorInfos;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetOwnedMonitorStackDepthInfo(thrd, &count, &pMonitorInfos));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetOwnedMonitorStackDepthInfo(thrd, &count, &pMonitorInfos));
     if (err != JVMTI_ERROR_NONE) {
         // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_INVALID_THREAD
         // JVMTI_ERROR_THREAD_NOT_ALIVE, JVMTI_ERROR_NULL_POINTER 
-        throw AgentException(err);
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
     }
     
     // Must release memeory manually
     JvmtiAutoFree af(pMonitorInfos);
 
     // Write monitor count to reply package
-    JDWP_TRACE_DATA("OwnedMonitorsStackDepthInfo: received: monitor count=" << count);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "OwnedMonitorsStackDepthInfo: received: monitor count=%d", count));
     m_cmdParser->reply.WriteInt(count);
     
     // Write each monitor and its stack depth to reply package 
@@ -409,32 +474,36 @@
         // Attain monitor and its stack depth from returned data.
         jobject monitor = pMonitorInfos[i].monitor;
         m_cmdParser->reply.WriteTaggedObjectID(jni, monitor);
-        JDWP_TRACE_DATA("OwnedMonitorsStackDepthInfo: received: monitor object=" << monitor);
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "OwnedMonitorsStackDepthInfo: received: monitor object=%p", monitor));
         
         jint stack_depth = pMonitorInfos[i].stack_depth;
-        JDWP_TRACE_DATA("OwnedMonitorsStackDepthInfo: received: monitor stack depth=" << stack_depth);
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "OwnedMonitorsStackDepthInfo: received: monitor stack depth=%d", stack_depth));
         m_cmdParser->reply.WriteInt(stack_depth);
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //ForceEarlyReturnHandler------------------------------------------------------
 
-void
+int
 ThreadReference::ForceEarlyReturnHandler::Execute(JNIEnv *jni)
-    throw (AgentException)
 {
     // Read thread id from ForceEarlyReturnHandler command
     jthread thrd = m_cmdParser->command.ReadThreadID(jni);
-    JDWP_TRACE_DATA("ForceEarlyReturn Command: received: threadID = " << thrd);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: received: threadID = %p", thrd));
 
     // If the thread is not suspended, throw exception
-    if (!GetThreadManager().IsSuspended(thrd))
-        throw AgentException(JDWP_ERROR_THREAD_NOT_SUSPENDED);
+    if (!GetThreadManager().IsSuspended(thrd)) {
+        AgentException e(JDWP_ERROR_THREAD_NOT_SUSPENDED);
+		JDWP_SET_EXCEPTION(e);
+        return JDWP_ERROR_THREAD_NOT_SUSPENDED;
+    }
 
     // Attain return value type from the command
     jdwpTaggedValue taggedValue = m_cmdParser->command.ReadValue(jni);
-    JDWP_TRACE_DATA("ForceEarlyReturn Command: received value type:" << taggedValue.tag);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: received value type: %d", taggedValue.tag));
     
     // Invoke relevant jvmti function according to return value's type
     jvmtiError err = JVMTI_ERROR_NONE;      
@@ -446,8 +515,8 @@
         case JDWP_TAG_THREAD_GROUP:
         case JDWP_TAG_CLASS_LOADER:
         case JDWP_TAG_CLASS_OBJECT:{
-            JDWP_TRACE_DATA("ForceEarlyReturn Command: jobject return value:"<< taggedValue.value.l);
-            JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnObject(thrd, taggedValue.value.l));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: jobject return value: %p", taggedValue.value.l));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->ForceEarlyReturnObject(thrd, taggedValue.value.l));
             break;
         }
         case JDWP_TAG_BOOLEAN:
@@ -459,59 +528,65 @@
             switch (taggedValue.tag) {
                 case JDWP_TAG_BOOLEAN:
                     ivalue = static_cast<jint>(taggedValue.value.z);
-                    JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(boolean)" << taggedValue.value.z);
+                    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: value=(boolean)%d", taggedValue.value.z));
                     break;
                 case JDWP_TAG_BYTE:
                     ivalue = static_cast<jint>(taggedValue.value.b);
-                    JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(byte)" << taggedValue.value.b);
+                    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: value=(byte)%d", taggedValue.value.b));
                     break;
                 case JDWP_TAG_CHAR:
                     ivalue = static_cast<jint>(taggedValue.value.c);
-                    JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(char)" << taggedValue.value.c);
+                    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: value=(char)%d", taggedValue.value.c));
                     break;
                 case JDWP_TAG_SHORT:
                     ivalue = static_cast<jint>(taggedValue.value.s);
-                    JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(short)" << taggedValue.value.s);
+                    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: value=(short)%d", taggedValue.value.s));
                     break;
                 case JDWP_TAG_INT:
                     ivalue = taggedValue.value.i;
-                    JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(int)" << taggedValue.value.i);
+                    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: value=(int)%d", taggedValue.value.i));
                     break;
             }
-            JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnInt(thrd, ivalue));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->ForceEarlyReturnInt(thrd, ivalue));
             break;
         }
         case JDWP_TAG_LONG:{
-            JDWP_TRACE_DATA("ForceEarlyReturn Command: jlong returne value:"<< taggedValue.value.j);
-            JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnLong(thrd, taggedValue.value.j));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: jlong return value:%lld", taggedValue.value.j));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->ForceEarlyReturnLong(thrd, taggedValue.value.j));
             break;
         }
         case JDWP_TAG_FLOAT:{
-            JDWP_TRACE_DATA("ForceEarlyReturn Command: jfloat return value:"<< taggedValue.value.f);
-            JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnFloat(thrd, taggedValue.value.f));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: jfloat return value:%f", taggedValue.value.f));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->ForceEarlyReturnFloat(thrd, taggedValue.value.f));
             break;
             
         }
         case JDWP_TAG_DOUBLE:{
-            JDWP_TRACE_DATA("ForceEarlyReturn Command: jdouble return value:"<< taggedValue.value.d);
-            JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnDouble(thrd, taggedValue.value.d));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: jdouble return value:%Lf", taggedValue.value.d));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->ForceEarlyReturnDouble(thrd, taggedValue.value.d));
             break;
         }
         case JDWP_TAG_VOID:{
-            JDWP_TRACE_DATA("ForceEarlyReturn Command: void return value");
-            JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnVoid(thrd));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: void return value"));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->ForceEarlyReturnVoid(thrd));
             break;
         }
         default:{
-            JDWP_TRACE_DATA("ForceEarlyReturn Command: Value's type is not supported " << taggedValue.tag);
-            throw AgentException(JDWP_ERROR_INVALID_TAG);
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command: Value's type is not supported %d", taggedValue.tag));
+            AgentException e(JDWP_ERROR_INVALID_TAG);
+			JDWP_SET_EXCEPTION(e);
+            return JDWP_ERROR_INVALID_TAG;
         }
     }
     
     if (err != JVMTI_ERROR_NONE) {
-        throw AgentException(err);
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
     }
-    JDWP_TRACE_DATA("ForceEarlyReturn Command finished.");
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ForceEarlyReturn Command finished."));
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Vitaly A. Provodin
- * @version $Revision: 1.4.2.1 $
- */
-
 /**
  * @file
  * ThreadReference.h
@@ -54,7 +48,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//NameHandler
 
@@ -71,7 +65,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//SuspendHandler
 
@@ -88,7 +82,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//ResumeHandler
 
@@ -105,7 +99,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//StatusHandler
 
@@ -122,7 +116,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//ThreadGroupHandler
 
@@ -139,7 +133,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//FramesHandler
 
@@ -156,7 +150,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//FrameCountHandler
 
@@ -173,7 +167,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//OwnedMonitorsHandler
 
@@ -190,7 +184,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//CurrentContendedMonitorHandler
 
@@ -207,7 +201,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//StopHandler
 
@@ -224,7 +218,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//InterruptHandler
 
@@ -241,7 +235,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//SuspendCountHandler
 
@@ -259,7 +253,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//OwnedMonitorsStackDepthInfoHandler
         
@@ -276,7 +270,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni);
 
         };//ForceEarlyReturnHandler
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.cpp Thu Jul 16 15:57:37 2009
@@ -15,13 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Vitaly A. Provodin
- * @version $Revision: 1.23.2.2 $
- */
-#include <string.h>
-
 #include "jvmti.h"
 #include "jdwp.h"
 
@@ -34,6 +27,13 @@
 #include "EventDispatcher.h"
 #include "TransportManager.h"
 #include "CallBacks.h"
+#include "ExceptionManager.h"
+
+
+#include "vmi.h"
+#include "hyport.h"
+
+#include <string.h>
 
 using namespace jdwp;
 using namespace VirtualMachine;
@@ -42,8 +42,8 @@
 //-----------------------------------------------------------------------------
 //VersionHandler---------------------------------------------------------------
 
-void
-VirtualMachine::VersionHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::VersionHandler::Execute(JNIEnv *jni) 
 {
     ClassManager &clsMgr = AgentBase::GetClassManager();
 
@@ -69,37 +69,32 @@
     char *description = reinterpret_cast<char*>
         (AgentBase::GetMemoryManager().Allocate(descriptionSize JDWP_FILE_LINE));
     AgentAutoFree dobj_description(description JDWP_FILE_LINE);
-    sprintf(description, pattern,
-        (javaVersion == 0) ? unknown : javaVersion,
-        (javaVmName == 0) ? unknown : javaVmName,
-        (javaVmInfo == 0) ? unknown : javaVmInfo,
-        (javaVmVersion == 0) ? unknown : javaVmVersion);
-
-    JDWP_TRACE_DATA("Version: send: "
-        << ", description=" << JDWP_CHECK_NULL(description)
-        << ", jdwpMajor=" << JDWP_VERSION_MAJOR
-        << ", jdwpMinor=" << JDWP_VERSION_MINOR
-        << ", vmVersion=" << JDWP_CHECK_NULL(javaVersion)
-        << ", vmVersion=" << JDWP_CHECK_NULL(javaVmName)
 
-    );
+    PORT_ACCESS_FROM_ENV(jni);
+    hystr_printf(privatePortLibrary, description, (U_32)descriptionSize, pattern, (javaVersion == 0) ? unknown : javaVersion,
+        (javaVmName == 0) ? unknown : javaVmName, (javaVmInfo == 0) ? unknown : javaVmInfo, (javaVmVersion == 0) ? unknown : javaVmVersion);
+
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Version: send: description=%s, jdwpMajor=%d, jdwpMinor=%d, vmVersion=%s, vmName=%s",
+                    JDWP_CHECK_NULL(description), JDWP_VERSION_MAJOR, JDWP_VERSION_MINOR,
+                    JDWP_CHECK_NULL(javaVersion), JDWP_CHECK_NULL(javaVmName)));
 
     m_cmdParser->reply.WriteString(description);
     m_cmdParser->reply.WriteInt(JDWP_VERSION_MAJOR);
     m_cmdParser->reply.WriteInt(JDWP_VERSION_MINOR);
     m_cmdParser->reply.WriteString(javaVersion);
     m_cmdParser->reply.WriteString(javaVmName);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //ClassesBySignatureHandler----------------------------------------------------
 
-void
-VirtualMachine::ClassesBySignatureHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::ClassesBySignatureHandler::Execute(JNIEnv *jni) 
 {
     const char *signature = m_cmdParser->command.ReadString();
-    JDWP_TRACE_DATA("ClassesBySignature: received: "
-        << "signature=" << JDWP_CHECK_NULL(signature));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassesBySignature: received: signature=%s", JDWP_CHECK_NULL(signature)));
 
     jint classCount = 0;
     jclass* classes = 0;
@@ -107,11 +102,16 @@
     jvmtiEnv* jvmti = AgentBase::GetJvmtiEnv();
 
     jvmtiError err;
-    JVMTI_TRACE(err, jvmti->GetLoadedClasses(&classCount, &classes));
+    AgentBase::GetJniEnv()->PushLocalFrame(100);
+
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetLoadedClasses(&classCount, &classes));
     JvmtiAutoFree dobj(classes);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE) {
+        AgentException e(err);
+        JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     int i;
     int count = 0;
@@ -120,22 +120,25 @@
         if (IsSignatureMatch(classes[i], signature)) {
             classes[count] = classes[i];
             count++;
-        }
+        } 
     }
+
     size_t classCountPos = m_cmdParser->reply.GetPosition();
     m_cmdParser->reply.WriteInt(count);
-    JDWP_TRACE_DATA("ClassesBySignature: classes=" << count);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassesBySignature: classes=%d", count));
     
     int notIncludedClasses = 0;
-    for (i = 0; i < count; i++)
+    for (i = count - 1; i >= 0; i --)
     {
         jdwpTypeTag refTypeTag = GetClassManager().GetJdwpTypeTag(classes[i]);
 
         jint status;
-        JVMTI_TRACE(err, jvmti->GetClassStatus(classes[i], &status));
-        if (err != JVMTI_ERROR_NONE)
-            throw AgentException(err);
-
+        JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassStatus(classes[i], &status));
+        if (err != JVMTI_ERROR_NONE){
+            AgentException e(err);
+            JDWP_SET_EXCEPTION(e);
+            return err;
+        }
         if (status == JVMTI_CLASS_STATUS_ARRAY) {
            status = 0;
         } else {
@@ -149,19 +152,19 @@
                 }
             }
         }
-        m_cmdParser->reply.WriteByte(refTypeTag);
+        m_cmdParser->reply.WriteByte((jbyte)refTypeTag);
         m_cmdParser->reply.WriteReferenceTypeID(jni, classes[i]);
         m_cmdParser->reply.WriteInt(status);
+
+
 #ifndef NDEBUG
         if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {    
             jvmtiError err;
             char* signature = 0;
-            JVMTI_TRACE(err, jvmti->GetClassSignature(classes[i], &signature, 0));
+            JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassSignature(classes[i], &signature, 0));
             JvmtiAutoFree afcs(signature);
-            JDWP_TRACE_DATA("ClassesBySignature: class#=" << i
-                << ", refTypeID=" << classes[i]
-                << ", status=" << status
-                << ", signature=" << JDWP_CHECK_NULL(signature));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassesBySignature: class#=%d, refTypeID=%p, status=%d, signature=%s", 
+                            i, classes[i], status, JDWP_CHECK_NULL(signature)));
         }
 #endif
     }
@@ -174,21 +177,26 @@
         m_cmdParser->reply.SetPosition(currentPos);
         m_cmdParser->reply.SetLength(currentLength);
     }
+
+    AgentBase::GetJniEnv()->PopLocalFrame(NULL);
+
+    return JDWP_ERROR_NONE;
 }
 
 bool
 VirtualMachine::ClassesBySignatureHandler::IsSignatureMatch(jclass klass,
                                                             const char *signature)
-                                                            throw(AgentException)
 {
     char* sign = 0;
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(klass, &sign, 0));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(klass, &sign, 0));
     JvmtiAutoFree dobj(sign);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "GetClassSignature failed with error %d on signature %s", err, signature));
+        return false;
+    }
 
     return strcmp(signature, sign) == 0;
 }
@@ -196,22 +204,27 @@
 //-----------------------------------------------------------------------------
 //AllClassesHandler------------------------------------------------------------
 
-void
-VirtualMachine::AllClassesHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::AllClassesHandler::Execute(JNIEnv *jni) 
 {
     jint classCount = 0;
     jclass* classes = 0;
 
     jvmtiEnv* jvmti = AgentBase::GetJvmtiEnv();
     jvmtiError err;
-    JVMTI_TRACE(err, jvmti->GetLoadedClasses(&classCount, &classes));
+
+    AgentBase::GetJniEnv()->PushLocalFrame(100);
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetLoadedClasses(&classCount, &classes));
 
     JvmtiAutoFree dobj(classes);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+        JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
-    JDWP_TRACE_DATA("AllClasses: classes=" << classCount);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "AllClasses: classes=%d", classCount));
     size_t classCountPos = m_cmdParser->reply.GetPosition();
     m_cmdParser->reply.WriteInt(classCount);
 
@@ -229,30 +242,40 @@
         m_cmdParser->reply.SetPosition(currentPos);
         m_cmdParser->reply.SetLength(currentLength);
     }
+
+    AgentBase::GetJniEnv()->PopLocalFrame(NULL);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 
 int
 VirtualMachine::AllClassesHandler::Compose41Class(JNIEnv *jni, jvmtiEnv* jvmti,
-        jclass klass) throw (AgentException)
+        jclass klass) 
 {
     jdwpTypeTag refTypeTag = GetClassManager().GetJdwpTypeTag(klass);
 
     char* signature = 0;
 
     jvmtiError err;
-    JVMTI_TRACE(err, jvmti->GetClassSignature(klass, &signature, 0));
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassSignature(klass, &signature, 0));
 
     JvmtiAutoFree dobj(signature);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     jint status;
-    JVMTI_TRACE(err, jvmti->GetClassStatus(klass, &status));
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassStatus(klass, &status));
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     // According to JVMTI spec ClassStatus flag for arrays and primitive classes must be zero
     if (status == JVMTI_CLASS_STATUS_ARRAY || status == JVMTI_CLASS_STATUS_PRIMITIVE) {
@@ -262,7 +285,7 @@
         return 1;
     }
 
-    m_cmdParser->reply.WriteByte(refTypeTag);
+    m_cmdParser->reply.WriteByte((jbyte)refTypeTag);
     m_cmdParser->reply.WriteReferenceTypeID(jni, klass);
     m_cmdParser->reply.WriteString(signature);
     m_cmdParser->reply.WriteInt(status);
@@ -273,25 +296,27 @@
 //-----------------------------------------------------------------------------
 //AllThreadHandler-------------------------------------------------------------
 
-void
+int
 VirtualMachine::AllThreadsHandler::Execute(JNIEnv *jni)
-    throw(AgentException)
 {
     jint totalThreadsCount, threadsCount;
     jthread* threads = 0;
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetAllThreads(&totalThreadsCount, &threads));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetAllThreads(&totalThreadsCount, &threads));
 
     JvmtiAutoFree dobj(threads);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     threadsCount = 0;
     ThreadManager& thrdMgr = GetThreadManager();
 
-    JDWP_TRACE_DATA("AllThreads: threads=" << totalThreadsCount);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "AllThreads: threads=%d", totalThreadsCount));
 
     int i;
     for (i = 0; i < totalThreadsCount; i++)
@@ -301,11 +326,10 @@
         if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
             jvmtiThreadInfo info;
             info.name = 0;
-            JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadInfo(threads[i], &info));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadInfo(threads[i], &info));
             JvmtiAutoFree jafInfoName(info.name);
-            JDWP_TRACE_DATA("AllThreads: thread#=" << i 
-                << ", name=" << JDWP_CHECK_NULL(info.name)
-                << ", isAgent=" << (thrdMgr.IsAgentThread(jni, threads[i])));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "AllThreads: thread#=%d, name=%s, isAgent=%s", 
+                            i, JDWP_CHECK_NULL(info.name), (thrdMgr.IsAgentThread(jni, threads[i])?"TRUE":"FALSE")));
         }
 #endif
 
@@ -321,27 +345,31 @@
     {
         m_cmdParser->reply.WriteThreadID(jni, threads[i]);
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //TopLevelThreadGroupsHandler--------------------------------------------------
 
-void
+int
 VirtualMachine::TopLevelThreadGroupsHandler::Execute(JNIEnv *jni)
-    throw(AgentException)
 {
     jint groupCount;
     jthreadGroup* groups = 0;
 
     jvmtiError err;
-    JVMTI_TRACE(err, GetJvmtiEnv()->GetTopThreadGroups(&groupCount, &groups));
+    JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetTopThreadGroups(&groupCount, &groups));
 
     JvmtiAutoFree dobj(groups);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
-    JDWP_TRACE_DATA("TopLevelThreadGroup: send: groupCount=" << groupCount);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "TopLevelThreadGroup: send: groupCount=%d", groupCount));
     m_cmdParser->reply.WriteInt(groupCount);
     for (jint i = 0; i < groupCount; i++) {
 
@@ -349,82 +377,94 @@
         if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
             jvmtiThreadGroupInfo info;
             info.name = 0;
-            JVMTI_TRACE(err, GetJvmtiEnv()->GetThreadGroupInfo(groups[i], &info));
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetThreadGroupInfo(groups[i], &info));
             JvmtiAutoFree jafInfoName(info.name);
         
-            JDWP_TRACE_DATA("TopLevelThreadGroup: send: group#" << i 
-                << ", groupID=" << groups[i]
-                << ", name=" << JDWP_CHECK_NULL(info.name));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "TopLevelThreadGroup: send: group#%d, groupID=%p, name=%s", 
+                            i, groups[i], JDWP_CHECK_NULL(info.name)));
         }
 #endif
 
         m_cmdParser->reply.WriteThreadGroupID(jni, groups[i]);
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //DisposeHandler---------------------------------------------------------------
 
-void
-VirtualMachine::DisposeHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::DisposeHandler::Execute(JNIEnv *jni) 
 {
-    JDWP_TRACE_DATA("Dispose: write reply");
-    m_cmdParser->WriteReply(jni);
-    JDWP_TRACE_DATA("Dispose: reset agent");
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Dispose: write reply"));
+    int ret = m_cmdParser->WriteReply(jni);
+    JDWP_CHECK_RETURN(ret);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Dispose: reset agent"));
     GetPacketDispatcher().Reset(jni);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //IDSizesHandler---------------------------------------------------------------
 
-void
-VirtualMachine::IDSizesHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::IDSizesHandler::Execute(JNIEnv *jni) 
 {
     m_cmdParser->reply.WriteInt(FIELD_ID_SIZE);
     m_cmdParser->reply.WriteInt(METHOD_ID_SIZE);
     m_cmdParser->reply.WriteInt(OBJECT_ID_SIZE);
     m_cmdParser->reply.WriteInt(REFERENCE_TYPE_ID_SIZE);
     m_cmdParser->reply.WriteInt(FRAME_ID_SIZE);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //SuspendHandler---------------------------------------------------------------
 
-void
-VirtualMachine::SuspendHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::SuspendHandler::Execute(JNIEnv *jni) 
 {
-    JDWP_TRACE_DATA("Suspend: suspendAll");
-    GetThreadManager().SuspendAll(jni);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Suspend: suspendAll"));
+    int ret = GetThreadManager().SuspendAll(jni);
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
 //ResumedHandler---------------------------------------------------------------
 
-void
-VirtualMachine::ResumeHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::ResumeHandler::Execute(JNIEnv *jni) 
 {
-    JDWP_TRACE_DATA("Resume: resumeAll");
-    GetThreadManager().ResumeAll(jni);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Resume: resumeAll"));
+    int ret = GetThreadManager().ResumeAll(jni);
+
+    return ret;
 }
 
 //-----------------------------------------------------------------------------
 //ExitHandler------------------------------------------------------------------
 
-void
-VirtualMachine::ExitHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::ExitHandler::Execute(JNIEnv *jni) 
 {
     jint exitCode = m_cmdParser->command.ReadInt();
-    JDWP_TRACE_DATA("Exit: received: exitCode=" << exitCode);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Exit: received: exitCode=%d", exitCode));
 
-    JDWP_TRACE_DATA("Exit: write reply");
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Exit: write reply"));
+    // No need to check return code here as we will exit the process immediately
     m_cmdParser->WriteReply(jni);
 
-    JDWP_TRACE_DATA("Exit: reset agent");
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Exit: reset agent"));
+    // No need to check return code here as we will exit the process immediately
     GetTransportManager().Reset();
     
-    JDWP_TRACE_DATA("Exit: terminate process");
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "Exit: terminate process"));
     exit(static_cast<int>(exitCode));
 
+    return JDWP_ERROR_NONE;
 /*
     // another variant is to call System.exit()
     ClassManager &clsMgr = AgentBase::GetClassManager();
@@ -440,15 +480,17 @@
 //-----------------------------------------------------------------------------
 //CreateStringHandler----------------------------------------------------------
 
-void
-VirtualMachine::CreateStringHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::CreateStringHandler::Execute(JNIEnv *jni) 
 {
     const char *utf = m_cmdParser->command.ReadString();
-    JDWP_TRACE_DATA("CreateString: received: string=" << JDWP_CHECK_NULL(utf));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "CreateString: received: string=%s", JDWP_CHECK_NULL(utf)));
     jstring str = jni->NewStringUTF(utf);
 
-    JDWP_TRACE_DATA("CreateString: send: objectID=" << str);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "CreateString: send: objectID=%p", str));
     m_cmdParser->reply.WriteObjectID(jni, str);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
@@ -459,9 +501,8 @@
     return (value == 1) ? JNI_TRUE : JNI_FALSE;
 }
 
-void
+int
 VirtualMachine::CapabilitiesHandler::Execute(JNIEnv *jni)
-    throw(AgentException)
 {
     jdwpCapabilities caps = GetCapabilities();
 
@@ -472,6 +513,8 @@
     m_cmdParser->reply.WriteBoolean(IsAdded(caps.canGetOwnedMonitorInfo));
     m_cmdParser->reply.WriteBoolean(IsAdded(caps.canGetCurrentContendedMonitor));
     m_cmdParser->reply.WriteBoolean(IsAdded(caps.canGetMonitorInfo));
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
@@ -479,7 +522,7 @@
 
 void
 VirtualMachine::ClassPathsHandler::WritePathStrings(char *str,
-        char pathSeparator) throw(AgentException)
+        char pathSeparator)
 {
     if (str == 0) {
         m_cmdParser->reply.WriteInt(1);
@@ -510,8 +553,8 @@
     }
 }
 
-void
-VirtualMachine::ClassPathsHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::ClassPathsHandler::Execute(JNIEnv *jni) 
 {
     ClassManager &clsMgr = AgentBase::GetClassManager();
 
@@ -536,66 +579,68 @@
     char pathSeparator =
         (pathSeparatorString == 0) ? ';' : pathSeparatorString[0];
 
-    JDWP_TRACE_DATA("ClassPaths: baseDir="
-        << JDWP_CHECK_NULL(baseDir));
-    JDWP_TRACE_DATA("ClassPaths: pathSeparatorString="
-        << JDWP_CHECK_NULL(pathSeparatorString));
-    JDWP_TRACE_DATA("ClassPaths: classPaths="
-        << JDWP_CHECK_NULL(classPaths));
-    JDWP_TRACE_DATA("ClassPaths: bootClassPaths="
-        << JDWP_CHECK_NULL(bootClassPaths));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassPaths: baseDir=%s", JDWP_CHECK_NULL(baseDir)));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassPaths: pathSeparatorString=%s", JDWP_CHECK_NULL(pathSeparatorString)));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassPaths: classPaths=%s", JDWP_CHECK_NULL(classPaths)));
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ClassPaths: bootClassPaths=%s", JDWP_CHECK_NULL(bootClassPaths)));
 
     m_cmdParser->reply.WriteString(baseDir);
     WritePathStrings(classPaths, pathSeparator);
     WritePathStrings(bootClassPaths, pathSeparator);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //DisposeObjectsHandler--------------------------------------------------------
 
-void
-VirtualMachine::DisposeObjectsHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::DisposeObjectsHandler::Execute(JNIEnv *jni) 
 {
     jint refCount;
     ObjectID objectID;
     jint objCount = m_cmdParser->command.ReadInt();
-    JDWP_TRACE_DATA("DisposeObjects: dispose: objects=" << objCount);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "DisposeObjects: dispose: objects=%d", objCount));
     for (jint i = 0; i < objCount; i++)
     {
         objectID = m_cmdParser->command.ReadRawObjectID();
         refCount = m_cmdParser->command.ReadInt();
         GetObjectManager().DisposeObject(jni, objectID, refCount);
-        JDWP_TRACE_DATA("DisposeObjects: object#=" << i 
-            << ", objectID=" << objectID);
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "DisposeObjects: object#=%d, objectID=%p", i, objectID));
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //HoldEventsHandler------------------------------------------------------------
 
-void
-VirtualMachine::HoldEventsHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::HoldEventsHandler::Execute(JNIEnv *jni) 
 {
-    JDWP_TRACE_DATA("HoldEvents: hold events");
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "HoldEvents: hold events"));
     GetEventDispatcher().HoldEvents();
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //ReleaseEventsHandler---------------------------------------------------------
 
-void
-VirtualMachine::ReleaseEventsHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::ReleaseEventsHandler::Execute(JNIEnv *jni) 
 {
-    JDWP_TRACE_DATA("ReleaseEvents: release events");
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "ReleaseEvents: release events"));
     GetEventDispatcher().ReleaseEvents();
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //CapabilitiesNewHandler-------------------------------------------------------
 
-void
+int
 VirtualMachine::CapabilitiesNewHandler::Execute(JNIEnv *jni)
-    throw(AgentException)
 {
     jdwpCapabilities caps = GetCapabilities();
 
@@ -627,6 +672,8 @@
     for (int i = 0; i < 11; i++){
         m_cmdParser->reply.WriteBoolean(JNI_FALSE);
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
@@ -634,8 +681,8 @@
 
 class DAgentAutoFree {
 public:
-    DAgentAutoFree(unsigned char **ptr, size_t count) throw() : m_ptr(ptr) {m_count = count;}
-    ~DAgentAutoFree() throw()
+    DAgentAutoFree(unsigned char **ptr, size_t count) : m_ptr(ptr) {m_count = count;}
+    ~DAgentAutoFree()
     {
         MemoryManager &mm = AgentBase::GetMemoryManager();
         if (m_ptr != 0)
@@ -657,13 +704,13 @@
     unsigned char **m_ptr;
 };
 
-void
-VirtualMachine::RedefineClassesHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::RedefineClassesHandler::Execute(JNIEnv *jni) 
 {
     MemoryManager &mm = GetMemoryManager();
 
     jint classCount = m_cmdParser->command.ReadInt();
-    JDWP_TRACE_DATA("RedefineClasses: received: classCount=" << classCount);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "RedefineClasses: received: classCount=%d", classCount));
 
     jvmtiClassDefinition *classDefs =
         reinterpret_cast<jvmtiClassDefinition *>(mm.Allocate(sizeof(jvmtiClassDefinition)*classCount JDWP_FILE_LINE));
@@ -678,7 +725,7 @@
 
         DAgentAutoFree dobjDefs(bytes, classCount);
 
-        JDWP_TRACE_DATA("RedefineClasses: classes" << classCount);
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "RedefineClasses: classes=%d", classCount));
         for (i = 0; i < classCount; i++)
         {
             classDefs[i].klass = m_cmdParser->command.ReadReferenceTypeID(jni);
@@ -692,34 +739,39 @@
             if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {    
                 jvmtiError err;
                 char* signature = 0;
-                JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(classDefs[i].klass, &signature, 0));
+                JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(classDefs[i].klass, &signature, 0));
                 JvmtiAutoFree afcs(signature);
-                JDWP_TRACE_DATA("RedefineClasses: class#=" << i
-                    << ", refTypeID=" << classDefs[i].klass
-                    << ", class_byte_count=" << classDefs[i].class_byte_count 
-                    << ", signature=" << JDWP_CHECK_NULL(signature));
+                JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "RedefineClasses: class#=%d, refTypeID=%p, class_byte_count=%d, signature=%s", 
+                                i, classDefs[i].klass, classDefs[i].class_byte_count, JDWP_CHECK_NULL(signature)));
             }
 #endif
         }
 
         jvmtiError err;
-        JVMTI_TRACE(err, GetJvmtiEnv()->RedefineClasses(classCount, classDefs));
+        JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->RedefineClasses(classCount, classDefs));
 
-        if (err != JVMTI_ERROR_NONE)
-            throw AgentException(err);
+        if (err != JVMTI_ERROR_NONE){
+            AgentException e(err);
+		    JDWP_SET_EXCEPTION(e);
+            return err;
+        }
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
 //SetDefaultStratumHandler-----------------------------------------------------
 
-void
-VirtualMachine::SetDefaultStratumHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::SetDefaultStratumHandler::Execute(JNIEnv *jni)
 {
-    // Note. The SetDefaultStratum handler is not implemented
-    // here because JDWP specs are not clear about this command.
-    JDWP_TRACE_DATA("SetDefaultStratumHandler: not implemented");
-    throw AgentException(JDWP_ERROR_NOT_IMPLEMENTED);
+    JDWP_TRACE(LOG_RELEASE, (LOG_FUNC_FL, "SetDefaultStratumHandler(%p)", jni));
+
+    char *stratum = m_cmdParser->command.ReadStringNoFree();
+    AgentBase::SetDefaultStratum(stratum);
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------
@@ -727,7 +779,7 @@
 
 int
 VirtualMachine::AllClassesWithGenericHandler::Compose41Class(JNIEnv *jni_env,
-            jvmtiEnv* jvmti, jclass klass) throw (AgentException)
+            jvmtiEnv* jvmti, jclass klass) 
 {
     jdwpTypeTag refTypeTag = GetClassManager().GetJdwpTypeTag(klass);
 
@@ -735,18 +787,24 @@
     char* generic = 0;
 
     jvmtiError err;
-    JVMTI_TRACE(err, jvmti->GetClassSignature(klass, &signature, &generic));
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassSignature(klass, &signature, &generic));
 
     JvmtiAutoFree dobjs(signature);
     JvmtiAutoFree dobjg(generic);
 
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     jint status;
-    JVMTI_TRACE(err, jvmti->GetClassStatus(klass, &status));
-    if (err != JVMTI_ERROR_NONE)
-        throw AgentException(err);
+    JVMTI_TRACE(LOG_DEBUG, err, jvmti->GetClassStatus(klass, &status));
+    if (err != JVMTI_ERROR_NONE){
+        AgentException e(err);
+		JDWP_SET_EXCEPTION(e);
+        return err;
+    }
 
     // According to JVMTI spec ClassStatus flag for arrays and primitive classes must be zero
     if (status == JVMTI_CLASS_STATUS_ARRAY || status == JVMTI_CLASS_STATUS_PRIMITIVE) {
@@ -756,7 +814,7 @@
         return 1;
     }
 
-    m_cmdParser->reply.WriteByte(refTypeTag);
+    m_cmdParser->reply.WriteByte((jbyte)refTypeTag);
     m_cmdParser->reply.WriteReferenceTypeID(jni_env, klass);
     m_cmdParser->reply.WriteString(signature);
 
@@ -766,9 +824,8 @@
         m_cmdParser->reply.WriteString("");
 
     m_cmdParser->reply.WriteInt(status);
-    JDWP_TRACE_DATA("AllClassesWithGeneric: typeTag=" << refTypeTag << ", refTypeID="
-         << klass << ", signature=" << JDWP_CHECK_NULL(signature) << ", generic=" 
-         << JDWP_CHECK_NULL(generic) << ", status=" << status);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "AllClassesWithGeneric: typeTag=%d, refTypeID=%p, signature=%s, generic=%s, status=%d", 
+                    refTypeTag, klass, JDWP_CHECK_NULL(signature), JDWP_CHECK_NULL(generic), status));
 
     return 0;
 }
@@ -777,26 +834,27 @@
 //-----------------------------------------------------------------------------
 //InstanceCountsHandler-------------------------------------------------
 
-void
-VirtualMachine::InstanceCountsHandler::Execute(JNIEnv *jni) throw(AgentException)
+int
+VirtualMachine::InstanceCountsHandler::Execute(JNIEnv *jni) 
 {
     jint refTypesCount = m_cmdParser->command.ReadInt();
     // Illegal argument
     if(refTypesCount < 0) {
-        throw AgentException(JDWP_ERROR_ILLEGAL_ARGUMENT);
+        AgentException e(JDWP_ERROR_ILLEGAL_ARGUMENT);
+		JDWP_SET_EXCEPTION(e);
+        return JDWP_ERROR_ILLEGAL_ARGUMENT;
     }
 
     m_cmdParser->reply.WriteInt(refTypesCount);
-    JDWP_TRACE_DATA("InstanceCounts: return the number of counts that follow:" << refTypesCount);
+    JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "InstanceCounts: return the number of counts that follow:%d", refTypesCount));
 
     // Number of reference types equals zero
     if(0 == refTypesCount) {
-        return;
+        return JDWP_ERROR_NONE;
     }
 
     jclass jvmClass;
     jvmtiError err;
-    char* signature = 0;
     // Tag is used to mark object which is reported in FollowReferences
     jlong tag_value = 0xffff;
     jlong tags[1] = {tag_value};
@@ -808,9 +866,9 @@
     memset(&hcbs, 0, sizeof(hcbs));
     hcbs.heap_iteration_callback = NULL;
     hcbs.heap_reference_callback = &HeapReferenceCallback;
-    hcbs.primitive_field_callback = &PrimitiveFieldCallback;
-    hcbs.array_primitive_value_callback = &ArrayPrimitiveValueCallback;
-    hcbs.string_primitive_value_callback = &StringPrimitiveValueCallback;
+    hcbs.primitive_field_callback = NULL;
+    hcbs.array_primitive_value_callback = NULL;
+    hcbs.string_primitive_value_callback = NULL;
 
     for(int i = 0; i < refTypesCount;i++) {
          jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
@@ -818,38 +876,57 @@
         // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
 #ifndef NDEBUG
         if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
-            JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0));
+            char* signature = 0;
+            JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0));
             JvmtiAutoFree afcs(signature);
-            JDWP_TRACE_DATA("SourceDebugExtension: received: refTypeID=" << jvmClass
-                << ", classSignature=" << JDWP_CHECK_NULL(signature));
+            JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "InstanceCounts: received: refTypeID=%p, classSignature=%s", jvmClass, JDWP_CHECK_NULL(signature)));
         }
 #endif
         
         //It initiates a traversal over the objects that are directly and indirectly reachable from the heap roots.
-        JVMTI_TRACE(err, GetJvmtiEnv()->FollowReferences(0, jvmClass,  NULL,
+        JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->FollowReferences(0, jvmClass,  NULL,
              &hcbs, &tag_value));
         if (err != JVMTI_ERROR_NONE) {
             // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_INVALID_CLASS
             // JVMTI_ERROR_INVALID_OBJECT, JVMTI_ERROR_NULL_POINTER 
-            throw AgentException(err);
+            AgentException e(err);
+		    JDWP_SET_EXCEPTION(e);
+            return err;
         }
 
+        jobject *pResultObjects = 0;
+
         // Return the instances that have been marked expected tag_value tag.
-        JVMTI_TRACE(err, GetJvmtiEnv()->GetObjectsWithTags(1, tags, &reachableInstancesNum,
-            NULL, NULL));
+        JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->GetObjectsWithTags(1, tags, &reachableInstancesNum,
+            &pResultObjects, NULL));
+		JvmtiAutoFree afResultObjects(pResultObjects);
   
         if (err != JVMTI_ERROR_NONE) {
             // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_ILLEGAL_ARGUMENT 
             // JVMTI_ERROR_ILLEGAL_ARGUMENT, JVMTI_ERROR_NULL_POINTER  
-            throw AgentException(err);
+            AgentException e(err);
+		    JDWP_SET_EXCEPTION(e);
+            return err;
         }
 
         m_cmdParser->reply.WriteLong(reachableInstancesNum);
-        JDWP_TRACE_DATA("InstanceCounts: return the number of instances for the corresponding  reference type:"
-            << reachableInstancesNum);
+        JDWP_TRACE(LOG_RELEASE, (LOG_DATA_FL, "InstanceCounts: return the number of instances for the corresponding  reference type:%d",
+                        reachableInstancesNum));
+	   //Set objects tags back to 0 
+       for(int i = 0; i < reachableInstancesNum; i++) {
+          JVMTI_TRACE(LOG_DEBUG, err, GetJvmtiEnv()->SetTag(pResultObjects[i], 0));
+          jni->DeleteLocalRef(pResultObjects[i]);
+          if (err != JVMTI_ERROR_NONE) {
+              AgentException e(err);
+	          JDWP_SET_EXCEPTION(e);
+              return err;
+          }
+        }
         // tag_value is changed to indicate instances of other types 
         tags[0] = ++tag_value;
     }
+
+    return JDWP_ERROR_NONE;
 }
 
 //-----------------------------------------------------------------------------

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/VirtualMachine.h Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Vitaly A. Provodin
- * @version $Revision: 1.6.2.1 $
- */
-
 /**
  * @file
  * VirtualMachine.h
@@ -54,7 +48,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };
 
@@ -71,11 +65,11 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         private:
             bool IsSignatureMatch(jclass klass, const char *signature)
-                throw(AgentException);
+                ;
 
         };//ClassesBySignatureHandler
 
@@ -92,7 +86,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
             /**
              * If the passed class (klass parameter) has status
@@ -109,8 +103,7 @@
              * @return 0 on success,
              *         1 otherwise.
              */
-            virtual int Compose41Class(JNIEnv *jni, jvmtiEnv* jvmti, jclass klass)
-                                            throw (AgentException);
+            virtual int Compose41Class(JNIEnv *jni, jvmtiEnv* jvmti, jclass klass);
 
         };//AllClassesHandler
 
@@ -127,7 +120,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//AllThreadsHandler
 
@@ -144,7 +137,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//TopLevelThreadGroupsHandler
 
@@ -161,7 +154,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//DisposeHandler
 
@@ -178,7 +171,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//IDSizesHandler
 
@@ -195,7 +188,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//SuspendHandler
 
@@ -212,7 +205,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//ResumeHandler
 
@@ -229,7 +222,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//ExitHandler
 
@@ -246,7 +239,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//CreateStringHandler
 
@@ -263,7 +256,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//CapabilitiesHandler
 
@@ -280,11 +273,11 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         private:
             void WritePathStrings(char *str, char pathSeparator)
-                throw(AgentException);
+                ;
 
         };//ClassPathsHandler
 
@@ -301,7 +294,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//DisposeObjectsHandler
 
@@ -318,7 +311,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//HoldEventsHandler
 
@@ -335,7 +328,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//ReleaseEventsHandler
 
@@ -352,7 +345,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//CapabilitiesNewHandler
 
@@ -369,7 +362,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//RedefineClassesHandler
 
@@ -386,7 +379,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//SetDefaultStratumHandler
 
@@ -412,8 +405,7 @@
              * @return 0 on success,
              *         1 otherwise.
              */
-            virtual int Compose41Class(JNIEnv *jni, jvmtiEnv* jvmti, jclass klass)
-                                            throw (AgentException);
+            virtual int Compose41Class(JNIEnv *jni, jvmtiEnv* jvmti, jclass klass);
 
         };//AllClassesWithGenericHandler
 
@@ -431,7 +423,7 @@
              *
              * @param jni - the JNI interface pointer
              */
-            virtual void Execute(JNIEnv *jni) throw(AgentException);
+            virtual int Execute(JNIEnv *jni) ;
 
         };//InstanceCountsHandler
     } // VirtualMachine



Mime
View raw message