## What is this? The following is a rough transcript of the [[third part of a short video presentation|RubyKaigi2010-emacs-rbdbgr-part2.ogv]] at Ruby Kaigi 2010. ## Transcript Previously, I have been running the debugger from the outset. However in Ruby, the debugger is not often run initially. Instead it is called from inside a running program. Let me show briefly how use the Emacs interface in this situation. Here is a program where I have added a call to the Ruby 1.9 debugger. ```ruby #!/usr/bin/env ruby require 'rbdbgr' # GCD. We assume positive numbers def gcd(a, b) Debugger.new.debugger # Call debugger here! # Make: a <= b if a > b a, b = [b, a] end return nil if a <= 0 if a == 1 or b-a == 0 return a end return gcd(b-a, a) end a, b = ARGV[0..1].map {|arg| arg.to_i} puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)] ``` Now I go into a normal comint shell: `M-x shell` And when I run the program: `ruby gcd-dbgcall.rb 3 5`, I am now in the debugger. But Emacs doesn't know that this shell is inside a particular debugger. So to tell Emacs this, use `M-x dbgr-track-mode` You are prompted for the name of a debugger. The debugger names you could list here include a [[couple of|http://github.com/rbdbgr]] [[Ruby debuggers|http://bashdb.sourceforge.net/ruby-debug/home-page.html]], a [[couple of|http://code.google.com/p/pydbgr/]] [[Python debuggers|http://bashdb.sf.net/pydb]], gdb, or [[some|http://bashdb.sf.net]] [[POSIX shell|http://github.com/rocky/kshdb]] [[debuggers|http://github.com/rocky/zshdb]]. And you can switch from one to the another afterwards. I will use `rbdbgr`. Note the mode line now has the name of the debugger. And use `frame 0` to refresh the display. Translation courtesy of SAWADA Tadashi