Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Debugger "next" doesn't catch exception rescue's sometimes #629

Closed
rocky opened this Issue Dec 26, 2010 · 4 comments

Comments

Projects
None yet
3 participants

rocky commented Dec 26, 2010

It looks like "next" stepping in the presence of raised exceptions sometimes has problems.

Here's an example excerpted from the rbx-require-relative's Rakefile modified to simplify it.

require 'rubinius/debugger'
Rubinius::Debugger.start
raise RuntimeError, 'This package is for rubinius only!' unless
  Object.constants.include?('Rubinius')

begin
  bogus_fn 'lib/version'
  puts 'Looks like you have bogus_fn'
  exit 5
rescue NameError
  puts 'rescued'
end
puts "finished"

When we try to "next" over the missing method "require_relative" we don't stop subsequently.

Here's a run:

rbx /tmp/except-bug.rb

| Breakpoint: main.__script__ at /tmp/except-bug.rb:2 (17)
| 2: Rubinius::Debugger.start
debug> n

| Breakpoint: main.__script__ at /tmp/except-bug.rb:4 (18)
| 4:   Object.constants.include?('Rubinius')
debug> n

| Breakpoint: main.__script__ at /tmp/except-bug.rb:4 (32)
| 4:   Object.constants.include?('Rubinius')
debug> n

| Breakpoint: main.__script__ at /tmp/except-bug.rb:7 (47)
| 7:   bogus_fn 'lib/version'
debug> n
rescued
finished

One thought as to how to fix is to issue the same kind of callback on rescue as is done on "call" is currently done when stepping. Not sure if this is relevant though. Stepping does work here.

However if this approach is used, I'd suggest that the "breakpoint" object passed back not also be nil. Better would be an "event" name like :rescue" (and for call how about :call).

rocky commented Mar 27, 2011

Here is a simpler example that I think shows the problem better.

require 'rubinius/debugger'
def boom
  exc = NameError.exception
  Rubinius::Debugger.start
  Rubinius.raise_exception exc
end
begin
  boom
rescue NameError
  puts 'rescued'
end
puts "finished"


rbx next2-bug.rb
| Breakpoint: Object#boom at next2-bug.rb:4 (17)
| 4:   Rubinius::Debugger.start
debug> n
| Breakpoint: Object#boom at next2-bug.rb:5 (18)
| 5:   Rubinius.raise_exception exc
debug> n
rescued
finished

As before, stepping into the exception does get you stopped inside the rescue.

It is important that the exception not be raised in the begin block where the rescue is. That also works with the next (step over) command.

Contributor

frodsan commented Nov 11, 2012

@rocky Hi! Is this still a problem?

rocky commented Nov 11, 2012

I think so. When you try the instructions above, what do you get?

I just did rvm install rubinius-head and tried exactly what I posted two years ago above your post. I get the same thing I see above.

Owner

YorickPeterse commented Dec 30, 2013

I'm moving this issue to rubinius/rubinius-debugger#3 since the debugger has been split up in a separate Gem. I put a link to this particular thread so people can read back what has been discussed so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment