IBM User Guide for Java V7 on Windows > Troubleshooting and support > Using diagnostic tools > Using the JVMTI
IBM JVMTI extensions
The IBM SDK provides extensions to the JVMTI. The sample shows you how to write a simple JVMTI agent that uses these extensions.
The IBM SDK extensions to JVMTI allow a JVMTI agent do the following tasks:
- Modify a dump.
- Modify a trace.
- Modify the logging configuration of the JVM.
- Initiate a JVM dump.
- Query the JRE native memory use.
- Find shared class caches.
- Remove shared class caches
The definitions you need when you write a JVMTI agent are provided in the header files jvmti.h and ibmjvmti.h. These files are in sdk\include.
The sample JVMTI agent consists of two functions:
- Agent_OnLoad()
- DumpStartCallback()
Agent_OnLoad()
This function is called by the JVM when the agent is loaded at JVM startup, which allows the JVMTI agent to modify JVM behavior before initialization is complete. The sample agent obtains access to the JVMTI interface using the JNI Invocation API function GetEnv(). The agent calls the APIs GetExtensionEvents() and GetExtensionFunctions() to find the JVMTI extensions supported by the JVM. These APIs provide access to the list of extensions available in the jvmtiExtensionEventInfo and jvmtiExtensionFunctionInfo structures. The sample uses an extension event and an extension function in the following way:
The sample JVMTI agent searches for the extension event VmDumpStart in the list of jvmtiExtensionEventInfo structures, using the identifier COM_IBM_VM_DUMP_START provided in ibmjvmti.h. When the event is found, the JVMTI agent calls the JVMTI interface SetExtensionEventCallback() to enable the event, providing a function DumpStartCallback() that is called when the event is triggered.
Next, the sample JVMTI agent searches for the extension function SetVMDump in the list of jvmtiExtensionFunctionInfo structures, using the identifier COM_IBM_SET_VM_DUMP provided in ibmjvmti.h. The JVMTI agent calls the function using the jvmtiExtensionFunction pointer to set a JVM dump option java:events=thrstart. This option requests the JVM to trigger a javadump every time a VM thread is started.
DumpStartCallback()
This callback function issues a message when the associated extension event is called. In the sample code, DumpStartCallback() is used when the VmDumpStart event is triggered.
Compiling and running the sample JVMTI agent
Use this command to build the sample JVMTI agent on Windows:
cl /I<SDK_path>\include /MD /FetiSample.dll tiSample.c /link /DLLwhere <SDK_path> is the path to your SDK installation.To run the sample JVMTI agent, use the command:
java -agentlib:tiSample -versionWhen the sample JVMTI agent loads, messages are generated. When the JVMTI agent initiates a Javadump, the message JVMDUMP010 is issued.
- Sample JVMTI agent
A sample JVMTI agent, written in C/C++, using the IBM JVMTI extensions.
Parent: Using the JVMTI
Error 404 - Not Found Error 404 - Not Found
The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.