【问题标题】:ruby debugger step into a block directly?ruby 调试器直接进入一个块?
【发布时间】:2012-07-25 19:58:31
【问题描述】:

在以下 Ruby 代码中:

#! /usr/bin/env ruby

require 'debugger'

def hello
  puts "hello"
  if block_given?
    yield
  end 
end 

def main
  debugger
  puts "test begin..."
  hello do   # <=  if you are here
    puts "here!" #<= how to get here without setting bp here or step into hello?
  end 
end 

main

在调试的时候很常见,我不关心让块产生的函数的实现,我只想直接单步进入该块,而不需要在那里手动设置断点。

ruby-debug19 或调试器中是否存在对这种“步入块”的支持?

【问题讨论】:

    标签: ruby debugging


    【解决方案1】:

    您是否尝试过对“continue”使用“c”命令?它可以选择使用行号,因此,根据您的代码示例尝试:

    c 16
    

    【讨论】:

    • 这就像我所希望的那样接近“进入当前区块”,谢谢!
    • 这有什么帮助? c 不会让它运行到最后吗?
    • c 16 会一直运行到第 16 行。根据文档:The optional argument line-specification allows you to specify a line number to set a one-time breakpoint which is deleted when that breakpoint is reached.
    猜你喜欢
    • 2023-03-04
    • 1970-01-01
    • 2022-10-19
    • 2013-04-19
    • 1970-01-01
    • 2010-11-04
    • 2015-02-17
    • 1970-01-01
    • 2015-07-28
    相关资源
    最近更新 更多