Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 348694c4bfd2fcd01336a7cb42eba72392d058c5
      
https://github.com/WebKit/WebKit/commit/348694c4bfd2fcd01336a7cb42eba72392d058c5
  Author: Yijia Huang <[email protected]>
  Date:   2026-04-08 (Wed, 08 Apr 2026)

  Changed paths:
    M JSTests/wasm/debugger/resources/swift-wasm/build.sh
    A JSTests/wasm/debugger/resources/swift-wasm/dynamic-module-load/func-a.wasm
    A 
JSTests/wasm/debugger/resources/swift-wasm/dynamic-module-load/func-a/Package.swift
    A 
JSTests/wasm/debugger/resources/swift-wasm/dynamic-module-load/func-a/Sources/func-a/func-a.swift
    A JSTests/wasm/debugger/resources/swift-wasm/dynamic-module-load/func-b.wasm
    A 
JSTests/wasm/debugger/resources/swift-wasm/dynamic-module-load/func-b/Package.swift
    A 
JSTests/wasm/debugger/resources/swift-wasm/dynamic-module-load/func-b/Sources/func-b/func-b.swift
    A JSTests/wasm/debugger/resources/swift-wasm/dynamic-module-load/main.js
    A JSTests/wasm/debugger/resources/wasm/dynamic-module-load.js
    M JSTests/wasm/debugger/tests/tests.py
    M Source/JavaScriptCore/runtime/StopTheWorldCallback.h
    M Source/JavaScriptCore/runtime/VM.cpp
    M Source/JavaScriptCore/tools/JSDollarVM.cpp
    M Source/JavaScriptCore/wasm/WasmIPIntSlowPaths.cpp
    M Source/JavaScriptCore/wasm/debugger/Debugger-Mutator-Protocol.md
    M Source/JavaScriptCore/wasm/debugger/README.md
    M Source/JavaScriptCore/wasm/debugger/WasmDebugServer.cpp
    M Source/JavaScriptCore/wasm/debugger/WasmDebugServer.h
    M Source/JavaScriptCore/wasm/debugger/WasmDebugServerUtilities.cpp
    M Source/JavaScriptCore/wasm/debugger/WasmDebugServerUtilities.h
    M Source/JavaScriptCore/wasm/debugger/WasmExecutionHandler.cpp
    M Source/JavaScriptCore/wasm/debugger/WasmExecutionHandler.h
    M Source/JavaScriptCore/wasm/debugger/WasmModuleManager.cpp
    M Source/JavaScriptCore/wasm/debugger/WasmModuleManager.h
    M Source/JavaScriptCore/wasm/debugger/WasmQueryHandler.cpp
    M Source/JavaScriptCore/wasm/debugger/tests/ExecutionHandlerTest.cpp
    M Source/JavaScriptCore/wasm/debugger/tests/ExecutionHandlerTestSupport.cpp
    M Source/WebKit/WebProcess/Inspector/WasmDebuggerDispatcher.cpp

  Log Message:
  -----------
  [JSC][WASM][Debugger] Notify LLDB when a new WebAssembly module is 
dynamically instantiated
https://bugs.webkit.org/show_bug.cgi?id=311390
rdar://173985480

Reviewed by Mark Lam (OOPS\!).

In native C++ debugging, dlopen triggers _dyld_debugger_notification which LLDB
intercepts to transparently resolve pending breakpoints in newly loaded 
libraries.
No equivalent mechanism exists for WASM: LLDB only queries qXfer:libraries:read
once at attach via DynamicLoaderWasmDYLD, then goes silent. As a result, pending
breakpoints targeting symbols in dynamically loaded WASM modules are never 
resolved
— the user sets "b func_b" before the module loads, and the breakpoint is 
silently
missed when func_b is eventually called.

To fix this, when a WebAssembly.Instance is created for a module that LLDB has 
not
yet seen, JSC stops all VMs via the existing STW mechanism and sends a T-packet
with library:; This causes LLDB to re-query qXfer:libraries:read, load debug 
info
for the new module, and resolve any pending breakpoints that target symbols in 
it.

Key design points:
- Notification fires at trackInstance (not trackModule) so the JS thread is at a
  safepoint and the stop is immediate. Modules compiled speculatively without
  instantiation (WebAssembly.compile) do not generate spurious stops.
- ModuleManager tracks a set of unnotified module IDs (m_unnotifiedModuleIds).
  Multiple modules compiled before any instance is created are batched: the 
first
  instance creation triggers one stop and LLDB picks up all pending modules in a
  single qXfer:libraries:read response, after which markModulesNotified() 
clears the set.
- isDebuggerReady() gates module-load notifications on the debugger having
  completed its startup exchange ('?' + first qXfer:libraries:read), replacing
  the old m_trapHandlingEnabled flag with a cleaner readiness concept.

As a prerequisite cleanup:
- StopData::Code and StopData::Location are removed; DebugState::Reason is the
  single source of truth for why the VM stopped. NewModuleLoad is represented as
  Reason::Interrupted with isNewModuleLoad flag rather than a separate enum 
value.
- BreakpointHit and TrapHit StopTheWorldEvents are merged into WasmProgramStop.
- isConnected() is renamed hasDebugger() to better reflect that it is a
  transport-level check, not a protocol-readiness check.
- $vm.hasDebuggerContinued() is added to JSDollarVM for test synchronization.

Tests:
* JSTests/wasm/debugger/tests/tests.py:
(DynamicModuleLoadTestCase):
(SwiftWasmDynamicModuleLoadTestCase):

Canonical link: https://commits.webkit.org/310825@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to