diff options
author | 2023-08-20 19:34:33 -0700 | |
---|---|---|
committer | 2023-08-20 19:34:33 -0700 | |
commit | 3de9ce5f30ad3a2a5615acb62a25cecdd2ddef33 (patch) | |
tree | edbfe3f14bc8f09497aeea2b88d60d9a070404f4 /src/bun.js/bindings/BunDebugger.cpp | |
parent | 65280853acf2385eae124ef4870af2751ad662df (diff) | |
download | bun-3de9ce5f30ad3a2a5615acb62a25cecdd2ddef33.tar.gz bun-3de9ce5f30ad3a2a5615acb62a25cecdd2ddef33.tar.zst bun-3de9ce5f30ad3a2a5615acb62a25cecdd2ddef33.zip |
Implement `--inspect-brk` (#4222)
* Implement `--inspect-brk`
* Bump WebKit
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/BunDebugger.cpp')
-rw-r--r-- | src/bun.js/bindings/BunDebugger.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/bun.js/bindings/BunDebugger.cpp b/src/bun.js/bindings/BunDebugger.cpp index 41001a8f2..440a5125b 100644 --- a/src/bun.js/bindings/BunDebugger.cpp +++ b/src/bun.js/bindings/BunDebugger.cpp @@ -23,14 +23,40 @@ static WebCore::ScriptExecutionContext* debuggerScriptExecutionContext = nullptr static WTF::Lock inspectorConnectionsLock = WTF::Lock(); static WTF::HashMap<ScriptExecutionContextIdentifier, Vector<BunInspectorConnection*, 8>>* inspectorConnections = nullptr; +static bool waitingForConnection = false; +extern "C" void Debugger__didConnect(); + +class BunJSGlobalObjectDebuggable final : public JSC::JSGlobalObjectDebuggable { +public: + using Base = JSC::JSGlobalObjectDebuggable; + + BunJSGlobalObjectDebuggable(JSC::JSGlobalObject& globalObject) + : Base(globalObject) + { + } + + ~BunJSGlobalObjectDebuggable() final + { + } + + void pauseWaitingForAutomaticInspection() override + { + } + void unpauseForInitializedInspector() override + { + if (waitingForConnection) { + waitingForConnection = false; + Debugger__didConnect(); + } + } +}; + enum class ConnectionStatus : int32_t { Pending = 0, Connected = 1, Disconnecting = 2, Disconnected = 3, }; -static bool waitingForConnection = false; -extern "C" void Debugger__didConnect(); class BunInspectorConnection : public Inspector::FrontendChannel { @@ -81,15 +107,9 @@ public: Bun__eventLoop__incrementRefConcurrently(reinterpret_cast<Zig::GlobalObject*>(globalObject)->bunVM(), 1); } globalObject->setInspectable(true); - auto& inspector = globalObject->inspectorDebuggable(); inspector.setInspectable(true); - - inspector.connect(*connection); - if (waitingForConnection) { - waitingForConnection = false; - Debugger__didConnect(); - } + globalObject->inspectorController().connectFrontend(*connection, true, waitingForConnection); Inspector::JSGlobalObjectDebugger* debugger = reinterpret_cast<Inspector::JSGlobalObjectDebugger*>(globalObject->debugger()); if (debugger) { @@ -99,7 +119,6 @@ public: } connection->receiveMessagesOnInspectorThread(context, reinterpret_cast<Zig::GlobalObject*>(globalObject)); - break; } default: { @@ -415,6 +434,8 @@ extern "C" void Bun__ensureDebugger(ScriptExecutionContextIdentifier scriptId, b auto* globalObject = ScriptExecutionContext::getScriptExecutionContext(scriptId)->jsGlobalObject(); globalObject->m_inspectorController = makeUnique<Inspector::JSGlobalObjectInspectorController>(*globalObject, Bun::BunInjectedScriptHost::create()); + globalObject->m_inspectorDebuggable = makeUnique<BunJSGlobalObjectDebuggable>(*globalObject); + globalObject->setInspectable(true); auto& inspector = globalObject->inspectorDebuggable(); |