jw项目windows环境软件安装
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines
8.0 KiB

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