Skip to content

Commit

Permalink
src: use PauseOnNextJavascriptStatement to implement --inspect-brk-node
Browse files Browse the repository at this point in the history
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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and rvagg committed Feb 28, 2019
1 parent 733beb7 commit 4ca0789
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 1 addition & 5 deletions lib/internal/bootstrap/primordials.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

/* global breakAtBootstrap, primordials */
/* global primordials */

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

if (breakAtBootstrap) {
debugger; // eslint-disable-line no-debugger
}

function copyProps(src, dest) {
for (const key of Reflect.ownKeys(src)) {
if (!Reflect.getOwnPropertyDescriptor(dest, key)) {
Expand Down
10 changes: 7 additions & 3 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,18 @@ MaybeLocal<Value> RunBootstrapping(Environment* env) {
// Store primordials
env->set_primordials(Object::New(isolate));
std::vector<Local<String>> primordials_params = {
FIXED_ONE_BYTE_STRING(isolate, "breakAtBootstrap"),
env->primordials_string()
};
std::vector<Local<Value>> primordials_args = {
Boolean::New(isolate,
env->options()->debug_options().break_node_first_line),
env->primordials()
};

#if HAVE_INSPECTOR
if (env->options()->debug_options().break_node_first_line) {
env->inspector_agent()->PauseOnNextJavascriptStatement(
"Break at bootstrap");
}
#endif // HAVE_INSPECTOR
MaybeLocal<Value> primordials_ret =
ExecuteBootstrapper(env,
"internal/bootstrap/primordials",
Expand Down

0 comments on commit 4ca0789

Please sign in to comment.