Debuggers

[ LiB ]

Debuggers

Ruby comes with a debugger, accessible on the command line, for stepping through problems with programs (see Figure 9.1). Type the following to access it:

Figure 9.1. Accessing the Ruby command-line debugger

graphic/09fig01.gif


 Ruby r debug MyProgramScript.rb 

The debugger has a number of useful commands for, well, debugging a Ruby program. These are listed in Table 9.1.

Table 9.1. Debug Commands

Command

Use

break

Set breakpoint at specified line or method

watch

Set a watchpoint for an expression

catch

Set a catchpoint for an exception

delete

Delete breakpoints or watchpoints

display

Set display expression to be printed when program stops

undisplay

Unset display

cont

Continue program execution

step

Step forward in the program until the next source line

next

Step forward in the program until the next source line. Treat method calls as one instruction

list

List line of source code

up

Select stack frame that called current stack frame

down

Select stack frame called by current stack frame

finish

Execute until selected stack frame returns

trace

Turn trace mode on or off

quit

Exit debugger

var global

Show global variables in current stack frame

var local

Show local variables in current stack frame

var instance

Show instance variables of the given object

var const

Show constants of the given object

method instance

Show methods of the given object

method

Show instance methods of the given class or module

thread list

Show thread list

thread current

Show current thread

thread

Switch to a given thread

thread stop

Stop the given thread

thread resume

Resume the given thread

p

Evaluate the given expression in current stack frame and show its value

help

Print debug commands

else

Evaluate input in the current stack frame and show its value


[ LiB ]


Game Programming with Pyton, Lua and Ruby
Game Programming with Pyton, Lua and Ruby
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 133

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net