From: ko1@... Date: 2015-08-21T09:56:00+00:00 Subject: [ruby-core:70506] [Ruby trunk - Feature #11348] [Feedback] TracePoint API needs events for fiber's switching Issue #11348 has been updated by Koichi Sasada. Status changed from Closed to Feedback I agree to add 'switching' events so I try to commit it. Could you try it and could you tell me "what" is not enough? (Actually, I don't increase the number of events) For example, how about to provide a method to know resume chain like that? ```ruby Fiber.new{ # f1 Fiber.new{ # f2 Fiber.nesting #=> [root_fiber, f1, f2] } } ``` (not sure nesting is good name or not) ---------------------------------------- Feature #11348: TracePoint API needs events for fiber's switching https://bugs.ruby-lang.org/issues/11348#change-53906 * Author: Oleg Sukhodolsky * Status: Feedback * Priority: Normal * Assignee: Koichi Sasada ---------------------------------------- as discussed in https://github.com/deivid-rodriguez/byebug/issues/153 current implementation of byebug/debase has problem with stepping when Enumarator/Fiber is used. The problem is that Fiber completely replaces stack (w/o any events) while the gems assume that any stack modification has corresponding call/return event. It would be nice to receive events for Fiber's switching (at least) to be able to track stack for every fiber independently. Also I think it would be nice to discuss the API before adding it because different set of event will allow to implement different debugger's capabilities. E.g. plain :fiber-changed (event about every fiber switch) will only allow us to handle every fiber independently (like threads are handled) while debugger's user may expect that step into on enumerator.next will step into enumerator's code and step out from that code should go to the place where enumerator.next has been called. So, perhaps we should have different events for Fiber#resume and Fiber#yield, but I'm not sure and would like to here other opinions. Here are two tests which can be used to play with (one for Enumerator, another for Fiber) ~~~ruby triangular_numbers = Enumerator.new do |yielder| number = 0 count = 1 loop do number += count count += 1 yielder.yield number end end print triangular_numbers.next, " " 5.times do print triangular_numbers.next, " " end ~~~ ~~~ruby fiber = Fiber.new do number = 0 count = 1 loop do number += count count += 1 Fiber.yield number end end print fiber.resume, " " 5.times do print fiber.resume, " " end ~~~ -- https://bugs.ruby-lang.org/