Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Fiber#backtrace_locations

fiber.backtrace_locations → array
fiber.backtrace_locations(start) → array
fiber.backtrace_locations(start, count) → array
fiber.backtrace_locations(start..end) → array

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

  1. 3.0
See also #backtrace #blocking? #alive? #inspect also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1