ext/byebug/byebug.c in byebug-2.1.1 vs ext/byebug/byebug.c in byebug-2.2.0
- old
+ new
@@ -2,11 +2,11 @@
static VALUE mByebug; /* Ruby Byebug Module object */
static VALUE tracing = Qfalse;
static VALUE post_mortem = Qfalse;
-static VALUE debug = Qfalse;
+static VALUE verbose = Qfalse;
static VALUE catchpoints = Qnil;
static VALUE breakpoints = Qnil;
static VALUE tracepoints = Qnil;
@@ -67,11 +67,11 @@
rb_trace_arg_t *trace_arg = rb_tracearg_from_tracepoint(trace_point); \
debug_context_t *dc; \
VALUE context; \
thread_context_lookup(rb_thread_current(), &context); \
Data_Get_Struct(context, debug_context_t, dc); \
- if (debug == Qtrue) trace_print(trace_arg, dc); \
+ if (verbose == Qtrue) trace_print(trace_arg, dc); \
#define EVENT_COMMON if (!trace_common(trace_arg, dc)) { return; }
static int
trace_common(rb_trace_arg_t *trace_arg, debug_context_t *dc)
@@ -180,17 +180,19 @@
/* TracePoint API event handlers */
static void
line_event(VALUE trace_point, void *data)
{
+ VALUE breakpoint, file, line, binding;
+ int moved = 0;
+
EVENT_SETUP
- VALUE breakpoint = Qnil;
- VALUE file = rb_tracearg_path(trace_arg);
- VALUE line = rb_tracearg_lineno(trace_arg);
- VALUE binding = rb_tracearg_binding(trace_arg);
- int moved = 0;
+ breakpoint = Qnil;
+ file = rb_tracearg_path(trace_arg);
+ line = rb_tracearg_lineno(trace_arg);
+ binding = rb_tracearg_binding(trace_arg);
EVENT_COMMON
if (dc->stack_size == 0) dc->stack_size++;
@@ -207,11 +209,16 @@
{
dc->steps = dc->steps <= 0 ? -1 : dc->steps - 1;
if (dc->stack_size <= dc->dest_frame)
{
dc->lines = dc->lines <= 0 ? -1 : dc->lines - 1;
- dc->dest_frame = dc->stack_size;
+ if (dc->stack_size < dc->dest_frame)
+ {
+ dc->dest_frame = dc->stack_size;
+ rb_funcall(mByebug, rb_intern("print"), 1,
+ rb_str_new2("Next went up a frame because previous frame finished\n"));
+ }
}
}
if (dc->steps == 0 || dc->lines == 0 ||
(CTX_FL_TEST(dc, CTX_FL_ENABLE_BKPT) &&
@@ -225,23 +232,25 @@
}
static void
call_event(VALUE trace_point, void *data)
{
+ VALUE breakpoint, klass, mid, binding, self, file, line;
+
EVENT_SETUP
dc->stack_size++;
EVENT_COMMON
- VALUE breakpoint = Qnil;
- VALUE klass = rb_tracearg_defined_class(trace_arg);
- VALUE mid = SYM2ID(rb_tracearg_method_id(trace_arg));
- VALUE binding = rb_tracearg_binding(trace_arg);
- VALUE self = rb_tracearg_self(trace_arg);
- VALUE file = rb_tracearg_path(trace_arg);
- VALUE line = rb_tracearg_lineno(trace_arg);
+ breakpoint = Qnil;
+ klass = rb_tracearg_defined_class(trace_arg);
+ mid = SYM2ID(rb_tracearg_method_id(trace_arg));
+ binding = rb_tracearg_binding(trace_arg);
+ self = rb_tracearg_self(trace_arg);
+ file = rb_tracearg_path(trace_arg);
+ line = rb_tracearg_lineno(trace_arg);
breakpoint = find_breakpoint_by_method(breakpoints, klass, mid, binding, self);
if (breakpoint != Qnil)
{
call_at_breakpoint(context, dc, breakpoint);
@@ -260,13 +269,15 @@
EVENT_COMMON
if (dc->stack_size + 1 == dc->before_frame)
{
+ VALUE file, line;
+
reset_stepping_stop_points(dc);
- VALUE file = rb_tracearg_path(trace_arg);
- VALUE line = rb_tracearg_lineno(trace_arg);
+ file = rb_tracearg_path(trace_arg);
+ line = rb_tracearg_lineno(trace_arg);
call_at_return(context, dc, file, line);
}
if (dc->stack_size + 1 == dc->after_frame)
{
@@ -302,23 +313,26 @@
}
static void
raise_event(VALUE trace_point, void *data)
{
- EVENT_SETUP
-
VALUE expn_class, aclass;
- VALUE err = rb_errinfo();
+ VALUE err;
VALUE ancestors;
int i;
debug_context_t *new_dc;
+ VALUE binding, path, lineno;
+ EVENT_SETUP
+
+ err = rb_errinfo();
+
EVENT_COMMON
- VALUE binding = rb_tracearg_binding(trace_arg);
- VALUE path = rb_tracearg_path(trace_arg);
- VALUE lineno = rb_tracearg_lineno(trace_arg);
+ binding = rb_tracearg_binding(trace_arg);
+ path = rb_tracearg_path(trace_arg);
+ lineno = rb_tracearg_lineno(trace_arg);
if (post_mortem == Qtrue)
{
context = context_dup(dc);
rb_ivar_set(err, rb_intern("@__bb_file") , path);
@@ -372,12 +386,10 @@
int i;
VALUE traces = tracepoints;
if (NIL_P(traces))
{
- traces = rb_ary_new();
-
int line_msk = RUBY_EVENT_LINE;
int call_msk = RUBY_EVENT_CALL | RUBY_EVENT_B_CALL | RUBY_EVENT_CLASS;
int return_msk = RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN | RUBY_EVENT_END;
int c_call_msk = RUBY_EVENT_C_CALL;
int c_return_msk = RUBY_EVENT_C_RETURN;
@@ -388,10 +400,11 @@
VALUE tpReturn = rb_tracepoint_new(Qnil, return_msk , return_event , 0);
VALUE tpCCall = rb_tracepoint_new(Qnil, c_call_msk , c_call_event , 0);
VALUE tpCReturn = rb_tracepoint_new(Qnil, c_return_msk, c_return_event, 0);
VALUE tpRaise = rb_tracepoint_new(Qnil, raise_msk , raise_event , 0);
+ traces = rb_ary_new();
rb_ary_push(traces, tpLine);
rb_ary_push(traces, tpCall);
rb_ary_push(traces, tpReturn);
rb_ary_push(traces, tpCCall);
rb_ary_push(traces, tpCReturn);
@@ -611,11 +624,37 @@
rb_exec_end_proc();
return status;
}
+/*
+ * call-seq:
+ * Byebug.verbose -> bool
+ *
+ * Returns +true+ if verbose output of TracePoint API events is enabled.
+ */
static VALUE
+bb_verbose(VALUE self)
+{
+ return verbose;
+}
+
+/*
+ * call-seq:
+ * Byebug.verbose = bool
+ *
+ * Enable verbose output of every TracePoint API events, useful for debugging
+ * byebug.
+ */
+static VALUE
+bb_set_verbose(VALUE self, VALUE value)
+{
+ verbose = RTEST(value) ? Qtrue : Qfalse;
+ return value;
+}
+
+static VALUE
set_current_skipped_status(VALUE status)
{
VALUE context;
debug_context_t *dc;
@@ -782,9 +821,11 @@
rb_define_module_function(mByebug, "started?" , bb_started , 0);
rb_define_module_function(mByebug, "stop" , bb_stop , 0);
rb_define_module_function(mByebug, "thread_context" , bb_thread_context , 1);
rb_define_module_function(mByebug, "tracing?" , bb_tracing , 0);
rb_define_module_function(mByebug, "tracing=" , bb_set_tracing , 1);
+ rb_define_module_function(mByebug, "verbose" , bb_verbose , 0);
+ rb_define_module_function(mByebug, "verbose=" , bb_set_verbose , 1);
cThreadsTable = rb_define_class_under(mByebug, "ThreadsTable", rb_cObject);
Init_context(mByebug);
Init_breakpoint(mByebug);