Skip to content

Commit 54d73ba

Browse files
author
Guy Bedford
authored
fix: debugger disabling (#223)
1 parent bd8104c commit 54d73ba

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

CMakeLists.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,23 @@ if (ENABLE_WPT)
5555
include("tests/wpt-harness/wpt.cmake")
5656
endif()
5757

58-
add_executable(starling-raw.wasm
59-
runtime/js.cpp
60-
runtime/allocator.cpp
61-
runtime/encode.cpp
62-
runtime/decode.cpp
63-
runtime/engine.cpp
64-
runtime/event_loop.cpp
65-
runtime/builtin.cpp
66-
runtime/script_loader.cpp
67-
runtime/debugger.cpp
58+
set(SOURCES
59+
runtime/js.cpp
60+
runtime/allocator.cpp
61+
runtime/encode.cpp
62+
runtime/decode.cpp
63+
runtime/engine.cpp
64+
runtime/event_loop.cpp
65+
runtime/builtin.cpp
66+
runtime/script_loader.cpp
6867
)
6968

69+
if (ENABLE_JS_DEBUGGER)
70+
list(APPEND SOURCES runtime/debugger.cpp)
71+
endif()
72+
73+
add_executable(starling-raw.wasm ${SOURCES})
74+
7075
target_link_libraries(starling-raw.wasm PRIVATE host_api extension_api builtins spidermonkey rust-crates)
7176

7277
option(USE_WASM_OPT "use wasm-opt to optimize the StarlingMonkey binary" ON)

runtime/engine.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include "jsfriendapi.h"
2121
#pragma clang diagnostic pop
2222

23-
#include "debugger.h"
23+
#ifdef JS_DEBUGGER
24+
#include "debugger.h"
25+
#endif
2426
#include "script_loader.h"
2527

2628
#include <decode.h>
@@ -443,11 +445,13 @@ Engine::Engine(std::unique_ptr<EngineConfig> config) {
443445
// Debugging isn't supported during wizening, so only try it when doing runtime evaluation.
444446
// The debugger can be initialized at runtime by whatever export is invoked on the
445447
// resumed wizer snapshot.
446-
content_debugger::maybe_init_debugger(this, false);
448+
#ifdef JS_DEBUGGER
449+
content_debugger::maybe_init_debugger(this, false);
447450
if (auto replacement_script_path = content_debugger::replacement_script_path()) {
448451
TRACE("Using replacement script path received from debugger: " << *replacement_script_path);
449452
content_script_path = replacement_script_path;
450453
}
454+
#endif
451455
}
452456

453457
if (content_script_path) {
@@ -538,10 +542,14 @@ bool Engine::run_initialization_script() {
538542

539543
JSAutoRealm ar(cx, global);
540544

541-
if (!JS_DefineFunction(cx, global, "defineBuiltinModule", ::define_builtin_module, 2, 0) ||
542-
!JS_DefineFunction(cx, global, "print", content_debugger::dbg_print, 1, 0)) {
545+
if (!JS_DefineFunction(cx, global, "defineBuiltinModule", ::define_builtin_module, 2, 0)) {
543546
return false;
544547
}
548+
#ifdef JS_DEBUGGER
549+
if (!JS_DefineFunction(cx, global, "print", content_debugger::dbg_print, 1, 0)) {
550+
return false;
551+
}
552+
#endif
545553

546554
auto path = config_->initializer_script_path.value();
547555
TRACE("Running initialization script from file " << path);

tests/e2e/init-script/init.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ const builtinMod = {
55
}
66

77
defineBuiltinModule('builtinMod', builtinMod);
8-
print("initialization done");
8+
if (typeof print !== 'undefined')
9+
print("initialization done");

0 commit comments

Comments
 (0)