Breakpoints

106 10
< Continued from page 2

Breakpoints are lines on which you want the program to stop execution. When the program reaches such a line, the debugger will stop execution and allow you to take control of the program. Breakpoints can be set on line numbers or on more descriptive things (such as methods).

Breakpoints can be set with the b command. It takes a single argument; the line of code or method name you want to break on. If you don't specify any line or method name, the breakpoint command will list all active breakpoints.


$ ruby -rdebug problem.rb data.txt
Debug.rb
Emacs support available.

problem.rb:3:lines = File.readlines(ARGV[0])
(rdb:1) l
[-2, 7] in problem.rb
1
2
=> 3 lines = File.readlines(ARGV[0])
4
5 lines.each do|l|
6 nums = l.split /,/
7 nums.map!{|n| n.to_f }
(rdb:1) b 7
Set breakpoint 1 at problem.rb:7
(rdb:1) b
Breakpoints:
1 problem.rb:7

(rdb:1) exit
Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.