|
1 /* |
|
2 * @(#)jdwpTransport.h 1.7 03/12/19 |
|
3 * |
|
4 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. |
|
5 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. |
|
6 */ |
|
7 |
|
8 /* |
|
9 * Java Debug Wire Protocol Transport Service Provider Interface. |
|
10 */ |
|
11 |
|
12 #ifndef JDWPTRANSPORT_H |
|
13 #define JDWPTRANSPORT_H |
|
14 |
|
15 #include "jni.h" |
|
16 |
|
17 enum { |
|
18 JDWPTRANSPORT_VERSION_1_0 = 0x00010000 |
|
19 }; |
|
20 |
|
21 #ifdef __cplusplus |
|
22 extern "C" { |
|
23 #endif |
|
24 |
|
25 struct jdwpTransportNativeInterface_; |
|
26 |
|
27 struct _jdwpTransportEnv; |
|
28 |
|
29 #ifdef __cplusplus |
|
30 typedef _jdwpTransportEnv jdwpTransportEnv; |
|
31 #else |
|
32 typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv; |
|
33 #endif /* __cplusplus */ |
|
34 |
|
35 /* |
|
36 * Errors. Universal errors with JVMTI/JVMDI equivalents keep the |
|
37 * values the same. |
|
38 */ |
|
39 typedef enum { |
|
40 JDWPTRANSPORT_ERROR_NONE = 0, |
|
41 JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103, |
|
42 JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110, |
|
43 JDWPTRANSPORT_ERROR_INTERNAL = 113, |
|
44 JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201, |
|
45 JDWPTRANSPORT_ERROR_IO_ERROR = 202, |
|
46 JDWPTRANSPORT_ERROR_TIMEOUT = 203, |
|
47 JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204 |
|
48 } jdwpTransportError; |
|
49 |
|
50 |
|
51 /* |
|
52 * Structure to define capabilities |
|
53 */ |
|
54 typedef struct { |
|
55 unsigned int can_timeout_attach :1; |
|
56 unsigned int can_timeout_accept :1; |
|
57 unsigned int can_timeout_handshake :1; |
|
58 unsigned int reserved3 :1; |
|
59 unsigned int reserved4 :1; |
|
60 unsigned int reserved5 :1; |
|
61 unsigned int reserved6 :1; |
|
62 unsigned int reserved7 :1; |
|
63 unsigned int reserved8 :1; |
|
64 unsigned int reserved9 :1; |
|
65 unsigned int reserved10 :1; |
|
66 unsigned int reserved11 :1; |
|
67 unsigned int reserved12 :1; |
|
68 unsigned int reserved13 :1; |
|
69 unsigned int reserved14 :1; |
|
70 unsigned int reserved15 :1; |
|
71 } JDWPTransportCapabilities; |
|
72 |
|
73 |
|
74 /* |
|
75 * Structures to define packet layout. |
|
76 * |
|
77 * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html |
|
78 */ |
|
79 |
|
80 enum { |
|
81 JDWPTRANSPORT_FLAGS_NONE = 0x0, |
|
82 JDWPTRANSPORT_FLAGS_REPLY = 0x80 |
|
83 }; |
|
84 |
|
85 typedef struct { |
|
86 jint len; |
|
87 jint id; |
|
88 jbyte flags; |
|
89 jbyte cmdSet; |
|
90 jbyte cmd; |
|
91 jbyte *data; |
|
92 } jdwpCmdPacket; |
|
93 |
|
94 typedef struct { |
|
95 jint len; |
|
96 jint id; |
|
97 jbyte flags; |
|
98 jshort errorCode; |
|
99 jbyte *data; |
|
100 } jdwpReplyPacket; |
|
101 |
|
102 typedef struct { |
|
103 union { |
|
104 jdwpCmdPacket cmd; |
|
105 jdwpReplyPacket reply; |
|
106 } type; |
|
107 } jdwpPacket; |
|
108 |
|
109 /* |
|
110 * JDWP functions called by the transport. |
|
111 */ |
|
112 typedef struct jdwpTransportCallback { |
|
113 void *(*alloc)(jint numBytes); /* Call this for all allocations */ |
|
114 void (*free)(void *buffer); /* Call this for all deallocations */ |
|
115 } jdwpTransportCallback; |
|
116 |
|
117 typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, |
|
118 jdwpTransportCallback *callback, |
|
119 jint version, |
|
120 jdwpTransportEnv** env); |
|
121 |
|
122 |
|
123 |
|
124 /* Function Interface */ |
|
125 |
|
126 struct jdwpTransportNativeInterface_ { |
|
127 /* 1 : RESERVED */ |
|
128 void *reserved1; |
|
129 |
|
130 /* 2 : Get Capabilities */ |
|
131 jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env, |
|
132 JDWPTransportCapabilities *capabilities_ptr); |
|
133 |
|
134 /* 3 : Attach */ |
|
135 jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env, |
|
136 const char* address, |
|
137 jlong attach_timeout, |
|
138 jlong handshake_timeout); |
|
139 |
|
140 /* 4: StartListening */ |
|
141 jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env, |
|
142 const char* address, |
|
143 char** actual_address); |
|
144 |
|
145 /* 5: StopListening */ |
|
146 jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env); |
|
147 |
|
148 /* 6: Accept */ |
|
149 jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env, |
|
150 jlong accept_timeout, |
|
151 jlong handshake_timeout); |
|
152 |
|
153 /* 7: IsOpen */ |
|
154 jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env); |
|
155 |
|
156 /* 8: Close */ |
|
157 jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env); |
|
158 |
|
159 /* 9: ReadPacket */ |
|
160 jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env, |
|
161 jdwpPacket *pkt); |
|
162 |
|
163 /* 10: Write Packet */ |
|
164 jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env, |
|
165 const jdwpPacket* pkt); |
|
166 |
|
167 /* 11: GetLastError */ |
|
168 jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, |
|
169 char** error); |
|
170 |
|
171 }; |
|
172 |
|
173 |
|
174 /* |
|
175 * Use inlined functions so that C++ code can use syntax such as |
|
176 * env->Attach("mymachine:5000", 10*1000, 0); |
|
177 * |
|
178 * rather than using C's :- |
|
179 * |
|
180 * (*env)->Attach(env, "mymachine:5000", 10*1000, 0); |
|
181 */ |
|
182 struct _jdwpTransportEnv { |
|
183 const struct jdwpTransportNativeInterface_ *functions; |
|
184 #ifdef __cplusplus |
|
185 |
|
186 jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) { |
|
187 return functions->GetCapabilities(this, capabilities_ptr); |
|
188 } |
|
189 |
|
190 jdwpTransportError Attach(const char* address, jlong attach_timeout, |
|
191 jlong handshake_timeout) { |
|
192 return functions->Attach(this, address, attach_timeout, handshake_timeout); |
|
193 } |
|
194 |
|
195 jdwpTransportError StartListening(const char* address, |
|
196 char** actual_address) { |
|
197 return functions->StartListening(this, address, actual_address); |
|
198 } |
|
199 |
|
200 jdwpTransportError StopListening(void) { |
|
201 return functions->StopListening(this); |
|
202 } |
|
203 |
|
204 jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) { |
|
205 return functions->Accept(this, accept_timeout, handshake_timeout); |
|
206 } |
|
207 |
|
208 jboolean IsOpen(void) { |
|
209 return functions->IsOpen(this); |
|
210 } |
|
211 |
|
212 jdwpTransportError Close(void) { |
|
213 return functions->Close(this); |
|
214 } |
|
215 |
|
216 jdwpTransportError ReadPacket(jdwpPacket *pkt) { |
|
217 return functions->ReadPacket(this, pkt); |
|
218 } |
|
219 |
|
220 jdwpTransportError WritePacket(const jdwpPacket* pkt) { |
|
221 return functions->WritePacket(this, pkt); |
|
222 } |
|
223 |
|
224 jdwpTransportError GetLastError(char** error) { |
|
225 return functions->GetLastError(this, error); |
|
226 } |
|
227 |
|
228 |
|
229 #endif /* __cplusplus */ |
|
230 }; |
|
231 |
|
232 #ifdef __cplusplus |
|
233 } /* extern "C" */ |
|
234 #endif /* __cplusplus */ |
|
235 |
|
236 #endif /* JDWPTRANSPORT_H */ |
|
237 |