←Older revision |
Revision as of 11:27, 1 August 2017 |
Line 23: |
Line 23: |
| Designing your own [[language]]? Do you want to spend time writing a [[debugger]]? If not, use [[Truffle]] and you'll get your [[debugger]] for free! | | Designing your own [[language]]? Do you want to spend time writing a [[debugger]]? If not, use [[Truffle]] and you'll get your [[debugger]] for free! |
| | | |
- | == Debugger in [[NetBeans]] 8.1 ==
| + | {{:TruffleNetBeansDebugger}} |
- | | + | |
- | [[NetBeans]] 8.1 will ship 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:
| + | |
- | | + | |
- | <source lang="bash">
| + | |
- | $ $GRAAL_VM/bin/maven_install_graalvm
| + | |
- | </source>
| + | |
- | | + | |
- | 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:
| + | |
- | | + | |
- | <source lang="bash">
| + | |
- | $ hg clone http://source.apidesign.org/hg/truffledebugdemo/
| + | |
- | $ cd truffledebugdemo
| + | |
- | $ hg up -C GraalVM-0.9
| + | |
- | </source>
| + | |
- | | + | |
- | With the sources you can now use the command line or the IDE to work with them:
| + | |
- | | + | |
- | <source lang="bash">
| + | |
- | # compile:
| + | |
- | $ JAVA_HOME=$GRAAL_VM mvn clean install
| + | |
- | # execute
| + | |
- | $ JAVA_HOME=$GRAAL_VM mvn exec:exec
| + | |
- | factorial(5) = 120
| + | |
- | </source>
| + | |
- | | + | |
- | The sample prints out value of factorial for five computed in four different ([[Java]], [[Ruby]], [[JavaScript]] and our testing simple language) [[language]]s.
| + | |
- | | + | |
- | ==== Debugging from [[NetBeans]] ====
| + | |
- | | + | |
- | Make sure [[NetBeans]] is running on the [[GraalVM]]:
| + | |
- | | + | |
- | <source lang="bash">
| + | |
- | $ /netbeans8.1/bin/netbeans --jdkhome $GRAAL_VM
| + | |
- | </source>
| + | |
- | | + | |
- | 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:
| + | |
- | | + | |
- | {{#ev:youtube|ewdzDqPsn38}} | + | |
- | | + | |
- | | + | |
- | [[Category:Video]]
| + | |