[#70257] [Ruby trunk - Feature #11420] [Open] Introduce ID key table into MRI — ko1@...

Issue #11420 has been reported by Koichi Sasada.

11 messages 2015/08/06

[ruby-core:70514] [Ruby trunk - Feature #11348] TracePoint API needs events for fiber's switching

From: os97673@...
Date: 2015-08-21 12:42:20 UTC
List: ruby-core #70514
Issue #11348 has been updated by Oleg Sukhodolsky.


Koichi Sasada wrote:
> 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?

I'm on vacation right now will play with ruby-head early next week.

----------------------------------------
Feature #11348: TracePoint API needs events for fiber's switching
https://bugs.ruby-lang.org/issues/11348#change-53916

* 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/

In This Thread

Prev Next