Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby debugger step into a block directly?

Tags:

ruby

debugging

In the following Ruby code:

#! /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

It's very common during debugging, I don't care about the implementation of the function that yields to the block, I just want to step into the block directly, without manually setting a break-point there.

Does any support for this kind of "step into block" exist in ruby-debug19 or debugger?

like image 830
Xiaotian Guo Avatar asked Jul 25 '12 19:07

Xiaotian Guo


People also ask

How do I run a Ruby script in debug mode?

In order to start the Ruby debugger, load the debug library using the command-line option -r debug. The debugger stops before the first line of executable code and asks for the input of user commands.

What is Byebug in Ruby?

Byebug is a Ruby debugger. It's implemented using the TracePoint C API for execution control and the Debug Inspector C API for call stack navigation. The core component provides support that front-ends can build on.

How does pry work?

Pry is like IRB on steroids Both IRB and Pry use REPL commands: Read, Evaluate, Print, and Loop. But Pry allows you to go further when debugging. For example, Pry gives you color-coded syntax, which helps when you're trying to figure out what will happen when code is executed.


1 Answers

Have you tried using the "c" command, for "continue"? It optionally takes a line number, so, based on your code sample try:

c 16
like image 181
the Tin Man Avatar answered Oct 06 '22 00:10

the Tin Man