summaryrefslogtreecommitdiff
path: root/libjava/include/jvmpi.h
blob: 1af9617825a6da9b05a506bdf042cf6dfd38ee55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/* Copyright (C) 2000  Free Software Foundation

   This file is part of libgcj.

This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */

/* Note: this file must be compilable by the C compiler (for now,
   assuming GNU C is ok).  This means you must never use `//'
   comments, and all C++-specific code must be conditional on
   __cplusplus.  */

#ifndef __GCJ_JVMPI_H__
#define __GCJ_JVMPI_H__

#include <jni.h>

/* JVMPI version numbers.  FIXME: this is a semi-random number.  The
   documentation doesn't say what it should be.  */
#define JVMPI_VERSION_1 0x00020001

/* JVMPI return codes.  FIXME: These are semi-random numbers.  The
   documentation doesn't say what they should be.  */
#define JVMPI_SUCCESS       0
#define JVMPI_FAIL          1
#define JVMPI_NOT_AVAILABLE 2

/* An opaque pointer representing an object ID.  */
struct _jobjectID;
typedef struct _jobjectID * jobjectID;       

typedef struct
{
  /* Source line number.  */
  jint lineno;
  /* Method being executed.  */
  jmethodID method_id;
} JVMPI_CallFrame;

typedef struct 
{
  JNIEnv *env_id;
  /* Number of frames in the call trace.  */
  jint num_frames;
  /* An array of frames representing the trace.  Callees first.  */
  JVMPI_CallFrame *frames;
} JVMPI_CallTrace;

typedef struct
{
  /* Name of the field.  */
  char *field_name;
  /* Signature of the field.  */
  char *field_signature;
} JVMPI_Field;

/* The documentation doesn't actually specify what the
   JVMPI_DUMP_LEVEL macros should be defined to.  Here's a reasonable
   guess.  */
#define JVMPI_DUMP_LEVEL_0 0
#define JVMPI_DUMP_LEVEL_1 1
#define JVMPI_DUMP_LEVEL_2 2
#define JVMPI_DUMP_LEVEL_3 3

typedef struct
{
  /* One of JVMPI_DUMP_LEVEL_0, JVMPI_DUMP_LEVEL_1 or
     JVMPI_DUMP_LEVEL_2.  */
  jint heap_dump_level;
} JVMPI_HeapDumpArg;

typedef struct
{
  /* Offset from the beginning of the method.  */
  jint offset;
  /* Line number from the beginning of the source file.  */
  jint lineno;
} JVMPI_Lineno;

typedef struct
{
  /* Name of the method.  */
  char *method_name;
  /* Signature of the method.  */
  char *method_signature;
  /* Start line number from the beginning of the source file.  */
  jint start_lineno;
  /* End line number from the beginning of the source file.  */
  jint end_lineno;
  /* The method ID.  */
  jmethodID method_id;
} JVMPI_Method;

/* An opaque pointer representing a raw monitor.  */
struct _JVMPI_RawMonitor;
typedef struct _JVMPI_RawMonitor *JVMPI_RawMonitor;

/* JVMPI event codes.  FIXME: These are semi-random numbers.  The
   documentation doesn't say what they should be.  */
#define JVMPI_EVENT_ARENA_DELETE                   0
#define JVMPI_EVENT_ARENA_NEW                      1
#define JVMPI_EVENT_CLASS_LOAD                     2
#define JVMPI_EVENT_CLASS_LOAD_HOOK                3
#define JVMPI_EVENT_CLASS_UNLOAD                   4
#define JVMPI_EVENT_COMPILED_METHOD_LOAD           5
#define JVMPI_EVENT_COMPILED_METHOD_UNLOAD         6
#define JVMPI_EVENT_DATA_DUMP_REQUEST              7
#define JVMPI_EVENT_DATA_RESET_REQUEST             8
#define JVMPI_EVENT_GC_FINISH                      9
#define JVMPI_EVENT_GC_START                      10
#define JVMPI_EVENT_HEAP_DUMP                     11
#define JVMPI_EVENT_JNI_GLOBALREF_ALLOC           12
#define JVMPI_EVENT_JNI_GLOBALREF_FREE            13
#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC      14
#define JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE       15
#define JVMPI_EVENT_JVM_INIT_DONE                 16
#define JVMPI_EVENT_JVM_SHUT_DOWN                 17
#define JVMPI_EVENT_METHOD_ENTRY                  18
#define JVMPI_EVENT_METHOD_ENTRY2                 19
#define JVMPI_EVENT_METHOD_EXIT                   20
#define JVMPI_EVENT_MONITOR_CONTENDED_ENTER       21
#define JVMPI_EVENT_MONITOR_CONTENDED_ENTERED     22
#define JVMPI_EVENT_MONITOR_CONTENDED_EXIT        23
#define JVMPI_EVENT_MONITOR_DUMP                  24
#define JVMPI_EVENT_MONITOR_WAIT                  25
#define JVMPI_EVENT_MONITOR_WAITED                26
#define JVMPI_EVENT_OBJECT_ALLOC                  27
#define JVMPI_EVENT_OBJECT_DUMP                   28
#define JVMPI_EVENT_OBJECT_FREE                   29
#define JVMPI_EVENT_OBJECT_MOVE                   30
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER   31
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED 32
#define JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT    33
#define JVMPI_EVENT_THREAD_END                    34
#define JVMPI_EVENT_THREAD_START                  35
#define JVMPI_EVENT_INSTRUCTION_START             36


typedef struct
{
  /* Event type.  */
  jint event_type;

  /* Evn where this event occurred.  */
  JNIEnv *env_id;

  union 
  {
    struct
    {
      char *class_name;
      char *source_name;
      jint num_interfaces;
      jint num_methods;
      JVMPI_Method *methods;
      jint num_static_fields;
      JVMPI_Field *statics;
      jint num_instance_fields;
      JVMPI_Field *instances;
      jobjectID class_id;
    } class_load;

    struct
    {
      jobjectID class_id;
    } class_unload;

    struct
    {
      jint arena_id;
      jobjectID class_id;
      jint is_array;
      jint size;
      jobjectID obj_id;
    } obj_alloc;

    struct
    {
      char *thread_name;
      char *group_name;
      char *parent_name;
      jobjectID thread_id;
      JNIEnv *thread_env_id;
    } thread_start;

  } u;

} JVMPI_Event;

typedef struct
{
  /* JVMPI version number.  */
  jint version;
  
  /* Implemented by the user...  */
  void (*NotifyEvent) (JVMPI_Event *event);
  
  /* Implemented by the runtime...  */
  jint (*EnableEvent) (jint event_type, void *arg);
  jint (*DisableEvent) (jint event_type, void *arg);
  jint (*RequestEvent) (jint event_type, void *arg);
  void (*GetCallTrace) (JVMPI_CallTrace *trace, jint depth);
  void (*ProfilerExit) (jint);
  JVMPI_RawMonitor (*RawMonitorCreate) (char *lock_name);
  void (*RawMonitorEnter) (JVMPI_RawMonitor lock_id);
  void (*RawMonitorExit) (JVMPI_RawMonitor lock_id);
  void (*RawMonitorWait) (JVMPI_RawMonitor lock_id, jlong ms);
  void (*RawMonitorNotifyAll) (JVMPI_RawMonitor lock_id);
  void (*RawMonitorDestroy) (JVMPI_RawMonitor lock_id);
  jlong (*GetCurrentThreadCpuTime) (void);
  void (*SuspendThread) (JNIEnv *env);
  void (*ResumeThread) (JNIEnv *env);
  jint (*GetThreadStatus) (JNIEnv *env);
  jboolean (*ThreadHasRun) (JNIEnv *env);
  jint (*CreateSystemThread) (char *name, jint priority, void (*f) (void *));
  void (*SetThreadLocalStorage) (JNIEnv *env_id, void *ptr);
  void *(*GetThreadLocalStorage) (JNIEnv *env_id);
  void (*DisableGC) (void);
  void (*EnableGC) (void);
  void (*RunGC) (void);
  jobjectID (*GetThreadObject) (JNIEnv *env);
  jobjectID (*GetMethodClass) (jmethodID mid);
  
} JVMPI_Interface;

#endif /* __GCJ_JVMPI_H__ */