2
|
1 |
/*
|
|
2 |
* Copyright 2003 Sun Microsystems, Inc. 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. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any 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 {
|
|
36 |
JDWPTRANSPORT_VERSION_1_0 = 0x00010000
|
|
37 |
};
|
|
38 |
|
|
39 |
#ifdef __cplusplus
|
|
40 |
extern "C" {
|
|
41 |
#endif
|
|
42 |
|
|
43 |
struct jdwpTransportNativeInterface_;
|
|
44 |
|
|
45 |
struct _jdwpTransportEnv;
|
|
46 |
|
|
47 |
#ifdef __cplusplus
|
|
48 |
typedef _jdwpTransportEnv jdwpTransportEnv;
|
|
49 |
#else
|
|
50 |
typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
|
|
51 |
#endif /* __cplusplus */
|
|
52 |
|
|
53 |
/*
|
|
54 |
* Errors. Universal errors with JVMTI/JVMDI equivalents keep the
|
|
55 |
* values the same.
|
|
56 |
*/
|
|
57 |
typedef enum {
|
|
58 |
JDWPTRANSPORT_ERROR_NONE = 0,
|
|
59 |
JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
|
|
60 |
JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
|
|
61 |
JDWPTRANSPORT_ERROR_INTERNAL = 113,
|
|
62 |
JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
|
|
63 |
JDWPTRANSPORT_ERROR_IO_ERROR = 202,
|
|
64 |
JDWPTRANSPORT_ERROR_TIMEOUT = 203,
|
|
65 |
JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
|
|
66 |
} jdwpTransportError;
|
|
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;
|
|
89 |
} JDWPTransportCapabilities;
|
|
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 {
|
|
99 |
JDWPTRANSPORT_FLAGS_NONE = 0x0,
|
|
100 |
JDWPTRANSPORT_FLAGS_REPLY = 0x80
|
|
101 |
};
|
|
102 |
|
|
103 |
typedef struct {
|
|
104 |
jint len;
|
|
105 |
jint id;
|
|
106 |
jbyte flags;
|
|
107 |
jbyte cmdSet;
|
|
108 |
jbyte cmd;
|
|
109 |
jbyte *data;
|
|
110 |
} jdwpCmdPacket;
|
|
111 |
|
|
112 |
typedef struct {
|
|
113 |
jint len;
|
|
114 |
jint id;
|
|
115 |
jbyte flags;
|
|
116 |
jshort errorCode;
|
|
117 |
jbyte *data;
|
|
118 |
} jdwpReplyPacket;
|
|
119 |
|
|
120 |
typedef struct {
|
|
121 |
union {
|
|
122 |
jdwpCmdPacket cmd;
|
|
123 |
jdwpReplyPacket reply;
|
|
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 */
|
|
133 |
} jdwpTransportCallback;
|
|
134 |
|
|
135 |
typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
|
|
136 |
jdwpTransportCallback *callback,
|
|
137 |
jint version,
|
|
138 |
jdwpTransportEnv** env);
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
/* Function Interface */
|
|
143 |
|
|
144 |
struct jdwpTransportNativeInterface_ {
|
|
145 |
/* 1 : RESERVED */
|
|
146 |
void *reserved1;
|
|
147 |
|
|
148 |
/* 2 : Get Capabilities */
|
|
149 |
jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
|
|
150 |
JDWPTransportCapabilities *capabilities_ptr);
|
|
151 |
|
|
152 |
/* 3 : Attach */
|
|
153 |
jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
|
|
154 |
const char* address,
|
|
155 |
jlong attach_timeout,
|
|
156 |
jlong handshake_timeout);
|
|
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 */
|
|
167 |
jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
|
|
168 |
jlong accept_timeout,
|
|
169 |
jlong handshake_timeout);
|
|
170 |
|
|
171 |
/* 7: IsOpen */
|
|
172 |
jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
|
|
173 |
|
|
174 |
/* 8: Close */
|
|
175 |
jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
|
|
176 |
|
|
177 |
/* 9: ReadPacket */
|
|
178 |
jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
|
|
179 |
jdwpPacket *pkt);
|
|
180 |
|
|
181 |
/* 10: Write Packet */
|
|
182 |
jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
|
|
183 |
const jdwpPacket* pkt);
|
|
184 |
|
|
185 |
/* 11: GetLastError */
|
|
186 |
jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
|
|
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 |
*/
|
|
200 |
struct _jdwpTransportEnv {
|
|
201 |
const struct jdwpTransportNativeInterface_ *functions;
|
|
202 |
#ifdef __cplusplus
|
|
203 |
|
|
204 |
jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
|
|
205 |
return functions->GetCapabilities(this, capabilities_ptr);
|
|
206 |
}
|
|
207 |
|
|
208 |
jdwpTransportError Attach(const char* address, jlong attach_timeout,
|
|
209 |
jlong handshake_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 |
|
|
222 |
jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
|
|
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 */
|