Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ext/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,16 @@ context_create(VALUE thread, VALUE cDebugThread) {
context->stack_size = 0;
locations = rb_funcall(thread, rb_intern("backtrace_locations"), 1, INT2FIX(1));
context->calced_stack_size = locations != Qnil ? RARRAY_LENINT(locations) : 0;
context->init_stack_size = -1;

context->stack = NULL;
context->thnum = ++thnum_current;
context->thread = thread;
context->flags = 0;
context->last_file = NULL;
context->last_line = -1;
context->hit_user_code = 0;
context->script_finished = 0;
context->stop_frame = -1;
context->thread_pause = 0;
context->stop_reason = CTX_STOP_NONE;
Expand Down
13 changes: 13 additions & 0 deletions ext/debase_internals.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ remove_pause_flag(VALUE thread, VALUE context_object, VALUE ignored)
static void
call_at_line(debug_context_t *context, char *file, int line, VALUE context_object)
{
context->hit_user_code = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you use this variable? you only write to it, it seems


rb_hash_foreach(contexts, remove_pause_flag, 0);
CTX_FL_UNSET(context, CTX_FL_STEPPED);
CTX_FL_UNSET(context, CTX_FL_FORCE_MOVE);
Expand Down Expand Up @@ -331,6 +333,13 @@ process_line_event(VALUE trace_point, void *data)
tp = TRACE_POINT;
path = rb_tracearg_path(tp);

if(context->stack_size <= context->init_stack_size && context->hit_user_code) {
context->script_finished = 1;
}
if(context->script_finished) {
return;
}

if (is_path_accepted(path)) {

lineno = rb_tracearg_lineno(tp);
Expand All @@ -340,6 +349,10 @@ process_line_event(VALUE trace_point, void *data)
update_stack_size(context);
print_event(tp, context);

if(context->init_stack_size == -1) {
context->init_stack_size = context->stack_size;
}

if (context->thread_pause) {
context->stop_next = 1;
context->dest_frame = -1;
Expand Down
3 changes: 3 additions & 0 deletions ext/debase_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ typedef struct debug_context {

char *last_file;
int last_line;
int init_stack_size;
int script_finished;
int hit_user_code;
} debug_context_t;

typedef struct
Expand Down