Hi all, I'm dying to know how to:
Sometimes it is possible that the back trace for other exceptions can get lost. This may be a result of MacRuby Ticket #1369, but it might also be because of MacRuby Ticket #1320 or perhaps some freedom patch in a library that you are using or have added yourself.
As the bug reports have outlined, the loss of back trace happens for multiple exception classes. There is a work around until the issue is properly addressed.
Back traces can be lost for reasons other than a bug. When using compiled MacRuby code, you cannot get a Ruby level back trace in case of an error. Having Ruby level backtraces for compiled code is a feature that has not yet been implemented.
In the mean time, if you suspect that the portion of a back trace that would come from a compiled file is the problem, then you can disable loading compiled files which will force MacRuby to load source ruby files instead. You can disable loading compiled files by setting the
VM_DISABLE_RBO environment variable before running a script. You can disable loading for a single session like so:
VM_DISABLE_RBO=1 macruby my_script.rb
Sometimes you may be hitting a bug related to garbage collection. For instance, a write barrier might be missing somewhere, which indirectly results in an object being prematurely collected, and by later a crash when trying to access the object in question.
To investigate this type of bugs, it can be handy to run your code with the garbage collection disabled.
GC_DISABLE=1 macruby my_script.rb
It is known that JIT optimization might take a long time. Sometimes you may load the RubyGems which is using many files. And loading might be too slowly.
To disable the JIT optimization, might improve the loading time.
VM_OPT_LEVEL=0 macruby my_script.rb
In addition, if your problem is not produced when you apply the
VM_OPT_LEVEL=0, it might be a bug related to JIT compiler.
You can set environment variables in Xcode by going to Product --> Edit Schemes. Add your variables in the Arguments tab.
Other debugging options are also available from MacRuby itself. You should check out Hacking.rdoc in the MacRuby source repository for more details.