Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
702 views
in Technique[技术] by (71.8m points)

jvm - Trace java bytecode stream

I would like to see the current (bytecode) instruction stream of the JVM it is executing. After some googleing, I found that the jvm debug build offers the -XX:+TraceBytecodesoption (see here). However, the mentioned link to the hotspot JVM debug build is dead and I could not find a debug build online :/

Is there another way to trace the jvm bytecode stream or can someone point me in the right direction? I'm running 64 bit ubuntu 16.04.

P.S: I know, its going to be painfully slow to print out the complete instruction stream. However, I am curios

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

-XX:+TraceBytecodes option is exactly what are you looking for. It is available in debug builds of HotSpot JVM. You can easily build JVM yourself - just HotSpot, not even JDK.

  1. Clone hotspot repository from OpenJDK 8 project

    hg clone http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot
    
  2. Build 'fastdebug' JVM (assuming JDK is already installed at /usr/java/jdk1.8.0_102)

    cd hotspot/make
    make ALT_BOOTDIR=/usr/java/jdk1.8.0_102 ARCH_DATA_MODEL=64 fastdebug
    

    You may add HOTSPOT_BUILD_JOBS=N to run compilation in N parallel processes.

  3. Run it

    export ALT_JAVA_HOME=/usr/java/jdk1.8.0_102
    ../build/linux/linux_amd64_compiler2/fastdebug/hotspot -XX:+TraceBytecodes MainClass
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...