Project

General

Profile

Actions

Backport #8489

closed

Tracepoint API: B_RETURN_EVENT not triggered when "next" used

Added by deivid (David Rodríguez) over 11 years ago. Updated over 11 years ago.


Description

I'm using the Tracepoint API in my gem and I notice that when the keyword next is used inside a block, a block return event (B_RETURN_EVENT) is not triggered. For example, I would expect the same number of B_CALL_EVENT and B_RETURN_EVENT in the piece of code:

traceBlocks = TracePoint.new(:b_call, :b_return) do |tp|
p "#{tp.event == :b_call ? 'Block called' : 'Block returned'}"
end.enable do
3.times do
next
end
end

but instead there are 4 B_CALL_EVENT and 1 B_RETURN_EVENT. As I understand it, "next" causes the block to exit immediately, returning control to the iterator, which may invoke the block again, so I would say a block return event should be triggered.

Thanks a lot.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0