Following are two examples of using ruby-debug on PickAxe ver. 2
Fibonacci example:
- t.rb executed with “ruby -t debug t.rb”, which lists ruby_debug.rb
code rather than t.rb code; and - t2,rb (with embedded “require ‘ruby-debug’”) run with “ruby t2.rb”
and correctly lists t2.rb code.
I’m running:
ruby 1.8.6
ruby-debug 0.10.3 (I believe; I list the gem info below)
WinXP-PRo/SP3
I hope the two listing present the issue clearly.
Thanks in Advance,
Richard
Command Window execution #1 for “ruby -t debug t.rb”
K:\Temp\Test>dir *.rb/b
t.rb
t2.rb
K:\Temp\Test>type t.rb
def fact(n)
if n <= 0
1
else
n * fact(n-1)
end
end
p fact(5)
K:\Temp\Test>ruby t.rb
120
K:\Temp\Test>ruby -r debug t.rb
Debug.rb
Emacs support available.
K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/ubygems.rb:
10:require ‘rubygems’
(rdb:1) list 1-20
[1, 20] in K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/site_ruby/1.8/
ubygems.rb
1 # This file allows for the running of rubygems with a nice
2 # command line look-and-feel: ruby -rubygems foo.rb
3 #–
4 # Copyright 2006 by Chad F., Rich Kilmer, Jim W. and
others.
5 # All rights reserved.
6 # See LICENSE.txt for permissions.
7 #++
8
9
=> 10 require ‘rubygems’
(rdb:1) q
Really quit? (y/n) y
K:\Temp\Test>“ruby -t debug t.rb”
Command window #2 for “ruby t2.rb” with "require ‘ruby-debug’
K:\Temp\Test>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
K:\Temp\Test>gem list ruby-debug
*** LOCAL GEMS ***
ruby-debug (0.10.3, 0.10.1, 0.10.0)
ruby-debug-base (0.10.3, 0.10.1, 0.10.0)
ruby-debug-ide (0.4.9, 0.1.10)
K:\Temp\Test>cd \
K:>:===================================
K:>:
K:>cd K:\Temp\Test
K:\Temp\Test>type t2.rb
require ‘ruby-debug’
def fact(n)
if n <= 0
1
else
debugger
n * fact(n-1)
end
end
p fact(5)
K:\Temp\Test>ruby t2.rb
t2.rb:8
n * fact(n-1)
(rdb:1) list 1-20
[1, 20] in t2.rb
1 require ‘ruby-debug’
2
3 def fact(n)
4 if n <= 0
5 1
6 else
7 debugger
=> 8 n * fact(n-1)
9 end
10 end
11
12 p fact(5)
(rdb:1) q
Really quit? (y/n) y
K:\Temp\Test>