[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby - Debugging

Jorge Domenico Bucaran Romano

5/24/2007 7:24:00 PM

How do I use the ruby default debugger?

--
Posted via http://www.ruby-....

19 Answers

Tomas Pospisek

5/24/2007 7:45:00 PM

0

Alexey Verkhovsky

5/24/2007 8:58:00 PM

0

On 5/24/07, How do I use the ruby default debugger? <jbucaran@gmail.com> wrote:
> How do I use the ruby default debugger?

Just don't. ruby-debug is a much better alternative.

Alex

Jorge Domenico Bucaran Romano

5/25/2007 2:38:00 AM

0

Tomas Pospisek's Mailing Lists wrote:
> On Fri, 25 May 2007, How do I use the ruby default debugger? wrote:
>
>> How do I use the ruby default debugger?
>
> $ ruby -rdebug /tmp/some_ruby_program.rb
> Debug.rb
> Emacs support available.
>
> /tmp/k.rb:1:puts "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)
>
> --

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!

--
Posted via http://www.ruby-....

Alex Gutteridge

5/25/2007 3:02:00 AM

0

On 25 May 2007, at 11:37, Jorge Domenico Bucaran Romano wrote:

> Tomas Pospisek's Mailing Lists wrote:
>> On Fri, 25 May 2007, How do I use the ruby default debugger? wrote:
>>
>>> How do I use the ruby default debugger?
>>
>> $ ruby -rdebug /tmp/some_ruby_program.rb
>> Debug.rb
>> Emacs support available.
>>
>> /tmp/k.rb:1:puts "a"
>> (rdb:1) help
>> Debugger help v.-0.002b
>> Commands
>> --

[snip]

>
> 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!

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



Jorge Domenico Bucaran Romano

5/25/2007 3:13:00 AM

0

Alex Gutteridge wrote:
> On 25 May 2007, at 11:37, Jorge Domenico Bucaran Romano wrote:
>
>>> (rdb:1) help
>>> Debugger help v.-0.002b
>>> Commands
>>> --
>
> [snip]
>
>> '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

I prefer using the Ruby default debugger since I am planning to build a
GUI for it, the minimal functionality. I try to use the debugger but it
just seems to be in the wrong file 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) list
[5, 14] in C:/Program Files/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) list all
[-5, 4] in C:/Program Files/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 Fowler, Rich Kilmer, Jim Weirich and
others.
(rdb:1)

--
Posted via http://www.ruby-....

Jorge Domenico Bucaran Romano

5/25/2007 3:19:00 AM

0

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.

--
Posted via http://www.ruby-....

Alex Gutteridge

5/25/2007 3:51:00 AM

0

On 25 May 2007, at 12:18, Jorge Domenico Bucaran Romano wrote:

> 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.
>
> --
> Posted via http://www.ruby-....
>

You've told it (via your environment settings from looking at that
line) to load rubygems. Loading rubygems executes Ruby code. The
debugger is preparing to debug that code. Once you are past that code
you can start to debug your program.

As I said, you need to set breakpoints in your script and jump to
those breakpoints. E.g:

[alexg@powerbook]/Users/alexg/Desktop(7): cat test.rb
a=1
puts a
[alexg@powerbook]/Users/alexg/Desktop(8): ruby -rdebug -rubygems test.rb
Debug.rb
Emacs support available.

/usr/local/lib/ruby/site_ruby/1.8/ubygems.rb:10:require 'rubygems'
(rdb:1) b test.rb:1
Set breakpoint 1 at test.rb:1
(rdb:1) c
Breakpoint 1, toplevel at test.rb:1
test.rb:1:a=1
(rdb:1) list
[-4, 5] in test.rb
=> 1 a=1
2 puts a
(rdb:1)

Alex Gutteridge

Bioinformatics Center
Kyoto University



Jorge Domenico Bucaran Romano

5/25/2007 4:17:00 AM

0

Is it necessary to load the rubygems when debugging? Why do I need this?
If not really necessary how do I remove it from my enviroment settings?

--
Posted via http://www.ruby-....

Jorge Domenico Bucaran Romano

5/25/2007 4:18:00 AM

0

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
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) 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)

--
Posted via http://www.ruby-....