Nested debugging

rocky edited this page Nov 7, 2010 · 2 revisions

Sometimes you are inside the debugger and want to debug start debugging another method or Ruby expression of your choosing. You can do this with the debug debugger command:


  (trepan): gdb(3,5)  # This evaluates without debugging into
  D=> 1
  (trepan): debug gcd(3,5)  # This debugs into gcd
  ENTERING NESTED DEBUGGER
  METHOD Object#gcd(a, b)
  -> (gcd.rb:4)
  def gcd(a, b)
  ((trepan)):  step  
  -- (gcd.rb:6)
  if a > b
  ((trepan)): continue
  LEAVING NESTED DEBUGGER
  R=> 1
  (gcd.rb:18) a, b = ARGV[0..1].map {|arg| arg.to_i}
  (trepan): 

Every time you nest debugging a new level of parenthesis is added. So ((trepan)) indicates you are nested once in the debugger.