/* * call-seq: * Debugger.debug_load(file, stop = false, increment_start = false) -> nil * * 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. */ static VALUE debug_debug_load(int argc, VALUE *argv, VALUE self) { VALUE file, stop, context, increment_start; debug_context_t *debug_context; int state = 0; if(rb_scan_args(argc, argv, "12", &file, &stop, &increment_start) == 1) { stop = Qfalse; increment_start = Qtrue; } debug_start(self); if (Qfalse == increment_start) start_count--; context = debug_current_context(self); Data_Get_Struct(context, debug_context_t, debug_context); debug_context->stack_size = 0; if(RTEST(stop)) debug_context->stop_next = 1; /* Initializing $0 to the script's path */ ruby_script(RSTRING(file)->ptr); rb_load_protect(file, 0, &state); if (0 != state) { VALUE errinfo = ruby_errinfo; debug_suspend(self); reset_stepping_stop_points(debug_context); ruby_errinfo = Qnil; return errinfo; } /* We should run all at_exit handler's in order to provide, * for instance, a chance to run all defined test cases */ rb_exec_end_proc(); /* We could have issued a Debugger.stop inside the debug session. */ if (start_count > 0) { debug_stop(self); } return Qnil; }