Let’s suppose I have a very simple Ruby program:
require 'rubygems'
require 'ruby-debug'
x = 1
debugger
puts x
When execution hits the ‘debugger’ command it properly halts and gives me the ‘rdb’ prompt.
Now: my goal is to have the program print 2 instead of 1. How to accomplish this? If I type ‘help’ then rdebug tells me:
ruby-debug help v0.10.4
Type 'help <command-name>' for help on a specific command
Available commands:
backtrace delete enable help method putl set trace
break disable eval info next quit show undisplay
catch display exit irb p reload step up
condition down finish kill pp restart thread var
continue edit frame list ps save tmate where
The ‘set’ command looks promising … but:
(rdb:1) help set
Modifies parts of the ruby-debug environment. Boolean values take
on, off, 1 or 0.
You can see these environment settings with the "show" command.
--
List of set subcommands:
--
set annotate -- Set annotation level
set args -- Set argument list to give program being debugged when it is started
set autoeval -- Evaluate every unrecognized command
set autolist -- Execute 'list' command on every breakpoint
set autoirb -- Invoke IRB on every stop
set autoreload -- Reload source code when changed
set basename -- Report file basename only showing file names
set callstyle -- Set how you want call parameters displayed
set debuggertesting -- Used when testing the debugger
set forcestep -- Make sure 'next/step' commands always move to a new line
set fullpath -- Display full file names in frames
set history -- Generic command for setting command history parameters
set keep-frame-bindings -- Save frame binding on each call
set linetrace+ -- Set line execution tracing to show different lines
set linetrace -- Set line execution tracing
set listsize -- Set number of source lines to list by default
set trace -- Display stack trace when 'eval' raises exception
set width -- Number of characters the debugger thinks are in a line
No dice. What to do?
I looked at the Official ruby-debug doc and I looked at the RailsGuides Debugging Rails Applications doc but didn’t see the answer.
You need to use
evalorpand thenfinishto continue through the script. Something like: