/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <string.h>
#include "jdwpTransport.h"
#include "shmemBase.h"
#include "sysShmem.h"
#include "sys.h"
/*
* The Shared Memory Transport Library.
*
* This module is an implementation of the Java Debug Wire Protocol Transport
* Service Provider Interface - see src/share/javavm/export/jdwpTransport.h.
*/
/*
* Thread-local index to the per-thread error message
*/
static int tlsIndex;
/*
* Return an error and record the error message associated with
* the error. Note the if (1==1) { } usage here is to avoid
* compilers complaining that a statement isn't reached which
* will arise if the semicolon (;) appears after the macro,
*/
if (1==1) { \
return err; \
}
/*
* Return an I/O error and record the error message.
*/
/*
* Set the error message for this thread. If the error is an I/O
* error then augment the supplied error message with the textual
* representation of the I/O error.
*/
static void
char *msg;
/* get any I/O first in case any system calls override errno */
if (err == JDWPTRANSPORT_ERROR_IO_ERROR) {
buf[0] = '\0';
}
}
/* free any current error */
}
/*
* For I/O errors append the I/O error message with to the
* supplied message. For all other errors just use the supplied
* message.
*/
if (err == JDWPTRANSPORT_ERROR_IO_ERROR) {
}
} else {
}
}
/* Put a pointer to the message in TLS */
}
static jdwpTransportError
{
unsigned int i;
jbyte b;
if (rv != 0) {
RETURN_IO_ERROR("receive failed during handshake");
}
if ((char)b != hello[i]) {
RETURN_IO_ERROR("handshake failed - debugger sent unexpected message");
}
}
if (rv != 0) {
RETURN_IO_ERROR("write failed during handshake");
}
}
return JDWPTRANSPORT_ERROR_NONE;
}
/*
* Return the capabilities of the shared memory transport. The shared
* memory transport supports both the attach and accept timeouts but
* doesn't support a handshake timeout.
*/
static jdwpTransportError JNICALL
{
return JDWPTRANSPORT_ERROR_NONE;
}
static jdwpTransportError JNICALL
{
}
/*
* If a name was selected by the function above, find it and return
* it in place of the original arg.
*/
char *name;
char *name2;
} else {
*actualAddress = name2;
}
}
} else {
RETURN_IO_ERROR("failed to create shared memory listener");
}
return JDWPTRANSPORT_ERROR_NONE;
}
static jdwpTransportError JNICALL
{
if (connection != NULL) {
}
}
if (rc == SYS_TIMEOUT) {
} else {
RETURN_IO_ERROR("failed to accept shared memory connection");
}
}
if (rc != JDWPTRANSPORT_ERROR_NONE) {
connection = NULL;
}
return rc;
}
static jdwpTransportError JNICALL
{
}
return JDWPTRANSPORT_ERROR_NONE;
}
static jdwpTransportError JNICALL
shmemAttach(jdwpTransportEnv* env, const char *address, jlong attachTimeout, jlong handshakeTimeout)
{
if (connection != NULL) {
}
}
if (rc == SYS_TIMEOUT) {
}
RETURN_IO_ERROR("failed to attach to shared memory connection");
}
if (rc != JDWPTRANSPORT_ERROR_NONE) {
connection = NULL;
}
return rc;
}
static jdwpTransportError JNICALL
{
}
}
if (connection == NULL) {
}
return JDWPTRANSPORT_ERROR_NONE;
} else {
RETURN_IO_ERROR("write packet failed");
}
}
static jdwpTransportError JNICALL
{
}
if (connection == NULL) {
}
return JDWPTRANSPORT_ERROR_NONE;
} else {
RETURN_IO_ERROR("receive packet failed");
}
}
{
if (connection != NULL) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
static jdwpTransportError JNICALL
{
if (current_connection != NULL) {
connection = NULL;
}
return JDWPTRANSPORT_ERROR_NONE;
}
/*
* Return the error message for this thread.
*/
static jdwpTransportError JNICALL
{
}
}
return JDWPTRANSPORT_ERROR_NONE;
}
{
if (version != JDWPTRANSPORT_VERSION_1_0) {
return JNI_EVERSION;
}
if (initialized) {
/*
* This library doesn't support multiple environments (yet)
*/
return JNI_EEXIST;
}
/* initialize base shared memory system */
/* save callbacks */
/* initialize interface table */
*result = &single_env;
/* initialized TLS */
tlsIndex = sysTlsAlloc();
return JNI_OK;
}