H
How do I use the ruby default debugger?
How do I use the ruby default debugger?
How do I use the ruby default debugger?
How do I use the ruby default debugger?
Tomas said:How do I use the ruby default debugger?
$ ruby -rdebug /tmp/some_ruby_program.rb
Debug.rb
Emacs support available.
/tmp/k.rb:1uts "a"
(rdb:1) help
Debugger help v.-0.002b
Commands
b[reak] [file:|class:]<line|method>
b[reak] [class.]<line|method>
set breakpoint to some position
wat[ch] <expression> set watchpoint to some expression
cat[ch] (<exception>|off) set catchpoint to an exception
b[reak] list breakpoints
cat[ch] show catchpoint
del[ete][ nnn] delete some or all breakpoints
disp[lay] <expression> add expression into display expression
list
undisp[lay][ nnn] delete one particular or all display
expressions
c[ont] run until program ends or hit breakpoint
s[tep][ nnn] step (into methods) one line or till line
nnn
n[ext][ nnn] go over one line or till line nnn
w[here] display frames
f[rame] alias for where
l[ist][ (-|nn-mm)] list program, - lists backwards
nn-mm lists given lines
up[ nn] move to higher frame
down[ nn] move to lower frame
fin[ish] return to outer frame
tr[ace] (on|off) set trace mode of current thread
tr[ace] (on|off) all set trace mode of all threads
q[uit] exit from debugger
v[ar] g[lobal] show global variables
v[ar] l[ocal] show local variables
v[ar] i[nstance] <object> show instance variables of object
v[ar] c[onst] <object> show constants of object
m[ethod] i[nstance] <obj> show methods of object
m[ethod] <class|module> show instance methods of class or module
th[read] l[ist] list all threads
th[read] c[ur[rent]] show current thread
th[read] [sw[itch]] <nnn> switch thread context to nnn
th[read] stop <nnn> stop thread nnn
th[read] resume <nnn> resume thread nnn
p expression evaluate expression and print its value
h[elp] print this help
<everything else> evaluate
(rdb:1)
--
[snip]Tomas said:$ ruby -rdebug /tmp/some_ruby_program.rb
Debug.rb
Emacs support available.
/tmp/k.rb:1uts "a"
(rdb:1) help
Debugger help v.-0.002b
Commands
--
Look what happened when I did just that:
C:\Users\jbucaran>ruby -rdebug
c:\users\jbucaran\desktop\demo2.rb
Debug.rb
Emacs support available.
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:require
'rubygems'
(rdb:1)
Help me I am clueless!
Alex said:[snip](rdb:1) help
Debugger help v.-0.002b
Commands
--
'rubygems'
(rdb:1)
Help me I am clueless!
The debugger is running and now you need to use it. Type help (as
shown above) to get a list of commands. You probably want to set
breakpoints at certain places in your script and then continue to
there using 'c' before you step through using 'n' or 's'. Googling
for 'ruby debugger' gives me the Pickaxe chapter on debugging which
is a good starting point if none of this makes sense.
Alex Gutteridge
Bioinformatics Center
Kyoto University
Also, why does it shows this:
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:require
'rubygems'
Not that I care much about it, since all I want to be able to
debug, but
I'd like to know what is it.
It is not working look at this:
C:\Users\jbucaran>ruby -rdebug c:\users\jbucaran\desktop\demo2.rb
Debug.rb
Emacs support available.
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:require
'rubygems'
(rdb:1) help
Debugger help v.-0.002b
[snip]
(rdb:1) b c:\users\jbucaran\desktop\demo2.rb
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:compile
error
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10: syntax
error, unexpe
cted $undefined, expecting tSTRING_CONTENT or tSTRING_DBEG or
tSTRING_DVAR or tS
TRING_END
c:\users\jbucaran\desktop\demo2
^
(rdb:1) Set breakpoint 1 at c:\users\jbucaran\desktop\demo2.rb:1
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10: warning:
parenthesiz
e argument(s) for future version
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:compile
error
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10: syntax
error, unexpe
cted tIDENTIFIER, expecting $end
Set breakpoint 1 at c:\users\jbucaran\desktop\demo2.rb:1
^
(rdb:1)
C:\Users\jbucaran>ruby -rdebug c:\users\jbucaran\desktop\demo2.rb
Debug.rb
Emacs support available.
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:require
'rubygems'
(rdb:1) b "c:\users\jbucaran\desktop\demo2.rb"
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:compile error
C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10: unterminated
string
meets end of file
(rdb:1)
I am sorry to bother like this, but is there any way I could get serious
documentation on how to use this, a good tutorial, maybe you can help me
here with a fine start. Please I can't believe it is so hard to do this.
Did you ask Google?
In your example above a file named "ubygems" is being parsed. Looks
like non-sense to me?
*t
ubygems.rb is the way rubygems is loaded when you run:
ruby -rubygems
Where "-rXYZ" means: "Please ruby, load the library XYZ first
please, before loading the actual program". And as can be seen
above, ruby does actually find a file/library named "ubygems" at
"C:/Program Files/Ruby/lib/ruby/site_ruby/1.8/ubygems.rb" which
doesn't make any sense to me because (AFAIK) there doesn't exist
and library named "ubygems" unless Jorge did something strange and
placed something there.
Or am I misstaken?
*t
ubygems *is* rubygems. This is getting off-topic, but ubygems.rb is the
reason you can write the aesthetically pleasing:
ruby -rubygems foo.rb
As well as:
ruby -rrubygems foo.rb
Note the double rr in the second one. Every installation of rubygems includes
ubygems.rb as far as I know. Try "locate '/ubygems.rb'" on your system.
Leslie said:Ok, I have something.puts a
Posted via http://www.ruby-forum.com/.
I saved your little program as "test.rb". When you set the breakpoint,
just
use the filename, not the path.
Here's my session:
C:\Documents and Settings\lesliev>ruby -rdebug test.rb
Debug.rb
Emacs support available.
c:/ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:require 'rubygems'
(rdb:1) b test.rb:3
Set breakpoint 1 at test.rb:3
(rdb:1) list
[5, 14] in c:/ruby/lib/ruby/site_ruby/1.8/ubygems.rb
5 # All rights reserved.
6 # See LICENSE.txt for permissions.
7 #++
8
9
=> 10 require 'rubygems'
(rdb:1) run
c:/ruby/lib/ruby/site_ruby/1.8/ubygems.rb:10:undefined local variable or
method `run' for main:Object
(rdb:1) c
Breakpoint 1, toplevel at test.rb:3
test.rb:3uts a
(rdb:1) list
[-2, 7] in test.rb
1
2 a = 2
=> 3 puts a
4 a = 3
5 puts a
6
7
(rdb:1)
Les
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.