* vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfp

with invoking RUBY_EVENT_C_RETURN.
  [Bug #9961]
* vm_core.h: ditto.
* eval.c (rb_protect): use it.
* eval.c (rb_rescue2): ditto.
* vm_eval.c (rb_iterate): ditto.
* test/ruby/test_settracefunc.rb: add a test.
* vm_core.h (rb_name_err_mesg_new):



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2014-06-19 12:43:48 +00:00
parent 370212a8ae
commit bef2e29aab
6 changed files with 90 additions and 14 deletions

View file

@ -1257,4 +1257,55 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_equal [], events # should be empty.
end
def test_rb_rescue
events = []
curr_thread = Thread.current
TracePoint.new(:a_call, :a_return){|tp|
next if curr_thread != Thread.current
events << [tp.event, tp.method_id]
}.enable do
begin
-Numeric.new
rescue => e
# ignore
end
end
assert_equal [
[:b_call, :test_rb_rescue],
[:c_call, :new],
[:c_call, :initialize],
[:c_return, :initialize],
[:c_return, :new],
[:c_call, :-@],
[:c_call, :coerce],
[:c_call, :to_s],
[:c_return, :to_s],
[:c_call, :new],
[:c_call, :initialize],
[:c_return, :initialize],
[:c_return, :new],
[:c_call, :exception],
[:c_return, :exception],
[:c_call, :backtrace],
[:c_return, :backtrace],
[:c_return, :coerce], # don't miss it!
[:c_call, :to_s],
[:c_return, :to_s],
[:c_call, :to_s],
[:c_return, :to_s],
[:c_call, :new],
[:c_call, :initialize],
[:c_return, :initialize],
[:c_return, :new],
[:c_call, :exception],
[:c_return, :exception],
[:c_call, :backtrace],
[:c_return, :backtrace],
[:c_return, :-@],
[:c_call, :===],
[:c_return, :===],
[:b_return, :test_rb_rescue]], events
end
end