Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 60532 invoked from network); 28 Nov 2006 17:51:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Nov 2006 17:51:11 -0000 Received: (qmail 52189 invoked by uid 500); 28 Nov 2006 17:51:19 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 52158 invoked by uid 500); 28 Nov 2006 17:51:19 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 52105 invoked by uid 99); 28 Nov 2006 17:51:19 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2006 09:51:19 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,UPPERCASE_25_50 X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2006 09:51:04 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id E4B9F1A9874; Tue, 28 Nov 2006 09:49:59 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r480141 [15/38] - in /harmony/enhanced/jdktools/trunk/modules/jpda: ./ doc/ doc/images/ make/ src/ src/common/ src/common/other/ src/common/other/jpda/ src/common/other/jpda/jdwp/ src/common/other/jpda/jdwp/agent/ src/common/other/jpda/jdwp... Date: Tue, 28 Nov 2006 17:49:31 -0000 To: commits@harmony.apache.org From: geirm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061128174959.E4B9F1A9874@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.cpp?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.cpp (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.cpp Tue Nov 28 09:49:08 2006 @@ -0,0 +1,342 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Viacheslav G. Rybalov + * @version $Revision: 1.14 $ + */ +// TransportManager.cpp +// + +#include "TransportManager.h" + +using namespace jdwp; + +static void* +Alloc(jint numBytes) +{ + return AgentBase::GetMemoryManager().AllocateNoThrow(numBytes JDWP_FILE_LINE); +} + +static void +Free(void *buffer) +{ + AgentBase::GetMemoryManager().Free(buffer JDWP_FILE_LINE); +} + +static jdwpTransportCallback callback = {Alloc, Free}; + +typedef void (JNICALL *jdwpTransport_UnLoad_Type)(jdwpTransportEnv** env); + +TransportManager::TransportManager() : AgentBase() +{ + m_connectTimeout = 0; + m_handshakeTimeout = 0; + m_ConnectionPrepared = false; + m_address = 0; + m_loadedLib = 0; + m_env = 0; + m_isServer = true; + m_lastErrorMessage = 0; +} //TransportManager::TransportManager() + +TransportManager::~TransportManager() +{ + if (m_address != 0) { + GetMemoryManager().Free(m_address JDWP_FILE_LINE); + } + if (m_loadedLib != 0) { + jdwpTransport_UnLoad_Type UnloadFunc = reinterpret_cast + (GetProcAddress(m_loadedLib, unLoadDecFuncName)); + if ((UnloadFunc != 0) && (m_env != 0)) { + (UnloadFunc) (&m_env); + } + FreeLibrary(m_loadedLib); + } +} //TransportManager::~TransportManager() + +void +TransportManager::Init(const char* transportName, + const char* libPath) throw(TransportException) +{ + JDWP_TRACE_ENTRY("Init(" << JDWP_CHECK_NULL(transportName) << ',' << JDWP_CHECK_NULL(libPath) << ')'); + + JDWP_TRACE_PROG("Init: transport name=" << JDWP_CHECK_NULL(transportName ) + << " libPath=" << JDWP_CHECK_NULL(libPath)); + + JDWP_ASSERT(m_loadedLib == 0); + + const char* begin = libPath; + do { + const char* end = strchr(begin, pathSeparator); + if (end != 0) { + char* dirName = static_cast(GetMemoryManager().Allocate(end - begin + 1 JDWP_FILE_LINE)); + AgentAutoFree afv(dirName JDWP_FILE_LINE); + strncpy(dirName , begin, end - begin); + dirName[end - begin] = 0; + if (strlen(dirName) != 0) { + m_loadedLib = LoadTransport(dirName, transportName); + } + if (*(end + 1) != 0) { + begin = end + 1; + } else { + break; + } + } else { + m_loadedLib = LoadTransport(begin, transportName); + break; + } + } while (m_loadedLib == 0); + if (m_loadedLib == 0) { + m_loadedLib = LoadTransport(0, transportName); + } + if (m_loadedLib == 0) { + if (m_lastErrorMessage != 0) { + GetMemoryManager().Free(m_lastErrorMessage JDWP_FILE_LINE); + } + size_t length = strlen("Loading of failed") + strlen(transportName) + 1; + m_lastErrorMessage = static_cast(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_OnLoad_t transportOnLoad = reinterpret_cast + (GetProcAddress(m_loadedLib, onLoadDecFuncName)); + if (transportOnLoad == 0) { + if (m_lastErrorMessage != 0) { + GetMemoryManager().Free(m_lastErrorMessage JDWP_FILE_LINE); + } + size_t length = strlen(" function not found in ") + strlen(transportName) + + strlen(onLoadDecFuncName) + 1; + m_lastErrorMessage = static_cast(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(); + } + jint res = (*transportOnLoad)(GetJavaVM(), &callback, JDWPTRANSPORT_VERSION_1_0, &m_env); + if (res == JNI_ENOMEM) { + if (m_lastErrorMessage != 0) { + GetMemoryManager().Free(m_lastErrorMessage JDWP_FILE_LINE); + } + size_t length = strlen("Out of memeory"); + m_lastErrorMessage = static_cast(GetMemoryManager().Allocate(length JDWP_FILE_LINE)); + sprintf(m_lastErrorMessage, "Out of memeory"); + throw TransportException(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(GetMemoryManager().Allocate(length JDWP_FILE_LINE)); + sprintf(m_lastErrorMessage, "Invoking of %s failed", onLoadDecFuncName); + JDWP_ERROR("Invoking of " << onLoadDecFuncName << " failed"); + throw TransportException(); + } + if (m_env == 0) { + if (m_lastErrorMessage != 0) { + GetMemoryManager().Free(m_lastErrorMessage JDWP_FILE_LINE); + } + size_t length = strlen("Transport provided invalid environment"); + m_lastErrorMessage = static_cast(GetMemoryManager().Allocate(length JDWP_FILE_LINE)); + sprintf(m_lastErrorMessage, "Transport provided invalid environment"); + JDWP_ERROR("Transport provided invalid environment"); + throw TransportException(); + } + +} // TransportManager::Init() + +void +TransportManager::PrepareConnection(const char* address, bool isServer, + jlong connectTimeout, jlong handshakeTimeout) throw(TransportException) +{ + JDWP_TRACE_ENTRY("PrepareConnection(" << JDWP_CHECK_NULL(address) << ',' << isServer + << ',' << connectTimeout << ',' << handshakeTimeout << ')'); + + JDWP_TRACE_PROG("PrepareConnection: address=" << JDWP_CHECK_NULL(address) + << " connectTimeout=" << connectTimeout + << " handshakeTimeout=" << handshakeTimeout + << " isServer=" << isServer); + + JDWP_ASSERT((m_loadedLib != 0) && (!m_ConnectionPrepared)); + + m_lastErrorMessage = 0; + + m_connectTimeout = connectTimeout; + m_handshakeTimeout = handshakeTimeout; + m_isServer = isServer; + + 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 ((connectTimeout != 0) && (!isServer) && (!capabilities.can_timeout_attach)) { + JDWP_INFO("Warning: transport does not support attach timeout"); + } + if ((handshakeTimeout != 0) && (!capabilities.can_timeout_handshake)) { + JDWP_INFO("Warning: transport does not support handshake timeout"); + } + + if (isServer) { + char* actualAddress; + err = m_env->StartListening(address, &actualAddress); + CheckReturnStatus(err); + JDWP_INFO("transport is listening on " << actualAddress); + JDWP_TRACE_PROG("PrepareConnection: listening on " << actualAddress); + AgentBase::GetMemoryManager().Free(actualAddress JDWP_FILE_LINE); + } else { + m_address = static_cast(GetMemoryManager().Allocate(strlen(address) + 1 JDWP_FILE_LINE)); + strcpy(m_address, address); + } + + m_ConnectionPrepared = true; + +} // TransportManager::PrepareConnection() + +void +TransportManager::Connect() throw(TransportException) +{ + JDWP_TRACE_PROG("Connect: isServer=" << m_isServer); + JDWP_ASSERT(m_ConnectionPrepared); + jdwpTransportError err; + if (m_isServer) { + err = m_env->Accept(m_connectTimeout, m_handshakeTimeout); + CheckReturnStatus(err); + } else { + err = m_env->Attach(m_address, m_connectTimeout, m_handshakeTimeout); + CheckReturnStatus(err); + } + JDWP_TRACE_PROG("Connect: connection established"); +} // TransportManager::Start() + +void +TransportManager::Launch(const char* command) throw(TransportException) +{ + JDWP_TRACE_PROG("Launch: " << JDWP_CHECK_NULL(command)); + JDWP_ASSERT(m_ConnectionPrepared); + StartDebugger(command); + Connect(); +} // TransportManager::Launch() + +void +TransportManager::Read(jdwpPacket* packet) throw(TransportException) +{ + JDWP_ASSERT(m_ConnectionPrepared); + JDWP_TRACE_PACKET("read packet"); + jdwpTransportError err = m_env->ReadPacket(packet); + CheckReturnStatus(err); + TracePacket("rcvt", packet); +} // TransportManager::Read() + +void +TransportManager::Write(const jdwpPacket *packet) throw(TransportException) +{ + JDWP_ASSERT(m_ConnectionPrepared); + JDWP_TRACE_PACKET("send packet"); + jdwpTransportError err = m_env->WritePacket(packet); + CheckReturnStatus(err); + TracePacket("sent", packet); +} // TransportManager::Write() + +void +TransportManager::Reset() throw(TransportException) +{ + JDWP_TRACE_PROG("Reset: close connection"); + if(m_env != 0) { + JDWP_ASSERT(m_ConnectionPrepared); + jdwpTransportError err = m_env->Close(); + CheckReturnStatus(err); + } + JDWP_TRACE_PROG("Reset: connection closed"); +} // TransportManager::Close() + + +void +TransportManager::Clean() throw(TransportException) +{ + JDWP_ASSERT(m_ConnectionPrepared); + JDWP_TRACE_PROG("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"); +} // TransportManager::Clean() + +bool + +TransportManager::IsOpen() +{ + if (!m_ConnectionPrepared) { + return false; + } + if (m_env->IsOpen() == JNI_TRUE) { + return true; + } else { + return false; + } +} // TransportManager::IsOpen() + +char* +TransportManager::GetLastTransportError() throw(TransportException) +{ + char* lastErrorMessage = 0; + if (m_lastErrorMessage != 0) { + lastErrorMessage = m_lastErrorMessage; + m_lastErrorMessage = 0; + } else { + JDWP_ASSERT(m_env != 0); + m_env->GetLastError(&lastErrorMessage); + } + JDWP_TRACE_PROG("GetLastTransportError: " << JDWP_CHECK_NULL(lastErrorMessage)); + return lastErrorMessage; +} // TransportManager::GetLastTransportError() + +void +TransportManager::CheckReturnStatus(jdwpTransportError err) throw(TransportException) +{ + 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); + } + char* lastErrorMessage = GetLastTransportError(); + AgentBase::GetMemoryManager().Free(lastErrorMessage JDWP_FILE_LINE); + throw TransportException(JDWP_ERROR_TRANSPORT_INIT, err); +} // 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)); + } 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)); + } +} // TracePacket() Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,175 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Viacheslav G. Rybalov + * @version $Revision: 1.10.2.1 $ + */ + +/** + * @file + * TransportManager.h + * + */ + +#ifndef _TRANSPORT_MANAGER_H_ +#define _TRANSPORT_MANAGER_H_ + +#include "jdwpTransport.h" +#include "AgentBase.h" +#include "AgentException.h" +#include "Log.h" +#include "TransportManager_pd.h" + +namespace jdwp { + + /** + * The given class provides a high level interface with the JDWP transport. + * At first the function Init() must be invoked. It loads and + * initializes specified transport. Further the function + * PrepareConnection() must be invoked. It makes some + * preparations for establishing connection. To connect with the debugger, + * function Connect() must be invoked. + */ + class TransportManager : public AgentBase { + public: + + /** + * A constructor. + */ + TransportManager(); + + /** + * A destructor. + */ + ~TransportManager(); + + /** + * Transport library initialization. + * + * @param transportName - the name of the transport (library) + * @param libPath - the library path + * + * @exception TransportException() - transport initialization + * error happens. + */ + void Init(const char* transportName, + const char* libPath) throw(TransportException); + + /** + * Connection preparation. If the agent is server, then starts listening. + * Must be invoked first. + * + * @param address - the string representing the address of + * the debugger ("host:port") + * @param isServer - if the agent is a server then TRUE, + * otherwise FALSE + * @param connectTimeout - attach either accept time-out + * @param handshakeTimeout - the handshake time-out + * + * @exception TransportException() - transport error happens. + */ + void PrepareConnection(const char* address, bool isServer, + jlong connectTimeout, jlong handshakeTimeout) throw(TransportException); + + /** + * Establish connection with the debugger. + * Must be invoked after Init(). + * + * @exception TransportException() - transport error happens. + */ + void Connect() throw(TransportException); + + /** + * Launch the debugger and establish connection. + * + * @param command - a command line to start the debugger + * + * @exception TransportException() - transport error happens. + */ + void Launch(const char* command) throw(TransportException); + + /** + * The given function does a blocking read on an open connection. + * + * @param packet - the jdwpPacket structure address + * populated by this function + * + * @exception TransportException() - transport error happens. + */ + void Read(jdwpPacket* packet) throw(TransportException); + + /** + * Writes a JDWP packet to an open connection. + * + * @param packet - the jdwpPacket structure address + * + * @exception TransportException() - transport error + * happens. + */ + void Write(const jdwpPacket *packet) throw(TransportException); + + /** + * Close an open connection. The connection may be established again. + * + * @exception TransportException() - transport error happens. + */ + void Reset() throw(TransportException); + + void Clean() throw(TransportException); + + /** + * Check the connection. + * @return Returns TRUE if connection is open, otherwise FALSE. + */ + bool IsOpen(); + + /** + * Returns the string representation of the last transport error. + * The caller is responsible to free the returned string. + * + * @exception TransportException() - transport error happens. + */ + char* GetLastTransportError() throw(TransportException); + + protected: + + private: + jlong m_connectTimeout; // attachTimeout or acceptTimeout timeout + jlong m_handshakeTimeout; // handshakeTimeout + bool m_ConnectionPrepared; // if true PrepareConnection done + bool m_isServer; // is jdwp agent server or not + 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) throw(AgentException); + void TracePacket(const char* message, const jdwpPacket* packet); + LoadedLibraryHandler LoadTransport(const char* dirName, const char* transportName); + + static const char* onLoadDecFuncName; + static const char* unLoadDecFuncName; + static const char pathSeparator; + + };//class TransportManager + +}//jdwp + +#endif // _TRANSPORT_MANAGER_H_ Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/TransportManager.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/jdwpTypes.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/jdwpTypes.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/jdwpTypes.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/jdwpTypes.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,129 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Pavel N. Vyssotski + * @version $Revision: 1.7.2.1 $ + */ + +/** + * @file + * jdwpTypes.h + * + */ + +#ifndef _JDWP_TYPES_H_ +#define _JDWP_TYPES_H_ + +#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; + typedef jlong MethodID; + typedef jlong ObjectID; + typedef ObjectID ReferenceTypeID; + typedef jlong FrameID; + + const size_t FIELD_ID_SIZE = sizeof(FieldID); + const size_t METHOD_ID_SIZE = sizeof(MethodID); + const size_t OBJECT_ID_SIZE = sizeof(ObjectID); + const size_t REFERENCE_TYPE_ID_SIZE = sizeof(ReferenceTypeID); + const size_t FRAME_ID_SIZE = sizeof(FrameID); + + typedef jint PacketID; + typedef jint RequestID; + + /** + * The structure containing the Java value with the associated JDWP tag. + */ + struct jdwpTaggedValue { + jdwpTag tag; + jvalue value; + }; + + /** + * The structure containing all JDWP capabilities. + * One bit per capability. + */ + struct jdwpCapabilities { + unsigned int canWatchFieldModification : 1; + unsigned int canWatchFieldAccess : 1; + unsigned int canGetBytecodes : 1; + unsigned int canGetSyntheticAttribute : 1; + unsigned int canGetOwnedMonitorInfo : 1; + unsigned int canGetCurrentContendedMonitor : 1; + unsigned int canGetMonitorInfo : 1; + unsigned int canRedefineClasses : 1; + unsigned int canAddMethod : 1; + unsigned int canUnrestrictedlyRedefineClasses : 1; + unsigned int canPopFrames : 1; + unsigned int canUseInstanceFilters : 1; + unsigned int canGetSourceDebugExtension : 1; + unsigned int canRequestVMDeathEvent : 1; + unsigned int canSetDefaultStratum : 1; + unsigned int : 17; + }; + + /** + * The structure containing JDWP location information. + */ + struct jdwpLocation { + jdwpTypeTag typeTag; + jclass classID; + jmethodID methodID; + jlocation loc; + }; + + /** + * Representation of the null value for the jobject JNI type and types + * derived from the jobject, jclass and so on. + */ + #define JOBJECT_NULL 0 + + /** + * Access flags for class, field, and method + * as defined in the JVM specification. + */ + enum { + ACC_PUBLIC = 0x0001, + ACC_PRIVATE = 0x0002, + ACC_PROTECTED = 0x0004, + ACC_STATIC = 0x0008, + ACC_FINAL = 0x0010, + ACC_SYNCHRONIZED = 0x0020, + ACC_SUPER = 0x0020, + ACC_VOLATILE = 0x0040, + ACC_TRANSIENT = 0x0080, + ACC_VARARGS = 0x0080, + ACC_NATIVE = 0x0100, + ACC_INTERFACE = 0x0200, + ACC_ABSTRACT = 0x0400, + ACC_STRICT = 0x0800, + ACC_SYNTHETIC = 0x1000, + ACC_ANNOTATION = 0x2000, + ACC_ENUM = 0x4000 + }; + +} + +#endif // _JDWP_TYPES_H_ Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/agent/core/jdwpTypes.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwp.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwp.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwp.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwp.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,359 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Pavel N. Vyssotski + * @version $Revision: 1.5.2.1 $ + */ + +/** + * @file + * jdwp.h + * + */ + +#ifndef _JDWP_H_ +#define _JDWP_H_ + +/* JDWP Version */ +#define JDWP_VERSION_MAJOR 1 +#define JDWP_VERSION_MINOR 5 + +/* General JDWP constants */ +#define JDWP_FLAG_REPLY_PACKET ((jbyte)0x80) +#define JDWP_MIN_PACKET_LENGTH 11 + +/* Command Sets */ +typedef enum jdwpCommandSet { + JDWP_COMMAND_SET_VIRTUAL_MACHINE = 1, + JDWP_COMMAND_SET_REFERENCE_TYPE = 2, + JDWP_COMMAND_SET_CLASS_TYPE = 3, + JDWP_COMMAND_SET_ARRAY_TYPE = 4, + JDWP_COMMAND_SET_INTERFACE_TYPE = 5, + JDWP_COMMAND_SET_METHOD = 6, + JDWP_COMMAND_SET_FIELD = 8, + JDWP_COMMAND_SET_OBJECT_REFERENCE = 9, + JDWP_COMMAND_SET_STRING_REFERENCE = 10, + JDWP_COMMAND_SET_THREAD_REFERENCE = 11, + JDWP_COMMAND_SET_THREAD_GROUP_REFERENCE = 12, + JDWP_COMMAND_SET_ARRAY_REFERENCE = 13, + JDWP_COMMAND_SET_CLASS_LOADER_REFERENCE = 14, + JDWP_COMMAND_SET_EVENT_REQUEST = 15, + JDWP_COMMAND_SET_STACK_FRAME = 16, + JDWP_COMMAND_SET_CLASS_OBJECT_REFERENCE = 17, + JDWP_COMMAND_SET_EVENT = 64 +} jdwpCommandSet; + + +typedef enum jdwpCommand { + + /* Commands VirtualMachine */ + JDWP_COMMAND_VM_VERSION = 1, + JDWP_COMMAND_VM_CLASSES_BY_SIGNATURE = 2, + JDWP_COMMAND_VM_ALL_CLASSES = 3, + JDWP_COMMAND_VM_ALL_THREADS = 4, + JDWP_COMMAND_VM_TOP_LEVEL_THREAD_GROUPS = 5, + JDWP_COMMAND_VM_DISPOSE = 6, + JDWP_COMMAND_VM_ID_SIZES = 7, + JDWP_COMMAND_VM_SUSPEND = 8, + JDWP_COMMAND_VM_RESUME = 9, + JDWP_COMMAND_VM_EXIT = 10, + JDWP_COMMAND_VM_CREATE_STRING = 11, + JDWP_COMMAND_VM_CAPABILITIES = 12, + JDWP_COMMAND_VM_CLASS_PATHS = 13, + JDWP_COMMAND_VM_DISPOSE_OBJECTS = 14, + JDWP_COMMAND_VM_HOLD_EVENTS = 15, + JDWP_COMMAND_VM_RELEASE_EVENTS = 16, + JDWP_COMMAND_VM_CAPABILITIES_NEW = 17, + JDWP_COMMAND_VM_REDEFINE_CLASSES = 18, + JDWP_COMMAND_VM_SET_DEFAULT_STRATUM = 19, + JDWP_COMMAND_VM_ALL_CLASSES_WITH_GENERIC= 20, + + /* Commands ReferenceType */ + JDWP_COMMAND_RT_SIGNATURE = 1, + JDWP_COMMAND_RT_CLASS_LOADER = 2, + JDWP_COMMAND_RT_MODIFIERS = 3, + JDWP_COMMAND_RT_FIELDS = 4, + JDWP_COMMAND_RT_METHODS = 5, + JDWP_COMMAND_RT_GET_VALUES = 6, + JDWP_COMMAND_RT_SOURCE_FILE = 7, + JDWP_COMMAND_RT_NESTED_TYPES = 8, + JDWP_COMMAND_RT_STATUS = 9, + JDWP_COMMAND_RT_INTERFACES = 10, + JDWP_COMMAND_RT_CLASS_OBJECT = 11, + JDWP_COMMAND_RT_SOURCE_DEBUG_EXTENSION = 12, + JDWP_COMMAND_RT_SIGNATURE_WITH_GENERIC = 13, + JDWP_COMMAND_RT_FIELDS_WITH_GENERIC = 14, + JDWP_COMMAND_RT_METHODS_WITH_GENERIC = 15, + + /* Commands ClassType */ + JDWP_COMMAND_CT_SUPERCLASS = 1, + JDWP_COMMAND_CT_SET_VALUES = 2, + JDWP_COMMAND_CT_INVOKE_METHOD = 3, + JDWP_COMMAND_CT_NEW_INSTANCE = 4, + + /* Commands ArrayType */ + JDWP_COMMAND_AT_NEW_INSTANCE = 1, + + /* Commands Method */ + JDWP_COMMAND_M_LINE_TABLE = 1, + JDWP_COMMAND_M_VARIABLE_TABLE = 2, + JDWP_COMMAND_M_BYTECODES = 3, + JDWP_COMMAND_M_OBSOLETE = 4, + JDWP_COMMAND_M_VARIABLE_TABLE_WITH_GENERIC = 5, + + /* Commands ObjectReference */ + JDWP_COMMAND_OR_REFERENCE_TYPE = 1, + JDWP_COMMAND_OR_GET_VALUES = 2, + JDWP_COMMAND_OR_SET_VALUES = 3, + JDWP_COMMAND_OR_MONITOR_INFO = 5, + JDWP_COMMAND_OR_INVOKE_METHOD = 6, + JDWP_COMMAND_OR_DISABLE_COLLECTION = 7, + JDWP_COMMAND_OR_ENABLE_COLLECTION = 8, + JDWP_COMMAND_OR_IS_COLLECTED = 9, + + /* Commands StringReference */ + JDWP_COMMAND_SR_VALUE = 1, + + /* Commands ThreadReference */ + JDWP_COMMAND_TR_NAME = 1, + JDWP_COMMAND_TR_SUSPEND = 2, + JDWP_COMMAND_TR_RESUME = 3, + JDWP_COMMAND_TR_STATUS = 4, + JDWP_COMMAND_TR_THREAD_GROUP = 5, + JDWP_COMMAND_TR_FRAMES = 6, + JDWP_COMMAND_TR_FRAME_COUNT = 7, + JDWP_COMMAND_TR_OWNED_MONITORS = 8, + JDWP_COMMAND_TR_CURRENT_CONTENDED_MONITOR = 9, + JDWP_COMMAND_TR_STOP = 10, + JDWP_COMMAND_TR_INTERRUPT = 11, + JDWP_COMMAND_TR_SUSPEND_COUNT = 12, + + /* Commands ThreadGroupReference */ + JDWP_COMMAND_TGR_NAME = 1, + JDWP_COMMAND_TGR_PARENT = 2, + JDWP_COMMAND_TGR_CHILDREN = 3, + + /* Commands ArrayReference */ + JDWP_COMMAND_AR_LENGTH = 1, + JDWP_COMMAND_AR_GET_VALUES = 2, + JDWP_COMMAND_AR_SET_VALUES = 3, + + /* Commands ClassLoaderReference */ + JDWP_COMMAND_CLR_VISIBLE_CLASSES = 1, + + /* Commands EventRequest */ + JDWP_COMMAND_ER_SET = 1, + JDWP_COMMAND_ER_CLEAR = 2, + JDWP_COMMAND_ER_CLEAR_ALL_BREAKPOINTS = 3, + + /* Commands StackFrame */ + JDWP_COMMAND_SF_GET_VALUES = 1, + JDWP_COMMAND_SF_SET_VALUES = 2, + JDWP_COMMAND_SF_THIS_OBJECT = 3, + JDWP_COMMAND_SF_POP_FRAME = 4, + + /* Commands ClassObjectReference */ + JDWP_COMMAND_COR_REFLECTED_TYPE = 1, + + /* Commands Event */ + JDWP_COMMAND_E_COMPOSITE = 100 + +} jdwpCommand; + + +/* Error Constants */ +typedef enum jdwpError { + JDWP_ERROR_NONE = 0, + JDWP_ERROR_INVALID_THREAD = 10, + JDWP_ERROR_INVALID_THREAD_GROUP = 11, + JDWP_ERROR_INVALID_PRIORITY = 12, + JDWP_ERROR_THREAD_NOT_SUSPENDED = 13, + JDWP_ERROR_THREAD_SUSPENDED = 14, + JDWP_ERROR_INVALID_OBJECT = 20, + JDWP_ERROR_INVALID_CLASS = 21, + JDWP_ERROR_CLASS_NOT_PREPARED = 22, + JDWP_ERROR_INVALID_METHODID = 23, + JDWP_ERROR_INVALID_LOCATION = 24, + JDWP_ERROR_INVALID_FIELDID = 25, + JDWP_ERROR_INVALID_FRAMEID = 30, + JDWP_ERROR_NO_MORE_FRAMES = 31, + JDWP_ERROR_OPAQUE_FRAME = 32, + JDWP_ERROR_NOT_CURRENT_FRAME = 33, + JDWP_ERROR_TYPE_MISMATCH = 34, + JDWP_ERROR_INVALID_SLOT = 35, + JDWP_ERROR_DUPLICATE = 40, + JDWP_ERROR_NOT_FOUND = 41, + JDWP_ERROR_INVALID_MONITOR = 50, + JDWP_ERROR_NOT_MONITOR_OWNER = 51, + JDWP_ERROR_INTERRUPT = 52, + JDWP_ERROR_INVALID_CLASS_FORMAT = 60, + JDWP_ERROR_CIRCULAR_CLASS_DEFINITION = 61, + JDWP_ERROR_FAILS_VERIFICATION = 62, + JDWP_ERROR_ADD_METHOD_NOT_IMPLEMENTED = 63, + JDWP_ERROR_SCHEMA_CHANGE_NOT_IMPLEMENTED = 64, + JDWP_ERROR_INVALID_TYPESTATE = 65, + JDWP_ERROR_HIERARCHY_CHANGE_NOT_IMPLEMENTED = 66, + JDWP_ERROR_DELETE_METHOD_NOT_IMPLEMENTED = 67, + JDWP_ERROR_UNSUPPORTED_VERSION = 68, + JDWP_ERROR_NAMES_DONT_MATCH = 69, + JDWP_ERROR_CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 70, + JDWP_ERROR_METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 71, + JDWP_ERROR_NOT_IMPLEMENTED = 99, + JDWP_ERROR_NULL_POINTER = 100, + JDWP_ERROR_ABSENT_INFORMATION = 101, + JDWP_ERROR_INVALID_EVENT_TYPE = 102, + JDWP_ERROR_ILLEGAL_ARGUMENT = 103, + JDWP_ERROR_OUT_OF_MEMORY = 110, + JDWP_ERROR_ACCESS_DENIED = 111, + JDWP_ERROR_VM_DEAD = 112, + JDWP_ERROR_INTERNAL = 113, + JDWP_ERROR_UNATTACHED_THREAD = 115, + JDWP_ERROR_INVALID_TAG = 500, + JDWP_ERROR_ALREADY_INVOKING = 502, + JDWP_ERROR_INVALID_INDEX = 503, + JDWP_ERROR_INVALID_LENGTH = 504, + JDWP_ERROR_INVALID_STRING = 506, + JDWP_ERROR_INVALID_CLASS_LOADER = 507, + JDWP_ERROR_INVALID_ARRAY = 508, + JDWP_ERROR_TRANSPORT_LOAD = 509, + JDWP_ERROR_TRANSPORT_INIT = 510, + JDWP_ERROR_NATIVE_METHOD = 511, + JDWP_ERROR_INVALID_COUNT = 512 +} jdwpError; + + +/* EventKind Constants */ +typedef enum jdwpEventKind { + JDWP_EVENT_SINGLE_STEP = 1, + JDWP_EVENT_BREAKPOINT = 2, + JDWP_EVENT_FRAME_POP = 3, + JDWP_EVENT_EXCEPTION = 4, + JDWP_EVENT_USER_DEFINED = 5, + JDWP_EVENT_THREAD_START = 6, + JDWP_EVENT_THREAD_END = 7, + JDWP_EVENT_THREAD_DEATH = JDWP_EVENT_THREAD_END, + JDWP_EVENT_CLASS_PREPARE = 8, + JDWP_EVENT_CLASS_UNLOAD = 9, + JDWP_EVENT_CLASS_LOAD = 10, + JDWP_EVENT_FIELD_ACCESS = 20, + JDWP_EVENT_FIELD_MODIFICATION = 21, + JDWP_EVENT_EXCEPTION_CATCH = 30, + JDWP_EVENT_METHOD_ENTRY = 40, + JDWP_EVENT_METHOD_EXIT = 41, + JDWP_EVENT_VM_INIT = 90, + JDWP_EVENT_VM_START = JDWP_EVENT_VM_INIT, + JDWP_EVENT_VM_DEATH = 99, + JDWP_EVENT_VM_DISCONNECTED = 100 +} jdwpEventKind; + +/* EventRequest/ModifierKind Constants */ +typedef enum jdwpRequestModifier { + JDWP_MODIFIER_NONE = 0, + JDWP_MODIFIER_COUNT = 1, + JDWP_MODIFIER_CONDITIONAL = 2, + JDWP_MODIFIER_THREAD_ONLY = 3, + JDWP_MODIFIER_CLASS_ONLY = 4, + JDWP_MODIFIER_CLASS_MATCH = 5, + JDWP_MODIFIER_CLASS_EXCLUDE = 6, + JDWP_MODIFIER_LOCATION_ONLY = 7, + JDWP_MODIFIER_EXCEPTION_ONLY = 8, + JDWP_MODIFIER_FIELD_ONLY = 9, + JDWP_MODIFIER_STEP = 10, + JDWP_MODIFIER_INSTANCE_ONLY = 11 +} jdwpRequestModifier; + +/* ThreadStatus Constants */ +typedef enum jdwpThreadStatus { + JDWP_THREAD_STATUS_UNKNOWN = -1, + JDWP_THREAD_STATUS_ZOMBIE = 0, + JDWP_THREAD_STATUS_RUNNING = 1, + JDWP_THREAD_STATUS_SLEEPING = 2, + JDWP_THREAD_STATUS_MONITOR = 3, + JDWP_THREAD_STATUS_WAIT = 4, + JDWP_THREAD_STATUS_NOT_STARTED = 5 +} jdwpThreadStatus; + +/* SuspendStatus Constants */ +#define JDWP_SUSPEND_STATUS_SUSPENDED 0x1 + +/* ClassStatus Constants */ +typedef enum jdwpClassStatus { + JDWP_CLASS_STATUS_VERIFIED = 1, + JDWP_CLASS_STATUS_PREPARED = 2, + JDWP_CLASS_STATUS_INITIALIZED = 4, + JDWP_CLASS_STATUS_ERROR = 8 +} jdwpClassStatus; + +/* TypeTag Constants */ +typedef enum jdwpTypeTag { + JDWP_TYPE_TAG_CLASS = 1, + JDWP_TYPE_TAG_INTERFACE = 2, + JDWP_TYPE_TAG_ARRAY = 3 +} jdwpTypeTag; + +/* Tag Constants */ +typedef enum jdwpTag { + JDWP_TAG_NONE = 0, + JDWP_TAG_ARRAY = 91, + JDWP_TAG_BYTE = 66, + JDWP_TAG_CHAR = 67, + JDWP_TAG_OBJECT = 76, + JDWP_TAG_FLOAT = 70, + JDWP_TAG_DOUBLE = 68, + JDWP_TAG_INT = 73, + JDWP_TAG_LONG = 74, + JDWP_TAG_SHORT = 83, + JDWP_TAG_VOID = 86, + JDWP_TAG_BOOLEAN = 90, + JDWP_TAG_STRING = 115, + JDWP_TAG_THREAD = 116, + JDWP_TAG_THREAD_GROUP = 103, + JDWP_TAG_CLASS_LOADER = 108, + JDWP_TAG_CLASS_OBJECT = 99 +} jdwpTag; + +/* representation of null ObjectID */ +#define JDWP_OBJECT_ID_NULL 0 + +/* StepDepth Constants */ +typedef enum jdwpStepDepth { + JDWP_STEP_INTO = 0, + JDWP_STEP_OVER = 1, + JDWP_STEP_OUT = 2 +} jdwpStepDepth; + +/* StepSize Constants */ +typedef enum jdwpStepSize { + JDWP_STEP_MIN = 0, + JDWP_STEP_LINE = 1 +} jdwpStepSize; + +/* SuspendPolicy Constants */ +typedef enum jdwpSuspendPolicy { + JDWP_SUSPEND_NONE = 0, + JDWP_SUSPEND_EVENT_THREAD = 1, + JDWP_SUSPEND_ALL = 2 +} jdwpSuspendPolicy; + +/* Invoke options constants */ +#define JDWP_INVOKE_SINGLE_THREADED 0x01 +#define JDWP_INVOKE_NONVIRTUAL 0x02 + + +#endif /* _JDWP_H_ */ Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwp.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwpTransport.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwpTransport.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwpTransport.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwpTransport.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,467 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Viacheslav G. Rybalov + * @version $Revision: 1.8.2.1 $ + */ + +/** + * @file + * jdwpTransport.h + * + */ + +#ifndef _JDWPTRANSPORT_H_ +#define _JDWPTRANSPORT_H_ + +#include "jni.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct jdwpTransportNativeInterface_; + +struct _jdwpTransportEnv; + +#ifdef __cplusplus +typedef _jdwpTransportEnv jdwpTransportEnv; +#else +typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv; +#endif + +/** + * JDWP transport version number. + */ +enum { + JDWPTRANSPORT_VERSION_1_0 = 0x00010000 +}; + +/** + * The list of JDWP transport error codes. + */ +typedef enum { + JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204, + JDWPTRANSPORT_ERROR_TIMEOUT = 203, + JDWPTRANSPORT_ERROR_IO_ERROR = 202, + JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201, + JDWPTRANSPORT_ERROR_INTERNAL = 113, + JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110, + JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103, + JDWPTRANSPORT_ERROR_NONE = 0 +} jdwpTransportError; + +/** + * The structure contains JDWP transport capabilities. + * One bit per capability. + */ +typedef struct { + unsigned int can_timeout_attach :1; + unsigned int can_timeout_accept :1; + unsigned int can_timeout_handshake :1; + unsigned int reserved3 :1; + unsigned int reserved4 :1; + unsigned int reserved5 :1; + unsigned int reserved6 :1; + unsigned int reserved7 :1; + unsigned int reserved8 :1; + unsigned int reserved9 :1; + unsigned int reserved10 :1; + unsigned int reserved11 :1; + unsigned int reserved12 :1; + unsigned int reserved13 :1; + unsigned int reserved14 :1; + unsigned int reserved15 :1; +} JDWPTransportCapabilities; + +/** + * JDWP transport flags. + */ +enum { + JDWPTRANSPORT_FLAGS_REPLY = 0x80, + JDWPTRANSPORT_FLAGS_NONE = 0x0 +}; + +/** + * The JDWP transport callback function type. + * See the JVM JPDA/JDWP specification for details. + */ +typedef struct jdwpTransportCallback { + void *(*alloc)(jint numBytes); + void (*free)(void *buffer); +} jdwpTransportCallback; + +/** + * The structure for the JDWP reply packet. + * See the JVM JPDA/JDWP specification for details. + */ +typedef struct { + + /** + * The entire packet size in bytes. + */ + jint len; + + /** + * The packet identification number. + */ + jint id; + + /** + * The packet type flag = JDWPTRANSPORT_FLAGS_REPLY. + */ + jbyte flags; + + /** + * The error code for the command packet that was replied to. + */ + jshort errorCode; + + /** + * Specific packet data. + */ + jbyte *data; + +} jdwpReplyPacket; + +/** + * The structure for the JDWP command packet. + * See the JVM JPDA/JDWP specification for details. + */ +typedef struct { + + /** + * The entire packet size in bytes. + */ + jint len; + + /** + * The packet identification number. + */ + jint id; + + /** + * The packet type flag = JDWPTRANSPORT_FLAGS_NONE. + */ + jbyte flags; + + /** + * The command set number. + */ + jbyte cmdSet; + + /** + * The command number. + */ + jbyte cmd; + + /** + * The specific packet data. + */ + jbyte *data; + +} jdwpCmdPacket; + +/** + * The unified structure for the JDWP command or reply packet. + */ +typedef struct { + union { + + /** + * The command packet. + */ + jdwpCmdPacket cmd; + + /** + * The reply packet. + */ + jdwpReplyPacket reply; + + } type; +} jdwpPacket; + +typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, + jdwpTransportCallback *callback, + jint version, jdwpTransportEnv** env); + +/** + * The structure representing transport-native interface with capabilities + * to establish a connection with the debugger as well as to communicate with it. + */ +struct jdwpTransportNativeInterface_ { + + void *reserved1; + + /** + * Gets capabilities of the used transport component. + * + * @param[in] env - the transport environment pointer + * @param[out] capabilitiesPtr - the pointer to capabilities descriptor + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env, + JDWPTransportCapabilities *capabilitiesPtr); + + /** + * Connects to the debugger listening on the specified address + * and establishes a communication channel after a successful handshake. + * + * @param[in] env - the transport environment pointer + * @param[out] address - the address at which the debugger listens + * @param[in] attachTimeout - the time-out for connection to the debugger + * @param[in] handshakeTimeout - the time-out for handshake with the debugger + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env, + const char* address, jlong attachTimeout, jlong handshakeTimeout); + + /** + * Starts listening at the specified address. + * + * @param[in] env - the ransport environment pointer + * @param[in] address - the address at which the listen starts + * @param[out] actualAddress - the real address at which the listen will + * start + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env, + const char* address, char** actualAddress); + + /** + * Stops listening operation. + * + * @param[in] env - the transport environment pointer + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env); + + /** + * Accepts the debugger and establishes a communication channel after a + * successful handshake. + * + * @param[in] env - the transport environment pointer + * @param[in] attachTimeout - the time-out for connection to the debugger + * @param[in] handshakeTimeout - the time-out for handshake with the debugger + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env, + jlong acceptTimeout, jlong handshakeTimeout); + + /** + * Checks whether the communication channel is opened. + * + * @param[in] env - the transport environment pointer + * + * @return Boolean. + */ + jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env); + + /** + * Closes the opened communication channel. + * + * @param[in] env - the transport environment pointer + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env); + + /** + * Reads a packet from the debugger. + * + * @param[in] env - the transport environment pointer + * @param[out] packet - the packet structure + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env, + jdwpPacket *packet); + + /** + * Sends the given packet to the debugger. + * + * @param[in] env - the transport environment pointer + * @param[in] packet - the packet structure + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env, + const jdwpPacket* packet); + + /** + * Gets the last transport-error description. + * + * @param[in] env - the transport environment pointer + * @param[out] msg - the pointer to the string buffer for an error message + * + * @return The transport-error code. + */ + jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, + char** msg); + +}; + +/** + * The structure contain pointer to the Transport native interface and + * wraps its code into C++ style members. + */ +struct _jdwpTransportEnv { + + const struct jdwpTransportNativeInterface_ *functions; + +#ifdef __cplusplus + + /** + * Gets capabilities of the used transport component. + * + * @param[out] capabilitiesPtr - the pointer to capabilities descriptor + * + * @return The transport-error code. + */ + jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilitiesPtr) + { + return functions->GetCapabilities(this, capabilitiesPtr); + } + + /** + * Connects to the debugger listening on the specified address + * and establishes a communication channel after a successful handshake. + * + * @param[in] address - the address at which the debugger listens + * @param[in] attachTimeout - the time-out for connection to the debugger + * @param[in] handshakeTimeout - the time-out for handshake with the debugger + * + * @return The transport-error code. + */ + jdwpTransportError Attach(const char* address, jlong attachTimeout, + jlong handshakeTimeout) + { + return functions->Attach(this, address, attachTimeout, handshakeTimeout); + } + + /** + * Starts listening at the specified address. + * + * @param[in] address - the address at which our listen starts + * @param[out] actualAddress - the real address at which the listen will + * start + * + * @return The transport-error code. + */ + jdwpTransportError StartListening(const char* address, + char** actualAddress) + { + return functions->StartListening(this, address, actualAddress); + } + + /** + * Stops listening operation. + * + * @return The transport-error code. + */ + jdwpTransportError StopListening(void) + { + return functions->StopListening(this); + } + + /** + * Accepts the debugger and establishes a communication channel after a + * successful handshake. + * + * @param[in] acceptTimeout - the time-out for accepting connection + * from the debugger + * @param[in] handshakeTimeout - the time-out for a handshake with the + * debugger + * + * @return The transport-error code. + */ + jdwpTransportError Accept(jlong acceptTimeout, jlong handshakeTimeout) + { + return functions->Accept(this, acceptTimeout, handshakeTimeout); + } + + /** + * Checks whether the communication channel is opened. + * + * @return Boolean. + */ + jboolean IsOpen(void) + { + return functions->IsOpen(this); + } + + /** + * Closes the opened communication channel. + * + * @return The transport-error code. + */ + jdwpTransportError Close(void) + { + return functions->Close(this); + } + + /** + * Reads a packet from the debugger. + * + * @param[out] packet - the packet structure + * + * @return The transport-error code. + */ + jdwpTransportError ReadPacket(jdwpPacket *packet) + { + return functions->ReadPacket(this, packet); + } + + /** + * Sends the given packet to the debugger. + * + * @param[in] packet - the packet structure + * + * @return The transport-error code. + */ + jdwpTransportError WritePacket(const jdwpPacket* packet) + { + return functions->WritePacket(this, packet); + } + + /** + * Gets the last transport error description. + * + * @param[out] msg - the pointer to the string buffer for an error message + * + * @return The transport-error code. + */ + jdwpTransportError GetLastError(char** msg) + { + return functions->GetLastError(this, msg); + } + +#endif +}; + +#ifdef __cplusplus +} +#endif + +#endif Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/generic/jdwpTransport.h ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.cpp URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.cpp?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.cpp (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.cpp Tue Nov 28 09:49:08 2006 @@ -0,0 +1,131 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Viacheslav G. Rybalov + * @version $Revision: 1.6 $ + */ +#include "SocketTransport_pd.h" + +void (*LastTransportError::m_free)(void *buffer) = 0; + +LastTransportError::LastTransportError(const char* messagePtr, int errorStatus, + void* (*alloc)(jint numBytes), void (*free)(void *buffer)) +{ + m_treadId = GetCurrentThreadId(); + m_lastErrorMessage = messagePtr; + m_lastErrorMessagePrefix = ""; + m_lastErrorStatus = errorStatus; + m_alloc = alloc; + m_free = free; + m_next = 0; +} + +LastTransportError::~LastTransportError(void) +{ + if (m_next != 0) { + delete m_next; + } +} + +void* +LastTransportError::operator new(size_t bytes, void* (*alloc)(jint numBytes), void (*free)(void *buffer)) +{ + return (*alloc)((jint)bytes); +} + +void +LastTransportError::operator delete(void* address) +{ + (*m_free)(address); +} + +void +LastTransportError::operator delete(void* address, void* (*alloc)(jint numBytes), void (*free)(void *buffer)) +{ + (*free)(address); +} + + +jdwpTransportError +LastTransportError::insertError(const char* messagePtr, int errorStatus) +{ + if (ThreadId_equal(m_treadId, GetCurrentThreadId())) { + 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); + if (m_next == 0) { + return JDWPTRANSPORT_ERROR_OUT_OF_MEMORY; + } + } + return JDWPTRANSPORT_ERROR_NONE; +} + +jdwpTransportError +LastTransportError::addErrorMessagePrefix(const char* prefixPtr) +{ + if (ThreadId_equal(m_treadId, GetCurrentThreadId())) { + m_lastErrorMessagePrefix = (prefixPtr == 0 ? "" : prefixPtr); + } else if (m_next != 0) { + return m_next->addErrorMessagePrefix(prefixPtr); + } + return JDWPTRANSPORT_ERROR_NONE; +} + +int +LastTransportError::GetLastErrorStatus() +{ + if (ThreadId_equal(m_treadId, GetCurrentThreadId())) { + return m_lastErrorStatus; + } else if (m_next != 0) { + return m_next->GetLastErrorStatus(); + } + return 0; +} + +char* +LastTransportError::GetLastErrorMessage() +{ + if (ThreadId_equal(m_treadId, GetCurrentThreadId())) { + char buf[32]; + sprintf(buf, "%d", m_lastErrorStatus); + + size_t strLength = (m_lastErrorStatus == 0) ? + strlen(m_lastErrorMessagePrefix) + strlen(m_lastErrorMessage) + 1 : + strlen(m_lastErrorMessagePrefix) + strlen(m_lastErrorMessage) + strlen(" (error code: )") + strlen(buf) + 1; + + char* message = (char*)(*m_alloc)((jint)strLength); + if (message == 0) { + return 0; + } + + if (m_lastErrorStatus == 0) { + sprintf(message, "%s%s", m_lastErrorMessagePrefix, m_lastErrorMessage); + } else { + sprintf(message, "%s%s (error code: %s)", m_lastErrorMessagePrefix, m_lastErrorMessage, buf); + } + return message; + + } else if (m_next != 0) { + return m_next->GetLastErrorMessage(); + } + return 0; +} Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.h URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.h?view=auto&rev=480141 ============================================================================== --- harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.h (added) +++ harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.h Tue Nov 28 09:49:08 2006 @@ -0,0 +1,115 @@ +/* + * Copyright 2005-2006 The Apache Software Foundation or its licensors, + * as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Viacheslav G. Rybalov + * @version $Revision: 1.9.2.1 $ + */ + +/** + * @file + * LastTransportError.h + * + */ + +#ifndef _LASTTRANSPORTERROR_H +#define _LASTTRANSPORTERROR_H + +#include "SocketTransport_pd.h" + +/** + * The given class is a container for message and status code of the last + * transport error. + */ +class LastTransportError +{ +public: + /** + * A constructor. + * + * @param messagePtr - the pointer to the string with diagnostics for the + * last failed operation + * @param errorStatus - the error status for the last failed operation + * @param alloc - the pointer to the function allocating the memory + * area + * @param free - the pointer to the function deallocating the memory + * area + */ + LastTransportError(const char* messagePtr, int errorStatus, + void* (*alloc)(jint numBytes), void (*free)(void *buffer)); + + /** + * A destructor. + */ + ~LastTransportError(); + + /** + * Inserts new Error data for the current thread. + * + * @param messagePtr - the pointer to the string with diagnostics for the + * last failed operation + * @param errorStatus - the error status for the last failed operation + * + * @return Returns JDWPTRANSPORT_ERROR_OUT_OF_MEMORY if out of memory, + * otherwise JDWPTRANSPORT_ERROR_NONE. + */ + jdwpTransportError insertError(const char* messagePtr, int errorStatus); + + /** + * Adds a message prefix for the current thread. + * + * @param prefixPtr - the pointer to the string with the message prefix + * + * @return Returns JDWPTRANSPORT_ERROR_OUT_OF_MEMORY if out of memory, + * otherwise JDWPTRANSPORT_ERROR_NONE. + */ + jdwpTransportError addErrorMessagePrefix(const char* prefixPtr); + + /** + * Returns the pointer to the string with diagnostics for the last failed + * operation in the current thread. + * + * @return Returns the pointer to the string with diagnostics for the last + * failed operation. + */ + char* GetLastErrorMessage(); + + /** + * Returns the error status for the last failed operation in the current + * thread. + * + * @return Returns the error status for the last failed operation. + */ + int GetLastErrorStatus(); + + void* operator new(size_t bytes, void* (*alloc)(jint numBytes), void (*free)(void *buffer)); + void operator delete(void* address); + void operator delete(void* address, void* (*alloc)(jint numBytes), void (*free)(void *buffer)); + +private: + 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 + int m_lastErrorStatus; // the error status for the last failed operation + LastTransportError* m_next; // pointer to the next LastTransportError + void* (*m_alloc)(jint numBytes); // function allocating the memory area, provided by the agent + static void (*m_free)(void *buffer); // function deallocating the memory area, provided by the agent + +}; + +#endif // _LASTTRANSPORTERROR_H Propchange: harmony/enhanced/jdktools/trunk/modules/jpda/src/common/other/jpda/jdwp/transport/common/LastTransportError.h ------------------------------------------------------------------------------ svn:eol-style = native