/*
* call-seq:
* Debugger.start -> bool
* Debugger.start { ... } -> obj
*
* This method activates the debugger.
* 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.
*
* <i>Note that if you want to stop debugger, you must call Debugger.stop as many time as you
* called Debugger.start method.</i>
*/
static VALUE
debug_start(VALUE self)
{
VALUE result;
start_count++;
if(IS_STARTED)
result = Qfalse;
else
{
breakpoints = rb_ary_new();
locker = Qnil;
threads_tbl = threads_table_create();
rb_add_event_hook(debug_event_hook, RUBY_EVENT_ALL);
result = Qtrue;
}
if(rb_block_given_p())
return rb_ensure(rb_yield, self, debug_stop_i, self);
return result;
}