Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/include/ibmjvmti.h
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#ifndef ibmjvmti_h
24
#define ibmjvmti_h
25
26
/* @ddr_namespace: default */
27
/*
28
*-----------------------------------------------------------------------------
29
* This file defines structures, constants, enums and other
30
* definitions which can be used with IBM Corporation's
31
* JVMTI extensions. These extensions are available through
32
* the JVMTI extension mechanism.
33
* See GetExtensionEvents(), GetExtensionFunctions() and
34
* SetExtensionEventCallback()
35
*-----------------------------------------------------------------------------
36
*/
37
38
39
#include "jvmti.h"
40
41
/*
42
*-----------------------------------------------------------------------------
43
* Extended JVMTI constants
44
*-----------------------------------------------------------------------------
45
*/
46
47
#define COM_IBM_COMPILING_START "com.ibm.CompilingStart"
48
#define COM_IBM_COMPILING_END "com.ibm.CompilingEnd"
49
50
#define COM_IBM_INSTRUMENTABLE_OBJECT_ALLOC "com.ibm.InstrumentableObjectAlloc"
51
52
#define COM_IBM_SET_VM_TRACE "com.ibm.SetVmTrace"
53
#define COM_IBM_SET_VM_DUMP "com.ibm.SetVmDump"
54
#define COM_IBM_RESET_VM_DUMP "com.ibm.ResetVmDump"
55
#define COM_IBM_TRIGGER_VM_DUMP "com.ibm.TriggerVmDump"
56
#define COM_IBM_VM_DUMP_START "com.ibm.VmDumpStart"
57
#define COM_IBM_VM_DUMP_END "com.ibm.VmDumpEnd"
58
#define COM_IBM_QUERY_VM_DUMP "com.ibm.QueryVmDump"
59
60
#define COM_IBM_QUERY_VM_LOG_OPTIONS "com.ibm.QueryVmLogOptions"
61
#define COM_IBM_SET_VM_LOG_OPTIONS "com.ibm.SetVmLogOptions"
62
63
#define COM_IBM_SET_VM_JLM "com.ibm.SetVmJlm"
64
#define COM_IBM_SET_VM_JLM_DUMP "com.ibm.SetVmJlmDump"
65
66
#define COM_IBM_GET_OS_THREAD_ID "com.ibm.GetOSThreadID"
67
68
#define COM_IBM_GET_STACK_TRACE_EXTENDED "com.ibm.GetStackTraceExtended"
69
#define COM_IBM_GET_ALL_STACK_TRACES_EXTENDED "com.ibm.GetAllStackTracesExtended"
70
#define COM_IBM_GET_THREAD_LIST_STACK_TRACES_EXTENDED "com.ibm.GetThreadListStackTracesExtended"
71
72
#define COM_IBM_GARBAGE_COLLECTION_CYCLE_START "com.ibm.GarbageCollectionCycleStart"
73
#define COM_IBM_GARBAGE_COLLECTION_CYCLE_FINISH "com.ibm.GarbageCollectionCycleFinish"
74
75
#define COM_IBM_GET_HEAP_FREE_MEMORY "com.ibm.GetHeapFreeMemory"
76
#define COM_IBM_GET_HEAP_TOTAL_MEMORY "com.ibm.GetHeapTotalMemory"
77
78
#define COM_IBM_ITERATE_SHARED_CACHES "com.ibm.IterateSharedCaches"
79
#define COM_IBM_DESTROY_SHARED_CACHE "com.ibm.DestroySharedCache"
80
81
#define COM_IBM_REMOVE_ALL_TAGS "com.ibm.RemoveAllTags"
82
83
#define COM_IBM_REGISTER_TRACE_SUBSCRIBER "com.ibm.RegisterTraceSubscriber"
84
#define COM_IBM_DEREGISTER_TRACE_SUBSCRIBER "com.ibm.DeregisterTraceSubscriber"
85
#define COM_IBM_FLUSH_TRACE_DATA "com.ibm.FlushTraceData"
86
#define COM_IBM_GET_TRACE_METADATA "com.ibm.GetTraceMetadata"
87
88
#define COM_IBM_GET_METHOD_AND_CLASS_NAMES "com.ibm.GetMethodAndClassNames"
89
90
#define COM_IBM_JLM_DUMP_STATS "com.ibm.JlmDumpStats"
91
92
#define COM_IBM_GET_MEMORY_CATEGORIES "com.ibm.GetMemoryCategories"
93
94
#define COM_IBM_REGISTER_VERBOSEGC_SUBSCRIBER "com.ibm.RegisterVerboseGCSubscriber"
95
#define COM_IBM_DEREGISTER_VERBOSEGC_SUBSCRIBER "com.ibm.DeregisterVerboseGCSubscriber"
96
97
#define COM_IBM_GET_J9VMTHREAD "com.ibm.GetJ9vmThread"
98
#define COM_IBM_GET_J9METHOD "com.ibm.GetJ9method"
99
100
#define COM_IBM_REGISTER_TRACEPOINT_SUBSCRIBER "com.ibm.RegisterTracePointSubscriber"
101
#define COM_IBM_DEREGISTER_TRACEPOINT_SUBSCRIBER "com.ibm.DeregisterTracePointSubscriber"
102
103
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA5 1
104
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA6 2
105
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA7 3
106
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA8 4
107
#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA9 5
108
/*
109
* No macro is defined for shared cache modLevel starting from Java 10. The value of modLevel equals to the java version number
110
* on which the shared cache is created.
111
*/
112
113
#define COM_IBM_SHARED_CACHE_ADDRMODE_32 32
114
#define COM_IBM_SHARED_CACHE_ADDRMODE_64 64
115
116
/*
117
* Constants for flags field of COM_IBM_ITERATE_SHARED_CACHES.
118
* Users should always pass one of the following values to the flags field of COM_IBM_ITERATE_SHARED_CACHES.
119
*/
120
#define COM_IBM_ITERATE_SHARED_CACHES_NO_FLAGS 0
121
122
/*
123
*-----------------------------------------------------------------------------
124
* Extended cacheType constants for COM_IBM_DESTROY_SHARED_CACHE
125
*-----------------------------------------------------------------------------
126
*/
127
#define COM_IBM_SHARED_CACHE_PERSISTENCE_DEFAULT 0
128
#define COM_IBM_SHARED_CACHE_PERSISTENT 1
129
#define COM_IBM_SHARED_CACHE_NONPERSISTENT 2
130
#define COM_IBM_SHARED_CACHE_SNAPSHOT 5
131
132
/*
133
*-----------------------------------------------------------------------------
134
* Return type for COM_IBM_DESTROY_SHARED_CACHE
135
*-----------------------------------------------------------------------------
136
*/
137
/* When no cache exists or successfully destroyed all caches. */
138
#define COM_IBM_DESTROYED_ALL_CACHE 0
139
/* When failed to destroy any cache. */
140
#define COM_IBM_DESTROYED_NONE -1
141
/* When failed to destroy cache of current generation. */
142
#define COM_IBM_DESTROY_FAILED_CURRENT_GEN_CACHEE -2
143
/* When failed to destroy one or more older generation cache and either current generation cache does not exists or is successfully destroyed */
144
#define COM_IBM_DESTROY_FAILED_OLDER_GEN_CACHE -3
145
146
/*
147
*-----------------------------------------------------------------------------
148
* Extended JVMTI enumerations
149
*-----------------------------------------------------------------------------
150
*/
151
enum {
152
COM_IBM_METHOD_ENTRY_EXTENDED_INTERPRETED = 0,
153
COM_IBM_METHOD_ENTRY_EXTENDED_COMPILED = 1,
154
COM_IBM_METHOD_ENTRY_EXTENDED_NATIVE = 2,
155
COM_IBM_METHOD_ENTRY_EXTENDED_PARTIAL_IN_LINE = 3,
156
COM_IBM_METHOD_ENTRY_EXTENDED_IN_LINE = 4
157
};
158
159
enum {
160
COM_IBM_JLM_START = 0,
161
COM_IBM_JLM_START_TIME_STAMP = 1,
162
COM_IBM_JLM_STOP = 2,
163
COM_IBM_JLM_STOP_TIME_STAMP = 3
164
};
165
166
enum {
167
COM_IBM_STACK_FRAME_EXTENDED_NOT_JITTED = 0,
168
COM_IBM_STACK_FRAME_EXTENDED_JITTED = 1,
169
COM_IBM_STACK_FRAME_EXTENDED_INLINED = 2
170
};
171
172
/**
173
* Bits used to select the type of data to be returned by the extended stack trace calls
174
*/
175
enum {
176
COM_IBM_GET_STACK_TRACE_PRUNE_UNREPORTED_METHODS = 1, /** Prunes methods for which method enter was not reported */
177
COM_IBM_GET_STACK_TRACE_ENTRY_LOCAL_STORAGE = 2, /** Returns ELS pointers */
178
COM_IBM_GET_STACK_TRACE_EXTRA_FRAME_INFO = 4, /** Returns jitted vs non-jitted data */
179
COM_IBM_GET_STACK_TRACE_MARK_INLINED_FRAMES = 8 /** Distinguish between jitted (root) and inlined */
180
};
181
182
183
/**
184
* JlmDumpStats format specifiers
185
*/
186
187
enum {
188
COM_IBM_JLM_DUMP_FORMAT_OBJECT_ID = 0,
189
COM_IBM_JLM_DUMP_FORMAT_TAGS = 1
190
};
191
192
193
#define JVMTI_MONITOR_JAVA 0x01
194
#define JVMTI_MONITOR_RAW 0x02
195
196
197
/*
198
*-----------------------------------------------------------------------------
199
* Extended JVMTI function types
200
*-----------------------------------------------------------------------------
201
*/
202
203
/*
204
*-----------------------------------------------------------------------------
205
* Extended JVMTI structure types
206
*-----------------------------------------------------------------------------
207
*/
208
209
typedef struct jlm_dump {
210
char * begin;
211
char * end;
212
} jlm_dump;
213
214
/* JLM dump format
215
*
216
* All entries are in packed big endian format
217
* u1 monitor type
218
*
219
* 1 Java monitor
220
* jobjectID object
221
* JNIEnv * owner thread
222
* u4 entry count
223
* u4 # of threads waiting to enter
224
* [JNIEnv *]* threads waiting to enter
225
* u4 # of threads waiting to be notified
226
* [JNIEnv *]* threads waiting to be notified
227
*
228
* 2 raw monitor
229
* char * name
230
* RawMonitor raw monitor
231
* JNIEnv * owner thread
232
* u4 entry count
233
* u4 # of threads waiting to enter
234
* [JNIEnv *]* threads waiting to enter
235
* u4 # of threads waiting to be notified
236
* [JNIEnv *]* threads waiting to be notified
237
*/
238
239
/**
240
* struct jvmtiFrameInfoExtended
241
* Has two additional fields, compared to struct jvmtiFrameInfo:
242
* machinepc and type
243
*/
244
typedef struct jvmtiFrameInfoExtended {
245
jmethodID method;
246
jlocation location;
247
jlocation machinepc;
248
jint type; /*!< frame type can be not jitted or jitted */
249
void * nativeFrameAddress; /*!< address of the native frame */
250
} jvmtiFrameInfoExtended;
251
252
/**
253
* struct jvmtiStackInfoExtended
254
* frame buffer is a pointer to jvmtiFrameInfoExtended,
255
* whereas frame buffer is pointer to jvmtiFrameInfo
256
* in struct jvmtiStackInfo
257
*/
258
typedef struct jvmtiStackInfoExtended {
259
jthread thread;
260
jint state;
261
jvmtiFrameInfoExtended* frame_buffer;
262
jint frame_count;
263
} jvmtiStackInfoExtended;
264
265
/**
266
* Version information for the COM_IBM_ITERATE_SHARED_CACHES API. Users
267
* should pass this value as the "version" parameter. If the jvmtiSharedCacheInfo
268
* structure is expanded, IBM will increment this define.
269
*/
270
#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_1 1
271
#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_2 2
272
#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_3 3
273
#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_4 4
274
#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_5 5
275
276
/**
277
* The following 5 macros can be used to get address mode and compressedRefs mode from jvmtiSharedCacheInfo.addrMode when COM_IBM_ITERATE_SHARED_CACHES_VERSION_3 or later is specified.
278
*/
279
#define COM_IBM_ITERATE_SHARED_CACHES_UNKNOWN_COMPRESSED_POINTERS_MODE 0x00000
280
#define COM_IBM_ITERATE_SHARED_CACHES_COMPRESSED_POINTERS_MODE 0x10000
281
#define COM_IBM_ITERATE_SHARED_CACHES_NON_COMPRESSED_POINTERS_MODE 0x20000
282
#define COM_IBM_ITERATE_SHARED_CACHES_GET_ADDR_MODE(value) (value & 0xFFFF)
283
#define COM_IBM_ITERATE_SHARED_CACHES_GET_CMPRSSREF_MODE(value) (value & (COM_IBM_ITERATE_SHARED_CACHES_COMPRESSED_POINTERS_MODE | COM_IBM_ITERATE_SHARED_CACHES_NON_COMPRESSED_POINTERS_MODE))
284
285
/**
286
* struct jvmtiSharedCacheInfo
287
* name - the name of the cache
288
* isCompatible - is the cache compatible with this JVM
289
* isPersistent - true if the cache is persistent cache, false if the cache is non-persistent or cache snapshot
290
* os_shmid - Operating System specific shared memory id
291
* os_semid - Operating System specific semaphore id
292
* modLevel - the modification level
293
* addrMode - the address mode of the JVM. This field includes additional information on whether it is a 64-bit compressedRefs cache when COM_IBM_ITERATE_SHARED_CACHES_VERSION_3 or later is specified
294
* isCorrupt - true when the cache is found to be corrupt
295
* cacheSize - the size of the cache
296
* freeBytes - the size of free space in the cache
297
* lastDetach - time from which last detach has happened
298
* cacheType - the type of the cache. This is the new field included when COM_IBM_ITERATE_SHARED_CACHES_VERSION_2 or later is specified
299
* softMaxBytes - the soft limit for the available space in the cache. This is the new field included when COM_IBM_ITERATE_SHARED_CACHES_VERSION_4 or later is specified
300
* layer - the shared cache layer number. It is -1 if the shared cache does not have a layer number. This is the new field included when COM_IBM_ITERATE_SHARED_CACHES_VERSION_5 or later is specified
301
*
302
* If IBM adds new information to this structure, it will be added
303
* to the end to preserve backwards compatibility, and
304
* COM_IBM_ITERATE_SHARED_CACHES_VERSION will be incremented.
305
*/
306
typedef struct jvmtiSharedCacheInfo {
307
const char *name;
308
jboolean isCompatible;
309
jboolean isPersistent;
310
jint os_shmid;
311
jint os_semid;
312
jint modLevel;
313
jint addrMode;
314
jboolean isCorrupt;
315
jlong cacheSize;
316
jlong freeBytes;
317
jlong lastDetach;
318
jint cacheType;
319
jlong softMaxBytes;
320
jint layer;
321
} jvmtiSharedCacheInfo;
322
323
/**
324
* Signature of callback function which must be provided to COM_IBM_ITERATE_SHARED_CACHES.
325
*
326
* When your callback is called you will be provided with:
327
* env - the jvmtiEnv you supplied when calling COM_IBM_ITERATE_SHARED_CACHES
328
* cache_info - a structure containing information about a shared cache
329
* user_data - the user_data you provided to COM_IBM_ITERATE_SHARED_CACHES
330
*
331
* Return - JNI_OK on success, JNI_ERR on failure (no more callbacks will be sent).
332
*/
333
typedef jint (JNICALL *jvmtiIterateSharedCachesCallback)(
334
jvmtiEnv *env, jvmtiSharedCacheInfo *cache_info, void *user_data);
335
336
/**
337
* struct jvmtiObjectRenameInfo
338
* oldAutoTag is the previous automatic tag.
339
* newAutoTag is the new automatic tag.
340
* The value 0 means that the object is deleted.
341
*/
342
typedef struct jvmtiObjectRenameInfo {
343
jlong oldAutoTag;
344
jlong newAutoTag;
345
} jvmtiObjectRenameInfo;
346
347
/*
348
* Trace subscriber callback function. This function will be passed records containing trace
349
* data as they are processed. This provides a mechanism for a user defined transport and is
350
* unrelated to actual formatting of the trace data.
351
* env - the jvmti env supplied when the subscriber was registered
352
* record - the record
353
* length - the size of the record
354
* userData - user data provided at registration
355
* return:
356
* JVMTI_ERROR_NONE - success
357
* any other value - the subscriber is deregistered and will not receive any more data
358
*
359
*/
360
typedef jvmtiError (*jvmtiTraceSubscriber)(jvmtiEnv *env, void *record, jlong length, void *userData);
361
362
/*
363
* Alarm callback function that's executed if the subscriber returns an error or misbehaves.
364
* env - the jvmti env supplied when the subscriber was registered
365
* subscriptionID - the ID of the subscription that raised the alarm
366
* userData - user data provided at registration
367
*/
368
typedef void (*jvmtiTraceAlarm)(jvmtiEnv *env, void *subscriptionID, void *userData);
369
370
371
372
/*
373
* Return data for the jvmtiGetMethodClassPackageNames extension. Keeps track of class,
374
* method and package name pointers copied into the user supplied buffer.
375
*/
376
typedef struct jvmtiExtensionRamMethodData
377
{
378
jchar * className; /* ptr into ramMethodStrings, a null terminated class name string */
379
jchar * methodName; /* ptr into ramMethodStrings, a null terminated method name string */
380
jvmtiError reasonCode; /* error code indicating why this record has not been returned back
381
(out of memory, invalid method or none) */
382
} jvmtiExtensionRamMethodData;
383
384
385
/**
386
* Version information for the GetMemoryCategories API. Users
387
* should pass this value as the "version" parameter. If the jvmtiMemoryCategory
388
* structure is expanded, IBM will increment this define.
389
*/
390
#define COM_IBM_GET_MEMORY_CATEGORIES_VERSION_1 1
391
392
/*
393
* Return data for the GetMemoryCategories API
394
*/
395
typedef struct jvmtiMemoryCategory {
396
/* Category name */
397
const char * name;
398
399
/* Bytes allocated under this category */
400
jlong liveBytesShallow;
401
402
/* Bytes allocated under this category and all child categories */
403
jlong liveBytesDeep;
404
405
/* Number of allocations under this category */
406
jlong liveAllocationsShallow;
407
408
/* Number of allocations under this category and all child categories */
409
jlong liveAllocationsDeep;
410
411
/* Pointer to the first child category (NULL if this node has no children) */
412
struct jvmtiMemoryCategory * firstChild;
413
414
/* Pointer to the next sibling category (NULL if this node has no next sibling)*/
415
struct jvmtiMemoryCategory * nextSibling;
416
417
/* Pointer to the parent category. (NULL if this node is a root) */
418
struct jvmtiMemoryCategory * parent;
419
} jvmtiMemoryCategory;
420
421
/*
422
* Verbose GC subscriber callback function. This function will be passed records containing verbose GC
423
* data as it is processed. The data is in ASCII XML. The data is valid for the duration of the callback.
424
* If the subscriber wishes to save the data, it must copy it elsewhere.
425
*
426
* Note that the callback is called while the VM is stopped, thus the callback must not use JNI functions
427
* and must not use JVMTI functions except those which specifically allow such use.
428
*
429
* @param env[in] the jvmti env supplied when the subscriber was registered
430
* @param record[in] the XML data
431
* @param length[in] the size of the record, in bytes. Does not include any NUL terminator, if any.
432
* @param userData[in] user data provided at registration
433
* @return JVMTI_ERROR_NONE on success
434
* If an error is returned, the alarm callback is called, the subscriber is deregistered, and no more data is sent
435
*/
436
typedef jvmtiError (*jvmtiVerboseGCSubscriber)(jvmtiEnv *env, const char *record, jlong length, void *userData);
437
438
/*
439
* Alarm callback function that's executed if the subscriber returns an error or misbehaves.
440
* @param env[in] the jvmti env supplied when the subscriber was registered
441
* @param subscriptionID[in] the ID of the subscription that raised the alarm
442
* @param userData[in] user data provided at registration
443
*/
444
typedef void (*jvmtiVerboseGCAlarm)(jvmtiEnv *env, void *subscriptionID, void *userData);
445
446
447
#endif /* ibmjvmti_h */
448
449