3. Setting up the JIT profiling feature

To gather information about JITed code from a virtual machine, it needs to be instrumented with an agent library. We use the agent libraries for Java in the following example. To use the Java profiling feature, you must build OProfile with the "--with-java" option (Section 7, “Installation”).

3.1. JVM instrumentation

Add this to the startup parameters of the JVM (for JVMTI):

-agentpath:<libdir>/libjvmti_oprofile.so[=<options>] 

or

-agentlib:jvmti_oprofile[=<options>] 

The JVMPI agent implementation is enabled with the command line option

-Xrunjvmpi_oprofile[:<options>] 

Currently, there is just one option available -- debug. For JVMPI, the convention for specifying an option is option_name=[yes|no]. For JVMTI, the option specification is simply the option name, implying "yes"; no option specified implies "no".

The agent library (installed in <oprof_install_dir>/lib/oprofile) needs to be in the library search path (e.g. add the library directory to LD_LIBRARY_PATH). If the command line of the JVM is not accessible, it may be buried within shell scripts or a launcher program. It may also be possible to set an environment variable to add the instrumentation. For Sun JVMs this is JAVA_TOOL_OPTIONS. Please check your JVM documentation for further information on the agent startup options.