diff options
author | 2023-04-13 04:54:05 -0700 | |
---|---|---|
committer | 2023-06-04 18:54:26 -0700 | |
commit | c4b3b321c2e0550a7bce92fdeee6082f61d5ccc8 (patch) | |
tree | f11152abed22716edc6e514ad41e2bbe70ad9bd0 | |
parent | cf599e77d9b6f919f5d4d505bd8bad9884662bf5 (diff) | |
download | bun-c4b3b321c2e0550a7bce92fdeee6082f61d5ccc8.tar.gz bun-c4b3b321c2e0550a7bce92fdeee6082f61d5ccc8.tar.zst bun-c4b3b321c2e0550a7bce92fdeee6082f61d5ccc8.zip |
slightly more progress
-rw-r--r-- | src/bun.js/bindings/BunInspector.cpp | 11 | ||||
-rw-r--r-- | src/bun.js/bindings/BunInspector.h | 1 | ||||
-rw-r--r-- | src/bun.js/event_loop.zig | 9 |
3 files changed, 20 insertions, 1 deletions
diff --git a/src/bun.js/bindings/BunInspector.cpp b/src/bun.js/bindings/BunInspector.cpp index a88823edd..4790c5a60 100644 --- a/src/bun.js/bindings/BunInspector.cpp +++ b/src/bun.js/bindings/BunInspector.cpp @@ -2,6 +2,7 @@ #include <JavaScriptCore/Heap.h> #include <JavaScriptCore/JSGlobalObject.h> #include "JSGlobalObjectInspectorController.h" +#include <JavaScriptCore/JSGlobalObjectDebugger.h> namespace Zig { @@ -111,6 +112,8 @@ void BunInspector::drainOutgoingMessages() } } +extern "C" void Bun__tickWhileWaitingForDebugger(JSC::JSGlobalObject* globalObject); + RefPtr<BunInspector> BunInspector::startWebSocketServer( WebCore::ScriptExecutionContext& context, WTF::String hostname, @@ -184,7 +187,13 @@ RefPtr<BunInspector> BunInspector::startWebSocketServer( *connectionPtr = new BunInspectorConnection(inspector); ws->subscribe("BunInspectorConnection"); BunInspectorConnection* connection = *connectionPtr; - inspector->connect(Inspector::FrontendChannel::ConnectionType::Local); }, + inspector->connect(Inspector::FrontendChannel::ConnectionType::Local); + auto* debugger = reinterpret_cast<Inspector::JSGlobalObjectDebugger*>(inspector->globalObject()->inspectorController().debugger()); + debugger->runWhilePausedCallback = [](JSC::JSGlobalObject& globalObject, bool& isPaused) { + while (isPaused) { + Bun__tickWhileWaitingForDebugger(&globalObject); + } + }; }, .message = [inspector](auto* ws, std::string_view message, uWS::OpCode opCode) { if (opCode == uWS::OpCode::TEXT) { diff --git a/src/bun.js/bindings/BunInspector.h b/src/bun.js/bindings/BunInspector.h index 219cfdcf3..c02e810cb 100644 --- a/src/bun.js/bindings/BunInspector.h +++ b/src/bun.js/bindings/BunInspector.h @@ -11,6 +11,7 @@ namespace Zig { using namespace JSC; +using namespace WebCore; class BunInspector final : public RefCounted<BunInspector>, ::Inspector::InspectorTarget, ::Inspector::FrontendChannel, public WebCore::ContextDestructionObserver { public: diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index c2125e64f..04935c79b 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -879,3 +879,12 @@ pub const AnyEventLoop = union(enum) { } } }; + +pub export fn Bun__tickWhileWaitingForDebugger(globalObject: *JSC.JSGlobalObject) callconv(.C) void { + globalObject.bunVM().eventLoop().tickPossiblyForever(); +} + +comptime { + if (!JSC.is_bindgen) + _ = Bun__tickWhileWaitingForDebugger; +} |