jvmpi.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* Copyright (C) 2000 Free Software Foundation
  2. This file is part of libgcj.
  3. This software is copyrighted work licensed under the terms of the
  4. Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
  5. details. */
  6. /* Note: this file must be compilable by the C compiler (for now,
  7. assuming GNU C is ok). This means you must never use `//'
  8. comments, and all C++-specific code must be conditional on
  9. __cplusplus. */
  10. #ifndef __GCJ_JVMPI_H__
  11. #define __GCJ_JVMPI_H__
  12. #include <jni.h>
  13. /* JVMPI version numbers. FIXME: this is a semi-random number. The
  14. documentation doesn't say what it should be. */
  15. #define JVMPI_VERSION_1 0x00020001
  16. /* JVMPI return codes. FIXME: These are semi-random numbers. The
  17. documentation doesn't say what they should be. */
  18. #define JVMPI_SUCCESS 0
  19. #define JVMPI_FAIL 1
  20. #define JVMPI_NOT_AVAILABLE 2
  21. /* An opaque pointer representing an object ID. */
  22. struct _jobjectID;
  23. typedef struct _jobjectID * jobjectID;
  24. typedef struct
  25. {
  26. /* Source line number. */
  27. jint lineno;
  28. /* Method being executed. */
  29. jmethodID method_id;
  30. } JVMPI_CallFrame;
  31. typedef struct
  32. {
  33. JNIEnv *env_id;
  34. /* Number of frames in the call trace. */
  35. jint num_frames;
  36. /* An array of frames representing the trace. Callees first. */
  37. JVMPI_CallFrame *frames;
  38. } JVMPI_CallTrace;
  39. typedef struct
  40. {
  41. /* Name of the field. */
  42. char *field_name;
  43. /* Signature of the field. */
  44. char *field_signature;
  45. } JVMPI_Field;
  46. /* The documentation doesn't actually specify what the
  47. JVMPI_DUMP_LEVEL macros should be defined to. Here's a reasonable
  48. guess. */
  49. #define JVMPI_DUMP_LEVEL_0 0
  50. #define JVMPI_DUMP_LEVEL_1 1
  51. #define JVMPI_DUMP_LEVEL_2 2
  52. #define JVMPI_DUMP_LEVEL_3 3
  53. typedef struct
  54. {
  55. /* One of JVMPI_DUMP_LEVEL_0, JVMPI_DUMP_LEVEL_1 or
  56. JVMPI_DUMP_LEVEL_2. */
  57. jint heap_dump_level;
  58. } JVMPI_HeapDumpArg;
  59. typedef struct
  60. {
  61. /* Offset from the beginning of the method. */
  62. jint offset;
  63. /* Line number from the beginning of the source file. */
  64. jint lineno;
  65. } JVMPI_Lineno;
  66. typedef struct
  67. {
  68. /* Name of the method. */
  69. char *method_name;
  70. /* Signature of the method. */
  71. char *method_signature;
  72. /* Start line number from the beginning of the source file. */
  73. jint start_lineno;
  74. /* End line number from the beginning of the source file. */
  75. jint end_lineno;
  76. /* The method ID. */
  77. jmethodID method_id;
  78. } JVMPI_Method;
  79. /* An opaque pointer representing a raw monitor. */
  80. struct _JVMPI_RawMonitor;
  81. typedef struct _JVMPI_RawMonitor *JVMPI_RawMonitor;
  82. /* JVMPI event codes. FIXME: These are semi-random numbers. The
  83. documentation doesn't say what they should be. */
  84. #define JVMPI_EVENT_ARENA_DELETE 0
  85. #define JVMPI_EVENT_ARENA_NEW 1
  86. #define JVMPI_EVENT_CLASS_LOAD 2
  87. #define JVMPI_EVENT_CLASS_LOAD_HOOK 3
  88. #define JVMPI_EVENT_CLASS_UNLOAD 4
  89. #define JVMPI_EVENT_COMPILED_METHOD_LOAD 5
  90. #define JVMPI_EVENT_COMPILED_METHOD_UNLOAD 6
  91. #define JVMPI_EVENT_DATA_DUMP_REQUEST 7
  92. #define JVMPI_EVENT_DATA_RESET_REQUEST 8
  93. #define JVMPI_EVENT_GC_FINISH 9
  94. #define JVMPI_EVENT_GC_START 10
  95. #define JVMPI_EVENT_HEAP_DUMP 11
  96. #define JVMPI_EVENT_JNI_GLOBALREF_ALLOC 12
  97. #define JVMPI_EVENT_JNI_GLOBALREF_FREE 13
  98. #define JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC 14
  99. #define JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE 15
  100. #define JVMPI_EVENT_JVM_INIT_DONE 16
  101. #define JVMPI_EVENT_JVM_SHUT_DOWN 17
  102. #define JVMPI_EVENT_METHOD_ENTRY 18
  103. #define JVMPI_EVENT_METHOD_ENTRY2 19
  104. #define JVMPI_EVENT_METHOD_EXIT 20
  105. #define JVMPI_EVENT_MONITOR_CONTENDED_ENTER 21
  106. #define JVMPI_EVENT_MONITOR_CONTENDED_ENTERED 22
  107. #define JVMPI_EVENT_MONITOR_CONTENDED_EXIT 23
  108. #define JVMPI_EVENT_MONITOR_DUMP 24
  109. #define JVMPI_EVENT_MONITOR_WAIT 25
  110. #define JVMPI_EVENT_MONITOR_WAITED 26
  111. #define JVMPI_EVENT_OBJECT_ALLOC 27
  112. #define JVMPI_EVENT_OBJECT_DUMP 28
  113. #define JVMPI_EVENT_OBJECT_FREE 29
  114. #define JVMPI_EVENT_OBJECT_MOVE 30
  115. #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER 31
  116. #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED 32
  117. #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT 33
  118. #define JVMPI_EVENT_THREAD_END 34
  119. #define JVMPI_EVENT_THREAD_START 35
  120. #define JVMPI_EVENT_INSTRUCTION_START 36
  121. typedef struct
  122. {
  123. /* Event type. */
  124. jint event_type;
  125. /* Evn where this event occurred. */
  126. JNIEnv *env_id;
  127. union
  128. {
  129. struct
  130. {
  131. char *class_name;
  132. char *source_name;
  133. jint num_interfaces;
  134. jint num_methods;
  135. JVMPI_Method *methods;
  136. jint num_static_fields;
  137. JVMPI_Field *statics;
  138. jint num_instance_fields;
  139. JVMPI_Field *instances;
  140. jobjectID class_id;
  141. } class_load;
  142. struct
  143. {
  144. jobjectID class_id;
  145. } class_unload;
  146. struct
  147. {
  148. jint arena_id;
  149. jobjectID class_id;
  150. jint is_array;
  151. jint size;
  152. jobjectID obj_id;
  153. } obj_alloc;
  154. struct
  155. {
  156. char *thread_name;
  157. char *group_name;
  158. char *parent_name;
  159. jobjectID thread_id;
  160. JNIEnv *thread_env_id;
  161. } thread_start;
  162. } u;
  163. } JVMPI_Event;
  164. typedef struct
  165. {
  166. /* JVMPI version number. */
  167. jint version;
  168. /* Implemented by the user... */
  169. void (*NotifyEvent) (JVMPI_Event *event);
  170. /* Implemented by the runtime... */
  171. jint (*EnableEvent) (jint event_type, void *arg);
  172. jint (*DisableEvent) (jint event_type, void *arg);
  173. jint (*RequestEvent) (jint event_type, void *arg);
  174. void (*GetCallTrace) (JVMPI_CallTrace *trace, jint depth);
  175. void (*ProfilerExit) (jint);
  176. JVMPI_RawMonitor (*RawMonitorCreate) (char *lock_name);
  177. void (*RawMonitorEnter) (JVMPI_RawMonitor lock_id);
  178. void (*RawMonitorExit) (JVMPI_RawMonitor lock_id);
  179. void (*RawMonitorWait) (JVMPI_RawMonitor lock_id, jlong ms);
  180. void (*RawMonitorNotifyAll) (JVMPI_RawMonitor lock_id);
  181. void (*RawMonitorDestroy) (JVMPI_RawMonitor lock_id);
  182. jlong (*GetCurrentThreadCpuTime) (void);
  183. void (*SuspendThread) (JNIEnv *env);
  184. void (*ResumeThread) (JNIEnv *env);
  185. jint (*GetThreadStatus) (JNIEnv *env);
  186. jboolean (*ThreadHasRun) (JNIEnv *env);
  187. jint (*CreateSystemThread) (char *name, jint priority, void (*f) (void *));
  188. void (*SetThreadLocalStorage) (JNIEnv *env_id, void *ptr);
  189. void *(*GetThreadLocalStorage) (JNIEnv *env_id);
  190. void (*DisableGC) (void);
  191. void (*EnableGC) (void);
  192. void (*RunGC) (void);
  193. jobjectID (*GetThreadObject) (JNIEnv *env);
  194. jobjectID (*GetMethodClass) (jmethodID mid);
  195. } JVMPI_Interface;
  196. #endif /* __GCJ_JVMPI_H__ */