Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

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

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.3 · 3.2 · 3.1 · 3.0