@@ -795,7 +795,9 @@ void ContextifyScript::RunInThisContext(
795
795
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0 (
796
796
TRACING_CATEGORY_NODE2 (vm, script), " RunInThisContext" , wrapped_script);
797
797
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 );
799
801
800
802
CHECK (args[0 ]->IsNumber ());
801
803
int64_t timeout = args[0 ]->IntegerValue (env->context ()).FromJust ();
@@ -806,8 +808,16 @@ void ContextifyScript::RunInThisContext(
806
808
CHECK (args[2 ]->IsBoolean ());
807
809
bool break_on_sigint = args[2 ]->IsTrue ();
808
810
811
+ CHECK (args[3 ]->IsBoolean ());
812
+ bool break_on_first_line = args[3 ]->IsTrue ();
813
+
809
814
// 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);
811
821
812
822
TRACE_EVENT_NESTABLE_ASYNC_END0 (
813
823
TRACING_CATEGORY_NODE2 (vm, script), " RunInThisContext" , wrapped_script);
@@ -819,7 +829,7 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
819
829
ContextifyScript* wrapped_script;
820
830
ASSIGN_OR_RETURN_UNWRAP (&wrapped_script, args.Holder ());
821
831
822
- CHECK_EQ (args.Length (), 4 );
832
+ CHECK_EQ (args.Length (), 5 );
823
833
824
834
CHECK (args[0 ]->IsObject ());
825
835
Local<Object> sandbox = args[0 ].As <Object>();
@@ -843,12 +853,16 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
843
853
CHECK (args[3 ]->IsBoolean ());
844
854
bool break_on_sigint = args[3 ]->IsTrue ();
845
855
856
+ CHECK (args[4 ]->IsBoolean ());
857
+ bool break_on_first_line = args[4 ]->IsTrue ();
858
+
846
859
// Do the eval within the context
847
860
Context::Scope context_scope (contextify_context->context ());
848
861
EvalMachine (contextify_context->env (),
849
862
timeout,
850
863
display_errors,
851
864
break_on_sigint,
865
+ break_on_first_line,
852
866
args);
853
867
854
868
TRACE_EVENT_NESTABLE_ASYNC_END0 (
@@ -859,6 +873,7 @@ bool ContextifyScript::EvalMachine(Environment* env,
859
873
const int64_t timeout,
860
874
const bool display_errors,
861
875
const bool break_on_sigint,
876
+ const bool break_on_first_line,
862
877
const FunctionCallbackInfo<Value>& args) {
863
878
if (!env->can_call_into_js ())
864
879
return false ;
@@ -874,6 +889,12 @@ bool ContextifyScript::EvalMachine(Environment* env,
874
889
PersistentToLocal::Default (env->isolate (), wrapped_script->script_ );
875
890
Local<Script> script = unbound_script->BindToCurrentContext ();
876
891
892
+ #if HAVE_INSPECTOR
893
+ if (break_on_first_line) {
894
+ env->inspector_agent ()->PauseOnNextJavascriptStatement (" Break on start" );
895
+ }
896
+ #endif
897
+
877
898
MaybeLocal<Value> result;
878
899
bool timed_out = false ;
879
900
bool received_signal = false ;
0 commit comments