Reputation: 1038
# 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:
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
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
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