@@ -795,7 +795,9 @@ void ContextifyScript::RunInThisContext(
795795 TRACE_EVENT_NESTABLE_ASYNC_BEGIN0 (
796796 TRACING_CATEGORY_NODE2 (vm, script), " RunInThisContext" , wrapped_script);
797797
798- CHECK_EQ (args.Length (), 3 );
798+ // TODO(addaleax): Use an options object or otherwise merge this with
799+ // RunInContext().
800+ CHECK_EQ (args.Length (), 4 );
799801
800802 CHECK (args[0 ]->IsNumber ());
801803 int64_t timeout = args[0 ]->IntegerValue (env->context ()).FromJust ();
@@ -806,8 +808,16 @@ void ContextifyScript::RunInThisContext(
806808 CHECK (args[2 ]->IsBoolean ());
807809 bool break_on_sigint = args[2 ]->IsTrue ();
808810
811+ CHECK (args[3 ]->IsBoolean ());
812+ bool break_on_first_line = args[3 ]->IsTrue ();
813+
809814 // Do the eval within this context
810- EvalMachine (env, timeout, display_errors, break_on_sigint, args);
815+ EvalMachine (env,
816+ timeout,
817+ display_errors,
818+ break_on_sigint,
819+ break_on_first_line,
820+ args);
811821
812822 TRACE_EVENT_NESTABLE_ASYNC_END0 (
813823 TRACING_CATEGORY_NODE2 (vm, script), " RunInThisContext" , wrapped_script);
@@ -819,7 +829,7 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
819829 ContextifyScript* wrapped_script;
820830 ASSIGN_OR_RETURN_UNWRAP (&wrapped_script, args.Holder ());
821831
822- CHECK_EQ (args.Length (), 4 );
832+ CHECK_EQ (args.Length (), 5 );
823833
824834 CHECK (args[0 ]->IsObject ());
825835 Local<Object> sandbox = args[0 ].As <Object>();
@@ -843,12 +853,16 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
843853 CHECK (args[3 ]->IsBoolean ());
844854 bool break_on_sigint = args[3 ]->IsTrue ();
845855
856+ CHECK (args[4 ]->IsBoolean ());
857+ bool break_on_first_line = args[4 ]->IsTrue ();
858+
846859 // Do the eval within the context
847860 Context::Scope context_scope (contextify_context->context ());
848861 EvalMachine (contextify_context->env (),
849862 timeout,
850863 display_errors,
851864 break_on_sigint,
865+ break_on_first_line,
852866 args);
853867
854868 TRACE_EVENT_NESTABLE_ASYNC_END0 (
@@ -859,6 +873,7 @@ bool ContextifyScript::EvalMachine(Environment* env,
859873 const int64_t timeout,
860874 const bool display_errors,
861875 const bool break_on_sigint,
876+ const bool break_on_first_line,
862877 const FunctionCallbackInfo<Value>& args) {
863878 if (!env->can_call_into_js ())
864879 return false ;
@@ -874,6 +889,12 @@ bool ContextifyScript::EvalMachine(Environment* env,
874889 PersistentToLocal::Default (env->isolate (), wrapped_script->script_ );
875890 Local<Script> script = unbound_script->BindToCurrentContext ();
876891
892+ #if HAVE_INSPECTOR
893+ if (break_on_first_line) {
894+ env->inspector_agent ()->PauseOnNextJavascriptStatement (" Break on start" );
895+ }
896+ #endif
897+
877898 MaybeLocal<Value> result;
878899 bool timed_out = false ;
879900 bool received_signal = false ;
0 commit comments