Ruby-Debugger newbie problem

R

RichardOnRails

Hi All,

Following is a Command window session trying to run Ruby Debugger on a
trivial program. The debugger seems to be stuck in "ubygems.rb" in my
Ruby installation rather than in my test program. Is my installation
messed up?

I'm running ruby 1.8.2 (2004-12-25) [i386-mswin32] on WinXP/SP2.

Thanks in Advance,
Richard

K:\_Projects\Ruby\_Ruby_Tests\TestDebugging>type TestDebugging101.rb
# TestDebugging101.rb
# K:\_Projects\Ruby\_Ruby_Tests\TestDebugging
p 'Line 3'
p 'Line 4'

K:\_Projects\Ruby\_Ruby_Tests\TestDebugging>ruby -rdebug
TestDebugging101.rb
Debug.rb
Emacs support available.

K:/_Utilities/Ruby_1.8.2-15/ruby/lib/ruby/site_ruby/1.8/ubygems.rb:
10:require 'rubygems'
(rdb:1) l
[5, 14] in K:/_Utilities/Ruby_1.8.2-15/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)
 
R

RichardOnRails

Hi All,

Following is a Command window session trying to run Ruby Debugger on a
trivial program. The debugger seems to be stuck in "ubygems.rb" in my
Ruby installation rather than in my test program. Is my installation
messed up?

I'm running ruby 1.8.2 (2004-12-25) [i386-mswin32] on WinXP/SP2.

Thanks in Advance,
Richard

K:\_Projects\Ruby\_Ruby_Tests\TestDebugging>type TestDebugging101.rb
# TestDebugging101.rb
# K:\_Projects\Ruby\_Ruby_Tests\TestDebugging
p 'Line 3'
p 'Line 4'

K:\_Projects\Ruby\_Ruby_Tests\TestDebugging>ruby -rdebug
TestDebugging101.rb
Debug.rb
Emacs support available.

K:/_Utilities/Ruby_1.8.2-15/ruby/lib/ruby/site_ruby/1.8/ubygems.rb:
10:require 'rubygems'
(rdb:1) l
[5, 14] in K:/_Utilities/Ruby_1.8.2-15/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)

OK, I see that I stopped at ubygems.rb:10

Question 1: Why did the debugger stop there and not continue with
statements 3& 4 in my test program? Is my Ruby installation messed
up?

Q 2: Why do I have a "upygems.rb" in my installation that has nothing
substantive than "require 'rubygems'"?

Q 3. Does the presence of this strangely named file "upygems.rb"
suggest my Ruby installation is messed up?

I continued the processing from the current point as shown below.

Q 4. Since I put a breakpoint at "upygems.rb:3", why didn't the
debugger stop there instead of running through the entire remainder of
the test program?

Thanks again in advance for any insights you may offer.

Regards,
Richard

(rdb:1) b K:/_Projects/Ruby_Tests/TestDebugging/TestDebugging101.rb:3
Set breakpoint 2 at K:/_Projects/Ruby_Tests/TestDebugging/
TestDebugging101.rb:3
(rdb:1) b
Breakpoints:
2 K:/_Projects/Ruby_Tests/TestDebugging/TestDebugging101.rb:3

(rdb:1) c
"Line 3"
"Line 4"

K:\_Projects\Ruby\_Ruby_Tests\TestDebugging>
 
S

s.ross

10:require 'rubygems'
(rdb:1) l
[5, 14] in K:/_Utilities/Ruby_1.8.2-15/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)

OK, I see that I stopped at ubygems.rb:10

Question 1: Why did the debugger stop there and not continue with
statements 3& 4 in my test program? Is my Ruby installation messed
up?

Q 2: Why do I have a "upygems.rb" in my installation that has nothing
substantive than "require 'rubygems'"?

Q 3. Does the presence of this strangely named file "upygems.rb"
suggest my Ruby installation is messed up?

I continued the processing from the current point as shown below.

Q 4. Since I put a breakpoint at "upygems.rb:3", why didn't the
debugger stop there instead of running through the entire remainder of
the test program?

Thanks again in advance for any insights you may offer.

Regards,
Richard

I'll take a guess.

Somewhere in your environment, you have the RUBY_OPTS variable set to -
rubygems. What does that do? It makes is so that when you type:

ruby myprogram.rb

the effect is:

ruby -rubygems myprogram.rb

Note that what you are really telling Ruby is to load your program,
require 'ubygems' and then start.

It turns out ubygems.rb is a stub file to make the command line nicer
(who wants to type ruby -rrubygems?)

Why you are getting hung up where you are is probably because that's
the first line that can possibly be executed, the others being
comments or whitespace. That's my guess, at least.

If you just type 'c' and press enter, your program will continue
merrily along.

How close did I get?
 
R

RichardOnRails

10:require 'rubygems'
(rdb:1) l
[5, 14] in K:/_Utilities/Ruby_1.8.2-15/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)
OK, I see that I stopped at ubygems.rb:10
Question 1: Why did the debugger stop there and not continue with
statements 3& 4 in my test program? Is my Ruby installation messed
up?
Q 2: Why do I have a "upygems.rb" in my installation that has nothing
substantive than "require 'rubygems'"?
Q 3. Does the presence of this strangely named file "upygems.rb"
suggest my Ruby installation is messed up?
I continued the processing from the current point as shown below.
Q 4. Since I put a breakpoint at "upygems.rb:3", why didn't the
debugger stop there instead of running through the entire remainder of
the test program?
Thanks again in advance for any insights you may offer.
Regards,
Richard

I'll take a guess.

Somewhere in your environment, you have the RUBY_OPTS variable set to -
rubygems. What does that do? It makes is so that when you type:

ruby myprogram.rb

the effect is:

ruby -rubygems myprogram.rb

Note that what you are really telling Ruby is to load your program,
require 'ubygems' and then start.

It turns out ubygems.rb is a stub file to make the command line nicer
(who wants to type ruby -rrubygems?)

Why you are getting hung up where you are is probably because that's
the first line that can possibly be executed, the others being
comments or whitespace. That's my guess, at least.

If you just type 'c' and press enter, your program will continue
merrily along.

How close did I get?

Thanks for responding!
Somewhere in your environment, you have the RUBY_OPTS variable set to -
rubygems.

You've got 100% so far :)
What does that do? [snip]
Wow: Still at 100% with a great explanation
Why you are getting hung up where you are is probably because that's
the first line that can possibly be executed, the others being
comments or whitespace. That's my guess, at least.

Sounds to me like 100% is holding!
If you just type 'c' and press enter, your program will continue
merrily along.

How close did I get?

Perfect score ... except for one issue: When I pressed C, the
debugger ran through the remaining statements of the test file,
not withstanding that I had set a breakpoint, as I documented at the
end of my second post.

Again, thanks for a great response.

Best wishes,
Richard
 
S

s.ross

I don't know if there's even code at ubygems.rb#3

In mine, the only line of code is on line 10.

When I'm using ruby-debug, I seed the whole process by finding where I
want to stop and putting a

debugger

call right there. Then I can hit 'c' with confidence. I'll be curious
to hear your findings on this.
 
R

RichardOnRails

I don't know if there's even code at ubygems.rb#3

In mine, the only line of code is on line 10.

When I'm using ruby-debug, I seed the whole process by finding where I
want to stop and putting a

debugger

call right there. Then I can hit 'c' with confidence. I'll be curious
to hear your findings on this.

Hi,

Sorry for not posting back sooner. I got distracted by some other
stuff. I've run across some negative comments about the Ruby
debugger, so I'm going to search for a better alternative.

I will post back with my new approach.

Regards,
Richard
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top