From 4ca07898d79c8d4c633fc8a5f86b1672a8b669b5 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 10 Feb 2019 19:57:21 +0800 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/26034 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gus Caplan Reviewed-By: James M Snell --- lib/internal/bootstrap/primordials.js | 6 +----- src/node.cc | 10 +++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/internal/bootstrap/primordials.js b/lib/internal/bootstrap/primordials.js index 85f1f54c1ccf7e..df399dc1736a54 100644 --- a/lib/internal/bootstrap/primordials.js +++ b/lib/internal/bootstrap/primordials.js @@ -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 @@ -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)) { diff --git a/src/node.cc b/src/node.cc index 7d9075b5e0a16e..f257495a1351e2 100644 --- a/src/node.cc +++ b/src/node.cc @@ -249,14 +249,18 @@ MaybeLocal RunBootstrapping(Environment* env) { // Store primordials env->set_primordials(Object::New(isolate)); std::vector> primordials_params = { - FIXED_ONE_BYTE_STRING(isolate, "breakAtBootstrap"), env->primordials_string() }; std::vector> 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 primordials_ret = ExecuteBootstrapper(env, "internal/bootstrap/primordials",