Home » Ruby programming

Ruby Debugger | Ruby Tools

Ruby Debugger: Here, we are going to learn about the Ruby Debugger, structure of Ruby Debugger, using Ruby Debugger, installing & uninstalling Ruby Debugger, etc.
Submitted by Hrithik Chandra Prasad, on August 21, 2019

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!





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.