RVM : Debugging the RVM

There are different tools for debugging Jikes RVM:

GDB

There is a limited amount of C code used to start Jikes RVM. The rvm script will start Jikes RVM using GDB (the GNU debugger) if the first argument is -gdb. Break points can be set in the C code, variables, registers can be expected in the C code.

rvm -gdb <RVM args> <name of Java application> <application args>

The dynamically created Java code doesn't provide GDB with the necessary symbol information for debugging. As some of the Java code is created in the boot image, it is possible to find the location of some Java methods and to break upon them. To determine the location use the RVM.map file. A script to enable use of the RVM.map as debugger information inside GDB is provided here.

Details of how to manually walk the stack in GDB can be found here

Other Tools

Other tools, such as valgrind, are occasionally useful in debugging or understanding the behaviour of JikesRVM.  The rvm script facilitates using these tools with the '-wrap' argument.

rvm -wrap "<wrapper-script-and-args>" <rest of command line>

For example, cachegrind can be invoked by

rvm -wrap "/path/to/valgrind --tool=cachegrind" <java-command-line>

The command and arguments immediately after the -wrap argument will be inserted into the script on the command line that invokes the boot image runner.  One useful variant is

rvm -wrap echo <rest of command line>

Debugger Thread

Jikes has an interactive debugger that you can invoke by sending SIGQUIT to Jikes while it's running:

pkill -SIGQUIT JikesRVM

In previous versions of Jikes, that stopped all threads and provided an interactive prompt, but currently it just dumps the state of the VM and continues immediately (that's a known issue: http://jira.codehaus.org/browse/RVM-570).

 Java Platform Debugger Architecture (JPDA)

In general the JPDA provides 3 mechanisms for debugging Java applications:

Currently JDWP code is being implemented in Jikes RVM based on the GNU Classpath implementation.