Project

General

Profile

Actions

Bug #11335

closed

`ruby -r debug` catchpoint problem

Added by sigsys (Math Ieu) almost 9 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.6p336 (2015-04-13 revision 50298) [i386-freebsd10]
[ruby-core:69878]
Tags:

Description

With a test-debug.rb like this:

raise 'test'

And starting the debugger like this:

ruby -r debug test-debug.rb

By default, the catchpoint is StandardError, but it doesn't work:

test-debug.rb:1:raise 'test'
(rdb:1) catch
Catchpoint StandardError.
(rdb:1) c
test-debug.rb:1:in `<main>': test (RuntimeError)

And the debugger exits without catching the exception.

But, by setting the catchpoint to NilClass (or one of its ancestors), then it works:

test-debug.rb:1:raise "test"
(rdb:1) catch NilClass
Set catchpoint NilClass.
(rdb:1) c
test-debug.rb:1: `' (NilClass)
        from test-debug.rb:1:in `<main>'
test-debug.rb:1:raise "test"

And the debugger does not exit and allows further debugging.

By looking at lib/debug.rb, it looks like that the set_trace_func callback it sets assumes that $! will be set to the exception to be raised when a 'raise' event occurs. But it is not the case, $! seems to always be nil.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0