/* * call-seq: * Debugger.start_ -> bool * Debugger.start_ { ... } -> bool * * This method is internal and activates the debugger. Use * Debugger.start (from <tt>lib/ruby-debug-base.rb</tt>) instead. * * The return value is the value of !Debugger.started? <i>before</i> * 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. * * <i>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.</i> */ static VALUE debug_start(VALUE self) { VALUE result; start_count++; if(IS_STARTED) result = Qfalse; else { locker = Qnil; rdebug_breakpoints = rb_ary_new(); rdebug_catchpoints = rb_hash_new(); rdebug_threads_tbl = threads_table_create(); rb_add_event_hook(debug_event_hook, RUBY_EVENT_ALL); result = Qtrue; } if(rb_block_given_p()) rb_ensure(rb_yield, self, debug_stop_i, self); return result; }