Debugging Rubinius Source

rocky edited this page Nov 7, 2010 · 2 revisions

Whenever the debugger can’t find the source code to the debugged program it offers assembly code in consolation. The most common occurance of this is in debugging into the Rubinius code itself e.g. each or times :

$ rbx /tmp/ex1.rb
-- (/tmp/ex1.rb:4)
1.times do
(trepanx): s
-> (kernel/common/integer.rb:117)
Bytecode between 0 and 14 for line 117
    0: push_has_block 
    1: goto_if_false 6
    3: push_nil 
    4: goto 14
    6: push_self 
    7: push_literal 0
    9: allow_private 
   10: send_stack 1, 1
   13: ret 
   14: pop 

If you find yourself tracing into Rubinius code, have the source code available, and want to see source code listings instead of LLVM instructions, use the dir command:

(trepanx): dir /home/rocky-rvm/.rvm/src/rbx-head/
  Source directories searched:   /home/rocky-rvm/.rvm/src/rbx-head/:$cdir:$cwd

Now as you go along you see the Rubinius source code. Below, frame is used to refresh the state

(trepanx): dir /home/rocky-rvm/.rvm/src/rbx-head/
  (trepanx): frame 0
  -> (kernel/common/integer.rb:117 remapped /home/rocky-rvm/.rvm/src/rbx-head/kernel/common/integer.rb:117)
  return to_enum :times unless block_given?
  (trepanx): list
  113   	    self - 1
  114   	  end
  116   	  def times
  117 ->	    return to_enum :times unless block_given?
  119   	    i = 0
  120   	    while i < self
  121   	      yield i
  122   	      i += 1

And iff this to your liking, put that dir command into your trepan startup script ~/.trepanxrc and you won’t ever have to enter it inside the debugger.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.