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