0N/A/*
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * Java Debug Wire Protocol Transport Service Provider Interface.
0N/A */
0N/A
0N/A#ifndef JDWPTRANSPORT_H
0N/A#define JDWPTRANSPORT_H
0N/A
0N/A#include "jni.h"
0N/A
0N/Aenum {
0N/A JDWPTRANSPORT_VERSION_1_0 = 0x00010000
0N/A};
0N/A
0N/A#ifdef __cplusplus
0N/Aextern "C" {
0N/A#endif
0N/A
0N/Astruct jdwpTransportNativeInterface_;
0N/A
0N/Astruct _jdwpTransportEnv;
0N/A
0N/A#ifdef __cplusplus
0N/Atypedef _jdwpTransportEnv jdwpTransportEnv;
0N/A#else
0N/Atypedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
0N/A#endif /* __cplusplus */
0N/A
0N/A/*
0N/A * Errors. Universal errors with JVMTI/JVMDI equivalents keep the
0N/A * values the same.
0N/A */
0N/Atypedef enum {
0N/A JDWPTRANSPORT_ERROR_NONE = 0,
0N/A JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
0N/A JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
0N/A JDWPTRANSPORT_ERROR_INTERNAL = 113,
0N/A JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
0N/A JDWPTRANSPORT_ERROR_IO_ERROR = 202,
0N/A JDWPTRANSPORT_ERROR_TIMEOUT = 203,
0N/A JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
0N/A} jdwpTransportError;
0N/A
0N/A
0N/A/*
0N/A * Structure to define capabilities
0N/A */
0N/Atypedef struct {
0N/A unsigned int can_timeout_attach :1;
0N/A unsigned int can_timeout_accept :1;
0N/A unsigned int can_timeout_handshake :1;
0N/A unsigned int reserved3 :1;
0N/A unsigned int reserved4 :1;
0N/A unsigned int reserved5 :1;
0N/A unsigned int reserved6 :1;
0N/A unsigned int reserved7 :1;
0N/A unsigned int reserved8 :1;
0N/A unsigned int reserved9 :1;
0N/A unsigned int reserved10 :1;
0N/A unsigned int reserved11 :1;
0N/A unsigned int reserved12 :1;
0N/A unsigned int reserved13 :1;
0N/A unsigned int reserved14 :1;
0N/A unsigned int reserved15 :1;
0N/A} JDWPTransportCapabilities;
0N/A
0N/A
0N/A/*
0N/A * Structures to define packet layout.
0N/A *
0N/A * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html
0N/A */
0N/A
0N/Aenum {
0N/A JDWPTRANSPORT_FLAGS_NONE = 0x0,
0N/A JDWPTRANSPORT_FLAGS_REPLY = 0x80
0N/A};
0N/A
0N/Atypedef struct {
0N/A jint len;
0N/A jint id;
0N/A jbyte flags;
0N/A jbyte cmdSet;
0N/A jbyte cmd;
0N/A jbyte *data;
0N/A} jdwpCmdPacket;
0N/A
0N/Atypedef struct {
0N/A jint len;
0N/A jint id;
0N/A jbyte flags;
0N/A jshort errorCode;
0N/A jbyte *data;
0N/A} jdwpReplyPacket;
0N/A
0N/Atypedef struct {
0N/A union {
0N/A jdwpCmdPacket cmd;
0N/A jdwpReplyPacket reply;
0N/A } type;
0N/A} jdwpPacket;
0N/A
0N/A/*
0N/A * JDWP functions called by the transport.
0N/A */
0N/Atypedef struct jdwpTransportCallback {
0N/A void *(*alloc)(jint numBytes); /* Call this for all allocations */
0N/A void (*free)(void *buffer); /* Call this for all deallocations */
0N/A} jdwpTransportCallback;
0N/A
0N/Atypedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
0N/A jdwpTransportCallback *callback,
0N/A jint version,
0N/A jdwpTransportEnv** env);
0N/A
0N/A
0N/A
0N/A/* Function Interface */
0N/A
0N/Astruct jdwpTransportNativeInterface_ {
0N/A /* 1 : RESERVED */
0N/A void *reserved1;
0N/A
0N/A /* 2 : Get Capabilities */
0N/A jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
0N/A JDWPTransportCapabilities *capabilities_ptr);
0N/A
0N/A /* 3 : Attach */
0N/A jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
0N/A const char* address,
0N/A jlong attach_timeout,
0N/A jlong handshake_timeout);
0N/A
0N/A /* 4: StartListening */
0N/A jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,
0N/A const char* address,
0N/A char** actual_address);
0N/A
0N/A /* 5: StopListening */
0N/A jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);
0N/A
0N/A /* 6: Accept */
0N/A jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
0N/A jlong accept_timeout,
0N/A jlong handshake_timeout);
0N/A
0N/A /* 7: IsOpen */
0N/A jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
0N/A
0N/A /* 8: Close */
0N/A jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
0N/A
0N/A /* 9: ReadPacket */
0N/A jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
0N/A jdwpPacket *pkt);
0N/A
0N/A /* 10: Write Packet */
0N/A jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
0N/A const jdwpPacket* pkt);
0N/A
0N/A /* 11: GetLastError */
0N/A jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
0N/A char** error);
0N/A
0N/A};
0N/A
0N/A
0N/A/*
0N/A * Use inlined functions so that C++ code can use syntax such as
0N/A * env->Attach("mymachine:5000", 10*1000, 0);
0N/A *
0N/A * rather than using C's :-
0N/A *
0N/A * (*env)->Attach(env, "mymachine:5000", 10*1000, 0);
0N/A */
0N/Astruct _jdwpTransportEnv {
0N/A const struct jdwpTransportNativeInterface_ *functions;
0N/A#ifdef __cplusplus
0N/A
0N/A jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
0N/A return functions->GetCapabilities(this, capabilities_ptr);
0N/A }
0N/A
0N/A jdwpTransportError Attach(const char* address, jlong attach_timeout,
0N/A jlong handshake_timeout) {
0N/A return functions->Attach(this, address, attach_timeout, handshake_timeout);
0N/A }
0N/A
0N/A jdwpTransportError StartListening(const char* address,
0N/A char** actual_address) {
0N/A return functions->StartListening(this, address, actual_address);
0N/A }
0N/A
0N/A jdwpTransportError StopListening(void) {
0N/A return functions->StopListening(this);
0N/A }
0N/A
0N/A jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
0N/A return functions->Accept(this, accept_timeout, handshake_timeout);
0N/A }
0N/A
0N/A jboolean IsOpen(void) {
0N/A return functions->IsOpen(this);
0N/A }
0N/A
0N/A jdwpTransportError Close(void) {
0N/A return functions->Close(this);
0N/A }
0N/A
0N/A jdwpTransportError ReadPacket(jdwpPacket *pkt) {
0N/A return functions->ReadPacket(this, pkt);
0N/A }
0N/A
0N/A jdwpTransportError WritePacket(const jdwpPacket* pkt) {
0N/A return functions->WritePacket(this, pkt);
0N/A }
0N/A
0N/A jdwpTransportError GetLastError(char** error) {
0N/A return functions->GetLastError(this, error);
0N/A }
0N/A
0N/A
0N/A#endif /* __cplusplus */
0N/A};
0N/A
0N/A#ifdef __cplusplus
0N/A} /* extern "C" */
0N/A#endif /* __cplusplus */
0N/A
0N/A#endif /* JDWPTRANSPORT_H */