Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/javavm/export/jdwpTransport.h
38813 views
/*1* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/*26* Java Debug Wire Protocol Transport Service Provider Interface.27*/2829#ifndef JDWPTRANSPORT_H30#define JDWPTRANSPORT_H3132#include "jni.h"3334enum {35JDWPTRANSPORT_VERSION_1_0 = 0x0001000036};3738#ifdef __cplusplus39extern "C" {40#endif4142struct jdwpTransportNativeInterface_;4344struct _jdwpTransportEnv;4546#ifdef __cplusplus47typedef _jdwpTransportEnv jdwpTransportEnv;48#else49typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;50#endif /* __cplusplus */5152/*53* Errors. Universal errors with JVMTI/JVMDI equivalents keep the54* values the same.55*/56typedef enum {57JDWPTRANSPORT_ERROR_NONE = 0,58JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,59JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,60JDWPTRANSPORT_ERROR_INTERNAL = 113,61JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,62JDWPTRANSPORT_ERROR_IO_ERROR = 202,63JDWPTRANSPORT_ERROR_TIMEOUT = 203,64JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 20465} jdwpTransportError;666768/*69* Structure to define capabilities70*/71typedef struct {72unsigned int can_timeout_attach :1;73unsigned int can_timeout_accept :1;74unsigned int can_timeout_handshake :1;75unsigned int reserved3 :1;76unsigned int reserved4 :1;77unsigned int reserved5 :1;78unsigned int reserved6 :1;79unsigned int reserved7 :1;80unsigned int reserved8 :1;81unsigned int reserved9 :1;82unsigned int reserved10 :1;83unsigned int reserved11 :1;84unsigned int reserved12 :1;85unsigned int reserved13 :1;86unsigned int reserved14 :1;87unsigned int reserved15 :1;88} JDWPTransportCapabilities;899091/*92* Structures to define packet layout.93*94* See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html95*/9697enum {98/*99* If additional flags are added that apply to jdwpCmdPacket,100* then debugLoop.c: reader() will need to be updated to101* accept more than JDWPTRANSPORT_FLAGS_NONE.102*/103JDWPTRANSPORT_FLAGS_NONE = 0x0,104JDWPTRANSPORT_FLAGS_REPLY = 0x80105};106107typedef struct {108jint len;109jint id;110jbyte flags;111jbyte cmdSet;112jbyte cmd;113jbyte *data;114} jdwpCmdPacket;115116typedef struct {117jint len;118jint id;119jbyte flags;120jshort errorCode;121jbyte *data;122} jdwpReplyPacket;123124typedef struct {125union {126jdwpCmdPacket cmd;127jdwpReplyPacket reply;128} type;129} jdwpPacket;130131/*132* JDWP functions called by the transport.133*/134typedef struct jdwpTransportCallback {135void *(*alloc)(jint numBytes); /* Call this for all allocations */136void (*free)(void *buffer); /* Call this for all deallocations */137} jdwpTransportCallback;138139typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,140jdwpTransportCallback *callback,141jint version,142jdwpTransportEnv** env);143144145146/* Function Interface */147148struct jdwpTransportNativeInterface_ {149/* 1 : RESERVED */150void *reserved1;151152/* 2 : Get Capabilities */153jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,154JDWPTransportCapabilities *capabilities_ptr);155156/* 3 : Attach */157jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,158const char* address,159jlong attach_timeout,160jlong handshake_timeout);161162/* 4: StartListening */163jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,164const char* address,165char** actual_address);166167/* 5: StopListening */168jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);169170/* 6: Accept */171jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,172jlong accept_timeout,173jlong handshake_timeout);174175/* 7: IsOpen */176jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);177178/* 8: Close */179jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);180181/* 9: ReadPacket */182jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,183jdwpPacket *pkt);184185/* 10: Write Packet */186jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,187const jdwpPacket* pkt);188189/* 11: GetLastError */190jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,191char** error);192193};194195196/*197* Use inlined functions so that C++ code can use syntax such as198* env->Attach("mymachine:5000", 10*1000, 0);199*200* rather than using C's :-201*202* (*env)->Attach(env, "mymachine:5000", 10*1000, 0);203*/204struct _jdwpTransportEnv {205const struct jdwpTransportNativeInterface_ *functions;206#ifdef __cplusplus207208jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {209return functions->GetCapabilities(this, capabilities_ptr);210}211212jdwpTransportError Attach(const char* address, jlong attach_timeout,213jlong handshake_timeout) {214return functions->Attach(this, address, attach_timeout, handshake_timeout);215}216217jdwpTransportError StartListening(const char* address,218char** actual_address) {219return functions->StartListening(this, address, actual_address);220}221222jdwpTransportError StopListening(void) {223return functions->StopListening(this);224}225226jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {227return functions->Accept(this, accept_timeout, handshake_timeout);228}229230jboolean IsOpen(void) {231return functions->IsOpen(this);232}233234jdwpTransportError Close(void) {235return functions->Close(this);236}237238jdwpTransportError ReadPacket(jdwpPacket *pkt) {239return functions->ReadPacket(this, pkt);240}241242jdwpTransportError WritePacket(const jdwpPacket* pkt) {243return functions->WritePacket(this, pkt);244}245246jdwpTransportError GetLastError(char** error) {247return functions->GetLastError(this, error);248}249250251#endif /* __cplusplus */252};253254#ifdef __cplusplus255} /* extern "C" */256#endif /* __cplusplus */257258#endif /* JDWPTRANSPORT_H */259260261