Java applications probe manager
Java™ Probe Manager (JPM) supports probing of Java applications in a way identical to C and C++ probe managers. A single Vue script should be able to trace multiple java applications at the same time by using different process IDs of the JVMs. The same script can be used to probe syscalls or C/C++ applications along with Java applications and can use other probe managers.
Like uft (user function tracing) probe manager java probe manager also accepts 5-tuple probe specification in the following format:
uftjava :< process_ID> :*:< _qualified_function_name >: entry
Where the second tuple is the process ID of JVM process corresponding to the Java application that is being traced.
Third field: reserved for future use.
Fourth field: where the java method needs to be specified.
This name is a completely qualified name as used in java applications like Mypackage.Myclass.Mymethod.
Some of the restrictions that may apply are
- Only pure java methods can be probed, Native (shared library calls) or encrypted codes are not traceable.
- Only entry probes are supported.
- Can support only JVM v 1.5 and above that supports JVMTI interface.
- At any given point of time, no two Probevue sessions can probe the same Java application with @@uftjava.
- Polymorphic/Overloaded methods are not supported.
- Tracing/accessing external variables with same name as any of the Probevue keywords or built-in names are not supported. This may need those external symbols (Java application variable names) to be renamed.
- Accessing arrays of java applications is not supported in this release.
- Accessing arrays of java applications is not supported in this release.
- get_function () built-in for java language is not supported in this release.
Data Access: The action blocks of java probes can access the following data similar to existing behavior.
- Action block can access global, local and kernel script variables.
- Action block can access method arguments (Entry class variables) of primitive types.
- Action block can access the built-in variables.
- Action block can access Java application variables through
fully qualified names, only static (class members).
x = some_package.app.class.var_x; //Access static/class member.
- Accessing java application primitive types variables is supported; they must be converted/promoted/casted implicitly without losing value to equivalent types in Vue language. But the actual memory usage (size) may differ from that of Java language.
The functions supported in the context of Java probe manager are listed in the following table:
Function | Description |
---|---|
stktrace() | Provides the Stack trace of the Java application (running thread) that is being traced. |
copy_userdata() | Copy data from java application into script variables. |
get_probe() | Returns the probe string. |
get_stktrace | Returns the runtime stack trace. |
get_location_point() | Returns the current probe location. |
get_userstring() | Copy string data from java application. |
exit() | exits from the probevue trace session. |
Changes to Probevue command:
Command | Description |
---|---|
-X option | This option can be used (along with -A option) to launch Java application, in the current release the user has to manually pass an additional optional string agentlib:probevuejava along with all the other options that are needed to run the java application. |
For Example:
probevue -X /usr/java5/bin/java -A -agentlib:probevuejava myjavaapp myscript.e
When running the 64 bit JVM, we have to use "agentlib:probevuejava64" as in:
probevue -X /usr/java5_64/bin/java -A -agentlib:probevuejava64 myjavaapp myscript.e
where myjavaapp is the java class of myjavaapp.java application
Example ExtendedClass.java Source:
class BaseClass
{
static int i=10;
public static void test(int x)
{
i += x;
}
}
public class ExtendedClass extends BaseClass
{
public static void test(int x, String msg)
{
i += x;
System.out.print("Java: " + msg + "\n\n");
BaseClass.test(x);
}
public static void main(String[] args)
{
BaseClass.test(5);
ExtendedClass.test(10, "hello");
}
}
Example test.e script for above Java application:
@@uftjava:$__CPID:*:"BaseClass.test":entry
{
printf("BaseClass.i: %d\n", BaseClass.i);
printf("BaseClass.test: %d\n", __arg1);
stktrace(0, -1);
printf("\n");
}
@@uftjava:$__CPID:*:"ExtendedClass.test":entry
{
printf("BaseClass.i: %d\n", BaseClass.i);
printf("ExtendedClass.test: %d, %s\n", __arg1, __arg2);
stktrace(0, -1);
printf("\n");
}
Example ProbeVue session with above script:
# probevue -X /usr/java5/jre/bin/java \
-A "-agentlib:probevuejava ExtendedClass" test.e
Java: hello
BaseClass.i: 10
BaseClass.test: 5
BaseClass.test()+0
ExtendedClass.main()+1
BaseClass.i: 15
ExtendedClass.test: 10, hello
ExtendedClass.test()+0
ExtendedClass.main()+8
BaseClass.i: 25
BaseClass.test: 10
BaseClass.test()+0
ExtendedClass.test()+39
ExtendedClass.main()+8