I have been working on beefing up the MRI Ruby 2.1.5 and 1.9.3 runtime.
This effort supports better run-time introspection, especially of the
Ruby VM, and debugging.
You can find the debugger gem on gemcutter:
https://rubygems.org/gems/trepanning . But this gem needs a patched MRI
Ruby runtime. That can be found
at https://sourceforge.net/projects/ruby-debugger-runtime/ which has
- individual isolated patches for specific features,
- the patches combined into one,
- complete tarballs, and
- and some OS packages (debs and rpms).
Of course you can install via RVM and instructions for that are at:
So what makes this debugger different and more powerful than others?
- a call frame object (RubyVM::Frame)
- support for fast debugger breakpoints, “step over” and “step out”
- access to instruction sequences at runtime
- access inside Ruby to VM registers
- access to the source text of eval when inside eval()
- More accurate location information
- access to C parameters in a C call
- memory addresses of C functions (useful in conjunction with gdb)
- seeing and changing event filters dynamically
These are, in truth, features of the runtime system. The debugger makes
use of these and other features to provide:
- nested debugging
- ability to skip over statements
- ability to modify function return values (often)
- ability to detect (sometimes) a non-local exception that is about to
raised before it is raised so you have access to the full call stack.
- display of the current VM PC and VM stack values
The debugger also has these features which in theory could be added to
(or are already part of) other debuggers:
- context sensitive debugger command completion
- extensive online help formatted via markdown/redcloth so it
adjusts to your terminal width and has nice formatting
- syntax highlighting
- stepping granularity control
- smart eval
- ability to go into irb from inside the debugger
- compatibility with gdb commands.
- out-of-process and out-of server debugger control
- disassembly of VM instructions
I imagine many or most people are happy with the existing set of
debuggers and don’t need the power that comes with this runtime or
debugger to warrant installation of yet another Ruby. This effort is for
those who want more.
This debugger is both a high-level debugger (like others)
and a low-level debugger like gdb or what you might get with dtrace.
However in contrast to most other tools it understand the Ruby MRI VM
So those who are interested in working on or understanding the MRI 2.1.5
Ruby VM might want to look at both the debugger and runtime.
information on the specific extensions and the broken out patches
with commentary can be at:
Since at runtime you can get the current PC and access to Ruby VM
instruction sequences, it is possible to use this to provide more
detailed and accurate code coverage and profiling information.
Without the patches, the runtime (I think) only gives you granularity
down to a line number. But of course it is possible to have several
statements and branching within a physical source-code line. So I
believe for the most accurate profiling you probably want VM
Finally, I should say that there’s still a bit more that could be done
and things could be improved. Perhaps that will happen later – we’ll
see. But what’s there goes a long way. It is about at the limit of my
ability both in terms of technical ability and time that I have to
devote on this.