是否可以从 Ruby 中的堆栈跟踪中提取局部变量及其值?

Is it possible to extract locals and their values from a stack trace in Ruby?

我正在调查我的 Ruby 应用程序中的崩溃。我日志中的堆栈跟踪信息不足,我无法重现错误。当发生未处理的异常时,我需要记录发生异常的框架中局部变量的值。

在 Ruby 中有什么方法可以做到这一点吗?

自己做起来并不容易,但是 banisterfiend 写的 gem binding_of_caller (gem) 使它成为可能。