/*******************************************************************************1* Copyright (c) 1991, 2021 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#ifndef ibmjvmti_h23#define ibmjvmti_h2425/* @ddr_namespace: default */26/*27*-----------------------------------------------------------------------------28* This file defines structures, constants, enums and other29* definitions which can be used with IBM Corporation's30* JVMTI extensions. These extensions are available through31* the JVMTI extension mechanism.32* See GetExtensionEvents(), GetExtensionFunctions() and33* SetExtensionEventCallback()34*-----------------------------------------------------------------------------35*/363738#include "jvmti.h"3940/*41*-----------------------------------------------------------------------------42* Extended JVMTI constants43*-----------------------------------------------------------------------------44*/4546#define COM_IBM_COMPILING_START "com.ibm.CompilingStart"47#define COM_IBM_COMPILING_END "com.ibm.CompilingEnd"4849#define COM_IBM_INSTRUMENTABLE_OBJECT_ALLOC "com.ibm.InstrumentableObjectAlloc"5051#define COM_IBM_SET_VM_TRACE "com.ibm.SetVmTrace"52#define COM_IBM_SET_VM_DUMP "com.ibm.SetVmDump"53#define COM_IBM_RESET_VM_DUMP "com.ibm.ResetVmDump"54#define COM_IBM_TRIGGER_VM_DUMP "com.ibm.TriggerVmDump"55#define COM_IBM_VM_DUMP_START "com.ibm.VmDumpStart"56#define COM_IBM_VM_DUMP_END "com.ibm.VmDumpEnd"57#define COM_IBM_QUERY_VM_DUMP "com.ibm.QueryVmDump"5859#define COM_IBM_QUERY_VM_LOG_OPTIONS "com.ibm.QueryVmLogOptions"60#define COM_IBM_SET_VM_LOG_OPTIONS "com.ibm.SetVmLogOptions"6162#define COM_IBM_SET_VM_JLM "com.ibm.SetVmJlm"63#define COM_IBM_SET_VM_JLM_DUMP "com.ibm.SetVmJlmDump"6465#define COM_IBM_GET_OS_THREAD_ID "com.ibm.GetOSThreadID"6667#define COM_IBM_GET_STACK_TRACE_EXTENDED "com.ibm.GetStackTraceExtended"68#define COM_IBM_GET_ALL_STACK_TRACES_EXTENDED "com.ibm.GetAllStackTracesExtended"69#define COM_IBM_GET_THREAD_LIST_STACK_TRACES_EXTENDED "com.ibm.GetThreadListStackTracesExtended"7071#define COM_IBM_GARBAGE_COLLECTION_CYCLE_START "com.ibm.GarbageCollectionCycleStart"72#define COM_IBM_GARBAGE_COLLECTION_CYCLE_FINISH "com.ibm.GarbageCollectionCycleFinish"7374#define COM_IBM_GET_HEAP_FREE_MEMORY "com.ibm.GetHeapFreeMemory"75#define COM_IBM_GET_HEAP_TOTAL_MEMORY "com.ibm.GetHeapTotalMemory"7677#define COM_IBM_ITERATE_SHARED_CACHES "com.ibm.IterateSharedCaches"78#define COM_IBM_DESTROY_SHARED_CACHE "com.ibm.DestroySharedCache"7980#define COM_IBM_REMOVE_ALL_TAGS "com.ibm.RemoveAllTags"8182#define COM_IBM_REGISTER_TRACE_SUBSCRIBER "com.ibm.RegisterTraceSubscriber"83#define COM_IBM_DEREGISTER_TRACE_SUBSCRIBER "com.ibm.DeregisterTraceSubscriber"84#define COM_IBM_FLUSH_TRACE_DATA "com.ibm.FlushTraceData"85#define COM_IBM_GET_TRACE_METADATA "com.ibm.GetTraceMetadata"8687#define COM_IBM_GET_METHOD_AND_CLASS_NAMES "com.ibm.GetMethodAndClassNames"8889#define COM_IBM_JLM_DUMP_STATS "com.ibm.JlmDumpStats"9091#define COM_IBM_GET_MEMORY_CATEGORIES "com.ibm.GetMemoryCategories"9293#define COM_IBM_REGISTER_VERBOSEGC_SUBSCRIBER "com.ibm.RegisterVerboseGCSubscriber"94#define COM_IBM_DEREGISTER_VERBOSEGC_SUBSCRIBER "com.ibm.DeregisterVerboseGCSubscriber"9596#define COM_IBM_GET_J9VMTHREAD "com.ibm.GetJ9vmThread"97#define COM_IBM_GET_J9METHOD "com.ibm.GetJ9method"9899#define COM_IBM_REGISTER_TRACEPOINT_SUBSCRIBER "com.ibm.RegisterTracePointSubscriber"100#define COM_IBM_DEREGISTER_TRACEPOINT_SUBSCRIBER "com.ibm.DeregisterTracePointSubscriber"101102#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA5 1103#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA6 2104#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA7 3105#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA8 4106#define COM_IBM_SHARED_CACHE_MODLEVEL_JAVA9 5107/*108* No macro is defined for shared cache modLevel starting from Java 10. The value of modLevel equals to the java version number109* on which the shared cache is created.110*/111112#define COM_IBM_SHARED_CACHE_ADDRMODE_32 32113#define COM_IBM_SHARED_CACHE_ADDRMODE_64 64114115/*116* Constants for flags field of COM_IBM_ITERATE_SHARED_CACHES.117* Users should always pass one of the following values to the flags field of COM_IBM_ITERATE_SHARED_CACHES.118*/119#define COM_IBM_ITERATE_SHARED_CACHES_NO_FLAGS 0120121/*122*-----------------------------------------------------------------------------123* Extended cacheType constants for COM_IBM_DESTROY_SHARED_CACHE124*-----------------------------------------------------------------------------125*/126#define COM_IBM_SHARED_CACHE_PERSISTENCE_DEFAULT 0127#define COM_IBM_SHARED_CACHE_PERSISTENT 1128#define COM_IBM_SHARED_CACHE_NONPERSISTENT 2129#define COM_IBM_SHARED_CACHE_SNAPSHOT 5130131/*132*-----------------------------------------------------------------------------133* Return type for COM_IBM_DESTROY_SHARED_CACHE134*-----------------------------------------------------------------------------135*/136/* When no cache exists or successfully destroyed all caches. */137#define COM_IBM_DESTROYED_ALL_CACHE 0138/* When failed to destroy any cache. */139#define COM_IBM_DESTROYED_NONE -1140/* When failed to destroy cache of current generation. */141#define COM_IBM_DESTROY_FAILED_CURRENT_GEN_CACHEE -2142/* When failed to destroy one or more older generation cache and either current generation cache does not exists or is successfully destroyed */143#define COM_IBM_DESTROY_FAILED_OLDER_GEN_CACHE -3144145/*146*-----------------------------------------------------------------------------147* Extended JVMTI enumerations148*-----------------------------------------------------------------------------149*/150enum {151COM_IBM_METHOD_ENTRY_EXTENDED_INTERPRETED = 0,152COM_IBM_METHOD_ENTRY_EXTENDED_COMPILED = 1,153COM_IBM_METHOD_ENTRY_EXTENDED_NATIVE = 2,154COM_IBM_METHOD_ENTRY_EXTENDED_PARTIAL_IN_LINE = 3,155COM_IBM_METHOD_ENTRY_EXTENDED_IN_LINE = 4156};157158enum {159COM_IBM_JLM_START = 0,160COM_IBM_JLM_START_TIME_STAMP = 1,161COM_IBM_JLM_STOP = 2,162COM_IBM_JLM_STOP_TIME_STAMP = 3163};164165enum {166COM_IBM_STACK_FRAME_EXTENDED_NOT_JITTED = 0,167COM_IBM_STACK_FRAME_EXTENDED_JITTED = 1,168COM_IBM_STACK_FRAME_EXTENDED_INLINED = 2169};170171/**172* Bits used to select the type of data to be returned by the extended stack trace calls173*/174enum {175COM_IBM_GET_STACK_TRACE_PRUNE_UNREPORTED_METHODS = 1, /** Prunes methods for which method enter was not reported */176COM_IBM_GET_STACK_TRACE_ENTRY_LOCAL_STORAGE = 2, /** Returns ELS pointers */177COM_IBM_GET_STACK_TRACE_EXTRA_FRAME_INFO = 4, /** Returns jitted vs non-jitted data */178COM_IBM_GET_STACK_TRACE_MARK_INLINED_FRAMES = 8 /** Distinguish between jitted (root) and inlined */179};180181182/**183* JlmDumpStats format specifiers184*/185186enum {187COM_IBM_JLM_DUMP_FORMAT_OBJECT_ID = 0,188COM_IBM_JLM_DUMP_FORMAT_TAGS = 1189};190191192#define JVMTI_MONITOR_JAVA 0x01193#define JVMTI_MONITOR_RAW 0x02194195196/*197*-----------------------------------------------------------------------------198* Extended JVMTI function types199*-----------------------------------------------------------------------------200*/201202/*203*-----------------------------------------------------------------------------204* Extended JVMTI structure types205*-----------------------------------------------------------------------------206*/207208typedef struct jlm_dump {209char * begin;210char * end;211} jlm_dump;212213/* JLM dump format214*215* All entries are in packed big endian format216* u1 monitor type217*218* 1 Java monitor219* jobjectID object220* JNIEnv * owner thread221* u4 entry count222* u4 # of threads waiting to enter223* [JNIEnv *]* threads waiting to enter224* u4 # of threads waiting to be notified225* [JNIEnv *]* threads waiting to be notified226*227* 2 raw monitor228* char * name229* RawMonitor raw monitor230* JNIEnv * owner thread231* u4 entry count232* u4 # of threads waiting to enter233* [JNIEnv *]* threads waiting to enter234* u4 # of threads waiting to be notified235* [JNIEnv *]* threads waiting to be notified236*/237238/**239* struct jvmtiFrameInfoExtended240* Has two additional fields, compared to struct jvmtiFrameInfo:241* machinepc and type242*/243typedef struct jvmtiFrameInfoExtended {244jmethodID method;245jlocation location;246jlocation machinepc;247jint type; /*!< frame type can be not jitted or jitted */248void * nativeFrameAddress; /*!< address of the native frame */249} jvmtiFrameInfoExtended;250251/**252* struct jvmtiStackInfoExtended253* frame buffer is a pointer to jvmtiFrameInfoExtended,254* whereas frame buffer is pointer to jvmtiFrameInfo255* in struct jvmtiStackInfo256*/257typedef struct jvmtiStackInfoExtended {258jthread thread;259jint state;260jvmtiFrameInfoExtended* frame_buffer;261jint frame_count;262} jvmtiStackInfoExtended;263264/**265* Version information for the COM_IBM_ITERATE_SHARED_CACHES API. Users266* should pass this value as the "version" parameter. If the jvmtiSharedCacheInfo267* structure is expanded, IBM will increment this define.268*/269#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_1 1270#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_2 2271#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_3 3272#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_4 4273#define COM_IBM_ITERATE_SHARED_CACHES_VERSION_5 5274275/**276* 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.277*/278#define COM_IBM_ITERATE_SHARED_CACHES_UNKNOWN_COMPRESSED_POINTERS_MODE 0x00000279#define COM_IBM_ITERATE_SHARED_CACHES_COMPRESSED_POINTERS_MODE 0x10000280#define COM_IBM_ITERATE_SHARED_CACHES_NON_COMPRESSED_POINTERS_MODE 0x20000281#define COM_IBM_ITERATE_SHARED_CACHES_GET_ADDR_MODE(value) (value & 0xFFFF)282#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))283284/**285* struct jvmtiSharedCacheInfo286* name - the name of the cache287* isCompatible - is the cache compatible with this JVM288* isPersistent - true if the cache is persistent cache, false if the cache is non-persistent or cache snapshot289* os_shmid - Operating System specific shared memory id290* os_semid - Operating System specific semaphore id291* modLevel - the modification level292* 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 specified293* isCorrupt - true when the cache is found to be corrupt294* cacheSize - the size of the cache295* freeBytes - the size of free space in the cache296* lastDetach - time from which last detach has happened297* cacheType - the type of the cache. This is the new field included when COM_IBM_ITERATE_SHARED_CACHES_VERSION_2 or later is specified298* 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 specified299* 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 specified300*301* If IBM adds new information to this structure, it will be added302* to the end to preserve backwards compatibility, and303* COM_IBM_ITERATE_SHARED_CACHES_VERSION will be incremented.304*/305typedef struct jvmtiSharedCacheInfo {306const char *name;307jboolean isCompatible;308jboolean isPersistent;309jint os_shmid;310jint os_semid;311jint modLevel;312jint addrMode;313jboolean isCorrupt;314jlong cacheSize;315jlong freeBytes;316jlong lastDetach;317jint cacheType;318jlong softMaxBytes;319jint layer;320} jvmtiSharedCacheInfo;321322/**323* Signature of callback function which must be provided to COM_IBM_ITERATE_SHARED_CACHES.324*325* When your callback is called you will be provided with:326* env - the jvmtiEnv you supplied when calling COM_IBM_ITERATE_SHARED_CACHES327* cache_info - a structure containing information about a shared cache328* user_data - the user_data you provided to COM_IBM_ITERATE_SHARED_CACHES329*330* Return - JNI_OK on success, JNI_ERR on failure (no more callbacks will be sent).331*/332typedef jint (JNICALL *jvmtiIterateSharedCachesCallback)(333jvmtiEnv *env, jvmtiSharedCacheInfo *cache_info, void *user_data);334335/**336* struct jvmtiObjectRenameInfo337* oldAutoTag is the previous automatic tag.338* newAutoTag is the new automatic tag.339* The value 0 means that the object is deleted.340*/341typedef struct jvmtiObjectRenameInfo {342jlong oldAutoTag;343jlong newAutoTag;344} jvmtiObjectRenameInfo;345346/*347* Trace subscriber callback function. This function will be passed records containing trace348* data as they are processed. This provides a mechanism for a user defined transport and is349* unrelated to actual formatting of the trace data.350* env - the jvmti env supplied when the subscriber was registered351* record - the record352* length - the size of the record353* userData - user data provided at registration354* return:355* JVMTI_ERROR_NONE - success356* any other value - the subscriber is deregistered and will not receive any more data357*358*/359typedef jvmtiError (*jvmtiTraceSubscriber)(jvmtiEnv *env, void *record, jlong length, void *userData);360361/*362* Alarm callback function that's executed if the subscriber returns an error or misbehaves.363* env - the jvmti env supplied when the subscriber was registered364* subscriptionID - the ID of the subscription that raised the alarm365* userData - user data provided at registration366*/367typedef void (*jvmtiTraceAlarm)(jvmtiEnv *env, void *subscriptionID, void *userData);368369370371/*372* Return data for the jvmtiGetMethodClassPackageNames extension. Keeps track of class,373* method and package name pointers copied into the user supplied buffer.374*/375typedef struct jvmtiExtensionRamMethodData376{377jchar * className; /* ptr into ramMethodStrings, a null terminated class name string */378jchar * methodName; /* ptr into ramMethodStrings, a null terminated method name string */379jvmtiError reasonCode; /* error code indicating why this record has not been returned back380(out of memory, invalid method or none) */381} jvmtiExtensionRamMethodData;382383384/**385* Version information for the GetMemoryCategories API. Users386* should pass this value as the "version" parameter. If the jvmtiMemoryCategory387* structure is expanded, IBM will increment this define.388*/389#define COM_IBM_GET_MEMORY_CATEGORIES_VERSION_1 1390391/*392* Return data for the GetMemoryCategories API393*/394typedef struct jvmtiMemoryCategory {395/* Category name */396const char * name;397398/* Bytes allocated under this category */399jlong liveBytesShallow;400401/* Bytes allocated under this category and all child categories */402jlong liveBytesDeep;403404/* Number of allocations under this category */405jlong liveAllocationsShallow;406407/* Number of allocations under this category and all child categories */408jlong liveAllocationsDeep;409410/* Pointer to the first child category (NULL if this node has no children) */411struct jvmtiMemoryCategory * firstChild;412413/* Pointer to the next sibling category (NULL if this node has no next sibling)*/414struct jvmtiMemoryCategory * nextSibling;415416/* Pointer to the parent category. (NULL if this node is a root) */417struct jvmtiMemoryCategory * parent;418} jvmtiMemoryCategory;419420/*421* Verbose GC subscriber callback function. This function will be passed records containing verbose GC422* data as it is processed. The data is in ASCII XML. The data is valid for the duration of the callback.423* If the subscriber wishes to save the data, it must copy it elsewhere.424*425* Note that the callback is called while the VM is stopped, thus the callback must not use JNI functions426* and must not use JVMTI functions except those which specifically allow such use.427*428* @param env[in] the jvmti env supplied when the subscriber was registered429* @param record[in] the XML data430* @param length[in] the size of the record, in bytes. Does not include any NUL terminator, if any.431* @param userData[in] user data provided at registration432* @return JVMTI_ERROR_NONE on success433* If an error is returned, the alarm callback is called, the subscriber is deregistered, and no more data is sent434*/435typedef jvmtiError (*jvmtiVerboseGCSubscriber)(jvmtiEnv *env, const char *record, jlong length, void *userData);436437/*438* Alarm callback function that's executed if the subscriber returns an error or misbehaves.439* @param env[in] the jvmti env supplied when the subscriber was registered440* @param subscriptionID[in] the ID of the subscription that raised the alarm441* @param userData[in] user data provided at registration442*/443typedef void (*jvmtiVerboseGCAlarm)(jvmtiEnv *env, void *subscriptionID, void *userData);444445446#endif /* ibmjvmti_h */447448449