×

Ruby Tutorial

Ruby Basics

Ruby Control Statements

Ruby Methods

Ruby Classes and Methods

Ruby Arrays

Ruby Sets

Ruby Strings

Ruby Classes & Objects

Ruby Hash

Ruby Tools

Ruby Functions

Ruby Built-in Functions

Misc.

Ruby Programs

Ruby Debugger | Ruby Tools

By IncludeHelp Last updated : December 01, 2024

Ruby Debugger

Before getting to know about Ruby debugger, let us understand what a debugger is? - "Debugger is nothing but a computer program which is used to test a program, find problems and resolve them in the target program". Ruby debugger is a ruby tool which works in the same way, it tests and debugs the target program. The fact is accepted that Ruby is an easy to learn language but at the same time one cannot deny the fact that the bugs may be present in its code, especially when the code is of few lines. Ruby debugger is usually provided with the standard distribution of Ruby.

If you want to load the ruby debugger, first you have to type "-r debug" in the command line.

How to use Ruby Debugger?

This must be a very prominent question because reading theory is easy but implementation in practical world is little tricky. If you want to use the Ruby debugger, write the following syntax in the command prompt,

 $ruby –r debug filename[, ...]

List of Ruby Debugging Commands

Following is the complete list of Ruby Debugging commands which you may require during the process of debugging a file. Using ...] is optional.

  • b[reak] [< file| class>:]< line| method>
    If you want to set the breakpoint to some specific positions, you are in need to use this command. Breakpoint is nothing but a pointer position where the program execution can be stopped for debugging reasons.
  • wat[ch] expression
    This is used to set the watch points. using ch is optional.
  • cat[ch] (exception|off)
    This command sets catchpoints to an expression. Use of ch is optional.
  • b[reak]
    This command is used to Display breakpoints and watchpoints.
  • del[ete] [n]
    It used to delete breakpoints. Use of ete is optional.
  • disp[lay] expression
    This command is used for Displaying value of expression.
  • undisp[lay] [ n]
    It is used to remove the display of n(whatever specified).
  • c[ont]
    By the use of this command, use can continue the paused execution.
  • s[tep] [ n]
    It is used to execute next n lines stepping into methods. writing tep is optional.
  • n[ext] [ n]
    It is used to executes next n lines stepping over methods. typing ext is optional.
  • w[here]
    This command is used to display the stack frame.
  • f[rame]
    Works exactly as where.
  • l[ist][<-| n- m>]
    It is used for displaying source line from m to n.
  • up [ n]
    It is used to moves up n (specified)levels in the stack frame.
  • down [ n]
    It is used to moves down n(specified) levels in the stack frame.
  • fin[ish]
    This command is used to finish the execution of current method.
  • tr[ace] [on|off]
    It is used to toggle trace mode on or off.
  • q[uit]
    Quit command is used to exit the debugger.
  • v[ar] g[lobal]
    If you want to display global variable, use this command.
  • v[ar] l[ocal]
    If you want to display local variable, make use of this command.
  • v[ar] i[instance] object
    This command is used to display instance variables of an object.
  • v[ar] c[onst] object
    This command helps by displaying constants of object.
  • m[ethod] i[instance] object
    It Displays instance methods of an object.
  • m[ethod] class| module
    It is used to display instance methods of the class or module.
  • th[read] l[ist]
    If you want to display threads, use this command.
  • th[read] c[ur[rent]]
    If you want to display the current thread, use this command.
  • th[read] n
    It is used to stop specified thread.

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.