File tree 5 files changed +25
-11
lines changed
5 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -684,6 +684,14 @@ inline void Environment::set_has_run_bootstrapping_code(bool value) {
684
684
has_run_bootstrapping_code_ = value;
685
685
}
686
686
687
+ inline bool Environment::has_serialized_options () const {
688
+ return has_serialized_options_;
689
+ }
690
+
691
+ inline void Environment::set_has_serialized_options (bool value) {
692
+ has_serialized_options_ = value;
693
+ }
694
+
687
695
inline bool Environment::is_main_thread () const {
688
696
return flags_ & kIsMainThread ;
689
697
}
Original file line number Diff line number Diff line change @@ -887,6 +887,9 @@ class Environment {
887
887
inline bool has_run_bootstrapping_code () const ;
888
888
inline void set_has_run_bootstrapping_code (bool has_run_bootstrapping_code);
889
889
890
+ inline bool has_serialized_options () const ;
891
+ inline void set_has_serialized_options (bool has_serialized_options);
892
+
890
893
static uint64_t AllocateThreadId ();
891
894
static constexpr uint64_t kNoThreadId = -1 ;
892
895
@@ -1104,6 +1107,8 @@ class Environment {
1104
1107
std::unordered_map<std::string, uint64_t > performance_marks_;
1105
1108
1106
1109
bool has_run_bootstrapping_code_ = false ;
1110
+ bool has_serialized_options_ = false ;
1111
+
1107
1112
bool can_call_into_js_ = true ;
1108
1113
Flags flags_;
1109
1114
uint64_t thread_id_;
Original file line number Diff line number Diff line change @@ -728,18 +728,12 @@ bool Agent::Start(const std::string& path,
728
728
return false ;
729
729
}
730
730
731
- // TODO(joyeecheung): we should not be using process as a global object
732
- // to transport --inspect-brk. Instead, the JS land can get this through
733
- // require('internal/options') since it should be set once CLI parsing
734
- // is done.
731
+ // Patch the debug options to implement waitForDebuggerOnStart for
732
+ // the NodeWorker.enable method.
735
733
if (wait_for_connect) {
736
- HandleScope scope (parent_env_->isolate ());
737
- parent_env_->process_object ()->DefineOwnProperty (
738
- parent_env_->context (),
739
- FIXED_ONE_BYTE_STRING (parent_env_->isolate (), " _breakFirstLine" ),
740
- True (parent_env_->isolate ()),
741
- static_cast <v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum))
742
- .FromJust ();
734
+ CHECK (!parent_env_->has_serialized_options ());
735
+ debug_options_.EnableBreakFirstLine ();
736
+ parent_env_->options ()->get_debug_options ()->EnableBreakFirstLine ();
743
737
client_->waitForFrontend ();
744
738
}
745
739
return true ;
Original file line number Diff line number Diff line change @@ -553,6 +553,7 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) {
553
553
return env->ThrowError (
554
554
" Should not query options before bootstrapping is done" );
555
555
}
556
+ env->set_has_serialized_options (true );
556
557
557
558
Isolate* isolate = env->isolate ();
558
559
Local<Context> context = env->context ();
Original file line number Diff line number Diff line change @@ -85,6 +85,12 @@ class DebugOptions : public Options {
85
85
return deprecated_debug && !inspector_enabled;
86
86
}
87
87
88
+ // Used to patch the options as if --inspect-brk is passed.
89
+ void EnableBreakFirstLine () {
90
+ inspector_enabled = true ;
91
+ break_first_line = true ;
92
+ }
93
+
88
94
bool wait_for_connect () const {
89
95
return break_first_line || break_node_first_line;
90
96
}
You can’t perform that action at this time.
0 commit comments