As most SketchUp Ruby extension developers would agree, debugging has always been a bit of a pain. In the past, there have been a few community projects that added debuggers to SketchUp, but these were often difficult to set up and some were abandoned over time. The rest of the Ruby community enjoys debugging with Integrated Development Environments (IDE) such as RubyMine, NetBeans and Aptana RadRails. All of these generally rely on various gems to be installed for remote debugging. Getting these gems to work within SketchUp’s embedded Ruby is usually non-trivial.
This week, we’re taking a small step towards making debugging for SketchUp extensions a bit easier. At 3D Basecamp 2014, we’ve announced an open source Ruby debugger framework. You’ll find the source code for this project hosted under our GitHub account:
We currently support Windows only but you can expect Mac support soon.
Setting it up is easy:
- Simply grab SURubyDebugger.dll from GitHub and copy it into your SketchUp installation directory:
C:\Program Files (x86)\SketchUp\SketchUp 2014
- Launch SketchUp with the following command line arguments:
SketchUp.exe -rdebug "ide port=1234"
The port should match the remote debugger port setting configured in the IDE.
SketchUp will start up and appear to be frozen. It is waiting for the debugger to show up.
Launch remote debugging in the IDE, SketchUp should continue running. You should see breakpoints hit when Ruby code execution reaches the specified lines.
If you are unfamiliar with installing and configuring the IDEs, we’ve posted some step-by-step instructions in the GitHub repository wiki.
We still have a few TODOs (such as multi-thread debugging, breakpoint conditions and exception breakpoints), so if you are versed in Ruby’s C API, please contribute to the project.