Search code examples
javajvmbytecode

Java byte code debugging with operand stack and locals visualization?


I'm looking for a tool for debugging and stepping through Java Bytecode, with visualizing of the basic JVM state, including the operand stack and the local variables array, merely for educational purposes and JVM learning (for myself, and hopefully for others as well). Is there such a tool at hand?

I came across the Bytecode Visualizer Eclipse plugin by Dr. Garbage, which allows breaking on and stepping through Bytecode, but it doesn't visualize the JVM state:

http://www.drgarbage.com/bytecode-visualizer

The following related questions (quite old) mention a few tools, some of which allow stepping through Bytecode, but none with JVM state visualization:

Is there such a tool at hand, that is capable of debugging simple Java programs? Or even a simple JVM simulator?

Thanks!


Solution

  • I've adapted the PyJVM to do what you are after. It shows a simple gui for each thread of the Java program (they have to be compiled for Java7).

    The only issue with this tool is that it doesn't have a GC, since garbage collection is handled by Python itself. Therefore, the Thread 1 (daemon) (the reference handler) will not ever do anything. Finalize method also won't trigger.

    Source is available on https://github.com/MatevzFa/pyjvm (warning: the source code isn't very nice to look at), you can also install it with pip (pip2 actually, since PyJVM is written in Python2).

    Install:

    pip install pyjvmgui
    

    Upgrade:

    pip install pyjvmgui --upgrade --no-deps
    

    I stil have to write a good README for it.