harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r794726 [15/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/transport/dt_socket/SocketTransport.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/dt_socket/SocketTransport.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/dt_socket/SocketTransport.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/dt_socket/SocketTransport.cpp Thu Jul 16 15:57:37 2009
@@ -17,18 +17,160 @@
  */
 
 /**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.13 $
- */
-// SocketTransport.cpp
-//
-
-/**
  * This is implementation of JDWP Agent TCP/IP Socket transport.
  * Main module.
  */
 
+#ifndef USING_VMI
+#define USING_VMI
+#endif
+
+#if defined(ZOS)
+#define _XOPEN_SOURCE  500
+#include <unistd.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
 #include "SocketTransport_pd.h"
+#include "hysocket.h"
+#include "hysock.h"
+
+#define READ_BUFFER_SIZE 32
+#define WRITE_BUFFER_SIZE 64
+
+static jbyte read_buffer[READ_BUFFER_SIZE];
+static char write_buffer[WRITE_BUFFER_SIZE];
+
+/**
+ * Returns the error status for the last failed operation. 
+ */
+static int
+GetLastErrorStatus(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    PORT_ACCESS_FROM_JAVAVM(ienv->jvm);
+    return hyerror_last_error_number();
+} // GetLastErrorStatus
+
+/**
+ * Retrieves the number of milliseconds, substitute for the corresponding Win32 
+ * function.
+ */
+static long 
+GetTickCount(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    PORT_ACCESS_FROM_JAVAVM(ienv->jvm);
+    return (long)hytime_current_time_millis();
+} // GetTickCount
+
+/**
+ * Initializes critical section lock objects.
+ */
+static inline void
+InitializeCriticalSections(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    JavaVM *vm = ienv->jvm;
+#ifdef HY_NO_THR
+    THREAD_ACCESS_FROM_JAVAVM(vm);
+#endif /* HY_NO_THR */
+    hythread_attach(NULL);
+
+    UDATA flags = 0;
+    if (hythread_monitor_init(&(ienv->readLock), 1) != 0) {
+        printf("initial error\n");
+    }
+
+    if (hythread_monitor_init(&(ienv->sendLock), 1) != 0) {
+        printf("initial error\n");
+    }
+    
+} //InitializeCriticalSections()
+
+/**
+ * Releases all resources used by critical-section lock objects.
+ */
+static inline void
+DeleteCriticalSections(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    JavaVM *vm = ienv->jvm;
+#ifdef HY_NO_THR
+    THREAD_ACCESS_FROM_JAVAVM(vm);
+#endif /* HY_NO_THR */
+
+    hythread_attach(NULL);
+    hythread_monitor_destroy(ienv->readLock);
+    hythread_monitor_destroy(ienv->sendLock);
+} //DeleteCriticalSections()
+
+/**
+ * Waits for ownership of the send critical-section object.
+ */
+static inline void
+EnterCriticalSendSection(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    JavaVM *vm = ienv->jvm;
+#ifdef HY_NO_THR
+    THREAD_ACCESS_FROM_JAVAVM(vm);
+#endif /* HY_NO_THR */
+
+    hythread_attach(NULL);
+    hythread_monitor_enter(ienv->sendLock);
+} //EnterCriticalSendSection()
+
+/**
+ * Waits for ownership of the read critical-section object.
+ */
+static inline void
+EnterCriticalReadSection(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    JavaVM *vm = ienv->jvm;
+#ifdef HY_NO_THR
+    THREAD_ACCESS_FROM_JAVAVM(vm);
+#endif /* HY_NO_THR */
+
+    hythread_attach(NULL);
+    hythread_monitor_enter(ienv->readLock);
+} //EnterCriticalReadSection()
+
+/**
+ * Releases ownership of the read critical-section object.
+ */
+static inline void
+LeaveCriticalReadSection(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    JavaVM *vm = ienv->jvm;
+#ifdef HY_NO_THR
+    THREAD_ACCESS_FROM_JAVAVM(vm);
+#endif /* HY_NO_THR */
+
+    hythread_attach(NULL);
+    hythread_monitor_exit(ienv->readLock);
+} //LeaveCriticalReadSection()
+
+/**
+ * Releases ownership of the send critical-section object.
+ */
+static inline void
+LeaveCriticalSendSection(jdwpTransportEnv* env)
+{
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    JavaVM *vm = ienv->jvm;
+#ifdef HY_NO_THR
+    THREAD_ACCESS_FROM_JAVAVM(vm);
+#endif /* HY_NO_THR */
+
+    hythread_attach(NULL);
+    hythread_monitor_exit(ienv->sendLock);
+} //LeaveCriticalSendSection()
+
 
 /**
  * This function sets into internalEnv struct message and status code of last transport error
@@ -40,7 +182,7 @@
     if (ienv->lastError != 0) {
         ienv->lastError->insertError(messagePtr, errorStatus);
     } else {
-        ienv->lastError = new(ienv->alloc, ienv->free) LastTransportError(messagePtr, errorStatus, ienv->alloc, ienv->free);
+        ienv->lastError = new(ienv->alloc, ienv->free) LastTransportError(ienv->jvm, messagePtr, errorStatus, ienv->alloc, ienv->free);
     }
     return;
 } // SetLastTranError
@@ -62,35 +204,49 @@
 /**
  * The timeout used for invocation of select function in SelectRead and SelectSend methods
  */
-static const jint cycle = 1000; // wait cycle in milliseconds 
+static const jint select_timeout = 5000; // wait cycle in milliseconds 
+
+/**
+ * This function enable/disables socket blocking mode 
+ */
+static bool 
+SetSocketBlockingMode(jdwpTransportEnv* env, hysocket_t sckt, bool isBlocked)
+{
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
+    jint ret = hysock_set_nonblocking(sckt, isBlocked ? FALSE : TRUE);
+    if (ret != 0){
+	SetLastTranError(env, "socket error", GetLastErrorStatus(env));
+        return false;
+    }
+    return true;
+
+} // SetSocketBlockingMode()
 
 /**
  * This function is used to determine the read status of socket (in terms of select function).
  * The function avoids absolutely blocking select
  */
 static jdwpTransportError 
-SelectRead(jdwpTransportEnv* env, SOCKET sckt, jlong deadline = 0) {
+SelectRead(jdwpTransportEnv* env, hysocket_t sckt, jlong deadline = 0) {
+    internalEnv* ienv = (internalEnv*)env->functions->reserved1;
+    PORT_ACCESS_FROM_JAVAVM(ienv->jvm);
 
-    jlong currentTimeout = cycle;
-    while ((deadline == 0) || ((currentTimeout = (deadline - GetTickCount())) > 0)) {
-        currentTimeout = currentTimeout < cycle ? currentTimeout : cycle;
-        TIMEVAL tv = {(long)(currentTimeout / 1000), (long)(currentTimeout % 1000)};
-        fd_set fdread;
-        FD_ZERO(&fdread);
-        FD_SET(sckt, &fdread);
-
-        int ret = select((int)sckt + 1, &fdread, NULL, NULL, &tv);
-        if (ret == SOCKET_ERROR) {
-            int err = GetLastErrorStatus();
-            // ignore signal interruption
-            if (err != SOCKET_ERROR_EINTR) {
-                SetLastTranError(env, "socket error", err);
-                return JDWPTRANSPORT_ERROR_IO_ERROR;
-            }
-        }
-        if ((ret > 0) && (FD_ISSET(sckt, &fdread))) {
-            return JDWPTRANSPORT_ERROR_NONE; //timeout is not occurred
-        }
+    if (deadline < 0)
+        return JDWPTRANSPORT_ERROR_NONE;
+
+    // default to 5s but don't allow anything less than 1s
+    deadline =
+      deadline == 0 ? select_timeout : (deadline < 1000 ? 1000 : deadline);
+    jint ret = hysock_select_read(sckt, (I_32) deadline / 1000 , (I_32) deadline % 1000, FALSE);
+    if (ret == 1){
+        return JDWPTRANSPORT_ERROR_NONE; //timeout is not occurred
+    }
+    if (ret != HYPORT_ERROR_SOCKET_TIMEOUT){
+        SetLastTranError(env, "socket error", ret);
+
+        return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
     SetLastTranError(env, "timeout occurred", 0);
     return JDWPTRANSPORT_ERROR_TIMEOUT; //timeout occurred
@@ -101,60 +257,75 @@
  * The function avoids absolutely blocking select
  */
 static jdwpTransportError 
-SelectSend(jdwpTransportEnv* env, SOCKET sckt, jlong deadline = 0) {
+SelectSend(jdwpTransportEnv* env, hysocket_t sckt, jlong deadline = 0) {
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
 
-    jlong currentTimeout = cycle;
-    while ((deadline == 0) || ((currentTimeout = (deadline - GetTickCount())) > 0)) {
-        currentTimeout = currentTimeout < cycle ? currentTimeout : cycle;
-        TIMEVAL tv = {(long)(currentTimeout / 1000), (long)(currentTimeout % 1000)};
-        fd_set fdwrite;
-        FD_ZERO(&fdwrite);
-        FD_SET(sckt, &fdwrite);
-
-        int ret = select((int)sckt + 1, NULL, &fdwrite, NULL, &tv);
-        if (ret == SOCKET_ERROR) {
-            int err = GetLastErrorStatus();
-            // ignore signal interruption
-            if (err != SOCKET_ERROR_EINTR) {
-                SetLastTranError(env, "socket error", err);
-                return JDWPTRANSPORT_ERROR_IO_ERROR;
-            }
-        }
-        if ((ret > 0) && (FD_ISSET(sckt, &fdwrite))) {
-            return JDWPTRANSPORT_ERROR_NONE; //timeout is not occurred
-        }
+    hyfdset_struct hyfdSet;
+    deadline = deadline == 0 ? 20000 : deadline;
+    
+    I_32 secTime = (long)(deadline / 1000);
+    I_32 uTime = (long)(deadline % 1000);
+
+    hytimeval_struct timeval;
+
+    hysock_fdset_zero(&hyfdSet);
+    hysock_fdset_set(sckt,&hyfdSet);
+
+    int ret = hysock_timeval_init(secTime,uTime,&timeval);
+
+    ret =  hysock_select(hysock_fdset_size(sckt),NULL,&hyfdSet,NULL,&timeval);
+
+    if (ret > 0){
+        return JDWPTRANSPORT_ERROR_NONE; //timeout has not occurred
+    }
+    if (ret != HYPORT_ERROR_SOCKET_TIMEOUT){
+    	 SetLastTranError(env, "socket error", ret);
+         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
     SetLastTranError(env, "timeout occurred", 0);
     return JDWPTRANSPORT_ERROR_TIMEOUT; //timeout occurred
-} // SelectRead
+} // SelectSend
 
 /**
  * This function sends data on a connected socket
  */
 static jdwpTransportError
-SendData(jdwpTransportEnv* env, SOCKET sckt, const char* data, int dataLength, jlong deadline = 0)
+SendData(jdwpTransportEnv* env, hysocket_t sckt, const char* data, int dataLength, jlong deadline = 0)
 {
     long left = dataLength;
     long off = 0;
     int ret;
 
-    while (left > 0) {
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
+    // Check if block
+    while (left > 0){
+#ifndef ZOS	    
         jdwpTransportError err = SelectSend(env, sckt, deadline);
         if (err != JDWPTRANSPORT_ERROR_NONE) {
             return err;
         }
-        ret = send(sckt, (data + off), left, 0);
-        if (ret == SOCKET_ERROR) {
-            int err = GetLastErrorStatus();
-            // ignore signal interruption
-            if (err != SOCKET_ERROR_EINTR) {
-                SetLastTranError(env, "socket error", err);
-                return JDWPTRANSPORT_ERROR_IO_ERROR;
-            }
+#endif
+#ifdef ZOS
+	if (!SetSocketBlockingMode(env, sckt, true)) {
+            return JDWPTRANSPORT_ERROR_IO_ERROR;
         }
-        left -= ret;
-        off += ret;
-    } //while
+#endif	
+	ret = hysock_write (sckt, (U_8 *)data+off, left, HYSOCK_NOFLAGS);
+#ifdef ZOS
+	if (!SetSocketBlockingMode(env, sckt, false)) {
+            return JDWPTRANSPORT_ERROR_IO_ERROR;
+        }
+#endif	
+	if (ret < 0){
+                SetLastTranError(env, "socket error", ret);
+                return JDWPTRANSPORT_ERROR_IO_ERROR; 
+	}
+	left -= ret;
+	off += ret;
+    }    
     return JDWPTRANSPORT_ERROR_NONE;
 } //SendData
 
@@ -162,8 +333,11 @@
  * This function receives data from a connected socket
  */
 static jdwpTransportError
-ReceiveData(jdwpTransportEnv* env, SOCKET sckt, char* buffer, int dataLength, jlong deadline = 0, int* readByte = 0)
+ReceiveData(jdwpTransportEnv* env, hysocket_t sckt, U_8 * buffer, int dataLength, jlong deadline = 0, int* readByte = 0)
 {
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
     long left = dataLength;
     long off = 0;
     int ret;
@@ -171,23 +345,26 @@
     if (readByte != 0) {
         *readByte = 0;
     }
-
     while (left > 0) {
         jdwpTransportError err = SelectRead(env, sckt, deadline);
         if (err != JDWPTRANSPORT_ERROR_NONE) {
             return err;
         }
-        ret = recv(sckt, (buffer + off), left, 0);
-        if (ret == SOCKET_ERROR) {
-            int err = GetLastErrorStatus();
-            // ignore signal interruption
-            if (err != SOCKET_ERROR_EINTR) {
-                SetLastTranError(env, "data receiving failed", err);
-                return JDWPTRANSPORT_ERROR_IO_ERROR;
-            }
+
+	if (!SetSocketBlockingMode(env, sckt, true)) {
+            return JDWPTRANSPORT_ERROR_IO_ERROR;
+    }
+ 	ret = hysock_read(sckt, (U_8 *) (buffer + off), left, HYSOCK_NOFLAGS);
+	if (!SetSocketBlockingMode(env, sckt, false)) {
+            return JDWPTRANSPORT_ERROR_IO_ERROR;
+    }
+
+        if (ret < 0) {
+            SetLastTranError(env, "data receiving failed", ret);
+            return JDWPTRANSPORT_ERROR_IO_ERROR;
         }
         if (ret == 0) {
-            SetLastTranError(env, "premature EOF", 0);
+            SetLastTranError(env, "premature EOF", HYSOCK_NOFLAGS);
             return JDWPTRANSPORT_ERROR_IO_ERROR;
         }
         left -= ret;
@@ -196,52 +373,38 @@
             *readByte = off;
         }
     } //while
-    return JDWPTRANSPORT_ERROR_NONE;
-} // ReceiveData
 
-/**
- * This function enable/disables socket blocking mode 
- */
-static bool 
-SetSocketBlockingMode(jdwpTransportEnv* env, SOCKET sckt, bool isBlocked)
-{
-    unsigned long ul = isBlocked ? 0 : 1;
-    if (ioctlsocket(sckt, FIONBIO, &ul) == SOCKET_ERROR) {
-        SetLastTranError(env, "socket error", GetLastErrorStatus());
-        return false;
-    }
-    return true;
-} // SetSocketBlockingMode()
+    return JDWPTRANSPORT_ERROR_NONE;   
+} // ReceiveData
 
 /**
  * This function performes handshake procedure
  */
 static jdwpTransportError 
-CheckHandshaking(jdwpTransportEnv* env, SOCKET sckt, jlong handshakeTimeout)
+CheckHandshaking(jdwpTransportEnv* env, hysocket_t sckt, jlong handshakeTimeout)
 {
     const char* handshakeString = "JDWP-Handshake";
-    char receivedString[14]; //length of "JDWP-Handshake"
-
-    jlong deadline = (handshakeTimeout == 0) ? 0 : (jlong)GetTickCount() + handshakeTimeout;
+    U_8 receivedString[14]; //length of "JDWP-Handshake"
+    jlong timeout = handshakeTimeout == 0 ? 30000 : handshakeTimeout;
 
     jdwpTransportError err;
-    err = SendData(env, sckt, handshakeString, (int)strlen(handshakeString), deadline);
+    err = SendData(env, sckt, handshakeString, (int)strlen(handshakeString), handshakeTimeout);
     if (err != JDWPTRANSPORT_ERROR_NONE) {
         SetLastTranErrorMessagePrefix(env, "'JDWP-Handshake' sending error: ");
         return err;
     }
-
-    err = ReceiveData(env, sckt, receivedString, (int)strlen(handshakeString), deadline);
+ 
+    err = ReceiveData(env, sckt, receivedString, (int)strlen(handshakeString),
+                      timeout);
+ 
     if (err != JDWPTRANSPORT_ERROR_NONE) {
         SetLastTranErrorMessagePrefix(env, "'JDWP-Handshake' receiving error: ");
         return err;
     }
-
     if (memcmp(receivedString, handshakeString, 14) != 0) {
         SetLastTranError(env, "handshake error, 'JDWP-Handshake' is not received", 0);
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
-
     return JDWPTRANSPORT_ERROR_NONE;
 }// CheckHandshaking
 
@@ -249,44 +412,60 @@
  * This function decodes address and populates sockaddr_in structure
  */
 static jdwpTransportError
-DecodeAddress(jdwpTransportEnv* env, const char *address, struct sockaddr_in *sa, bool isServer) 
+DecodeAddress(jdwpTransportEnv* env, const char *address, hysockaddr_t sa, bool isServer) 
 {
-    memset(sa, 0, sizeof(struct sockaddr_in));
-    sa->sin_family = AF_INET;
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+    const char * localhost = "127.0.0.1";
+    const char * anyhost = "0.0.0.0";
 
     if ((address == 0) || (*address == 0)) {  //empty address
-        sa->sin_addr.s_addr = isServer ? htonl(INADDR_ANY) : inet_addr("127.0.0.1");
-        sa->sin_port = 0;
+        hysock_sockaddr(sa,  isServer ? anyhost : localhost, 0);
         return JDWPTRANSPORT_ERROR_NONE;
     }
 
-    const char* colon = strchr(address, ':');
+    char *finalAddress = (char*)(((internalEnv*)env->functions->reserved1)->alloc)((jint)strlen(address)+1);
+    if (finalAddress == 0) {
+        SetLastTranError(env, "out of memory", 0);
+        return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY;
+    }
+    memcpy(finalAddress, address, strlen(address)+1);
+
+#ifdef ZOS
+    __atoe(finalAddress);
+#endif
+
+#ifdef ZOS
+// Ensure that the ':' is in EBCDIC on zOS platforms
+#pragma convlit(suspend)
+#endif
+    const char* colon = strchr(finalAddress, ':');
+#ifdef ZOS
+#pragma convlit(resume)
+#endif
     if (colon == 0) {  //address is like "port"
-        sa->sin_port = htons((u_short)atoi(address));
-        sa->sin_addr.s_addr = isServer ? htonl(INADDR_ANY) : inet_addr("127.0.0.1");
+        hysock_sockaddr(sa,  isServer ? anyhost : localhost,  hysock_htons((U_16)atoi(finalAddress)));
     } else { //address is like "host:port"
-        sa->sin_port = htons((u_short)atoi(colon + 1));
-
         char *hostName = (char*)(((internalEnv*)env->functions->reserved1)
-            ->alloc)((jint)(colon - address + 1));
+            ->alloc)((jint)(colon - finalAddress + 1));
         if (hostName == 0) {
             SetLastTranError(env, "out of memory", 0);
+            (((internalEnv*)env->functions->reserved1)->free)(finalAddress);
             return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY;
         }
-        memcpy(hostName, address, colon - address);
-        hostName[colon - address] = '\0';
-        sa->sin_addr.s_addr = inet_addr(hostName);
-        if (sa->sin_addr.s_addr == INADDR_NONE) {
-            struct hostent *host = gethostbyname(hostName);
-            if (host == 0) {
+        memcpy(hostName, address, colon - finalAddress); // Use address here, not finalAddress, as we want to keep the string ASCII on zOS
+        hostName[colon - finalAddress] = '\0';
+        int ret = hysock_sockaddr(sa,  hostName, hysock_htons((U_16)atoi(colon + 1)));
+        if (ret != 0){
                 SetLastTranError(env, "unable to resolve host name", 0);
                 (((internalEnv*)env->functions->reserved1)->free)(hostName);
+                (((internalEnv*)env->functions->reserved1)->free)(finalAddress);
                 return JDWPTRANSPORT_ERROR_IO_ERROR;
-            }
-            memcpy(&(sa->sin_addr), host->h_addr_list[0], host->h_length);
-        } //if
+        }
         (((internalEnv*)env->functions->reserved1)->free)(hostName);
     } //if
+    (((internalEnv*)env->functions->reserved1)->free)(finalAddress);
+
     return JDWPTRANSPORT_ERROR_NONE;
 } //DecodeAddress
 
@@ -299,9 +478,8 @@
 {
     memset(capabilitiesPtr, 0, sizeof(JDWPTransportCapabilities));
     capabilitiesPtr->can_timeout_attach = 1;
-    capabilitiesPtr->can_timeout_accept = 1;
+    capabilitiesPtr->can_timeout_accept = 1;       
     capabilitiesPtr->can_timeout_handshake = 1;
-
     return JDWPTRANSPORT_ERROR_NONE;
 } //TCPIPSocketTran_GetCapabilities
 
@@ -310,27 +488,36 @@
  */
 static jdwpTransportError JNICALL 
 TCPIPSocketTran_Close(jdwpTransportEnv* env)
-{
-    SOCKET envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
-    if (envClientSocket == INVALID_SOCKET) {
+{  
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+    hysocket_t envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
+    if (envClientSocket == NULL) {
         return JDWPTRANSPORT_ERROR_NONE;
     }
 
-    ((internalEnv*)env->functions->reserved1)->envClientSocket = INVALID_SOCKET;
+    ((internalEnv*)env->functions->reserved1)->envClientSocket = NULL;
+    if (hysock_socketIsValid(envClientSocket)==0){
+        return JDWPTRANSPORT_ERROR_NONE;
+    }
 
     int err;
-    err = shutdown(envClientSocket, SD_BOTH);
-    if (err == SOCKET_ERROR) {
-        SetLastTranError(env, "close socket failed", GetLastErrorStatus());
-        return JDWPTRANSPORT_ERROR_IO_ERROR;
+    err = hysock_shutdown_input(envClientSocket);
+    if (err == 0){
+	 err = hysock_shutdown_output(envClientSocket);
     }
 
-    err = closesocket(envClientSocket);
-    if (err == SOCKET_ERROR) {
-        SetLastTranError(env, "close socket failed", GetLastErrorStatus());
+    // it seems no necessary to check if the stream is really closed
+    // if (err != 0) {
+    //    SetLastTranError(env, "shutdown socket failed", GetLastErrorStatus(env));
+    //    return JDWPTRANSPORT_ERROR_IO_ERROR;
+    // }
+    
+    err = hysock_close(&envClientSocket);
+    if (err != 0) {
+        SetLastTranError(env, "close socket failed", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
-
     return JDWPTRANSPORT_ERROR_NONE;
 } //TCPIPSocketTran_Close
 
@@ -338,17 +525,24 @@
  * This function sets socket options SO_REUSEADDR and TCP_NODELAY
  */
 static bool 
-SetSocketOptions(jdwpTransportEnv* env, SOCKET sckt) 
+SetSocketOptions(jdwpTransportEnv* env, hysocket_t sckt) 
 {
-    BOOL isOn = TRUE;
-    if (setsockopt(sckt, SOL_SOCKET, SO_REUSEADDR, (const char*)&isOn, sizeof(isOn)) == SOCKET_ERROR) {                                                              
-        SetLastTranError(env, "setsockopt(SO_REUSEADDR) failed", GetLastErrorStatus());
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
+    BOOLEAN isOn = TRUE;
+
+#ifndef ZOS
+    if (hysock_setopt_bool(sckt, HY_SOL_SOCKET, HY_SO_REUSEADDR, &isOn) != 0){
+        SetLastTranError(env, "setsockopt(SO_REUSEADDR) failed", GetLastErrorStatus(env));
         return false;
     }
-    if (setsockopt(sckt, IPPROTO_TCP, TCP_NODELAY, (const char*)&isOn, sizeof(isOn)) == SOCKET_ERROR) {
-        SetLastTranError(env, "setsockopt(TCPNODELAY) failed", GetLastErrorStatus());
+    if (hysock_setopt_bool(sckt, HY_IPPROTO_TCP, HY_TCP_NODELAY,  &isOn) != 0) {
+        SetLastTranError(env, "setsockopt(TCPNODELAY) failed", GetLastErrorStatus(env));
         return false;
     }
+#endif
+
     return true;
 } // SetSocketOptions()
 
@@ -359,6 +553,12 @@
 TCPIPSocketTran_Attach(jdwpTransportEnv* env, const char* address,
         jlong attachTimeout, jlong handshakeTimeout)
 {
+    internalEnv *ienv = (internalEnv*)env->functions->reserved1;
+    PORT_ACCESS_FROM_JAVAVM(ienv->jvm);
+
+    hysocket_t clientSocket;  
+    hysockaddr_struct serverSockAddr;  
+                                   
     if ((address == 0) || (*address == 0)) {
         SetLastTranError(env, "address is missing", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
@@ -374,27 +574,27 @@
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
     }
 
-    SOCKET envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
-    if (envClientSocket != INVALID_SOCKET) {
+    hysocket_t envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
+    if (envClientSocket != NULL) {
         SetLastTranError(env, "there is already an open connection to the debugger", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
-    SOCKET envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
-    if (envServerSocket != INVALID_SOCKET) {
+    hysocket_t envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
+    if (envServerSocket != NULL) {
         SetLastTranError(env, "transport is currently in listen mode", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
-    struct sockaddr_in serverSockAddr;
     jdwpTransportError res = DecodeAddress(env, address, &serverSockAddr, false);
     if (res != JDWPTRANSPORT_ERROR_NONE) {
         return res;
     }
 
-    SOCKET clientSocket = socket(AF_INET, SOCK_STREAM, 0);
-    if (clientSocket == INVALID_SOCKET) {
-        SetLastTranError(env, "unable to create socket", GetLastErrorStatus());
+    int ret = hysock_socket(&clientSocket, HYSOCK_AFINET, HYSOCK_STREAM, HYSOCK_DEFPROTOCOL);
+	   // socket(AF_INET, SOCK_STREAM, 0);
+    if (ret != 0) {
+        SetLastTranError(env, "unable to create socket", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
     
@@ -406,43 +606,34 @@
         if (!SetSocketBlockingMode(env, clientSocket, true)) {
             return JDWPTRANSPORT_ERROR_IO_ERROR;
         }
-        int err = connect(clientSocket, (struct sockaddr *)&serverSockAddr, sizeof(serverSockAddr));
-        if (err == SOCKET_ERROR) {
-            SetLastTranError(env, "connection failed", GetLastErrorStatus());
+        int err = hysock_connect(clientSocket, &serverSockAddr);
+	//int err = connect(clientSocket, (struct sockaddr *)&serverSockAddr, sizeof(serverSockAddr));
+	if (err != 0 ) {
+            SetLastTranError(env, "connection failed", GetLastErrorStatus(env));
             SetSocketBlockingMode(env, clientSocket, false);
             return JDWPTRANSPORT_ERROR_IO_ERROR;
-        }
+        }  
         if (!SetSocketBlockingMode(env, clientSocket, false)) {
             return JDWPTRANSPORT_ERROR_IO_ERROR;
-        }
+	    }
     } else {
-        if (!SetSocketBlockingMode(env, clientSocket, false)) {
+	if (!SetSocketBlockingMode(env, clientSocket, false)) {
             return JDWPTRANSPORT_ERROR_IO_ERROR;
-        }
-        int err = connect(clientSocket, (struct sockaddr *)&serverSockAddr, sizeof(serverSockAddr));
-        if (err == SOCKET_ERROR) {
-            if (GetLastErrorStatus() != SOCKETWOULDBLOCK) {
-                SetLastTranError(env, "connection failed", GetLastErrorStatus());
+	    }
+        int err = hysock_connect(clientSocket, &serverSockAddr);
+        if (err != 0) {
+            //HYPORT_ERROR_SOCKET_EINPROGRESS will be returned when the non-blocking socket would wait for estabish
+            if (err != HYPORT_ERROR_SOCKET_WOULDBLOCK && err != HYPORT_ERROR_SOCKET_EINPROGRESS) {
+                SetLastTranError(env, "connection failed", GetLastErrorStatus(env));
                 return JDWPTRANSPORT_ERROR_IO_ERROR;
-            } else {  
-                fd_set fdwrite;
-                FD_ZERO(&fdwrite);
-                FD_SET(clientSocket, &fdwrite);
-                TIMEVAL tv = {(long)(attachTimeout / 1000), (long)(attachTimeout % 1000)};
-
-                int ret = select((int)clientSocket + 1, NULL, &fdwrite, NULL, &tv);
-                if (ret == SOCKET_ERROR) {
-                    SetLastTranError(env, "socket error", GetLastErrorStatus());
-                    return JDWPTRANSPORT_ERROR_IO_ERROR;
-                }
-                if ((ret != 1) || !(FD_ISSET(clientSocket, &fdwrite))) {
-                    SetLastTranError(env, "timeout occurred", 0);
-                    return JDWPTRANSPORT_ERROR_IO_ERROR;
-                }
+            } else {
+                int ret = SelectSend(env, clientSocket, attachTimeout);
+		if (ret != JDWPTRANSPORT_ERROR_NONE){
+			return JDWPTRANSPORT_ERROR_IO_ERROR;
+		}
             }
         }
     }
-
     EnterCriticalSendSection(env);
     EnterCriticalReadSection(env);
     ((internalEnv*)env->functions->reserved1)->envClientSocket = clientSocket;
@@ -453,7 +644,6 @@
         TCPIPSocketTran_Close(env);
         return res;
     }
-
     return JDWPTRANSPORT_ERROR_NONE;
 } //TCPIPSocketTran_Attach
 
@@ -464,28 +654,32 @@
 TCPIPSocketTran_StartListening(jdwpTransportEnv* env, const char* address, 
         char** actualAddress)
 {
-    SOCKET envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
-    if (envClientSocket != INVALID_SOCKET) {
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
+    hysocket_t envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
+    if (envClientSocket != NULL) {
         SetLastTranError(env, "there is already an open connection to the debugger", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
-    SOCKET envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
-    if (envServerSocket != INVALID_SOCKET) {
+    hysocket_t envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
+    if (envServerSocket != NULL) {
         SetLastTranError(env, "transport is currently in listen mode", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
     jdwpTransportError res;
-    struct sockaddr_in serverSockAddr;
+    hysockaddr_struct serverSockAddr;
     res = DecodeAddress(env, address, &serverSockAddr, true);
     if (res != JDWPTRANSPORT_ERROR_NONE) {
         return res;
     }
 
-    SOCKET serverSocket = socket(AF_INET, SOCK_STREAM, 0);
-    if (serverSocket == INVALID_SOCKET) {
-        SetLastTranError(env, "unable to create socket", GetLastErrorStatus());
+    hysocket_t serverSocket;
+    int ret = hysock_socket(&serverSocket, HYSOCK_AFINET, HYSOCK_STREAM, HYSOCK_DEFPROTOCOL); //socket(AF_INET, SOCK_STREAM, 0);
+    if (ret != 0) {
+        SetLastTranError(env, "unable to create socket", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
 
@@ -495,15 +689,16 @@
 
     int err;
 
-    err = bind(serverSocket, (struct sockaddr *)&serverSockAddr, sizeof(serverSockAddr));
-    if (err == SOCKET_ERROR) {
-        SetLastTranError(env, "binding to port failed", GetLastErrorStatus());
+    err = hysock_bind (serverSocket, &serverSockAddr);
+    // bind(serverSocket, (struct sockaddr *)&serverSockAddr, sizeof(serverSockAddr));
+    if (err != 0 ) {
+        SetLastTranError(env, "binding to port failed", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
-    err = listen(serverSocket, SOMAXCONN);
-    if (err == SOCKET_ERROR) {
-        SetLastTranError(env, "listen start failed", GetLastErrorStatus());
+    err = hysock_listen(serverSocket, 100);
+    if (err != 0) {
+        SetLastTranError(env, "listen start failed", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
@@ -513,41 +708,21 @@
 
     ((internalEnv*)env->functions->reserved1)->envServerSocket = serverSocket;
 
-    socklen_t len = sizeof(serverSockAddr);
-    err = getsockname(serverSocket, (struct sockaddr *)&serverSockAddr, &len);
-    if (err == SOCKET_ERROR) {
-        SetLastTranError(env, "socket error", GetLastErrorStatus());
+    err = hysock_getsockname(serverSocket, &serverSockAddr);
+    if (err != 0) {
+        SetLastTranError(env, "socket error", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
     char* retAddress = 0;
 
-    // RI always returns only port number in listening mode
-/*
-    char portName[6];
-    sprintf(portName, "%d", ntohs(serverSockAddr.sin_port)); //instead of itoa()
-
-    char hostName[NI_MAXHOST];
-    if (getnameinfo((struct sockaddr *)&serverSockAddr, len, hostName, sizeof(hostName), NULL, 0, 0)) {
-        return JDWPTRANSPORT_ERROR_IO_ERROR;
-    }
-    if (strcmp(hostName, "0.0.0.0") == 0) {
-        gethostname(hostName, sizeof(hostName));
-    }
-    retAddress = (char*)(((internalEnv*)env->functions->reserved1)
-        ->alloc)((jint)(strlen(hostName) + strlen(portName) + 2)); 
-    if (retAddress == 0) {
-        SetLastTranError(env, "out of memory", 0);
-        return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY;
-    }
-    sprintf(retAddress, "%s:%s", hostName, portName);
-*/
     retAddress = (char*)(((internalEnv*)env->functions->reserved1)->alloc)(6 + 1); 
     if (retAddress == 0) {
         SetLastTranError(env, "out of memory", 0);
         return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY;
     }
-    sprintf(retAddress, "%d", ntohs(serverSockAddr.sin_port));
+    // print server port
+    hystr_printf(privatePortLibrary, retAddress, 7, "%d",hysock_ntohs(hysock_sockaddr_port(&serverSockAddr)));
 
     *actualAddress = retAddress;
 
@@ -560,18 +735,22 @@
 static jdwpTransportError JNICALL 
 TCPIPSocketTran_StopListening(jdwpTransportEnv* env)
 {
-    SOCKET envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
-    if (envServerSocket == INVALID_SOCKET) {
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
+    hysocket_t envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
+    if (envServerSocket == NULL) {
         return JDWPTRANSPORT_ERROR_NONE;
     }
 
-    if (closesocket(envServerSocket) == SOCKET_ERROR) {
-        SetLastTranError(env, "close socket failed", GetLastErrorStatus());
+    int err = hysock_close(&envServerSocket);
+    ((internalEnv*)env->functions->reserved1)->envServerSocket = NULL;
+    
+    if (err != 0) {
+        SetLastTranError(env, "close socket failed", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
 
-    ((internalEnv*)env->functions->reserved1)->envServerSocket = INVALID_SOCKET;
-
     return JDWPTRANSPORT_ERROR_NONE;
 } //TCPIPSocketTran_StopListening
 
@@ -582,6 +761,9 @@
 TCPIPSocketTran_Accept(jdwpTransportEnv* env, jlong acceptTimeout,
         jlong handshakeTimeout)
 {
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
     if (acceptTimeout < 0) {
         SetLastTranError(env, "acceptTimeout timeout is negative", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
@@ -592,35 +774,43 @@
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
     }
 
-    SOCKET envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
-    if (envClientSocket != INVALID_SOCKET) {
+    hysocket_t envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
+    if (envClientSocket != NULL) {
         SetLastTranError(env, "there is already an open connection to the debugger", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
-    SOCKET envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
-    if (envServerSocket == INVALID_SOCKET) {
+    hysocket_t envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
+    if (envServerSocket == NULL) {
         SetLastTranError(env, "transport is not currently in listen mode", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
     }
 
-    struct sockaddr serverSockAddr;
-    socklen_t len = sizeof(serverSockAddr);
-    int res = getsockname(envServerSocket, &serverSockAddr, &len);
-    if (res == SOCKET_ERROR) {
-        SetLastTranError(env, "connection failed", GetLastErrorStatus());
-        return JDWPTRANSPORT_ERROR_IO_ERROR;
-    }
+    hysockaddr_struct serverSockAddr;
 
-    jlong deadline = (acceptTimeout == 0) ? 0 : (jlong)GetTickCount() + acceptTimeout;
-    jdwpTransportError err = SelectRead(env, envServerSocket, deadline);
-    if (err != JDWPTRANSPORT_ERROR_NONE) {
-        return err;
-    }
+    hysocket_t clientSocket;
+    U_8 nlocalAddrBytes[HYSOCK_INADDR_LEN];
+    I_32 ret = hysock_sockaddr_init6(&serverSockAddr, nlocalAddrBytes, HYSOCK_INADDR_LEN, HYADDR_FAMILY_AFINET4, hysock_sockaddr_port(&serverSockAddr), 0, 0, envServerSocket);
+
+
+#ifndef WIN32
+    // workaround for some platform cannot close a socket blocking on accept
+    do{
+        ret = hysock_select_read(envServerSocket, 1, 0, TRUE);
+        envServerSocket = ((internalEnv*)env->functions->reserved1)->envServerSocket;
+    } while (ret == HYPORT_ERROR_SOCKET_TIMEOUT && envServerSocket != NULL);
+    if (ret != 1){
+        SetLastTranError(env, "socket accept failed or closed", GetLastErrorStatus(env));
+	return JDWPTRANSPORT_ERROR_IO_ERROR;
+    }
+#endif
+
+    SetSocketBlockingMode(env, envServerSocket, true);
+    ret = hysock_accept(envServerSocket, &serverSockAddr, &clientSocket);
+    SetSocketBlockingMode(env, envServerSocket, false);
 
-    SOCKET clientSocket = accept(envServerSocket, &serverSockAddr, &len);
-    if (clientSocket == INVALID_SOCKET) {
-        SetLastTranError(env, "socket accept failed", GetLastErrorStatus());
+    if (ret != 0) {
+        SetLastTranError(env, "socket accept failed", GetLastErrorStatus(env));
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     }
 
@@ -631,15 +821,13 @@
     EnterCriticalSendSection(env);
     EnterCriticalReadSection(env);
     ((internalEnv*)env->functions->reserved1)->envClientSocket = clientSocket;
-
-    err = CheckHandshaking(env, clientSocket, (long)handshakeTimeout);
+    jdwpTransportError err = CheckHandshaking(env, clientSocket, (long)handshakeTimeout);
     LeaveCriticalReadSection(env);
     LeaveCriticalSendSection(env);
     if (err != JDWPTRANSPORT_ERROR_NONE) {
         TCPIPSocketTran_Close(env);
         return err;
     }
-
     return JDWPTRANSPORT_ERROR_NONE;
 } //TCPIPSocketTran_Accept
 
@@ -649,8 +837,8 @@
 static jboolean JNICALL 
 TCPIPSocketTran_IsOpen(jdwpTransportEnv* env)
 {
-    SOCKET envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
-    if (envClientSocket == INVALID_SOCKET) {
+    hysocket_t envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
+    if (envClientSocket == NULL) {
         return JNI_FALSE;
     }
     return JNI_TRUE;
@@ -660,12 +848,15 @@
  * This function read packet
  */
 static jdwpTransportError
-ReadPacket(jdwpTransportEnv* env, SOCKET envClientSocket, jdwpPacket* packet)
+ReadPacket(jdwpTransportEnv* env, hysocket_t envClientSocket, jdwpPacket* packet)
 {
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+
     jdwpTransportError err;
     int length;
     int readBytes = 0;
-    err = ReceiveData(env, envClientSocket, (char *)&length, sizeof(jint), 0, &readBytes);
+    err = ReceiveData(env, envClientSocket, (U_8 *)&length, sizeof(jint), -1, &readBytes);
     if (err != JDWPTRANSPORT_ERROR_NONE) {
         if (readBytes == 0) {
             packet->type.cmd.len = 0;
@@ -673,44 +864,52 @@
         }
         return err;
     }
+    packet->type.cmd.len = (jint)hysock_ntohl(length);
 
-    packet->type.cmd.len = (jint)ntohl(length);
-    
-    int id;
-    err = ReceiveData(env, envClientSocket, (char *)&(id), sizeof(jint));
-    if (err != JDWPTRANSPORT_ERROR_NONE) {
-        return err;
+    bool isUseBuffer = false;
+    jbyte* buffer = 0;
+    if (packet->type.cmd.len - 4 > READ_BUFFER_SIZE) {
+        buffer = (jbyte*)(((internalEnv*)env->functions->reserved1)->alloc)(packet->type.cmd.len - 4);
+        isUseBuffer = false;
+    } else {
+        buffer = read_buffer;
+        isUseBuffer = true;
     }
 
-    packet->type.cmd.id = (jint)ntohl(id);
-
-    err = ReceiveData(env, envClientSocket, (char *)&(packet->type.cmd.flags), sizeof(jbyte));
+    err = ReceiveData(env, envClientSocket, (U_8 *)buffer, packet->type.cmd.len - 4);
     if (err != JDWPTRANSPORT_ERROR_NONE) {
         return err;
     }
 
+    int offset = 0;
+
+    int id;
+    memcpy(&id, buffer + offset, sizeof(jint));
+    offset += sizeof(jint);
+    packet->type.cmd.id = (jint)hysock_ntohl(id);
+
+    memcpy(&(packet->type.cmd.flags), buffer + offset, sizeof(jbyte));
+    offset += sizeof(jbyte);
+
     if (packet->type.cmd.flags & JDWPTRANSPORT_FLAGS_REPLY) {
-        u_short errorCode;
-        err = ReceiveData(env, envClientSocket, (char*)&(errorCode), sizeof(jshort));
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            return err;
-        }
-        packet->type.reply.errorCode = (jshort)ntohs(errorCode); 
+        int errorCode;
+	memcpy(&errorCode, buffer + offset, sizeof(jshort));
+	offset += sizeof(jshort);
+        packet->type.reply.errorCode = (jshort)hysock_ntohs((U_16)errorCode);
     } else {
-        err = ReceiveData(env, envClientSocket, (char*)&(packet->type.cmd.cmdSet), sizeof(jbyte));
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            return err;
-        }
- 
-        err = ReceiveData(env, envClientSocket, (char*)&(packet->type.cmd.cmd), sizeof(jbyte));
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            return err;
-        }
+	memcpy(&(packet->type.cmd.cmdSet), buffer + offset, sizeof(jbyte));
+	offset += sizeof(jbyte);
+
+	memcpy(&(packet->type.cmd.cmd), buffer + offset, sizeof(jbyte));
+	offset += sizeof(jbyte);
     } //if
 
     int dataLength = packet->type.cmd.len - 11;
     if (dataLength < 0) {
         SetLastTranError(env, "invalid packet length received", 0);
+        if (!isUseBuffer) {
+            (((internalEnv*)env->functions->reserved1)->free)(buffer);
+        }
         return JDWPTRANSPORT_ERROR_IO_ERROR;
     } else if (dataLength == 0) {
         packet->type.cmd.data = 0;
@@ -718,14 +917,19 @@
         packet->type.cmd.data = (jbyte*)(((internalEnv*)env->functions->reserved1)->alloc)(dataLength);
         if (packet->type.cmd.data == 0) {
             SetLastTranError(env, "out of memory", 0);
-            return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY;
+        if (!isUseBuffer) {
+            (((internalEnv*)env->functions->reserved1)->free)(buffer);
         }
-        err = ReceiveData(env, envClientSocket, (char *)packet->type.cmd.data, dataLength);
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            (((internalEnv*)env->functions->reserved1)->free)(packet->type.cmd.data);
-            return err;
+            return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY;
         }
+
+	memcpy(packet->type.cmd.data, buffer + offset, dataLength);
+	offset += dataLength;
     } //if
+
+    if (!isUseBuffer) {
+        (((internalEnv*)env->functions->reserved1)->free)(buffer);
+    }
     return JDWPTRANSPORT_ERROR_NONE;
 }
 
@@ -735,13 +939,14 @@
 static jdwpTransportError JNICALL 
 TCPIPSocketTran_ReadPacket(jdwpTransportEnv* env, jdwpPacket* packet)
 {
+    PORT_ACCESS_FROM_JAVAVM(((internalEnv*)env->functions->reserved1)->jvm);
     if (packet == 0) {
         SetLastTranError(env, "packet is 0", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
     }
 
-    SOCKET envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
-    if (envClientSocket == INVALID_SOCKET) {
+    hysocket_t envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
+    if (envClientSocket == NULL) {
         SetLastTranError(env, "there isn't an open connection to a debugger", 0);
         LeaveCriticalReadSection(env);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE ;
@@ -750,16 +955,18 @@
     EnterCriticalReadSection(env);
     jdwpTransportError err = ReadPacket(env, envClientSocket, packet);
     LeaveCriticalReadSection(env);
-    return JDWPTRANSPORT_ERROR_NONE;
+    return err;
 } //TCPIPSocketTran_ReadPacket
 
 /**
  * This function implements jdwpTransportEnv::WritePacket
  */
 static jdwpTransportError 
-WritePacket(jdwpTransportEnv* env, SOCKET envClientSocket, const jdwpPacket* packet)
+WritePacket(jdwpTransportEnv* env, hysocket_t envClientSocket, const jdwpPacket* packet)
 {
-    int packetLength = packet->type.cmd.len;
+    JavaVM *vm = ((internalEnv*)env->functions->reserved1)->jvm;
+    PORT_ACCESS_FROM_JAVAVM(vm);
+    jint packetLength = packet->type.cmd.len;
     if (packetLength < 11) {
         SetLastTranError(env, "invalid packet length", 0);
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
@@ -771,50 +978,60 @@
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
     }
 
-    int dataLength = packetLength - 11;
-    packetLength = htonl(packetLength);
+    jint dataLength = packetLength - 11;
+    bool isUseBuffer = false;
 
-    jdwpTransportError err;
-    err = SendData(env, envClientSocket, (char*)&packetLength, sizeof(jint));
-    if (err != JDWPTRANSPORT_ERROR_NONE) {
-        return err;
+    char* buffer = 0;
+    if (packetLength > WRITE_BUFFER_SIZE) {
+        buffer = (char*)(((internalEnv*)env->functions->reserved1)->alloc)(packet->type.cmd.len);
+        isUseBuffer = false;
+    } else {
+        buffer = write_buffer;
+        isUseBuffer = true;
     }
 
-    int id = htonl(packet->type.cmd.id);
+    int offset = 0;
 
-    err = SendData(env, envClientSocket, (char*)&id, sizeof(jint));
-    if (err != JDWPTRANSPORT_ERROR_NONE) {
-        return err;
-    }
+    packetLength = hysock_htonl(packetLength);
+    memcpy(buffer + offset, &packetLength, sizeof(jint));
+    offset += sizeof(jint);
 
-    err = SendData(env, envClientSocket, (char*)&(packet->type.cmd.flags), sizeof(jbyte));
-    if (err != JDWPTRANSPORT_ERROR_NONE) {
-        return err;
-    }
+    jint id = hysock_htonl (packet->type.cmd.id);
+    memcpy(buffer + offset, &id, sizeof(jint));
+    offset += sizeof(jint);
+
+    memcpy(buffer + offset, &(packet->type.cmd.flags), sizeof(jbyte));
+    offset += sizeof(jbyte);
 
     if (packet->type.cmd.flags & JDWPTRANSPORT_FLAGS_REPLY) {
-        u_short errorCode = htons(packet->type.reply.errorCode);
-        err = SendData(env, envClientSocket, (char*)&errorCode, sizeof(jshort));
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            return err;
-        }
+        U_16 errorCode = hysock_htons((U_16)packet->type.reply.errorCode);
+	memcpy(buffer + offset, &errorCode, sizeof(jshort));
+	offset += sizeof(jshort);
     } else {
-        err = SendData(env, envClientSocket, (char*)&(packet->type.cmd.cmdSet), sizeof(jbyte));
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            return err;
-        }
-        err = SendData(env, envClientSocket, (char*)&(packet->type.cmd.cmd), sizeof(jbyte));
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            return err;
-        }
+	memcpy(buffer + offset, &(packet->type.cmd.cmdSet), sizeof(jbyte));
+	offset += sizeof(jbyte);
+
+	memcpy(buffer + offset, &(packet->type.cmd.cmd), sizeof(jbyte));
+	offset += sizeof(jbyte);
     } //if
     
     if (data != 0) {
-        err = SendData(env, envClientSocket, data, dataLength);
-        if (err != JDWPTRANSPORT_ERROR_NONE) {
-            return err;
-        }
+	memcpy(buffer + offset, data, dataLength);
+	offset += dataLength;
     } //if
+
+    jdwpTransportError err;
+    err = SendData(env, envClientSocket, buffer, packet->type.cmd.len);
+    if (err != JDWPTRANSPORT_ERROR_NONE) {
+        if (!isUseBuffer) {
+            (((internalEnv*)env->functions->reserved1)->free)(buffer);
+        }
+	return err;
+    }
+
+    if (!isUseBuffer) {
+        (((internalEnv*)env->functions->reserved1)->free)(buffer);
+    }
     return JDWPTRANSPORT_ERROR_NONE;
 }
 
@@ -830,10 +1047,10 @@
         return JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT;
     }
 
-    SOCKET envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
-    if (envClientSocket == INVALID_SOCKET) {
+    hysocket_t envClientSocket = ((internalEnv*)env->functions->reserved1)->envClientSocket;
+    if (envClientSocket == NULL) {
         SetLastTranError(env, "there isn't an open connection to a debugger", 0);
-        LeaveCriticalSendSection(env);
+        //LeaveCriticalSendSection(env);
         return JDWPTRANSPORT_ERROR_ILLEGAL_STATE;
     }
 
@@ -850,6 +1067,7 @@
 TCPIPSocketTran_GetLastError(jdwpTransportEnv* env, char** message)
 {
     *message = ((internalEnv*)env->functions->reserved1)->lastError->GetLastErrorMessage();
+
     if (*message == 0) {
         return JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE;
     }
@@ -875,8 +1093,8 @@
     iEnv->alloc = callback->alloc;
     iEnv->free = callback->free;
     iEnv->lastError = 0;
-    iEnv->envClientSocket = INVALID_SOCKET;
-    iEnv->envServerSocket = INVALID_SOCKET;
+    iEnv->envClientSocket = NULL;
+    iEnv->envServerSocket = NULL;
 
     jdwpTransportNativeInterface_* envTNI = (jdwpTransportNativeInterface_*)callback
         ->alloc(sizeof(jdwpTransportNativeInterface_));
@@ -932,3 +1150,4 @@
     unLoadFree((void*)(*env));
 } //jdwpTransport_UnLoad
 
+

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/dt_socket/SocketTransport.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/dt_socket/SocketTransport.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/dt_socket/SocketTransport.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/transport/dt_socket/SocketTransport.h Thu Jul 16 15:57:37 2009
@@ -17,11 +17,6 @@
  */
 
 /**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.5.2.1 $
- */
-
-/**
  * @file
  * SocketTransport.h
  *
@@ -32,6 +27,14 @@
 
 #ifndef _SOCKETTRANSPORT_H
 #define _SOCKETTRANSPORT_H
+#if defined(ZOS)
+#define _XOPEN_SOURCE  500
+#endif
+
+#include "SocketTransport_pd.h"
+#include "hythread.h"
+
+typedef hythread_monitor_t CriticalSection;
 
 struct internalEnv {
     JavaVM *jvm;                    // the JNI invocation interface, provided 
@@ -40,8 +43,8 @@
                                     // provided by the agent 
     void (*free)(void *buffer);     // the function deallocating an area of memory, 
                                     // provided by the agent
-    SOCKET envClientSocket;         // the client socket, INVALID_SOCKET if closed
-    SOCKET envServerSocket;         // the server socket, INVALID_SOCKET if closed
+    hysocket_t envClientSocket;         // the client socket, INVALID_SOCKET if closed
+    hysocket_t envServerSocket;         // the server socket, INVALID_SOCKET if closed
     LastTransportError* lastError;  // last errors
     CriticalSection readLock;       // the critical-section lock object for socket
                                     // read operations

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.cpp Thu Jul 16 15:57:37 2009
@@ -17,23 +17,18 @@
  */
 
 /**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.14 $
- */
-
-// TransportManager_pd.cpp
-//
-
-/**
  * This header file includes platform depended definitions for types, 
  * constants, include statements and functions for Linux platform.
  */
 
 #include <unistd.h>
 #include <errno.h>
+#include <ctype.h>
 #include <string.h>
+#include "vmi.h"
 #include "TransportManager_pd.h"
 #include "TransportManager.h"
+#include "ExceptionManager.h"
 
 using namespace jdwp;
 
@@ -41,9 +36,9 @@
 const char* TransportManager::unLoadDecFuncName = "jdwpTransport_UnLoad";
 const char TransportManager::pathSeparator = ':';
 
-void TransportManager::StartDebugger(const char* command, int extra_argc, const char* extra_argv[]) throw(AgentException)
+int TransportManager::StartDebugger(const char* command, int extra_argc, const char* extra_argv[])
 {
-    JDWP_TRACE_ENTRY("StartDebugger(" << JDWP_CHECK_NULL(command) << ',' << extra_argc << ',' << extra_argv << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "StartDebugger(%s,%d,%p)", JDWP_CHECK_NULL(command), extra_argc, extra_argv));
 
     // allocate array for parsed arguments
 
@@ -58,7 +53,7 @@
     AgentAutoFree afv(cmd JDWP_FILE_LINE);
 
     if (command != 0 && cmd_len > 0) {
-        JDWP_TRACE_PROG("StartDebugger: parse: cmd=" << JDWP_CHECK_NULL(command));
+        JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: parse: cmd=%s", JDWP_CHECK_NULL(command)));
 
         const char *arg = command, *p;
         char *arg1 = cmd, *s;
@@ -91,11 +86,13 @@
                 if (*p == '\0' || isspace(*p)) {
                      *(s++) = '\0';
                      if (argc >= max_argc) {
-                        JDWP_ERROR("Too many arguments for launching debugger proccess: " << argc);
-                        throw AgentException(JDWP_ERROR_INTERNAL);
+                        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Too many arguments for launching debugger proccess: %d", argc));
+                        AgentException ex = AgentException(JDWP_ERROR_INTERNAL);
+                        JDWP_SET_EXCEPTION(ex);
+                        return JDWP_ERROR_INTERNAL;
                      }
                      argv[argc++] = arg1;
-                     JDWP_TRACE_PROG("StartDebugger: launch: arg[" << argc << "]=" << JDWP_CHECK_NULL(arg1));
+                     JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: launch: arg[%d]=%s", argc, JDWP_CHECK_NULL(arg1)));
                      arg = p;
                      arg1 = s;
                      break;
@@ -114,7 +111,7 @@
     int i;
     for (i = 0; i < extra_argc; i++) {
          if (extra_argv[i] != 0) {
-             JDWP_TRACE_PROG("StartDebugger: launch: arg[" << argc << "]=" << JDWP_CHECK_NULL(extra_argv[i]));
+             JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: launch: arg[%d]=%s", argc, JDWP_CHECK_NULL(extra_argv[i])));
              argv[argc++] = const_cast<char*>(extra_argv[i]);
          }
     }
@@ -124,65 +121,19 @@
 
     int pid = fork();
     if (pid == -1) {
-        JDWP_ERROR("Failed to fork debugger process: error=" << errno);
-        throw AgentException(JDWP_ERROR_INTERNAL);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Failed to fork debugger process: error=%d", errno));
+        AgentException ex = AgentException(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     } else if (pid == 0) {
         // execute debugger in child process
         execv(argv[0], argv);
         // returned here only in case of error, terminate child process
-        JDWP_DIE("Failed to execute debugger process: error=" << errno);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Failed to execute debugger process: error=%d", errno));
+        ::exit(1);
     } else {
-        JDWP_TRACE_PROG("StartDebugger: launched: pid=" << pid);
+        JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: launched: pid=%d", pid));
     }
-}
 
-ProcPtr jdwp::GetProcAddress(LoadedLibraryHandler libHandler, const char* procName)
-{
-    JDWP_TRACE_ENTRY("GetProcAddress(" << libHandler << ',' << JDWP_CHECK_NULL(procName) << ')');
-
-    dlerror();
-    ProcPtr res = (ProcPtr)dlsym(libHandler, procName);
-    const char* errorMessage = dlerror();
-    if (errorMessage) {
-        JDWP_TRACE_PROG("FreeLibrary: getting library entry failed (error: " << errorMessage << ")");
-    }
-    return res;
-}
-
-bool jdwp::FreeLibrary(LoadedLibraryHandler libHandler)
-{
-    JDWP_TRACE_ENTRY("FreeLibrary(" << libHandler << ')');
-
-    dlerror();
-    if (dlclose(libHandler) != 0) {
-        JDWP_TRACE_PROG("FreeLibrary: closing library failed (error: " << dlerror() << ")");
-        return false;
-    }
-    return true;
-}
-
-LoadedLibraryHandler TransportManager::LoadTransport(const char* dirName, const char* transportName)
-{
-    JDWP_TRACE_ENTRY("LoadTransport(" << JDWP_CHECK_NULL(dirName) << ',' << JDWP_CHECK_NULL(transportName) << ')');
-
-    JDWP_ASSERT(transportName != 0);
-    dlerror();
-    char* transportFullName = 0;
-    if (dirName == 0) {
-        size_t length = strlen(transportName) + 7;
-        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length JDWP_FILE_LINE));
-        sprintf(transportFullName, "lib%s.so", transportName);
-    } else {
-        size_t length = strlen(dirName) + strlen(transportName) + 8;
-        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length JDWP_FILE_LINE));
-        sprintf(transportFullName, "%s/lib%s.so", dirName, transportName);
-    }
-    AgentAutoFree afv(transportFullName JDWP_FILE_LINE);
-    LoadedLibraryHandler res = dlopen(transportFullName, RTLD_LAZY);
-    if (res == 0) {
-        JDWP_TRACE_PROG("LoadTransport: loading library " << transportFullName << " failed (error: " << dlerror() << ")");
-    } else {
-        JDWP_TRACE_PROG("LoadTransport: transport library " << transportFullName << " loaded");
-    }
-    return res;
+    return JDWP_ERROR_NONE;
 }

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/core/TransportManager_pd.h Thu Jul 16 15:57:37 2009
@@ -17,11 +17,6 @@
  */
 
 /**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.6.2.1 $
- */
-
-/**
  * @file
  * TransportManager_pd.h
  *
@@ -34,17 +29,6 @@
 
 #include <dlfcn.h>
 #include <unistd.h>
-
-namespace jdwp {
-
-    typedef void* LoadedLibraryHandler;
-
-    typedef void (*ProcPtr)();
-
-    ProcPtr GetProcAddress(LoadedLibraryHandler libHandler, const char* procName);
-
-    bool FreeLibrary(LoadedLibraryHandler libHandler);
-
-}//jdwp
+#include "hyport.h"
 
 #endif // _TRANSPORT_MANAGER_PD_H_

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/agent/makefile Thu Jul 16 15:57:37 2009
@@ -22,15 +22,8 @@
 COMMON=../../common/
 CMNAGENT=$(COMMON)agent/
 
-CFLAGS += -fpic
-CXXFLAGS += -fpic
-
-INCLUDES += -I$(CMNAGENT)commands -I$(CMNAGENT)core \
-            -I$(COMMON)generic -Icore
-
-INCLUDES := -I../../../include $(INCLUDES)
-
-LDFLAGS += $(STDCLIBS)
+INCLUDES := -I../../../include -I$(CMNAGENT)commands -I$(CMNAGENT)core \
+            -I$(COMMON)generic -Icore $(INCLUDES)
 
 BUILDFILES = \
     $(CMNAGENT)commands/ArrayReference.o \
@@ -53,11 +46,42 @@
     $(CMNAGENT)core/ObjectManager.o $(CMNAGENT)core/OptionParser.o $(CMNAGENT)core/PacketDispatcher.o \
     $(CMNAGENT)core/PacketParser.o $(CMNAGENT)core/RequestManager.o $(CMNAGENT)core/RequestModifier.o \
     $(CMNAGENT)core/ThreadManager.o $(CMNAGENT)core/TransportManager.o $(CMNAGENT)core/AgentManager.o \
-    $(CMNAGENT)core/CallBacks.o \
+    $(CMNAGENT)core/CallBacks.o $(CMNAGENT)core/ExceptionManager.o\
     core/TransportManager_pd.o
 
-MDLLIBFILES = 
+
+ifneq ($(HY_OS),zos)
+  # !zOS
+  OPT += -fno-exceptions -fno-rtti 
+  ifneq ($(HY_OS),aix)
+    # !AIX and !zOS
+    MDLLIBFILES = $(LIBPATH)libvmi.so
+    DLL_LDFLAGS += -fno-exceptions -fno-rtti
+    LDFLAGS += $(STDCLIBS)
+  else
+    # AIX
+    MDLLIBFILES = 
+    LDFLAGS += -L$(LIBPATH). -L$(LIBPATH)../. $(STDCLIBS) -lvmi
+  endif
+else
+  # zOS
+  MDLLIBFILES = $(LIBPATH)libvmi.x
+  LDFLAGS += $(STDCLIBS)
+endif
+
+ifeq ($(HY_NO_THR),true)
+MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
+endif
 
 DLLNAME = ../libjdwp.so
 
+STDCLIBS = 
+
+CCVERSION=$(shell $(CC) -v 2>&1 | sed -e '1,3d; s/gcc version \([^ ]\+\).*/\1/')
+ifneq ($(HY_OS),zos)
+  ifeq (1,$(shell expr "$(CCVERSION)" \>= "3.4.6"))
+    OPT += -fno-threadsafe-statics
+  endif
+endif
+
 include $(HY_HDK)/build/make/rules.mk

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/SocketTransport_pd.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/SocketTransport_pd.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/SocketTransport_pd.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/SocketTransport_pd.h Thu Jul 16 15:57:37 2009
@@ -17,11 +17,6 @@
  */
 
 /**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.5.2.1 $
- */
-
-/**
  * @file
  * SocketTransport_pd.h
  *
@@ -33,23 +28,17 @@
 #define _SOCKETTRANSPORT_PD_H
 
 
-#include <pthread.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netinet/tcp.h> 
-#include <pthread.h>
+#include "LastTransportError.h"
+#include "vmi.h"
+#include "hythread.h"
+#include "hysock.h"
+#include "hyport.h"
+
+#include "jni.h"
 
-typedef pthread_mutex_t CriticalSection;
+//typedef pthread_mutex_t CriticalSection;
 typedef int SOCKET;
+//typedef pthread_t ThreadId_t;
 
 #include "jdwpTransport.h"
 #include "LastTransportError.h"
@@ -58,106 +47,6 @@
 typedef timeval TIMEVAL;
 typedef int BOOL;
 
-const int TRUE = 1;
 const int SOCKET_ERROR = -1;
-const int SOCKET_ERROR_EINTR = EINTR;
-const int INVALID_SOCKET = -1;
-const int SD_BOTH = 2;
-const int SOCKETWOULDBLOCK = EINPROGRESS;
-
-/**
- * Returns the error status for the last failed operation. 
- */
-static inline int
-GetLastErrorStatus()
-{
-    return errno;
-}
-
-/**
- * Retrieves the number of milliseconds, substitute for the corresponding Win32 
- * function.
- */
-static inline long 
-GetTickCount(void)
-{
-    struct timeval t;
-    gettimeofday(&t, 0);
-    return t.tv_sec * 1000 + (t.tv_usec/1000);
-}
-
-/**
- * Closes socket, substitute for the corresponding Win32 function.
- */
-static inline int 
-closesocket(SOCKET s)
-{
-    return close(s);
-}
-
-/**
- * Closes socket, substitute for the corresponding Win32 function.
- */
-static inline int 
-ioctlsocket( SOCKET s, long cmd, u_long* argp)
-{
-    return ioctl(s, cmd, argp);
-}
-
-/**
- * Initializes critical-section lock objects.
- */
-static inline void
-InitializeCriticalSections(jdwpTransportEnv* env)
-{
-    pthread_mutex_init(&(((internalEnv*)env->functions->reserved1)->readLock), 0);
-    pthread_mutex_init(&(((internalEnv*)env->functions->reserved1)->sendLock), 0);
-}
- 
-/**
- * Releases all resources used by critical-section lock objects.
- */
-static inline void
-DeleteCriticalSections(jdwpTransportEnv* env)
-{
-    pthread_mutex_destroy(&(((internalEnv*)env->functions->reserved1)->readLock));
-    pthread_mutex_destroy(&(((internalEnv*)env->functions->reserved1)->sendLock));
-}
-
-/**
- * Waits for ownership of the read critical-section object.
- */
-static inline void
-EnterCriticalReadSection(jdwpTransportEnv* env)
-{
-    pthread_mutex_lock(&(((internalEnv*)env->functions->reserved1)->readLock));
-}
-
-/**
- * Waits for ownership of the send critical-section object.
- */
-static inline void
-EnterCriticalSendSection(jdwpTransportEnv* env)
-{
-    pthread_mutex_lock(&(((internalEnv*)env->functions->reserved1)->sendLock));
-}
-
-/**
- * Releases ownership of the read critical-section object.
- */
-static inline void
-LeaveCriticalReadSection(jdwpTransportEnv* env)
-{
-    pthread_mutex_unlock(&(((internalEnv*)env->functions->reserved1)->readLock));
-}
-
-/**
- * Releases ownership of the send critical-section object.
- */
-static inline void
-LeaveCriticalSendSection(jdwpTransportEnv* env)
-{
-    pthread_mutex_unlock(&(((internalEnv*)env->functions->reserved1)->sendLock));
-}
 
 #endif //_SOCKETTRANSPORT_PD_H

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/makefile?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/makefile (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/unix/transport/dt_socket/makefile Thu Jul 16 15:57:37 2009
@@ -16,31 +16,51 @@
 #
 # Makefile for module jdwp - transport
 #
-# export HY_HDK=/home/geir/dev/apache/harmony/enhanced/trunk/working_classlib/deploy/
-# export HY_DRLVM=/home/geir/dev/apache/harmony/enhanced/trunk/working_vm/build/deploy/
-
-#
 
 include $(HY_HDK)/build/make/defines.mk
 
 COMMON=../../../common/
 CMNTRANS=$(COMMON)transport/
 
-CFLAGS += -fpic
-CXXFLAGS += -fpic
-
-INCLUDES += -I$(CMNTRANS)common -I$(CMNTRANS)dt_socket \
-            -I$(COMMON)generic -I. \
-            -I../common
-
-LDFLAGS += $(STDCLIBS)
+INCLUDES := -I../../../../include -I$(CMNTRANS)common -I$(CMNTRANS)dt_socket \
+            -I$(COMMON)generic -I. $(INCLUDES)
 
 BUILDFILES = \
     $(CMNTRANS)common/LastTransportError.o \
-    $(CMNTRANS)dt_socket/SocketTransport.o
+    $(CMNTRANS)dt_socket/SocketTransport.o 
 
-MDLLIBFILES = 
+ifneq ($(HY_OS),zos)
+  # !zOS
+  OPT += -fno-exceptions -fno-rtti
+  ifneq ($(HY_OS),aix)
+    # !AIX and !zOS
+    MDLLIBFILES = $(LIBPATH)libvmi.so
+    DLL_LDFLAGS += -fno-exceptions -fno-rtti
+    LDFLAGS += $(STDCLIBS)
+  else
+    # AIX
+    MDLLIBFILES =
+    LDFLAGS += -L$(LIBPATH). -L$(LIBPATH)../. $(STDCLIBS)  -lvmi 
+  endif
+else
+  # zOS
+  MDLLIBFILES = $(LIBPATH)libvmi.x
+  LDFLAGS += $(STDCLIBS)
+endif
+
+ifeq ($(HY_NO_THR),true)
+MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
+endif
 
 DLLNAME = ../../libdt_socket.so
 
+STDCLIBS = 
+
+CCVERSION=$(shell $(CC) -v 2>&1 | sed -e '1,3d; s/gcc version \([^ ]\+\).*/\1/')
+ifneq ($(HY_OS),zos)
+  ifeq (1,$(shell expr "$(CCVERSION)" \>= "3.4.6"))
+    OPT += -fno-threadsafe-statics
+  endif
+endif
+
 include $(HY_HDK)/build/make/rules.mk

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.cpp Thu Jul 16 15:57:37 2009
@@ -15,21 +15,16 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
-/**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.10 $
- */
-// TransportManager_pd.cpp
-//
-
 /**
  * This header file includes platform depended definitions for types, 
  * constants, include statements and functions for Win32 platform.
  */
 
-#include "TransportManager_pd.h"
+// Windows Header Files:
+#include <windows.h>
+
 #include "TransportManager.h"
+#include "ExceptionManager.h"
 #include <process.h>
 
 using namespace jdwp;
@@ -46,22 +41,22 @@
 
 const char TransportManager::pathSeparator = ';';
 
-void TransportManager::StartDebugger(const char* command, int extra_argc, const char* extra_argv[]) throw(AgentException)
+int TransportManager::StartDebugger(const char* command, int extra_argc, const char* extra_argv[])
 {
-    JDWP_TRACE_ENTRY("StartDebugger(" << JDWP_CHECK_NULL(command) << ',' << extra_argc << ',' << extra_argv << ')');
+    JDWP_TRACE_ENTRY(LOG_RELEASE, (LOG_FUNC_FL, "StartDebugger(%s,%d,%p)", JDWP_CHECK_NULL(command), extra_argc, extra_argv));
 
-JDWP_TRACE_PROG("StartDebugger: transport=" << JDWP_CHECK_NULL(extra_argv[0]));
-JDWP_TRACE_PROG("StartDebugger: address=" << JDWP_CHECK_NULL(extra_argv[1]));
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: transport=%s", JDWP_CHECK_NULL(extra_argv[0])));
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: address=%s", JDWP_CHECK_NULL(extra_argv[1])));
 
     // append extra arguments to command line
 
-    int cmd_len = strlen(command);
+    int cmd_len = (int)strlen(command);
     int extra_len = 0;
     int i;
 
     for (i = 0; i < extra_argc; i++) {
          if (extra_argv[i] != 0) {
-             extra_len += strlen(extra_argv[i]) + 1;
+             extra_len += (int)strlen(extra_argv[i]) + 1;
          }
     }
 
@@ -85,41 +80,22 @@
     si.cb = sizeof(si);
     ZeroMemory(&pi, sizeof(pi));
 
-    JDWP_TRACE_PROG("StartDebugger: launch: cmd=" << JDWP_CHECK_NULL(cmd));
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: launch: cmd=%s", JDWP_CHECK_NULL(cmd)));
 
     if(!CreateProcess(NULL, const_cast<LPSTR>(cmd), NULL, NULL, 
             TRUE, NULL, NULL, NULL, &si, &pi)) {
-        JDWP_ERROR("Failed to launch debugger process: error=" << GetLastError());
-        throw AgentException(JDWP_ERROR_INTERNAL);
+        JDWP_TRACE(LOG_RELEASE, (LOG_ERROR_FL, "Failed to launch debugger process: error=%d", GetLastError()));
+        AgentException ex = AgentException(JDWP_ERROR_INTERNAL);
+        JDWP_SET_EXCEPTION(ex);
+        return JDWP_ERROR_INTERNAL;
     }
 
-    JDWP_TRACE_PROG("StartDebugger: launched: pid=" << pi.dwProcessId);
+    JDWP_TRACE(LOG_RELEASE, (LOG_PROG_FL, "StartDebugger: launched: pid=%d", pi.dwProcessId));
 
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
+
+    return JDWP_ERROR_NONE;
 }
 
-LoadedLibraryHandler TransportManager::LoadTransport(const char* dirName, const char* transportName)
-{
-    JDWP_TRACE_ENTRY("LoadTransport(" << JDWP_CHECK_NULL(dirName) << ',' << JDWP_CHECK_NULL(transportName) << ')');
 
-    JDWP_ASSERT(transportName != 0);
-    char* transportFullName = 0;
-    if (dirName == 0) {
-        size_t length = strlen(transportName) + 5;
-        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length JDWP_FILE_LINE));
-        sprintf(transportFullName, "%s.dll", transportName);
-    } else {
-        size_t length = strlen(dirName) + strlen(transportName) + 6;
-        transportFullName = static_cast<char *>(GetMemoryManager().Allocate(length JDWP_FILE_LINE));
-        sprintf(transportFullName, "%s\\%s.dll", dirName, transportName);
-    }
-    AgentAutoFree afv(transportFullName JDWP_FILE_LINE);
-    LoadedLibraryHandler res = LoadLibrary(transportFullName);
-    if (res == 0) {
-        JDWP_TRACE_PROG("LoadTransport: loading library " << transportFullName << " failed (error code: " << GetLastError() << ")");
-    } else {
-        JDWP_TRACE_PROG("LoadTransport: transport library " << transportFullName << " loaded");
-    }
-    return res;
-}

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/core/TransportManager_pd.h Thu Jul 16 15:57:37 2009
@@ -17,11 +17,6 @@
  */
 
 /**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.5.2.1 $
- */
-
-/**
  * @file
  * TransportManager_pd.h
  *
@@ -33,13 +28,5 @@
 #define _TRANSPORT_MANAGER_PD_H_
 
 #define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
-// Windows Header Files:
-#include <windows.h>
-
-namespace jdwp {
-
-    typedef HMODULE LoadedLibraryHandler;
-
-}//jdwp
 
 #endif // _TRANSPORT_MANAGER_PD_H_

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/jdwp.rc
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/jdwp.rc?rev=794726&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/jdwp.rc (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/jdwp.rc Thu Jul 16 15:57:37 2009
@@ -0,0 +1,48 @@
+;
+; 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.
+;
+#include <windows.h>
+#include <winver.h>
+#include "..\..\..\include\jdwpcfg.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 6,0,0,0
+ PRODUCTVERSION 6,0,0,0
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+	BLOCK "StringFileInfo"
+	BEGIN
+		BLOCK "040904b0"
+		BEGIN
+			VALUE "CompanyName", "The Apache Software Foundation.\0"
+			VALUE "FileDescription", "JDWP Agent Library\0"
+			VALUE "FileVersion", "6.0.0-" BUILD_LEVEL "\0"
+			VALUE "InternalName", "jdwp\0"
+			VALUE "LegalCopyright", "(c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable.\0"
+			VALUE "OriginalFilename", "jdwp.dll\0"
+			VALUE "ProductName", "Apache Harmony\0"
+			VALUE "ProductVersion", "6.0.0-" BUILD_LEVEL "\0"
+		END
+	END
+	BLOCK "VarFileInfo"
+	BEGIN
+		VALUE "Translation", 0x0409, 1200
+	END
+END

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/agent/makefile Thu Jul 16 15:57:37 2009
@@ -22,6 +22,16 @@
 COMMON=..\..\common\# comment to avoid \ being treated as continuation
 CMNAGENT=$(COMMON)agent\# comment to avoid \ being treated as continuation
 
+!IF "$(HY_OS)-$(HY_ARCH)" == "windows-x86_64" 
+WARNING_LEVEL=W0
+PLATFORM_64=-DHYX86_64 -Oi -DWIN64 -D_WIN64 -D_AMD64_=1
+CPU=AMD64
+HYCOMMONCFLAGS = -GS- -EHs-c- /wd4530 $(HYCOMMONCFLAGS)
+!ELSE
+WARNING_LEVEL=WX
+HYCOMMONCFLAGS = -GS -GX $(HYCOMMONCFLAGS)
+!ENDIF
+
 LIBBASE=jdwp
 DLLNAME=..\$(LIBBASE).dll
 LIBNAME=$(LIBPATH)$(LIBBASE).lib
@@ -55,16 +65,18 @@
     $(CMNAGENT)core\ObjectManager.obj $(CMNAGENT)core\OptionParser.obj $(CMNAGENT)core\PacketDispatcher.obj \
     $(CMNAGENT)core\PacketParser.obj $(CMNAGENT)core\RequestManager.obj $(CMNAGENT)core\RequestModifier.obj \
     $(CMNAGENT)core\ThreadManager.obj $(CMNAGENT)core\TransportManager.obj $(CMNAGENT)core\AgentManager.obj \
-    $(CMNAGENT)core\CallBacks.obj \
+    $(CMNAGENT)core\CallBacks.obj $(CMNAGENT)core\ExceptionManager.obj\
     core\TransportManager_pd.obj
 
-VIRTFILES = 
+HYRCFLAGS = -I../../../include
+
+VIRTFILES = jdwp.res
 
 SYSLIBFILES = 
 
-MDLLIBFILES = 
+MDLLIBFILES = $(LIBPATH)vmi.lib $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX)
   
 DLLBASE=0x13200000
-COMMENT=/comment:"JDWP agent native code. (c) Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable."
+COMMENT=/comment:"JDWP agent native code. (c) Copyright 2005 - 2009 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/SharedMemTransport.cpp Thu Jul 16 15:57:37 2009
@@ -35,7 +35,7 @@
     if (ienv->lastError != 0) {
         ienv->lastError->insertError(messagePtr, errorStatus);
     } else {
-        ienv->lastError = new(ienv->alloc, ienv->free) LastTransportError(messagePtr, errorStatus, ienv->alloc, ienv->free);
+        ienv->lastError = new(ienv->alloc, ienv->free) LastTransportError(ienv->jvm, messagePtr, errorStatus, ienv->alloc, ienv->free);
     }
     return;
 } // SetLastTranError

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/makefile?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/makefile (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_shmem/makefile Thu Jul 16 15:57:37 2009
@@ -43,6 +43,8 @@
 
 SYSLIBFILES = 
 
+MDLLIBFILES = $(LIBPATH)vmi.lib $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX)
+
 DLLBASE=0x13200000
 COMMENT=/comment:"JDWP shmem transport native code. (c) Copyright 2008 The Apache Software Foundation or its licensors, as applicable."
 

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/SocketTransport_pd.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/SocketTransport_pd.h?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/SocketTransport_pd.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/SocketTransport_pd.h Thu Jul 16 15:57:37 2009
@@ -17,11 +17,6 @@
  */
 
 /**
- * @author Viacheslav G. Rybalov
- * @version $Revision: 1.7.2.1 $
- */
-
-/**
  * @file
  * SocketTransport_pd.h
  *
@@ -39,11 +34,12 @@
 #include <Winsock2.h>
 #include <Ws2tcpip.h>
 
-typedef CRITICAL_SECTION CriticalSection;
-
 #include "jdwpTransport.h"
+#include "vmi.h"
+#include "hyport.h"
 #include "LastTransportError.h"
 #include "SocketTransport.h"
+#include "jni.h"
 
 typedef int socklen_t;
 
@@ -58,61 +54,4 @@
 {
     return WSAGetLastError();
 } //GetLastErrorStatus()
-
-/**
- * Initializes critical section lock objects.
- */
-static inline void
-InitializeCriticalSections(jdwpTransportEnv* env)
-{
-    InitializeCriticalSection(&(((internalEnv*)env->functions->reserved1)->readLock));
-    InitializeCriticalSection(&(((internalEnv*)env->functions->reserved1)->sendLock));
-} //InitializeCriticalSections()
-
-/**
- * Releases all resources used by critical-section lock objects.
- */
-static inline void
-DeleteCriticalSections(jdwpTransportEnv* env)
-{
-    DeleteCriticalSection(&(((internalEnv*)env->functions->reserved1)->readLock));
-    DeleteCriticalSection(&(((internalEnv*)env->functions->reserved1)->sendLock));
-} //DeleteCriticalSections()
-
-/**
- * Waits for ownership of the read critical-section object.
- */
-static inline void
-EnterCriticalReadSection(jdwpTransportEnv* env)
-{
-    EnterCriticalSection(&(((internalEnv*)env->functions->reserved1)->readLock));
-} //EnterCriticalReadSection()
-
-/**
- * Waits for ownership of the send critical-section object.
- */
-static inline void
-EnterCriticalSendSection(jdwpTransportEnv* env)
-{
-    EnterCriticalSection(&(((internalEnv*)env->functions->reserved1)->sendLock));
-} //EnterCriticalSendSection()
-
-/**
- * Releases ownership of the read critical-section object.
- */
-static inline void
-LeaveCriticalReadSection(jdwpTransportEnv* env)
-{
-    LeaveCriticalSection(&(((internalEnv*)env->functions->reserved1)->readLock));
-} //LeaveCriticalReadSection()
-
-/**
- * Releases ownership of the send critical-section object.
- */
-static inline void
-LeaveCriticalSendSection(jdwpTransportEnv* env)
-{
-    LeaveCriticalSection(&(((internalEnv*)env->functions->reserved1)->sendLock));
-} //LeaveCriticalSendSection()
-
-#endif // _SOCKETTRANSPORT_PD_H
+#endif // _SOCKETTRANSPORT_PD_Hi

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/dt_socket.rc
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/dt_socket.rc?rev=794726&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/dt_socket.rc (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/dt_socket.rc Thu Jul 16 15:57:37 2009
@@ -0,0 +1,48 @@
+;
+; 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.
+;
+#include <windows.h>
+#include <winver.h>
+#include "..\..\..\..\include\jdwpcfg.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 6,0,0,0
+ PRODUCTVERSION 6,0,0,0
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+	BLOCK "StringFileInfo"
+	BEGIN
+		BLOCK "040904b0"
+		BEGIN
+			VALUE "CompanyName", "The Apache Software Foundation.\0"
+			VALUE "FileDescription", "Socket Transport Library\0"
+			VALUE "FileVersion", "6.0.0-" BUILD_LEVEL "\0"
+			VALUE "InternalName", "dt_socket\0"
+			VALUE "LegalCopyright", "(c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable.\0"
+			VALUE "OriginalFilename", "dt_socket.dll\0"
+			VALUE "ProductName", "Apache Harmony\0"
+			VALUE "ProductVersion", "6.0.0-" BUILD_LEVEL "\0"
+		END
+	END
+	BLOCK "VarFileInfo"
+	BEGIN
+		VALUE "Translation", 0x0409, 1200
+	END
+END

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/makefile?rev=794726&r1=794725&r2=794726&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/makefile (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/windows/transport/dt_socket/makefile Thu Jul 16 15:57:37 2009
@@ -14,7 +14,7 @@
 #  limitations under the License.
 
 #
-# Makefile for module jdwp - dt_socket transport
+# Makefile for module jdwp - socket transport
 #
 
 !include <$(HY_HDK)\build\make\defines.mak>
@@ -22,6 +22,16 @@
 COMMON=..\..\..\common\# comment to avoid \ being treated as continuation
 CMNTRANS=$(COMMON)transport\# comment to avoid \ being treated as continuation
 
+!IF "$(HY_OS)-$(HY_ARCH)" == "windows-x86_64" 
+WARNING_LEVEL=W0
+PLATFORM_64=-DHYX86_64 -Oi -DWIN64 -D_WIN64 -D_AMD64_=1
+CPU=AMD64
+HYCOMMONCFLAGS = -GS- -EHs-c- /wd4530 $(HYCOMMONCFLAGS)
+!ELSE
+WARNING_LEVEL=WX
+HYCOMMONCFLAGS = -GS -GX $(HYCOMMONCFLAGS)
+!ENDIF
+
 LIBBASE=dt_socket
 DLLNAME=..\..\$(LIBBASE).dll
 LIBNAME=$(LIBPATH)$(LIBBASE).lib
@@ -31,21 +41,24 @@
          -I$(COMMON)generic -I. \
          -I..\common
 
-HYCFLAGS = $(HYCFLAGS) $(INCLUDES) -GX -wd4290
+HYCFLAGS = -I..\..\..\..\include $(HYCFLAGS) $(INCLUDES) -GX -wd4290
 
 HYLDFLAGS = $(HYLDFLAGS) -def:$(LIBBASE).def
 
 BUILDFILES = \
     $(CMNTRANS)common\LastTransportError.obj \
-    $(CMNTRANS)dt_socket\SocketTransport.obj 
+    $(CMNTRANS)dt_socket\SocketTransport.obj \
+    SocketTransport_pd.obj
+
+HYRCFLAGS = -I..\..\..\..\include
 
-VIRTFILES = 
+VIRTFILES = dt_socket.res
 
 SYSLIBFILES = 
 
-MDLLIBFILES = 
+MDLLIBFILES = $(LIBPATH)vmi.lib $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX)
   
 DLLBASE=0x13200000
-COMMENT=/comment:"JDWP socket transport native code. (c) Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable."
+COMMENT=/comment:"JDWP socket transport native code. (c) Copyright 2005 - 2009 The Apache Software Foundation or its licensors, as applicable."
 
 !include <$(HY_HDK)\build\make\rules.mak>



Mime
View raw message