Commit 95b2f02d authored by Benedikt Meurer's avatar Benedikt Meurer Committed by V8 LUCI CQ

[refactor] Introduce dedicated WasmScript::SetBreakPointOnEntry().

Previously we had passed kOnEntryBreakpointPosition as a marker through
the regular SetBreakPointForScript() logic and handled that specially in
WasmScript, however this instrumentation breakpoint is special and gets
in the way of returning more information about a regular breakpoint in
case of crbug.com/700516, so I decided to just isolate that into it's
own method, especially since the only user already special-cases Wasm
anyways.

Bug: chromium:1162229, chromium:700516
Change-Id: Ie7966c1701365a4b03710d6dc32cc8278577ee3a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3026711
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75724}
parent 1fa2d2f3
......@@ -545,9 +545,8 @@ bool Script::SetBreakpointOnScriptEntry(BreakpointId* id) const {
i::Isolate* isolate = script->GetIsolate();
#if V8_ENABLE_WEBASSEMBLY
if (script->type() == i::Script::TYPE_WASM) {
int position = i::WasmScript::kOnEntryBreakpointPosition;
return isolate->debug()->SetBreakPointForScript(
script, isolate->factory()->empty_string(), &position, id);
isolate->debug()->SetOnEntryBreakpointForWasmScript(script, id);
return true;
}
#endif // V8_ENABLE_WEBASSEMBLY
i::SharedFunctionInfo::ScriptIterator it(isolate, *script);
......
......@@ -805,6 +805,16 @@ void Debug::RemoveBreakpoint(int id) {
}
#if V8_ENABLE_WEBASSEMBLY
void Debug::SetOnEntryBreakpointForWasmScript(Handle<Script> script, int* id) {
RCS_SCOPE(isolate_, RuntimeCallCounterId::kDebugger);
DCHECK_EQ(Script::TYPE_WASM, script->type());
*id = ++thread_local_.last_breakpoint_id_;
Handle<BreakPoint> break_point = isolate_->factory()->NewBreakPoint(
*id, isolate_->factory()->empty_string());
RecordWasmScriptWithBreakpoints(script);
WasmScript::SetBreakPointOnEntry(script, break_point);
}
void Debug::RemoveBreakpointForWasmScript(Handle<Script> script, int id) {
RCS_SCOPE(isolate_, RuntimeCallCounterId::kDebugger);
if (script->type() == Script::TYPE_WASM) {
......
......@@ -252,6 +252,7 @@ class V8_EXPORT_PRIVATE Debug {
Handle<String> condition, int* id);
void RemoveBreakpoint(int id);
#if V8_ENABLE_WEBASSEMBLY
void SetOnEntryBreakpointForWasmScript(Handle<Script> script, int* id);
void RemoveBreakpointForWasmScript(Handle<Script> script, int id);
void RecordWasmScriptWithBreakpoints(Handle<Script> script);
......
......@@ -902,21 +902,7 @@ int FindNextBreakablePosition(wasm::NativeModule* native_module, int func_index,
// static
bool WasmScript::SetBreakPoint(Handle<Script> script, int* position,
Handle<BreakPoint> break_point) {
// Special handling for on-entry breakpoints.
if (*position == kOnEntryBreakpointPosition) {
AddBreakpointToInfo(script, *position, break_point);
script->set_break_on_entry(true);
// Update the "break_on_entry" flag on all live instances.
i::WeakArrayList weak_instance_list = script->wasm_weak_instance_list();
for (int i = 0; i < weak_instance_list.length(); ++i) {
if (weak_instance_list.Get(i)->IsCleared()) continue;
i::WasmInstanceObject instance = i::WasmInstanceObject::cast(
weak_instance_list.Get(i)->GetHeapObject());
instance.set_break_on_entry(true);
}
return true;
}
DCHECK_NE(kOnEntryBreakpointPosition, *position);
// Find the function for this breakpoint.
const wasm::WasmModule* module = script->wasm_native_module()->module();
......@@ -934,6 +920,23 @@ bool WasmScript::SetBreakPoint(Handle<Script> script, int* position,
breakable_offset, break_point);
}
// static
void WasmScript::SetBreakPointOnEntry(Handle<Script> script,
Handle<BreakPoint> break_point) {
// Special handling for on-entry breakpoints.
AddBreakpointToInfo(script, kOnEntryBreakpointPosition, break_point);
script->set_break_on_entry(true);
// Update the "break_on_entry" flag on all live instances.
i::WeakArrayList weak_instance_list = script->wasm_weak_instance_list();
for (int i = 0; i < weak_instance_list.length(); ++i) {
if (weak_instance_list.Get(i)->IsCleared()) continue;
i::WasmInstanceObject instance =
i::WasmInstanceObject::cast(weak_instance_list.Get(i)->GetHeapObject());
instance.set_break_on_entry(true);
}
}
// static
bool WasmScript::SetBreakPointOnFirstBreakableForFunction(
Handle<Script> script, int func_index, Handle<BreakPoint> break_point) {
......
......@@ -754,6 +754,12 @@ class WasmScript : public AllStatic {
V8_EXPORT_PRIVATE static bool SetBreakPoint(Handle<Script>, int* position,
Handle<BreakPoint> break_point);
// Set an "on entry" breakpoint (a.k.a. instrumentation breakpoint) inside
// the given module. This will affect all live and future instances of the
// module.
V8_EXPORT_PRIVATE static void SetBreakPointOnEntry(
Handle<Script>, Handle<BreakPoint> break_point);
// Set a breakpoint on first breakable position of the given function index
// inside the given module. This will affect all live and future instances of
// the module.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment