OSDN Git Service

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