Module Debugger
In: lib/ruby-debug-base.rb
ext/ruby_debug.c

Summary

This is a singleton class allows controlling the debugger. Use it to start/stop debugger, set/remove breakpoints, etc.

Methods

Classes and Modules

Class Debugger::Context

Constants

DEFAULT_START_SETTINGS = { :init => true, # Set $0 and save ARGV? :post_mortem => false, # post-mortem debugging on uncaught exception? :tracing => nil   Default options to Debugger.start
VERSION = rb_str_new2(DEBUG_VERSION)

Attributes

handler  [RW]  interface modules provide handler object
last_exception  [RW] 
reload_source_on_change  [RW]  if true, checks the modification time of source files and reloads if it was modified

Public Class methods

Adds a new breakpoint. source is a name of a file or a class. pos is a line number or a method name if source is a class name. condition is a string which is evaluated to true when this breakpoint is activated.

Sets catchpoint. Returns the string passed.

Returns a current catchpoints, which is a hash exception names that will trigger a debugger when raised. The values are the number of times taht catchpoint was hit, initially 0.

Returns an array of all contexts.

Returns current context. Note: Debugger.current_context.thread == Thread.current

Register at_exit hook which is escaped from the debugger. FOR INTERNAL USE ONLY.

Same as Kernel#load but resets current context‘s frames. stop parameter forces the debugger to stop at the first line of code in the file increment_start determines if start_count should be incremented. When

 control threads are used, they have to be set up before loading the
 debugger; so here +increment_start+ will be false.

FOR INTERNAL USE ONLY.

Interrupts the current thread

Interrupts the last debugged thread

Setting to true will make the debugger create frame bindings.

Returns true if the debugger will collect frame bindings.

Returns last debugged context.

Activates the post-mortem mode. There are two ways of using it:

Global post-mortem mode

By calling Debugger.post_mortem method without a block, you install at_exit hook that intercepts any unhandled by your script exceptions and enables post-mortem mode.

Local post-mortem mode

If you know that a particular block of code raises an exception you can enable post-mortem mode by wrapping this block with Debugger.post_mortem, e.g.

  def offender
     raise 'error'
  end
  Debugger.post_mortem do
     ...
     offender
     ...
  end

Sets post-moterm flag. FOR INTERNAL USE ONLY.

Returns true if post-moterm debugging is enabled.

Removes breakpoint by its id. id is an identificator of a breakpoint.

The code inside of the block is escaped from the debugger.

This method is internal and activates the debugger. Use Debugger.start (from lib/ruby-debug-base.rb) instead.

The return value is the value of !Debugger.started? before issuing the start; That is, true is returned, unless debugger was previously started.

If a block is given, it starts debugger and yields to block. When the block is finished executing it stops the debugger with Debugger.stop method. Inside the block you will probably want to have a call to Debugger.debugger. For example:

  Debugger.start{debugger; foo}  # Stop inside of foo

Also, ruby-debug only allows one invocation of debugger at a time; nested Debugger.start‘s have no effect and you can‘t use this inside the debugger itself.

Note that if you want to completely remove the debugger hook, you must call Debugger.stop as many times as you called Debugger.start method.

Returns true the debugger is started.

This method disables the debugger. It returns true if the debugger is disabled, otherwise it returns false.

Note that if you want to complete remove the debugger hook, you must call Debugger.stop as many times as you called Debugger.start method.

Returns context of the thread passed as an argument.

Returns true if the global tracing is activated.

Sets the global tracing flag.

Setting to true will make the debugger save argument info on calls.

Returns true if the debugger track frame argument values on calls.

Public Instance methods

Debugger.start(options) -> bool Debugger.start(options) { … } -> obj

If it‘s called without a block it returns true, unless debugger was already started. If a block is given, it starts debugger and yields to block. When the block is finished executing it stops the debugger with Debugger.stop method.

If a block is given, it starts debugger and yields to block. When the block is finished executing it stops the debugger with Debugger.stop method. Inside the block you will probably want to have a call to Debugger.debugger. For example:

    Debugger.start{debugger; foo}  # Stop inside of foo

Also, ruby-debug only allows one invocation of debugger at a time; nested Debugger.start‘s have no effect and you can‘t use this inside the debugger itself.

Note that if you want to stop debugger, you must call Debugger.stop as many time as you called Debugger.start method.

options is a hash used to set various debugging options. Set :init true if you want to save ARGV and some variables which make a debugger restart possible. Only the first time :init is set true will values get set. Since ARGV is saved, you should make sure it hasn‘t been changed before the (first) call. Set :post_mortem true if you want to enter post-mortem debugging on an uncaught exception. Once post-mortem debugging is set, it can‘t be unset.

[Validate]