annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/jdwpTransport.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
jpayne@69 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jpayne@69 4 *
jpayne@69 5 * This code is free software; you can redistribute it and/or modify it
jpayne@69 6 * under the terms of the GNU General Public License version 2 only, as
jpayne@69 7 * published by the Free Software Foundation. Oracle designates this
jpayne@69 8 * particular file as subject to the "Classpath" exception as provided
jpayne@69 9 * by Oracle in the LICENSE file that accompanied this code.
jpayne@69 10 *
jpayne@69 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jpayne@69 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jpayne@69 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jpayne@69 14 * version 2 for more details (a copy is included in the LICENSE file that
jpayne@69 15 * accompanied this code).
jpayne@69 16 *
jpayne@69 17 * You should have received a copy of the GNU General Public License version
jpayne@69 18 * 2 along with this work; if not, write to the Free Software Foundation,
jpayne@69 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jpayne@69 20 *
jpayne@69 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jpayne@69 22 * or visit www.oracle.com if you need additional information or have any
jpayne@69 23 * questions.
jpayne@69 24 */
jpayne@69 25
jpayne@69 26 /*
jpayne@69 27 * Java Debug Wire Protocol Transport Service Provider Interface.
jpayne@69 28 */
jpayne@69 29
jpayne@69 30 #ifndef JDWPTRANSPORT_H
jpayne@69 31 #define JDWPTRANSPORT_H
jpayne@69 32
jpayne@69 33 #include "jni.h"
jpayne@69 34
jpayne@69 35 enum {
jpayne@69 36 JDWPTRANSPORT_VERSION_1_0 = 0x00010000,
jpayne@69 37 JDWPTRANSPORT_VERSION_1_1 = 0x00010001
jpayne@69 38 };
jpayne@69 39
jpayne@69 40 #ifdef __cplusplus
jpayne@69 41 extern "C" {
jpayne@69 42 #endif
jpayne@69 43
jpayne@69 44 struct jdwpTransportNativeInterface_;
jpayne@69 45
jpayne@69 46 struct _jdwpTransportEnv;
jpayne@69 47
jpayne@69 48 #ifdef __cplusplus
jpayne@69 49 typedef _jdwpTransportEnv jdwpTransportEnv;
jpayne@69 50 #else
jpayne@69 51 typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
jpayne@69 52 #endif /* __cplusplus */
jpayne@69 53
jpayne@69 54 /*
jpayne@69 55 * Errors. Universal errors with JVMTI/JVMDI equivalents keep the
jpayne@69 56 * values the same.
jpayne@69 57 */
jpayne@69 58 typedef enum {
jpayne@69 59 JDWPTRANSPORT_ERROR_NONE = 0,
jpayne@69 60 JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
jpayne@69 61 JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
jpayne@69 62 JDWPTRANSPORT_ERROR_INTERNAL = 113,
jpayne@69 63 JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
jpayne@69 64 JDWPTRANSPORT_ERROR_IO_ERROR = 202,
jpayne@69 65 JDWPTRANSPORT_ERROR_TIMEOUT = 203,
jpayne@69 66 JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
jpayne@69 67 } jdwpTransportError;
jpayne@69 68
jpayne@69 69
jpayne@69 70 /*
jpayne@69 71 * Structure to define capabilities
jpayne@69 72 */
jpayne@69 73 typedef struct {
jpayne@69 74 unsigned int can_timeout_attach :1;
jpayne@69 75 unsigned int can_timeout_accept :1;
jpayne@69 76 unsigned int can_timeout_handshake :1;
jpayne@69 77 unsigned int reserved3 :1;
jpayne@69 78 unsigned int reserved4 :1;
jpayne@69 79 unsigned int reserved5 :1;
jpayne@69 80 unsigned int reserved6 :1;
jpayne@69 81 unsigned int reserved7 :1;
jpayne@69 82 unsigned int reserved8 :1;
jpayne@69 83 unsigned int reserved9 :1;
jpayne@69 84 unsigned int reserved10 :1;
jpayne@69 85 unsigned int reserved11 :1;
jpayne@69 86 unsigned int reserved12 :1;
jpayne@69 87 unsigned int reserved13 :1;
jpayne@69 88 unsigned int reserved14 :1;
jpayne@69 89 unsigned int reserved15 :1;
jpayne@69 90 } JDWPTransportCapabilities;
jpayne@69 91
jpayne@69 92
jpayne@69 93 /*
jpayne@69 94 * Structures to define packet layout.
jpayne@69 95 *
jpayne@69 96 * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html
jpayne@69 97 */
jpayne@69 98
jpayne@69 99 #define JDWP_HEADER_SIZE 11
jpayne@69 100
jpayne@69 101 enum {
jpayne@69 102 /*
jpayne@69 103 * If additional flags are added that apply to jdwpCmdPacket,
jpayne@69 104 * then debugLoop.c: reader() will need to be updated to
jpayne@69 105 * accept more than JDWPTRANSPORT_FLAGS_NONE.
jpayne@69 106 */
jpayne@69 107 JDWPTRANSPORT_FLAGS_NONE = 0x0,
jpayne@69 108 JDWPTRANSPORT_FLAGS_REPLY = 0x80
jpayne@69 109 };
jpayne@69 110
jpayne@69 111 typedef struct {
jpayne@69 112 jint len;
jpayne@69 113 jint id;
jpayne@69 114 jbyte flags;
jpayne@69 115 jbyte cmdSet;
jpayne@69 116 jbyte cmd;
jpayne@69 117 jbyte *data;
jpayne@69 118 } jdwpCmdPacket;
jpayne@69 119
jpayne@69 120 typedef struct {
jpayne@69 121 jint len;
jpayne@69 122 jint id;
jpayne@69 123 jbyte flags;
jpayne@69 124 jshort errorCode;
jpayne@69 125 jbyte *data;
jpayne@69 126 } jdwpReplyPacket;
jpayne@69 127
jpayne@69 128 typedef struct {
jpayne@69 129 union {
jpayne@69 130 jdwpCmdPacket cmd;
jpayne@69 131 jdwpReplyPacket reply;
jpayne@69 132 } type;
jpayne@69 133 } jdwpPacket;
jpayne@69 134
jpayne@69 135 /*
jpayne@69 136 * JDWP functions called by the transport.
jpayne@69 137 */
jpayne@69 138 typedef struct jdwpTransportCallback {
jpayne@69 139 void *(*alloc)(jint numBytes); /* Call this for all allocations */
jpayne@69 140 void (*free)(void *buffer); /* Call this for all deallocations */
jpayne@69 141 } jdwpTransportCallback;
jpayne@69 142
jpayne@69 143 typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
jpayne@69 144 jdwpTransportCallback *callback,
jpayne@69 145 jint version,
jpayne@69 146 jdwpTransportEnv** env);
jpayne@69 147
jpayne@69 148 /*
jpayne@69 149 * JDWP transport configuration from the agent.
jpayne@69 150 */
jpayne@69 151 typedef struct jdwpTransportConfiguration {
jpayne@69 152 /* Field added in JDWPTRANSPORT_VERSION_1_1: */
jpayne@69 153 const char* allowed_peers; /* Peers allowed for connection */
jpayne@69 154 } jdwpTransportConfiguration;
jpayne@69 155
jpayne@69 156
jpayne@69 157 /* Function Interface */
jpayne@69 158
jpayne@69 159 struct jdwpTransportNativeInterface_ {
jpayne@69 160 /* 1 : RESERVED */
jpayne@69 161 void *reserved1;
jpayne@69 162
jpayne@69 163 /* 2 : Get Capabilities */
jpayne@69 164 jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
jpayne@69 165 JDWPTransportCapabilities *capabilities_ptr);
jpayne@69 166
jpayne@69 167 /* 3 : Attach */
jpayne@69 168 jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
jpayne@69 169 const char* address,
jpayne@69 170 jlong attach_timeout,
jpayne@69 171 jlong handshake_timeout);
jpayne@69 172
jpayne@69 173 /* 4: StartListening */
jpayne@69 174 jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,
jpayne@69 175 const char* address,
jpayne@69 176 char** actual_address);
jpayne@69 177
jpayne@69 178 /* 5: StopListening */
jpayne@69 179 jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);
jpayne@69 180
jpayne@69 181 /* 6: Accept */
jpayne@69 182 jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
jpayne@69 183 jlong accept_timeout,
jpayne@69 184 jlong handshake_timeout);
jpayne@69 185
jpayne@69 186 /* 7: IsOpen */
jpayne@69 187 jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
jpayne@69 188
jpayne@69 189 /* 8: Close */
jpayne@69 190 jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
jpayne@69 191
jpayne@69 192 /* 9: ReadPacket */
jpayne@69 193 jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
jpayne@69 194 jdwpPacket *pkt);
jpayne@69 195
jpayne@69 196 /* 10: Write Packet */
jpayne@69 197 jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
jpayne@69 198 const jdwpPacket* pkt);
jpayne@69 199
jpayne@69 200 /* 11: GetLastError */
jpayne@69 201 jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
jpayne@69 202 char** error);
jpayne@69 203
jpayne@69 204 /* 12: SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */
jpayne@69 205 jdwpTransportError (JNICALL *SetTransportConfiguration)(jdwpTransportEnv* env,
jpayne@69 206 jdwpTransportConfiguration *config);
jpayne@69 207 };
jpayne@69 208
jpayne@69 209
jpayne@69 210 /*
jpayne@69 211 * Use inlined functions so that C++ code can use syntax such as
jpayne@69 212 * env->Attach("mymachine:5000", 10*1000, 0);
jpayne@69 213 *
jpayne@69 214 * rather than using C's :-
jpayne@69 215 *
jpayne@69 216 * (*env)->Attach(env, "mymachine:5000", 10*1000, 0);
jpayne@69 217 */
jpayne@69 218 struct _jdwpTransportEnv {
jpayne@69 219 const struct jdwpTransportNativeInterface_ *functions;
jpayne@69 220 #ifdef __cplusplus
jpayne@69 221
jpayne@69 222 jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
jpayne@69 223 return functions->GetCapabilities(this, capabilities_ptr);
jpayne@69 224 }
jpayne@69 225
jpayne@69 226 jdwpTransportError Attach(const char* address, jlong attach_timeout,
jpayne@69 227 jlong handshake_timeout) {
jpayne@69 228 return functions->Attach(this, address, attach_timeout, handshake_timeout);
jpayne@69 229 }
jpayne@69 230
jpayne@69 231 jdwpTransportError StartListening(const char* address,
jpayne@69 232 char** actual_address) {
jpayne@69 233 return functions->StartListening(this, address, actual_address);
jpayne@69 234 }
jpayne@69 235
jpayne@69 236 jdwpTransportError StopListening(void) {
jpayne@69 237 return functions->StopListening(this);
jpayne@69 238 }
jpayne@69 239
jpayne@69 240 jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
jpayne@69 241 return functions->Accept(this, accept_timeout, handshake_timeout);
jpayne@69 242 }
jpayne@69 243
jpayne@69 244 jboolean IsOpen(void) {
jpayne@69 245 return functions->IsOpen(this);
jpayne@69 246 }
jpayne@69 247
jpayne@69 248 jdwpTransportError Close(void) {
jpayne@69 249 return functions->Close(this);
jpayne@69 250 }
jpayne@69 251
jpayne@69 252 jdwpTransportError ReadPacket(jdwpPacket *pkt) {
jpayne@69 253 return functions->ReadPacket(this, pkt);
jpayne@69 254 }
jpayne@69 255
jpayne@69 256 jdwpTransportError WritePacket(const jdwpPacket* pkt) {
jpayne@69 257 return functions->WritePacket(this, pkt);
jpayne@69 258 }
jpayne@69 259
jpayne@69 260 jdwpTransportError GetLastError(char** error) {
jpayne@69 261 return functions->GetLastError(this, error);
jpayne@69 262 }
jpayne@69 263
jpayne@69 264 /* SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */
jpayne@69 265 jdwpTransportError SetTransportConfiguration(jdwpTransportEnv* env,
jpayne@69 266 return functions->SetTransportConfiguration(this, config);
jpayne@69 267 }
jpayne@69 268
jpayne@69 269 #endif /* __cplusplus */
jpayne@69 270 };
jpayne@69 271
jpayne@69 272 #ifdef __cplusplus
jpayne@69 273 } /* extern "C" */
jpayne@69 274 #endif /* __cplusplus */
jpayne@69 275
jpayne@69 276 #endif /* JDWPTRANSPORT_H */