ruby - 添加黑盒库以进行 Pry 调试

标签 ruby pry byebug

使用 Pry 时是否可以“黑箱”库?

我喜欢在遇到断点时遍历堆栈,但我真的不关心事件记录事务管理等。事实上,有时它甚至使遍历堆栈变得毫无用处。

在 javascript 中,很容易将脚本添加到忽略列表中,并且在调试期间只是跳过它们。有没有办法用 Pry 实现类似的行为?

其他详细信息

我所说的堆栈遍历是指使用“向上”移动到调用源代码行,该行将源代码标记移动到前一个堆栈帧。

我想忽略我自己的代码之外的框架,例如 ActiveRecord 和大多数第三方 gem。我不介意使用黑名单或白名单。

Bundle 给了我这些 gem 版本:

Using byebug 9.0.6
Using pry 0.12.2
Using pry-byebug 3.4.3

最佳答案

pry-byebug 中不存在请求的功能。您可以在以下GitHub issue for pry-byebug上添加您的+1(或编写一些代码) :

My question/suggestion is that if there's a way to filter or skip over external library, or a setting to step into the next line that belongs to a script within the current application. For example, step into a method call will skip over any Rails's internal script or any currently-used gem and stop at the next line of the file that's inside the application.

以及 this GitHub issue :

I think it would be super useful to have a command that lets you run until you hit the next line of non-Rails/non-gem code.

由于最初的问题已经开放了近六年,我认为您最好的选择是帮助构建该功能,而不是在现有问题上添加 +1。

pry-byebug 的作者还提供 this workaround在另一个非常相似的问题的答案中:

you need to manually set breakpoints to jump from controller to view and the other way around

关于ruby - 添加黑盒库以进行 Pry 调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58506691/

相关文章:

ruby-on-rails - Rails 测试数据库中的默认值失败

ruby-on-rails - 如何在 Sidekiq 和 Foreman 中使用 Byebug

java - 如何覆盖扩展 Java 类的 Ruby 类的构造函数?

ruby - Net-SSH Ruby 身份验证

ruby-on-rails - ruby rails 3 : In views when to use partial vs helper vs loop

ruby - 如何在 Pry 控制台中提供自定义方法

ruby-on-rails - 在 RSpec 中使用 Thread.new 测试并发性

ruby - 从 irb 或 pry 运行单元测试

ruby - 如何在 Debian Linux for ARM 上运行 pry

ruby-on-rails - 让 Byebug 在不退出 Pry 的情况下完成执行