instance method
Fiber#backtrace_locations
(?::Integer start, ?::Integer count) -> ::Array[::Thread::Backtrace::Location]?
(::Range[::Integer]) -> ::Array[::Thread::Backtrace::Location]?
fiber.backtrace_locations → array
fiber.backtrace_locations(start) → array
fiber.backtrace_locations(start, count) → array
fiber.backtrace_locations(start..end) → array
cont.c
View on GitHub ↗
static VALUE
rb_fiber_backtrace_locations(int argc, VALUE *argv, VALUE fiber)
{
return rb_vm_backtrace_locations(argc, argv, &fiber_ptr(fiber)->cont.saved_ec);
}
Like backtrace, but returns each line of the execution stack as a Thread::Backtrace::Location. Accepts the same arguments as backtrace.
Example
f = Fiber.new { Fiber.yield } f.resume loc = f.backtrace_locations.first loc.label #=> "yield" loc.path #=> "test.rb" loc.lineno #=> 1
Ruby version changes
-
3.0
-
Fiber#backtraceandFiber#backtrace_locationsprovide per-fiber backtrace. [Feature #16815]
-