Dart: Exploring the DartVM From a Debugger on Mac OSX
This may be useless to many, obvious to some and complete wrong for others, but I would like to comment for the wondering dart on how to debug the VM. Goal of this post is to provide a quick and reproducible way to explore the DartVM at runtime on Mac OSX. I personally enjoy watching code from a debugger, so this was helpful to explore what is going on under the hood. We currently have two projects to debug from. dartruntime and dart.googlecode.com. Get this version of Eclipse Mac OSX 32bit cocoa.
I typically use the cmake branch cause I’m working with dart on Mac OSX and I dont want to touch xcode. The main dart project generates xcode projects for builds, you could use xcode to edit the c++ code. Having to choose between eclipse or xcode, I personally pick eclipse. Using the cmake project is a little cleaner/simpiler/complete to import from as Makefile project. (I could be wrong, but didn’t want to invest more time into importing stuff I’m not interested in). Setting up DartVM the song and dance from googlecode goes like this. For using the cmake branch provided by Peter Kümmel is as follows:[sourcecode lang=”bash”]git clone git@github.com:syntheticpp/dartruntime.git
cd dartruntime
git checkout -b cmake origin/cmake
cd ..
mkdir build
cd build
cmake ../dartruntime/cmake/
make -j4
echo "main() { print(\"Hello World\!\"); }" > hello.dart
./bin/dart ./hello.dart[/sourcecode]
After having a debug build on either branch you can target the executable directly by choosing to importing C/C++ Executable. Next select the executable you want to target from either build. The debug builds will provide all the symbols and source code mapping. Name the project and debug launch target as you need. Set the arguments to pass to the dartvm, here we are setting a hello world sample based on an Actor Model. The debugger will break on the main entry point.
[gallery]
It is proabably possible that the dart runtime envionment setup is similar to what chrome is used too, so the instructions on how to setup eclipse for chrome may also apply. I have not tried it out my self. A follow up post will show how to import the c++ code to eclipse and build from generated Makefiles.