harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r794726 [14/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/nativ...
Date Thu, 16 Jul 2009 15:57:41 GMT
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.cpp
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.cpp
Thu Jul 16 15:57:37 2009
@@ -16,16 +16,13 @@
  *  limitations under the License.
  */
 
-/**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.14 $
- */
-// TransportManager.cpp
-//
-
-#include <string.h>
+#ifndef USING_VMI
+#define USING_VMI
 
 #include "TransportManager.h"
+#include "ExceptionManager.h"
+
+#include <string.h>
 
 using namespace jdwp;
 
@@ -57,35 +54,52 @@
     m_isServer = true;
     m_lastErrorMessage = 0;
     m_isConnected = false;
+    m_isCleaned = false;
 } //TransportManager::TransportManager()
 
 TransportManager::~TransportManager()
 {
+#if defined(WIN32) || defined(WIN64)
+    if (m_sendMonitor !=0) {
+        delete m_sendMonitor;
+        m_sendMonitor = 0;
+    }
+#endif
     if (m_address != 0) {
         GetMemoryManager().Free(m_address JDWP_FILE_LINE);
     }
     if (m_loadedLib != 0) {
-        jdwpTransport_UnLoad_Type UnloadFunc = reinterpret_cast<jdwpTransport_UnLoad_Type>
-                (GetProcAddress(m_loadedLib, unLoadDecFuncName)); 
+	    PORT_ACCESS_FROM_JAVAVM(GetJavaVM()); 
+        jdwpTransport_UnLoad_Type UnloadFunc = 0;
+		UDATA ret = hysl_lookup_name(m_loadedLib, (const char*) unLoadDecFuncName, (UDATA*) &UnloadFunc,
"VL");
+        if (ret != 0) {
+	        ret = hysl_lookup_name(m_loadedLib, "jdwpTransport_UnLoad", (UDATA*) &UnloadFunc,
"VL");
+        }
+	    //	reinterpret_cast<jdwpTransport_UnLoad_Type>
+        //        (GetProcAddress(m_loadedLib, unLoadDecFuncName)); 
         if ((UnloadFunc != 0) && (m_env != 0)) {
             (UnloadFunc) (&m_env); 
-        }
-        FreeLibrary(m_loadedLib); 
+		}
+		hysl_close_shared_library (m_loadedLib);
     }
 } //TransportManager::~TransportManager()
 
-void 
+int 
 TransportManager::Init(const char* transportName, 
-                const char* libPath) throw(TransportException)
+                const char* libPath)
 {
-    JDWP_TRACE_ENTRY("Init(" << JDWP_CHECK_NULL(transportName) << ',' <<
JDWP_CHECK_NULL(libPath) << ')');
+    JDWP_CHECK_NULL(transportName);
+    JDWP_CHECK_NULL(libPath);
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "Init(%s,%s)", transportName, libPath));
 
-    JDWP_TRACE_PROG("Init: transport=" << JDWP_CHECK_NULL(transportName )
-        << ", libPath=" << JDWP_CHECK_NULL(libPath));
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Init: transport=%s, libPath=%s", transportName,
libPath));
 
     JDWP_ASSERT(m_loadedLib == 0);
+    PORT_ACCESS_FROM_JAVAVM(GetJavaVM());
     m_isConnected = false;
-
+#if defined(WIN32) || defined(WIN64)
+    m_sendMonitor = new AgentMonitor("_jdwp_send_waitMonitor");
+#endif
     m_transportName = transportName;
     const char* begin = libPath;
     do {
@@ -117,13 +131,19 @@
         }
         size_t length = strlen("Loading of  failed") + strlen(transportName) + 1;
         m_lastErrorMessage = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
-        sprintf(m_lastErrorMessage, "Loading of %s failed", transportName);
-        JDWP_ERROR("Loading of " << transportName << " failed");
-        throw TransportException(JDWP_ERROR_TRANSPORT_LOAD, JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+        hystr_printf(privatePortLibrary, m_lastErrorMessage, (U_32)length, "Loading of %s
failed", transportName);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, m_lastErrorMessage));
+        AgentException ex(JDWP_ERROR_TRANSPORT_LOAD,
+						   JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_TRANSPORT_LOAD;
     }
 
-    jdwpTransport_OnLoad_t transportOnLoad = reinterpret_cast<jdwpTransport_OnLoad_t>
-            (GetProcAddress(m_loadedLib, onLoadDecFuncName));
+    jdwpTransport_OnLoad_t transportOnLoad;
+    UDATA ret = hysl_lookup_name(m_loadedLib, (char*) onLoadDecFuncName, (UDATA*) &transportOnLoad,
"ILLIL");
+    if (ret != 0) {
+	ret = hysl_lookup_name(m_loadedLib, "jdwpTransport_OnLoad", (UDATA*) &transportOnLoad,
"ILLIL");
+    }
     if (transportOnLoad == 0) {
         if (m_lastErrorMessage != 0) {
             GetMemoryManager().Free(m_lastErrorMessage JDWP_FILE_LINE);
@@ -131,10 +151,14 @@
         size_t length = strlen(" function not found in ") + strlen(transportName)
             + strlen(onLoadDecFuncName) + 1;
         m_lastErrorMessage = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
-        sprintf(m_lastErrorMessage, "%s function not found in %s", onLoadDecFuncName, transportName);
-        JDWP_ERROR(onLoadDecFuncName << " function not found in " << transportName);
-        throw TransportException(JDWP_ERROR_TRANSPORT_INIT, JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+        hystr_printf(privatePortLibrary, m_lastErrorMessage, (U_32)length, "%s function not
found in %s", onLoadDecFuncName, transportName);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, m_lastErrorMessage));
+        AgentException ex(JDWP_ERROR_TRANSPORT_INIT,
+						   JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_TRANSPORT_INIT;
     }
+ 
     jint res = (*transportOnLoad)(GetJavaVM(), &callback, JDWPTRANSPORT_VERSION_1_0,
&m_env);
     if (res == JNI_ENOMEM) {
         if (m_lastErrorMessage != 0) {
@@ -142,17 +166,22 @@
         }
         size_t length = strlen("Out of memory");
         m_lastErrorMessage = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
-        sprintf(m_lastErrorMessage, "Out of memeory");
-        throw TransportException(JDWP_ERROR_OUT_OF_MEMORY);
+        hystr_printf(privatePortLibrary, m_lastErrorMessage, (U_32)length, "Out of memeory");
+        AgentException ex(JDWP_ERROR_OUT_OF_MEMORY);
+    	JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_OUT_OF_MEMORY;
     } else if (res != JNI_OK) {
         if (m_lastErrorMessage != 0) {
             GetMemoryManager().Free(m_lastErrorMessage JDWP_FILE_LINE);
         }
         size_t length = strlen("Invoking of  failed") + strlen(onLoadDecFuncName) + 1;
         m_lastErrorMessage = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
-        sprintf(m_lastErrorMessage, "Invoking of %s failed", onLoadDecFuncName);
-        JDWP_ERROR("Invoking of " << onLoadDecFuncName << " failed");
-        throw TransportException(JDWP_ERROR_TRANSPORT_INIT, JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+        hystr_printf(privatePortLibrary, m_lastErrorMessage, (U_32)length, "Invoking of %s
failed", onLoadDecFuncName);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, m_lastErrorMessage));
+        AgentException ex(JDWP_ERROR_TRANSPORT_INIT,
+						   JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_TRANSPORT_INIT;
     }
     if (m_env == 0) {
         if (m_lastErrorMessage != 0) {
@@ -160,24 +189,26 @@
         }
         size_t length = strlen("Transport provided invalid environment");
         m_lastErrorMessage = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
-        sprintf(m_lastErrorMessage, "Transport provided invalid environment");
-        JDWP_ERROR("Transport provided invalid environment");
-        throw TransportException(JDWP_ERROR_TRANSPORT_INIT, JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+        hystr_printf(privatePortLibrary, m_lastErrorMessage, (U_32)length, "Transport provided
invalid environment");
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, m_lastErrorMessage));
+        AgentException ex(JDWP_ERROR_TRANSPORT_INIT,
+						   JDWPTRANSPORT_ERROR_NONE, m_lastErrorMessage);
+    	JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_TRANSPORT_INIT;
     }
 
+    return JDWP_ERROR_NONE;
 } // TransportManager::Init()
 
-void 
+int 
 TransportManager::PrepareConnection(const char* address, bool isServer, 
-                jlong connectTimeout, jlong handshakeTimeout) throw(TransportException)
+                jlong connectTimeout, jlong handshakeTimeout)
 {
-    JDWP_TRACE_ENTRY("PrepareConnection(" << JDWP_CHECK_NULL(address) << ','
<< isServer 
-        << ',' << connectTimeout << ',' << handshakeTimeout <<
')');
+    JDWP_CHECK_NULL(address);
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "PrepareConnection(%s,%s,%lld,%lld)", address,
(isServer?"TRUE":"FALSE"), connectTimeout, handshakeTimeout));
     
-    JDWP_TRACE_PROG("PrepareConnection: address=" << JDWP_CHECK_NULL(address) 
-        << " connectTimeout=" << connectTimeout 
-        << " handshakeTimeout=" << handshakeTimeout 
-        << " isServer=" << isServer);
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "PrepareConnection: address=%s isServer=%s connectTimeout=%lld
handshakeTimeout=%lld",
+                    address, (isServer?"TRUE":"FALSE"), connectTimeout, handshakeTimeout));
 
     JDWP_ASSERT((m_loadedLib != 0) && (!m_ConnectionPrepared));
 
@@ -189,22 +220,37 @@
 
     JDWPTransportCapabilities capabilities;
     jdwpTransportError err = m_env->GetCapabilities(&capabilities);
-    CheckReturnStatus(err);
-    if ((connectTimeout != 0) && isServer && (!capabilities.can_timeout_accept))
{
-        JDWP_INFO("Warning: transport does not support accept timeout");
+    if (err != JDWPTRANSPORT_ERROR_NONE) {
+        return CheckReturnStatus(err);
+    }
+
+    /*
+	if ((connectTimeout != 0) && isServer && (!capabilities.can_timeout_accept))
{
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Warning: transport does not support accept
timeout"));
     }
     if ((connectTimeout != 0) && (!isServer) && (!capabilities.can_timeout_attach))
{
-        JDWP_INFO("Warning: transport does not support attach timeout");
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Warning: transport does not support attach
timeout"));
     }
     if ((handshakeTimeout != 0) && (!capabilities.can_timeout_handshake)) {
-        JDWP_INFO("Warning: transport does not support handshake timeout");
+        JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Warning: transport does not support handshake
timeout"));
+    }
+	*/
+
+	// only print error message when all of handshake, accept and attach timeout can not be
used.
+    if ((handshakeTimeout != 0) && (!capabilities.can_timeout_handshake) &&
(connectTimeout != 0)) {
+        if ((isServer && (!capabilities.can_timeout_accept)) || ((!isServer) &&
(!capabilities.can_timeout_attach))) {
+            JDWP_TRACE(LOG_RELEASE, (LOG_INFO_FL, "Warning: transport does not support timeouts"));
+        }
     }
 
     if (isServer) {
         err = m_env->StartListening(address, &m_address); 
-        CheckReturnStatus(err);
-        JDWP_INFO("transport is listening on " << m_address);
-        JDWP_TRACE_PROG("PrepareConnection: listening on " << m_address);
+        if (err != JDWPTRANSPORT_ERROR_NONE) {
+            return CheckReturnStatus(err);
+        }
+
+        JDWP_TRACE(LOG_RELEASE, (LOG_SIMPLE_FL, "Listening for transport %s at address: %s",
m_transportName, m_address));
+        JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "PrepareConnection: listening on %s", m_address));
     } else {
         m_address = static_cast<char *>(GetMemoryManager().Allocate(strlen(address)
+ 1 JDWP_FILE_LINE));
         strcpy(m_address, address);
@@ -212,84 +258,145 @@
 
     m_ConnectionPrepared = true;
 
+    return JDWP_ERROR_NONE;
 } // TransportManager::PrepareConnection()
 
-void 
-TransportManager::Connect() throw(TransportException)
+int 
+TransportManager::Connect()
 {
     if (m_isConnected) {
-        return;
+        return JDWP_ERROR_NONE;
     }
 
-    JDWP_TRACE_PROG("Connect: isServer=" << m_isServer);
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Connect: isServer=%s", (m_isServer?"TRUE":"FALSE")));
     JDWP_ASSERT(m_ConnectionPrepared);
     jdwpTransportError err;
     if (m_isServer) {
-        err = m_env->Accept(m_connectTimeout, m_handshakeTimeout);
-        CheckReturnStatus(err);
+        if (strcmp("dt_shmem", m_transportName)) {
+            err = m_env->Accept(m_connectTimeout, m_handshakeTimeout);
+            if (err != JDWPTRANSPORT_ERROR_NONE) {
+                return CheckReturnStatus(err);
+            }
+        } else {
+            /*
+             * Work around: because Accept can't be interrupted by StopListening
+             * when use "dt_shmem", we use loop instead of blocking at Accept
+             */
+            jlong timeout = 100;
+            jlong total = m_connectTimeout;
+            while (m_connectTimeout == 0 || total > 0) {
+                if (m_isCleaned) {
+                    AgentException ex(JDWP_ERROR_TRANSPORT_INIT, JDWPTRANSPORT_ERROR_NONE,
"Connection failed");
+                    JDWP_SET_EXCEPTION(ex);
+                    return JDWP_ERROR_TRANSPORT_INIT;
+                }
+
+                err = m_env->Accept(timeout, m_handshakeTimeout);
+
+                if (err == JDWPTRANSPORT_ERROR_NONE) {
+                    break;
+                }
+
+                if (err != JDWPTRANSPORT_ERROR_TIMEOUT) {
+                    return CheckReturnStatus(err);
+                }
+
+                total -= timeout;
+            }
+            if (err != JDWPTRANSPORT_ERROR_NONE) {
+                return CheckReturnStatus(err);
+            }
+        }
     } else {
         err = m_env->Attach(m_address, m_connectTimeout, m_handshakeTimeout);
-        CheckReturnStatus(err);
+        if (err != JDWPTRANSPORT_ERROR_NONE) {
+            return CheckReturnStatus(err);
+        }
     }
     m_isConnected = true;
-    JDWP_TRACE_PROG("Connect: connection established");
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Connect: connection established"));
+    return JDWP_ERROR_NONE;
 } // TransportManager::Connect()
 
-void 
-TransportManager::Launch(const char* command) throw(AgentException)
+int 
+TransportManager::Launch(const char* command)
 {
-    JDWP_TRACE_PROG("Launch: " << JDWP_CHECK_NULL(command));
+    JDWP_CHECK_NULL(command);
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Launch: %s", command));
     JDWP_ASSERT(m_ConnectionPrepared);
     const char* extra_argv[2];
     extra_argv[0] = m_transportName;
     extra_argv[1] = m_address;
-    StartDebugger(command, 2, extra_argv);
-    Connect();
+    int ret = StartDebugger(command, 2, extra_argv);
+    JDWP_CHECK_RETURN(ret);
+    ret = Connect();
+    return ret;
 } // TransportManager::Launch()
 
-void 
-TransportManager::Read(jdwpPacket* packet) throw(TransportException)
+int 
+TransportManager::Read(jdwpPacket* packet)
 {
     JDWP_ASSERT(m_ConnectionPrepared);
-    JDWP_TRACE_PACKET("read packet");
+    JDWP_TRACE(LOG_RELEASE, (LOG_PACKET_FL, "read packet"));
     jdwpTransportError err = m_env->ReadPacket(packet);
-    CheckReturnStatus(err);
+    if (err != JDWPTRANSPORT_ERROR_NONE) {
+        return CheckReturnStatus(err);
+    }
     TracePacket("rcvt", packet);
+    return JDWP_ERROR_NONE;
 } // TransportManager::Read()
 
-void 
-TransportManager::Write(const jdwpPacket *packet) throw(TransportException)
+int 
+TransportManager::Write(const jdwpPacket *packet)
 {
     JDWP_ASSERT(m_ConnectionPrepared);
-    JDWP_TRACE_PACKET("send packet");
-    jdwpTransportError err = m_env->WritePacket(packet);
-    CheckReturnStatus(err);
+    JDWP_TRACE(LOG_RELEASE, (LOG_PACKET_FL, "send packet"));
+    jdwpTransportError err;
+#if defined(WIN32) || defined(WIN64)
+    // work around: prevent different threads from sending data at the same time.
+    // This enables Harmony jdwp to work with RI dt_shmem.dll
+    {
+    MonitorAutoLock lock(m_sendMonitor JDWP_FILE_LINE);
+#endif
+    err = m_env->WritePacket(packet);
+#if defined(WIN32) || defined(WIN64)
+    }
+#endif
+    if (err != JDWPTRANSPORT_ERROR_NONE) {
+        return CheckReturnStatus(err);
+    }
     TracePacket("sent", packet);
+    return JDWP_ERROR_NONE;
 } // TransportManager::Write()
 
-void 
-TransportManager::Reset() throw(TransportException)
+int 
+TransportManager::Reset()
 {
-    JDWP_TRACE_PROG("Reset: close connection");
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Reset: close connection"));
     if(m_env != 0) {
         JDWP_ASSERT(m_ConnectionPrepared);
         jdwpTransportError err = m_env->Close();
-        CheckReturnStatus(err);
+        if (err != JDWPTRANSPORT_ERROR_NONE) {
+            return CheckReturnStatus(err);
+        }
     }
     m_isConnected = false;
-    JDWP_TRACE_PROG("Reset: connection closed");
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Reset: connection closed"));
+    return JDWP_ERROR_NONE;
 } // TransportManager::Reset()
 
 
 void 
-TransportManager::Clean() throw(TransportException)
+TransportManager::Clean()
 {
-    JDWP_TRACE_PROG("Clean: close connection and stop listening");
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Clean: close connection and stop listening"));
     if (m_env != 0) {
         m_env->Close();
         m_env->StopListening();
     }
-    JDWP_TRACE_PROG("Clean: connection closed and listening stopped");
+
+    m_isCleaned = true;
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "Clean: connection closed and listening stopped"));
 } // TransportManager::Clean()
 
 bool 
@@ -307,7 +414,7 @@
 } // TransportManager::IsOpen()
 
 char* 
-TransportManager::GetLastTransportError() throw(TransportException)
+TransportManager::GetLastTransportError()
 {
     char* lastErrorMessage = 0;
     if (m_lastErrorMessage != 0) {
@@ -317,39 +424,86 @@
         JDWP_ASSERT(m_env != 0);
         m_env->GetLastError(&lastErrorMessage);
     }
-    JDWP_TRACE_PROG("GetLastTransportError: " << JDWP_CHECK_NULL(lastErrorMessage));
+    JDWP_CHECK_NULL(lastErrorMessage);
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "GetLastTransportError: %s", lastErrorMessage));
     return lastErrorMessage;
 } // TransportManager::GetLastTransportError()
 
-void 
-TransportManager::CheckReturnStatus(jdwpTransportError err) throw(TransportException)
+/**
+ * Returns JDWP_ERROR_NONE if there is no error, an error value 
+ * otherwise 
+ */
+int
+TransportManager::CheckReturnStatus(jdwpTransportError err)
 {
-    if (err == JDWPTRANSPORT_ERROR_NONE) {
-        return;
-    }
     if (err == JDWPTRANSPORT_ERROR_OUT_OF_MEMORY) {
-        throw TransportException(JDWP_ERROR_OUT_OF_MEMORY, JDWPTRANSPORT_ERROR_OUT_OF_MEMORY);
+        AgentException ex(JDWP_ERROR_OUT_OF_MEMORY, JDWPTRANSPORT_ERROR_OUT_OF_MEMORY);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_OUT_OF_MEMORY;
     }
     char* lastErrorMessage = GetLastTransportError();
-    // AgentBase::GetMemoryManager().Free(lastErrorMessage JDWP_FILE_LINE);
-    throw TransportException(JDWP_ERROR_TRANSPORT_INIT, err, lastErrorMessage);
+    AgentException ex(JDWP_ERROR_TRANSPORT_INIT, err, lastErrorMessage);
+    JDWP_SET_EXCEPTION(ex);
+    return JDWP_ERROR_TRANSPORT_INIT;
 } // TransportManager::CheckReturnStatus()
 
 inline void 
 TransportManager::TracePacket(const char* message, const jdwpPacket* packet) 
 { 
     if (packet->type.cmd.flags & JDWPTRANSPORT_FLAGS_REPLY) { 
-        JDWP_TRACE_PACKET(message 
-                <<" length=" << packet->type.cmd.len 
-                << " Id=" << packet->type.cmd.id 
-                << " flag=REPLY" 
-                << " errorCode=" << (short)(packet->type.reply.errorCode));
+        JDWP_TRACE(LOG_RELEASE, (LOG_PACKET_FL, "%s length=%d id=%d flag=REPLY errorCode=%d",
+                          message, packet->type.cmd.len, packet->type.cmd.id, (short)(packet->type.reply.errorCode)));
     } else { 
-        JDWP_TRACE_PACKET(message 
-                <<" length=" << packet->type.cmd.len 
-                << " Id=" << packet->type.cmd.id 
-                << " flag=NONE"
-                << " cmdSet=" << (int)(packet->type.cmd.cmdSet) 
-                << " cmd=" << (int)(packet->type.cmd.cmd)); 
+        JDWP_TRACE(LOG_RELEASE, (LOG_PACKET_FL, "%s length=%d id=%d flag=NONE cmdSet=%d cmd=%d",
+                          message, packet->type.cmd.len, packet->type.cmd.id, (int)(packet->type.cmd.cmdSet),
(int)(packet->type.cmd.cmd)));
+
     } 
 } // TransportManager::TracePacket()
+
+LoadedLibraryHandler TransportManager::LoadTransport(const char* dirName, const char* transportName)
+{
+//    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(GetJavaVM());
+
+    JDWP_CHECK_NULL(dirName); JDWP_CHECK_NULL(transportName);
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "LoadTransport(%s,%s)", dirName, transportName));
+
+    JDWP_ASSERT(transportName != 0);
+    char* transportFullName = 0;
+
+#ifdef WIN32
+    if (dirName == 0) {
+        size_t length = strlen(transportName) + 5;
+        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
+        hystr_printf(privatePortLibrary, transportFullName, (U_32)length, "%s.dll", transportName);
+    } else {
+        size_t length = strlen(dirName) + strlen(transportName) + 6;
+        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
+        hystr_printf(privatePortLibrary, transportFullName, (U_32)length, "%s\\%s.dll", dirName,
transportName);
+    }
+#else
+    if (dirName == 0) {
+        size_t length = strlen(transportName) + 7;
+        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
+        hystr_printf(privatePortLibrary, transportFullName, length, "lib%s.so", transportName);
+    } else {
+        size_t length = strlen(dirName) + strlen(transportName) + 8;
+        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length
JDWP_FILE_LINE));
+        hystr_printf(privatePortLibrary, transportFullName, length, "%s/lib%s.so", dirName,
transportName);
+    }
+#endif
+//    AgentAutoFree afv(transportFullName JDWP_FILE_LINE);
+    UDATA res;
+    UDATA ret = hysl_open_shared_library(transportFullName,&res, FALSE);
+
+    if (ret != 0) {
+	JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "LoadTransport: loading library %s failed: %s)", transportFullName,
hyerror_last_error_message()));
+        //JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "LoadTransport: loading library " <<
transportFullName << " failed (error code: " << GetLastTransportError() <<
")"));
+        res = 0;
+    } else {
+        JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "LoadTransport: transport library %s loaded",
transportFullName));
+    }
+    return (LoadedLibraryHandler)res;
+}
+
+#endif

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.h
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/TransportManager.h
Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.10.2.1 $
- */
-
 /**
  * @file
  * TransportManager.h
@@ -30,14 +24,21 @@
 #ifndef _TRANSPORT_MANAGER_H_
 #define _TRANSPORT_MANAGER_H_
 
+
+#include "TransportManager_pd.h"
 #include "jdwpTransport.h"
 #include "AgentBase.h"
 #include "AgentException.h"
 #include "Log.h"
-#include "TransportManager_pd.h"
+#include "AgentMonitor.h"
+#include "vmi.h"
+#include "hythread.h"
+#include "hyport.h"
 
 namespace jdwp {
 
+typedef UDATA LoadedLibraryHandler;
+
     /**
      * The given class provides a high level interface with the JDWP transport.
      * At first the function Init() must be invoked. It loads and
@@ -68,8 +69,8 @@
          * @exception TransportException() - transport initialization
          *            error happens.
          */
-        void Init(const char* transportName, 
-                const char* libPath) throw(TransportException);
+        int Init(const char* transportName, 
+                const char* libPath);
 
         /**
          * Connection preparation. If the agent is server, then starts listening.
@@ -84,8 +85,8 @@
          *
          * @exception TransportException() - transport error happens.
          */
-        void PrepareConnection(const char* address, bool isServer, 
-                jlong connectTimeout, jlong handshakeTimeout) throw(TransportException);
+        int PrepareConnection(const char* address, bool isServer, 
+                jlong connectTimeout, jlong handshakeTimeout);
         
         /**
          * Establish connection with the debugger.
@@ -93,7 +94,7 @@
          *
          * @exception TransportException() - transport error happens.
          */
-        void Connect() throw(TransportException);
+        int Connect();
         
         /**
          * Launch the debugger and establish connection.
@@ -102,7 +103,7 @@
          *
          * @exception AgentException() - any error happens.
          */
-        void Launch(const char* command) throw(AgentException);
+        int Launch(const char* command);
         
         /**
          * The given function does a blocking read on an open connection.
@@ -112,7 +113,7 @@
          *
          * @exception TransportException() - transport error happens.
          */
-        void Read(jdwpPacket* packet) throw(TransportException);
+        int Read(jdwpPacket* packet);
         
         /**
          * Writes a JDWP packet to an open connection.
@@ -122,16 +123,16 @@
          * @exception TransportException() - transport error 
          *            happens.
          */
-        void Write(const jdwpPacket *packet) throw(TransportException);
+        int Write(const jdwpPacket *packet);
         
         /**
          * Close an open connection. The connection may be established again.
          * 
          * @exception TransportException() - transport error happens.
          */
-        void Reset() throw(TransportException);
+        int Reset();
 
-        void Clean() throw(TransportException);
+        void Clean();
         
         /**
          * Check the connection.
@@ -145,7 +146,7 @@
          *
          * @exception TransportException() - transport error happens.
          */
-        char* GetLastTransportError() throw(TransportException);
+        char* GetLastTransportError();
 
     protected:
 
@@ -155,14 +156,17 @@
         bool m_ConnectionPrepared;               // if true PrepareConnection done
         bool m_isConnected;                      // true if connection is established
         bool m_isServer;                         // is jdwp agent server or not
+        bool m_isCleaned;                        // is clean method is invoked
         const char* m_transportName;             // transport name
         char* m_address;                         // transport address
         jdwpTransportEnv* m_env;                 // jdwpTransport environment
         LoadedLibraryHandler m_loadedLib;        // transport library handler
         char* m_lastErrorMessage;                // last error message
-
-        void CheckReturnStatus(jdwpTransportError err) throw(TransportException);
-        void StartDebugger(const char* command, int extra_argc, const char* extra_argv[])
throw(AgentException);
+#if defined(WIN32) || defined(WIN64)
+	AgentMonitor* m_sendMonitor;
+#endif
+        int CheckReturnStatus(jdwpTransportError err);
+        int StartDebugger(const char* command, int extra_argc, const char* extra_argv[]);
         void TracePacket(const char* message, const jdwpPacket* packet);
         LoadedLibraryHandler LoadTransport(const char* dirName, const char* transportName);
 

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Util.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Util.h?rev=794726&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Util.h
(added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Util.h
Thu Jul 16 15:57:37 2009
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+/**
+ * @file
+ * Util.h
+ *
+ * Add some util classes to replace C++ STL
+ */
+
+#ifndef _UTIL_H_
+#define _UTIL_H_
+#define JDWP_DEFAULT_VECTOR_SIZE 32
+
+#include "stdlib.h"
+#include "string.h"
+#include "jni.h"
+#include "PacketParser.h"
+
+namespace jdwp{
+     // element in queue
+     template <class U>
+     struct Element {
+         U* element;
+         Element* previous;
+         Element* next;
+     };
+
+     // A queue/deque class for jdwp use
+     class JDWPQueue {
+         private:
+         Element<EventComposer>* header;
+         Element<EventComposer>* tail;
+         jint queuesize;
+
+         public:
+
+         /**
+          * A constructor.
+          * Creates a new instance.
+          *
+          */
+         JDWPQueue(){
+            header = NULL;
+            tail = NULL;
+            queuesize = 0;
+         }
+
+         /**
+          * A destructor.
+          * Destroys the given instance.
+         */
+         ~JDWPQueue(){
+            clear();
+         }
+
+         void clear(){
+             Element<EventComposer>* delp, * walkp = header;
+             while((delp = walkp) != NULL){
+                walkp = walkp->next;
+                free(delp);
+             }
+	     header = tail = NULL;
+             queuesize = 0;
+         }
+
+         bool empty(){
+             return queuesize == 0;
+         }
+
+         EventComposer* front(){
+            if (header != NULL){
+                 return header->element;
+            }
+            return NULL;
+         }
+
+         void pop(){
+             Element<EventComposer>* ret = header;
+             if (queuesize > 0){
+                header = header->next;
+                if (header != NULL){
+                    header->previous = NULL;
+                } else {
+		    // the list is empty, the tail is null as the header 
+                    tail = NULL;
+		}
+                queuesize--;
+		free(ret);
+             }
+         }
+
+         jint size(){
+             return queuesize;
+         }
+
+         void push(EventComposer* ec){
+             Element<EventComposer>* newElement = (Element<EventComposer>*)malloc(sizeof(Element<EventComposer>));
+             newElement->element = ec;
+             newElement->next = NULL;
+
+             if (tail == NULL){
+                // header should be null as well    
+                tail = header = newElement;
+                header->previous = NULL;
+             } else {
+                newElement->previous = tail;
+                tail->next = newElement;
+                tail = newElement;
+	     }
+             queuesize ++;
+         }
+     };
+
+     // a simple jdwp vector, replace the standard lib one.
+     // WARNING: only for current JDWP using now, no guarantee its correctness for new functions.
+     template <class T>
+     class JDWPVector {
+
+         private:
+         T** elements;
+         jint vectorsize;
+	 jint vectorcount;
+	
+         public:
+         // a simple jdwp vector iterator, replace the standard lib one.
+         // WARNING: only for current JDWP using now, no guarantee its correctness for new
functions.
+	 // WARNING: it do not check the synchronization of its vector
+	 class iterator{
+		 private:
+                        int currentIndex;
+			JDWPVector* vector;
+	         public:
+			iterator(JDWPVector* const jvector){
+                                 vector = jvector;
+                                 currentIndex = 0;
+			}
+
+			T* getNext(){
+				if (currentIndex < vector->vectorcount){
+				        T* ret = vector->getIndexof(currentIndex);
+					currentIndex ++;
+					return ret;
+				}
+				return NULL;
+			}
+
+			bool hasNext(){
+				if (currentIndex < vector->vectorcount){
+					return true;
+				}
+				// Tricky here: make hasCurrent correct here.
+				// In iterator search, we call hasNext before getNext
+				// however, if check hasNext is false, we should set 
+				// hasCurrent to false to show we've searched the whole iterator
+				currentIndex++;
+				return false;
+			}
+
+			// Note: c++ iterator is different from java vection, it can take current element
+			// again and again, in this case we can check if we have a current element, then
+			// use getCurrent()
+			bool hasCurrent(){
+                                return (currentIndex >0 && currentIndex <=
vector->vectorcount);
+			}
+
+			T* getCurrent(){
+				return vector->getIndexof(currentIndex -1);
+			}
+
+			jint getIndex(){
+				return currentIndex - 1;
+			}
+
+			// avoid a compiler error, reset this iterator
+			void reset(){
+				currentIndex = 0;
+			}
+
+			// do not move pointer
+			void remove(){
+				vector->remove(currentIndex - 1);
+				backwards();
+			}
+
+			// step back
+			// Warning: no check here, for inner use only
+			void backwards(){
+				currentIndex --;
+			}
+
+	 };
+
+         /**
+          * A constructor.
+          * Creates a new instance.
+          *
+          */
+         JDWPVector(){
+	    // default size
+            vectorsize = JDWP_DEFAULT_VECTOR_SIZE;
+            vectorcount = 0;
+            elements = (T**) malloc(sizeof(T*)*vectorsize);
+         }
+
+         /**
+          * A destructor.
+          * Destroys the given instance.
+         */
+         ~JDWPVector(){
+             free(elements);
+             vectorsize = 0;
+             vectorcount = 0;
+         }
+
+	 // WARNING: no check if the slot is empty
+	 void insert(int index, T* in){
+            //T* newElement = (T*)malloc(sizeof(T));
+            //memcpy(newElement,in,sizeof(T));
+	    elements[index] = in;
+	 }
+
+	 // learn from  c++ vector, clear a slot but do not delete
+	 void insertNULL(int index){
+            elements[index] = NULL;
+	 }
+
+	 T* getIndexof(int index){
+	    return elements[index];
+	 }
+
+         void clear(){
+	     free(elements);
+             vectorsize = JDWP_DEFAULT_VECTOR_SIZE;
+             vectorcount = 0;
+             elements = (T**) malloc(sizeof(T*)*vectorsize);
+         }
+
+        bool empty(){
+             return vectorcount == 0;
+        }
+
+	T* back(){
+	     return getIndexof(vectorcount-1);
+	}
+
+	iterator begin(){
+	     return iterator(this);
+	}
+
+        jint size(){
+            return vectorcount;
+        }
+
+        void push_back(T* ec){
+           //T* newElement = (T*)malloc(sizeof(T));
+           //memcpy(newElement,ec,sizeof(T));
+           if (vectorcount >= vectorsize*0.75){
+		// vector is full, extends the vector
+                vectorsize = vectorsize << 1;
+                T** newelements = (T**) malloc(sizeof(T *)*vectorsize);
+		for (jint i = 0; i < vectorcount; i++){
+                    newelements[i] = elements[i];
+                }
+	        free(elements);
+		elements = newelements;
+           }
+           elements[vectorcount] = ec;
+           vectorcount++;
+        }
+
+	void pop_back(){
+		remove(vectorcount-1);
+	}
+
+	 // delete an vector element related to the iterator current element
+	void erase(iterator iter){
+	     jint eraseIndex = iter.getIndex();
+             remove(eraseIndex);
+        }
+
+	void remove(int eraseIndex){
+             if ((vectorcount<<2) < vectorsize && vectorsize > JDWP_DEFAULT_VECTOR_SIZE){
+		    // vector has too small elements, compact the vector
+		    vectorsize = vectorsize >> 1;
+                    T** newelements = (T**) malloc(sizeof(T *)*vectorsize);
+                    jint i = 0;
+		    for (; i < eraseIndex; i++){
+                        newelements[i] = elements[i];
+                    }
+		    for (; i < vectorcount - 1; i++){
+                        newelements[i] = elements[i+1];
+                    }
+	            free(elements);
+		    elements = newelements;
+	     } else {
+		    for (jint i = eraseIndex ; i < vectorcount - 1; i++){
+                        elements[i] = elements[i+1];
+                    }
+	     }
+             vectorcount--;
+	 }
+     };
+}
+#endif //_UTIL_H_

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/Util.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/jdwpTypes.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/jdwpTypes.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/jdwpTypes.h
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/jdwpTypes.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 Pavel N. Vyssotski
- * @version $Revision: 1.7.2.1 $
- */
-
 /**
  * @file
  * jdwpTypes.h
@@ -33,9 +27,6 @@
 #include "jni.h"
 #include "jdwp.h"
 
-// Defined to parse bytes order for x86 platform
-#define IS_BIG_ENDIAN_PLATFORM 1
-
 namespace jdwp {
 
     typedef jlong FieldID;

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
Thu Jul 16 15:57:37 2009
@@ -32,7 +32,7 @@
 
 /* JDWP Version */
 #define JDWP_VERSION_MAJOR 1
-#define JDWP_VERSION_MINOR 5
+#define JDWP_VERSION_MINOR 6
 
 /* General JDWP constants */
 #define JDWP_FLAG_REPLY_PACKET ((jbyte)0x80)

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.cpp
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.cpp
Thu Jul 16 15:57:37 2009
@@ -16,18 +16,41 @@
  *  limitations under the License.
  */
 
-/**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.6 $
- */
+#ifndef USING_VMI
+#define USING_VMI
+#endif
+
 #include "LastTransportError.h"
+#include "hyport.h"
+#include "vmi.h"
+#include "hythread.h"
+
+#include <string.h>
 
 void (*LastTransportError::m_free)(void *buffer) = 0;
 
-LastTransportError::LastTransportError(const char* messagePtr, int errorStatus, 
+static inline ThreadId_t
+_GetCurrentThreadId(JavaVM *jvm)
+{
+    ThreadId_t tid;
+#ifdef HY_NO_THR
+    THREAD_ACCESS_FROM_JAVAVM(jvm);
+#endif /* HY_NO_THR */
+    hythread_attach(&tid);
+    return tid;
+} // GetCurrentThreadId()
+
+
+static inline bool ThreadId_equal(ThreadId_t treadId1, ThreadId_t treadId2)
+{
+    return (treadId1 == treadId2);
+} // ThreadId_equal()
+
+LastTransportError::LastTransportError(JavaVM *jvm, const char* messagePtr, int errorStatus,

         void* (*alloc)(jint numBytes), void (*free)(void *buffer))
 {
-    m_treadId = GetCurrentThreadId();
+    m_jvm = jvm;
+    m_treadId = _GetCurrentThreadId(m_jvm);
     m_lastErrorMessage = messagePtr;
     m_lastErrorMessagePrefix = "";
     m_lastErrorStatus = errorStatus;
@@ -65,14 +88,15 @@
 jdwpTransportError
 LastTransportError::insertError(const char* messagePtr, int errorStatus)
 {
-    if (ThreadId_equal(m_treadId, GetCurrentThreadId())) {
+
+    if (ThreadId_equal(m_treadId, _GetCurrentThreadId(m_jvm))) {
         m_lastErrorMessage = messagePtr;
         m_lastErrorStatus = errorStatus;
         m_lastErrorMessagePrefix = "";
     } else if (m_next != 0) {
         return m_next->insertError(messagePtr, errorStatus);
     } else {
-        m_next = new(m_alloc, m_free) LastTransportError(messagePtr, errorStatus, m_alloc,
m_free);
+        m_next = new(m_alloc, m_free) LastTransportError(m_jvm, messagePtr, errorStatus,
m_alloc, m_free);
         if (m_next == 0) {
             return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY;
         }
@@ -83,7 +107,7 @@
 jdwpTransportError 
 LastTransportError::addErrorMessagePrefix(const char* prefixPtr)
 {
-    if (ThreadId_equal(m_treadId, GetCurrentThreadId())) {
+    if (ThreadId_equal(m_treadId, _GetCurrentThreadId(m_jvm))) {
         m_lastErrorMessagePrefix = (prefixPtr == 0 ? "" : prefixPtr);
     } else if (m_next != 0) {
         return m_next->addErrorMessagePrefix(prefixPtr);
@@ -94,7 +118,7 @@
 int 
 LastTransportError::GetLastErrorStatus()
 {
-    if (ThreadId_equal(m_treadId, GetCurrentThreadId())) {
+    if (ThreadId_equal(m_treadId, _GetCurrentThreadId(m_jvm))) {
         return m_lastErrorStatus;
     } else if (m_next != 0) {
         return m_next->GetLastErrorStatus();
@@ -105,9 +129,11 @@
 char* 
 LastTransportError::GetLastErrorMessage() 
 {
-    if (ThreadId_equal(m_treadId, GetCurrentThreadId())) {
+    PORT_ACCESS_FROM_JAVAVM(m_jvm);
+
+    if (ThreadId_equal(m_treadId, _GetCurrentThreadId(m_jvm))) {
         char buf[32];
-        sprintf(buf, "%d", m_lastErrorStatus);
+        hystr_printf(privatePortLibrary, buf, 32, "%d", m_lastErrorStatus);
 
         size_t strLength = (m_lastErrorStatus == 0) ? 
             strlen(m_lastErrorMessagePrefix) + strlen(m_lastErrorMessage) + 1 :
@@ -119,9 +145,9 @@
         }
 
         if (m_lastErrorStatus == 0) {
-            sprintf(message, "%s%s", m_lastErrorMessagePrefix, m_lastErrorMessage);
+            hystr_printf(privatePortLibrary, message, (U_32)strLength, "%s%s", m_lastErrorMessagePrefix,
m_lastErrorMessage);
         } else {
-            sprintf(message, "%s%s (error code: %s)", m_lastErrorMessagePrefix, m_lastErrorMessage,
buf);
+            hystr_printf(privatePortLibrary, message, (U_32)strLength, "%s%s (error code:
%s)", m_lastErrorMessagePrefix, m_lastErrorMessage, buf);
         }
         return message;
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.h
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/common/LastTransportError.h
Thu Jul 16 15:57:37 2009
@@ -15,12 +15,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.9.2.1 $
- */
-
 /**
  * @file
  * LastTransportError.h
@@ -29,9 +23,15 @@
 
 #ifndef _LASTTRANSPORTERROR_H
 #define _LASTTRANSPORTERROR_H
-
+#if defined(ZOS)
+#define _XOPEN_SOURCE  500
+#endif
+
+#include "jni.h"
+#include "jvmti.h"
+#include "hythread.h"
 #include "jdwpTransport.h"
-#include "LastTransportError_pd.h"
+typedef hythread_t ThreadId_t;
 
 /**
  * The given class is a container for message and status code of the last 
@@ -51,7 +51,7 @@
      * @param free        - the pointer to the function deallocating the memory 
      *                      area 
      */
-    LastTransportError(const char* messagePtr, int errorStatus, 
+    LastTransportError(JavaVM *jvm, const char* messagePtr, int errorStatus, 
         void* (*alloc)(jint numBytes), void (*free)(void *buffer));
 
     /**
@@ -103,6 +103,7 @@
     void operator delete(void* address, void* (*alloc)(jint numBytes), void (*free)(void
*buffer));
 
 private:
+    JavaVM *m_jvm;
     ThreadId_t m_treadId;             // the thread Id
     const char* m_lastErrorMessage;   // diagnostics for the last failed operation 
     const char* m_lastErrorMessagePrefix;   // diagnostics prefix for the last failed operation
 



Mime
View raw message