TruffleNetBeansDebugger
From APIDesign
JaroslavTulach (Talk | contribs)
(New page: == Debugger in NetBeans 8.1 == NetBeans 8.1 and newer ships with support for debugging of Truffle languages. Here is a promotional video demonstrating how to use such feature,...)
Next diff →
Current revision
Debugger in NetBeans 8.1
NetBeans 8.1 and newer ships with support for debugging of Truffle languages. Here is a promotional video demonstrating how to use such feature, but you can try that too! Just get the most recent build of NetBeans, install the Truffle Debugging Support module and get the sources:
- Download latest daily build of NetBeans - tested on netbeans-trunk-nightly-201510210002-javase.zip downloaded from http://bits.netbeans.org/download/trunk/nightly/2015-10-21_00-02-28/zip/
- Install Truffle Debugging Support: Go to Tools/Plugins/Available Plugins and seek for Truffle, then install.
- Get the latest GraalVM build from the OTN: http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html
Installing Maven Bits and Working with Sources
Assuming your GraalVM is installed in directory $GRAAL_VM, continue by installing essential Truffle binaries into your local Maven repository:
$ $GRAAL_VM/bin/maven_install_graalvm
and then you can work with the sources. First of all obtain them and switch to the correct (known to work at present time) revision:
$ hg clone http://source.apidesign.org/hg/truffledebugdemo/ $ cd truffledebugdemo $ hg up -C GraalVM-0.9
With the sources you can now use the command line or the IDE to work with them:
# compile: $ JAVA_HOME=$GRAAL_VM mvn clean install # execute $ JAVA_HOME=$GRAAL_VM mvn exec:exec factorial(5) = 120
The sample prints out value of factorial for five computed in four different (Java, Ruby, JavaScript and our testing simple language) languages.
Debugging from NetBeans
Make sure NetBeans is running on the GraalVM:
$ /netbeans8.1/bin/netbeans --jdkhome $GRAAL_VM
Open the project sources in the IDE (File/Open Project, select the truffledebugdemo directory). Open MixLanguages.java source file. Put breakpoint to MixLanguages.java line 37 that invokes the global factorial symbol and debug the project (Debug/Debug Project or press Ctrl-F5). Once the breakpoint is hit, you can step-into (F7), you'll be in JavaScript. If you continue stepping in you'll get into simple language and then also into Ruby. Values of local variables will be available. Enjoy: