[go: up one dir, main page]

HomePage | RecentChanges | Full Index

Debug

Debugging Java programs with SableVM and Eclipse

It is now possible to debug Java applications and libraries (including the basic class library) using SableVM and Eclipse! Thanks to many months of work by Nizar Ahmouda, SableVM implements the required JVMDI and JDWP specifications for debugging Java programs.

This page provides step-by-step instructions for setting up this debugging environment. Important: Please follow these instructions rigorously.

Note that you will need two Java Virtual Machines: one to run Eclipse and one to run the debugged application. The first must be a recent release of SableVM and the second must be a snapshot of SableVM that includes JVMDI/JDWP support.

DO NOT ATTEMPT TO RUN ECLIPSE ON A DEBUG VERSION OF SABLEVM. As written in the previous paragraph, you must use an efficient, released version of SableVM to run Eclipse. You must only use a debug version of SableVM to run a debugged Java application from within Eclipse (as described later in this document).

Quick start instructions

The instructions below assume you have all the needed dependencies installed. You do if you ever installed SableVM from source. If you use Debian execute (as root) the following command: apt-get build-dep sablevm sablevm-classlib.

To get the whole thing working, do the following:

 su
 cd /tmp
 wget -c ftp://ftp.cse.buffalo.edu/pub/Eclipse/eclipse/downloads/drops/S-3.1M1-200408122000/eclipse-SDK-3.1M1-linux-gtk.zip
 wget -c http://sablevm.org/people/nizar/sablevm-nizar-debug+3895.tar.gz
 wget -c http://sablevm.org/people/nizar/sablevm-classpath-nizar-debug+3895.tar.gz
 wget -c http://sablevm.org/people/nizar/eclipse-sablevm
 wget -c http://sablevm.org/download/release/1.11.3/sablevm-1.11.3.tar.gz
 wget -c http://sablevm.org/download/release/1.11.3/sablevm-classpath-1.11.3.tar.gz
 for archive in sablevm-1.11.3.tar.gz sablevm-classpath-1.11.3.tar.gz \
   sablevm-nizar-debug+3895.tar.gz sablevm-classpath-nizar-debug+3895.tar.gz; do tar -zxf $archive; done
 cd /tmp/sablevm-1.11.3 && ./configure && make install
 cd /tmp/sablevm-classpath-1.11.3 && ./configure && make install
 cd /tmp/sablevm-nizar-debug+3895 && ./configure && make install
 cd /tmp/sablevm-classpath-nizar-debug+3895 && ./configure && make install
 cd /usr/local && unzip /tmp/eclipse-SDK-3.1M1-linux-gtk.zip
 chmod +x /tmp/eclipse-sablevm && cp -f /tmp/eclipse-sablevm /usr/local/bin
 exit

We're almost done. To set up your Eclipse environment to use debug-enabled SableVM do the following:

Troubleshooting - FAQ

Note about JVMDI and JDWP support in SableVM

The support for JVMDI and JDWP is not yet included into mainline SableVM releases. As the issues for merging this support into the mainline are not completely resolved yet, we have decided to temporarily release fully functional snapshots of the SableVM debug branch. This branch comes with an implementation of the Java Virtual Machine Debug Interface (JVMDI) and the Java debug Wire Protocol (JDWP). This new functionality has only undergone internal testing with Eclipse 2.1 and 3.1, so we do appreciate all reports about bugs and missing features. Please refer to http://sablevm.org/bugs/open for the list of open bug reports and use http://sablevm.org/bugs/new to report new problems and wishes.

Step-by-step detailed instructions

Running Eclipse on SableVM

1. Fetch sablevm-1.11.3.tar.gz and sablevm-classpath-1.11.3.tar.gz from the SableVM 1.11.3 release directory.

2. Compile and install them as usual, e.g.:

 tar -xzf sablevm-1.11.3.tar.gz
 cd sablevm-1.11.3
 ./configure && make && make install
 cd ..
 tar -xzf sablevm-classpath-1.11.3.tar.gz
 cd sablevm-classpath-1.11.3
 ./configure && make && make install

This will install SableVM in the /usr/local directory hierarchy. (Debian users can apt-get install sablevm to install a precompiled version in the / directory hierarchy).

3. Fetch the Eclipse 3.1M1 binary for your architecture from http://www.eclipse.org/downloads/index.php, then use the following script to run it. Note: Make sure you point JAVA and ECLIPSE_HOME to the 'java-sablevm' and Eclipse main directory accordingly.

 #!/bin/sh
 JAVA=/usr/local/bin/java-sablevm
 ECLIPSE_HOME=/usr/local/eclipse
 
 #########################################################################
 # You should NOT need to modify anything below this line.               #
 #########################################################################
 if [ ! -x $JAVA -o ! -f $ECLIPSE_HOME/startup.jar ]; then
   echo "Error: 'java' command or Eclipse's startup.jar not found!"
   echo "  JAVA=$JAVA"
   echo "  ECLIPSE_HOME=$ECLIPSE_HOME"
   echo "  Check the directories in $0 script and try again!"
   exit 1
 fi
 
 JAVACMD="$JAVA -Dosgi.locking=none $XML_LIBS"
 
 for one in `find $ECLIPSE_HOME -name \*.so | sed 's/^\(.*\)\/[^\/]*$/\1/g' |sort|uniq`; do
   if [ "X$LD_LIBRARY_PATH" = "X" ]; then
     LD_LIBRARY_PATH=$one
   else
     LD_LIBRARY_PATH="$LD_LIBRARY_PATH":$one
   fi
 done
 
 export LD_LIBRARY_PATH JAVACMD ECLIPSE_HOME JAVA
 MAIN=org.eclipse.core.launcher.Main
 echo "Eclipse from $ECLIPSE_HOME is starting up using $JAVA JVM."
 echo "Please be patient..."
 exec $JAVACMD -cp $ECLIPSE_HOME/startup.jar $MAIN -os linux -ws gtk -consolelog

Installing Debug-enabled SableVM

1. Fetch sablevm-nizar-debug+3895.tar.gz and sablevm-classpath-nizar-debug+3895.tar.gz from the SableVM developper directory.

2. Compile and install them as usual, e.g.:

 tar -xzf sablevm-nizar-debug+3895.tar.gz
 cd sablevm-nizar-debug+3895
 ./configure && make && make install
 cd ..
 tar -xzf sablevm-classpath-nizar-debug+3895.tar.gz
 cd sablevm-classpath-nizar-debug+3895
 ./configure && make && make install

This will install debug-enabled SableVM in the /usr/local/sablevm-debug directory hierarchy. If you provide a prefix make sure that it is different from the SableVM installation used to run Eclipse!!!.

Setting up Eclipse Environment for Debugging with SableVM

This is a step-by-step guide on how to configure your Eclipse environment.

In order to perform all the required operations (setting breakpoints...), the debugged application is suspended just before its main executes. So click the 'Resume' button to effectively start it.

After following the above instructions, you are able to enjoy all the advantages of a user-friendly IDE as seen on the screenshot.

TODO

Please note that the SableVM Debug extension is still in its final stage of development, so some features are missing. Here is the list of the features that still have to be implemented or problems that are known with this implementation. In JVMDI:

In JDWP:

Depending on wich Eclipse version you run, the debugged application may hang at the end of its execution. Press the 'Stop' button one last time to stop it.