Skip to content

Commit 7cf9930

Browse files
joyeecheungaddaleax
authored andcommitted
src: use PauseOnNextJavascriptStatement to implement --inspect-brk-node
Instead of using the `debugger;` statement which is visible in the JS source code and makes primordials.js environment-dependent. PR-URL: #26034 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 03506d7 commit 7cf9930

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/internal/bootstrap/primordials.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
/* global breakAtBootstrap, primordials */
3+
/* global primordials */
44

55
// This file subclasses and stores the JS builtins that come from the VM
66
// so that Node.js's builtin modules do not need to later look these up from
@@ -12,10 +12,6 @@
1212
// `primordials.Object` where `primordials` is a lexical variable passed
1313
// by the native module compiler.
1414

15-
if (breakAtBootstrap) {
16-
debugger; // eslint-disable-line no-debugger
17-
}
18-
1915
function copyProps(src, dest) {
2016
for (const key of Reflect.ownKeys(src)) {
2117
if (!Reflect.getOwnPropertyDescriptor(dest, key)) {

src/node.cc

+7-3
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,18 @@ MaybeLocal<Value> RunBootstrapping(Environment* env) {
249249
// Store primordials
250250
env->set_primordials(Object::New(isolate));
251251
std::vector<Local<String>> primordials_params = {
252-
FIXED_ONE_BYTE_STRING(isolate, "breakAtBootstrap"),
253252
env->primordials_string()
254253
};
255254
std::vector<Local<Value>> primordials_args = {
256-
Boolean::New(isolate,
257-
env->options()->debug_options().break_node_first_line),
258255
env->primordials()
259256
};
257+
258+
#if HAVE_INSPECTOR
259+
if (env->options()->debug_options().break_node_first_line) {
260+
env->inspector_agent()->PauseOnNextJavascriptStatement(
261+
"Break at bootstrap");
262+
}
263+
#endif // HAVE_INSPECTOR
260264
MaybeLocal<Value> primordials_ret =
261265
ExecuteBootstrapper(env,
262266
"internal/bootstrap/primordials",

0 commit comments

Comments
 (0)