diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 4127d6735adb28..d3048daebe2ccc 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -9430,6 +9430,19 @@ bool debug::Script::SetBreakpoint(v8::Local condition, return true; } +bool debug::Script::SetBreakpointOnScriptEntry(BreakpointId* id) const { + i::Handle script = Utils::OpenHandle(this); + i::Isolate* isolate = script->GetIsolate(); + i::SharedFunctionInfo::ScriptIterator it(isolate, *script); + for (i::SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) { + if (sfi->is_toplevel()) { + return isolate->debug()->SetBreakpointForFunction( + handle(sfi, isolate), isolate->factory()->empty_string(), id); + } + } + return false; +} + void debug::RemoveBreakpoint(Isolate* v8_isolate, BreakpointId id) { i::Isolate* isolate = reinterpret_cast(v8_isolate); i::HandleScope handle_scope(isolate); @@ -9823,8 +9836,8 @@ bool debug::SetFunctionBreakpoint(v8::Local function, i::Handle condition_string = condition.IsEmpty() ? isolate->factory()->empty_string() : Utils::OpenHandle(*condition); - return isolate->debug()->SetBreakpointForFunction(jsfunction, - condition_string, id); + return isolate->debug()->SetBreakpointForFunction( + handle(jsfunction->shared(), isolate), condition_string, id); } debug::PostponeInterruptsScope::PostponeInterruptsScope(v8::Isolate* isolate) diff --git a/deps/v8/src/debug/debug-interface.h b/deps/v8/src/debug/debug-interface.h index bdefe78225c4e5..07b19e3c277c2c 100644 --- a/deps/v8/src/debug/debug-interface.h +++ b/deps/v8/src/debug/debug-interface.h @@ -141,6 +141,7 @@ class V8_EXPORT_PRIVATE Script { LiveEditResult* result) const; bool SetBreakpoint(v8::Local condition, debug::Location* location, BreakpointId* id) const; + bool SetBreakpointOnScriptEntry(BreakpointId* id) const; }; // Specialization for wasm Scripts. diff --git a/deps/v8/src/debug/debug.cc b/deps/v8/src/debug/debug.cc index d33fc316694537..e6aa2fe10c8400 100644 --- a/deps/v8/src/debug/debug.cc +++ b/deps/v8/src/debug/debug.cc @@ -589,13 +589,12 @@ bool Debug::CheckBreakPoint(Handle break_point, return result->BooleanValue(isolate_); } -bool Debug::SetBreakPoint(Handle function, +bool Debug::SetBreakpoint(Handle shared, Handle break_point, int* source_position) { HandleScope scope(isolate_); // Make sure the function is compiled and has set up the debug info. - Handle shared(function->shared(), isolate_); if (!EnsureBreakInfo(shared)) return false; PrepareFunctionForDebugExecution(shared); @@ -750,13 +749,13 @@ int Debug::GetFunctionDebuggingId(Handle function) { return id; } -bool Debug::SetBreakpointForFunction(Handle function, +bool Debug::SetBreakpointForFunction(Handle shared, Handle condition, int* id) { *id = ++thread_local_.last_breakpoint_id_; Handle breakpoint = isolate_->factory()->NewBreakPoint(*id, condition); int source_position = 0; - return SetBreakPoint(function, breakpoint, &source_position); + return SetBreakpoint(shared, breakpoint, &source_position); } void Debug::RemoveBreakpoint(int id) { diff --git a/deps/v8/src/debug/debug.h b/deps/v8/src/debug/debug.h index e0d675fc7d2d03..1d600574b23775 100644 --- a/deps/v8/src/debug/debug.h +++ b/deps/v8/src/debug/debug.h @@ -227,7 +227,7 @@ class V8_EXPORT_PRIVATE Debug { Handle GetLoadedScripts(); // Break point handling. - bool SetBreakPoint(Handle function, + bool SetBreakpoint(Handle shared, Handle break_point, int* source_position); void ClearBreakPoint(Handle break_point); void ChangeBreakOnException(ExceptionBreakType type, bool enable); @@ -235,7 +235,7 @@ class V8_EXPORT_PRIVATE Debug { bool SetBreakPointForScript(Handle