@@ -303,6 +303,8 @@ remove_pause_flag(VALUE thread, VALUE context_object, VALUE ignored)
303303static void
304304call_at_line (debug_context_t * context , char * file , int line , VALUE context_object )
305305{
306+ context -> hit_user_code = 1 ;
307+
306308 rb_hash_foreach (contexts , remove_pause_flag , 0 );
307309 CTX_FL_UNSET (context , CTX_FL_STEPPED );
308310 CTX_FL_UNSET (context , CTX_FL_FORCE_MOVE );
@@ -331,6 +333,13 @@ process_line_event(VALUE trace_point, void *data)
331333 tp = TRACE_POINT ;
332334 path = rb_tracearg_path (tp );
333335
336+ if (context -> stack_size <= context -> init_stack_size && context -> hit_user_code ) {
337+ context -> script_finished = 1 ;
338+ }
339+ if (context -> script_finished ) {
340+ return ;
341+ }
342+
334343 if (is_path_accepted (path )) {
335344
336345 lineno = rb_tracearg_lineno (tp );
@@ -340,6 +349,10 @@ process_line_event(VALUE trace_point, void *data)
340349 update_stack_size (context );
341350 print_event (tp , context );
342351
352+ if (context -> init_stack_size == -1 ) {
353+ context -> init_stack_size = context -> stack_size ;
354+ }
355+
343356 if (context -> thread_pause ) {
344357 context -> stop_next = 1 ;
345358 context -> dest_frame = -1 ;
0 commit comments