ext/ruby_debug.c in ruby-debug-base-0.10.2 vs ext/ruby_debug.c in ruby-debug-base-0.10.3
- old
+ new
@@ -2,13 +2,13 @@
#include <stdio.h>
#include <node.h>
#include <rubysig.h>
#include <st.h>
-#include <version.h>
+#include <intern.h>
-#define DEBUG_VERSION "0.10.2"
+#define DEBUG_VERSION "0.10.3"
#ifdef _WIN32
struct FRAME {
VALUE self;
@@ -339,10 +339,11 @@
for(i = 0; i < debug_context->stack_size; i++)
{
frame = &(debug_context->frames[i]);
rb_gc_mark(frame->binding);
rb_gc_mark(frame->self);
+ rb_gc_mark(frame->arg_ary);
if(frame->dead)
{
rb_gc_mark(frame->info.copy.locals);
rb_gc_mark(frame->info.copy.args);
}
@@ -464,30 +465,10 @@
args = rb_ary_new3(3, context, file, line);
return rb_protect(call_at_line_unprotected, args, 0);
}
-static VALUE
-call_at_return_unprotected(VALUE args)
-{
- VALUE context;
- context = *RARRAY(args)->ptr;
- return rb_funcall2(context, idAtReturn, RARRAY(args)->len - 1, RARRAY(args)->ptr + 1);
-}
-
-static VALUE
-call_at_return(VALUE context, debug_context_t *debug_context, VALUE file, VALUE line)
-{
- VALUE args;
-
- last_debugged_thnum = debug_context->thnum;
- save_current_position(debug_context);
-
- args = rb_ary_new3(3, context, file, line);
- return rb_protect(call_at_return_unprotected, args, 0);
-}
-
static void
save_call_frame(rb_event_t event, VALUE self, char *file, int line, ID mid, debug_context_t *debug_context)
{
VALUE binding;
debug_frame_t *debug_frame;
@@ -508,10 +489,11 @@
debug_frame->binding = binding;
debug_frame->id = mid;
debug_frame->orig_id = mid;
debug_frame->dead = 0;
debug_frame->self = self;
+ debug_frame->arg_ary = Qnil;
debug_frame->info.runtime.frame = ruby_frame;
debug_frame->info.runtime.scope = ruby_scope;
debug_frame->info.runtime.dyna_vars = event == RUBY_EVENT_LINE ? ruby_dyna_vars : NULL;
if (RTEST(track_frame_args))
copy_scalar_args(debug_frame);
@@ -999,23 +981,32 @@
}
/*
* call-seq:
* Debugger.start_ -> bool
- * Debugger.start_ { ... } -> obj
+ * Debugger.start_ { ... } -> bool
*
* This method is internal and activates the debugger. Use
- * Debugger.start (from ruby-debug-base.rb) instead.
+ * Debugger.start (from <tt>lib/ruby-debug-base.rb</tt>) instead.
*
- * 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.
+ * 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 stop debugger, you must call
- * Debugger.stop as many time as you called Debugger.start
- * method.</i>
+ * <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;
@@ -1032,25 +1023,26 @@
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);
+ if(rb_block_given_p())
+ rb_ensure(rb_yield, self, debug_stop_i, self);
+
return result;
}
/*
* call-seq:
* Debugger.stop -> bool
*
* This method disables the debugger. It returns +true+ if the debugger is disabled,
* otherwise it returns +false+.
*
- * <i>Note that if you want to stop debugger, you must call
- * Debugger.stop as many times as you called Debugger.start
- * method.</i>
+ * <i>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.</i>
*/
static VALUE
debug_stop(VALUE self)
{
debug_check_started();
@@ -1405,19 +1397,31 @@
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;
}
- debug_stop(self);
+
+ /* 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;
}
static VALUE
set_current_skipped_status(VALUE status)
@@ -2066,10 +2070,10 @@
return CTX_FL_TEST(debug_context, CTX_FL_TRACING) ? Qtrue : Qfalse;
}
/*
* call-seq:
- * context.tracking = bool
+ * context.tracing = bool
*
* Controls the tracing for this context.
*/
static VALUE
context_set_tracing(VALUE self, VALUE value)