Nick Legend
Nick Legend

Reputation: 1038

ruby -rdebug doesn't stop at breakpoints

# myapp.rb
myvar = 'Hello'
myvar += ' world'
myvar += '!'
puts myvar
puts 'Bye!'

Trying to debug it:

>ruby -rdebug myapp.rb
<...>/ruby-2.7.2-1/lib/ruby/2.7.0/x64-mingw32/continuation.so: warning: callcc is obsolete; use Fiber instead
Debug.rb
Emacs support available.

<...>/ruby-2.7.2-1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:172:    if RUBYGEMS_ACTIVATION_MONITOR.respond_to?(:mon_owned?)
(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
. . .
  c[ont]                     run until program ends or hit breakpoint
. . .  

Ok, let's do it:

(rdb:1) b myapp.rb:1
Set breakpoint 1 at D:/temp/r/myapp.rb:1
(rdb:1) cont
Hello world!
Bye!

Actual behavior: doesn't stop at breakpoints.

Expected behavior: must stop at breakpoints.

Used gdb for C/C++ and pdb for Python. They have similar interface and work.

The questions are:

  1. Please tell if you can reproduce this problem.
  2. What is the reason of this problem?
  3. Is this a bug or a feature?
  4. How to make the debugger stop at breakpoints?

Could not google the answer. There's an example here (in the end of the page) that, to my mind, doesn't expressly show the expected breakpoint behavior. As the author didn't demonstrate this simple and obvious use case then there must be a problem here.

UPDATE

Checked in Linux -- works as expected.

Upvotes: 1

Views: 394

Answers (2)

Richard Sharman
Richard Sharman

Reputation: 19

Try specifying the absolute filename of the program, in other words try running the program as ruby -rdebug $PWD/myapp.rb

I posted a bug report for version 2.7.2 just now: https://bugs.ruby-lang.org/issues/17492?next_issue_id=17491

Upvotes: 2

Nick Legend
Nick Legend

Reputation: 1038

Tried with a previous version of Ruby 2.5.3 -- works as expected. The same is on Linux:

$ ruby -rdebug myapp.rb
/usr/lib/x86_64-linux-gnu/ruby/2.5.0/continuation.so: warning: callcc is obsolete; use Fiber instead
Debug.rb
Emacs support available.

myapp.rb:1:myvar = 'Hello'
(rdb:1) b 3
Set breakpoint 1 at myapp.rb:3
(rdb:1) c
Breakpoint 1, toplevel at myapp.rb:3
myapp.rb:3:myvar += '!'

Probably the problem is in the new version or with my installation in Windows.

Upvotes: 0

Related Questions