Btrace is a Java-based tool that can dynamically track bytecode. It can monitor the execution status of Java programs at runtime without modifying the current program, for example, you can monitor the memory status and call methods. However, it can only run on JDK 6 + and later versions. for some reasons, for example, in JDK 5, jtwti (Java Virtual Machine toolkit interface: Java Virtual Machine Tool interface, refer to this article: http://www.ibm.com/developerworks/cn/java/j-lo-jvmti/), only supports native-based
Library, rather than a jar-based proxy.
It is very simple to use, the simplest is to write the Java source code, directly put it in its bin directory to execute it, it has a detailed userguide: Compile.
However, in some cases, we do not have JDK In the runtime environment, but only JRE. We need to make some modifications to btrace for normal use.
1. Copy tools. jar from JDK to a suitable directory (such as./tmp );
2. set libattach from JDK. so is also copied to the above directory (ex. /tmp)-This file should be selected based on the number of operating system digits of the current running system, such as 32-bit or 64-bit, we need to select a file from the appropriate JDK;
3. modify the btrace script. The script is in the bin directory. Modify different btrace files based on different systems-change tools_jar = "$ {java_home}/lib/tools. jar "changed to the tool copied above. jar;
4. modify the btrace script. The script is under the bin directory. Modify different btrace files based on different systems-Modify the line executed by Java (I. e. is the row starting with $ java_home}/bin/Java.) Add the parameter-djava. library. path =/tmp, the/tmp directory is where we store libattach. so file location;
5. Execute the command according to the original execution method.
The above is translated to: https://kenai.com/projects/btrace/forums/tips-tricks/topics/13119-Using-BTrace-with-JRE-as-a-target-VM