process: expose process.features.inspector
Instead of using process.config.variables.v8_enable_inspector to detect whether inspector is enabled in the build. PR-URL: https://github.com/nodejs/node/pull/25819 Refs: https://github.com/nodejs/node/issues/25343 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
39d922123c
commit
c2359bdad6
@ -268,12 +268,13 @@ process.assert = deprecate(
|
|||||||
|
|
||||||
// TODO(joyeecheung): this property has not been well-maintained, should we
|
// TODO(joyeecheung): this property has not been well-maintained, should we
|
||||||
// deprecate it in favor of a better API?
|
// deprecate it in favor of a better API?
|
||||||
const { isDebugBuild, hasOpenSSL } = config;
|
const { isDebugBuild, hasOpenSSL, hasInspector } = config;
|
||||||
Object.defineProperty(process, 'features', {
|
Object.defineProperty(process, 'features', {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: false,
|
writable: false,
|
||||||
configurable: false,
|
configurable: false,
|
||||||
value: {
|
value: {
|
||||||
|
inspector: hasInspector,
|
||||||
debug: isDebugBuild,
|
debug: isDebugBuild,
|
||||||
uv: true,
|
uv: true,
|
||||||
ipv6: true, // TODO(bnoordhuis) ping libuv
|
ipv6: true, // TODO(bnoordhuis) ping libuv
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
let session;
|
let session;
|
||||||
function sendInspectorCommand(cb, onError) {
|
function sendInspectorCommand(cb, onError) {
|
||||||
const { hasInspector } = internalBinding('config');
|
const { hasInspector } = internalBinding('config');
|
||||||
const inspector = hasInspector ? require('inspector') : undefined;
|
|
||||||
if (!hasInspector) return onError();
|
if (!hasInspector) return onError();
|
||||||
|
const inspector = require('inspector');
|
||||||
if (session === undefined) session = new inspector.Session();
|
if (session === undefined) session = new inspector.Session();
|
||||||
try {
|
try {
|
||||||
session.connect();
|
session.connect();
|
||||||
|
@ -57,18 +57,18 @@ static void Initialize(Local<Object> target,
|
|||||||
READONLY_TRUE_PROPERTY(target, "hasTracing");
|
READONLY_TRUE_PROPERTY(target, "hasTracing");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_INSPECTOR
|
|
||||||
READONLY_TRUE_PROPERTY(target, "hasInspector");
|
|
||||||
#else
|
|
||||||
READONLY_FALSE_PROPERTY(target, "hasInspector");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(NODE_WITHOUT_NODE_OPTIONS)
|
#if !defined(NODE_WITHOUT_NODE_OPTIONS)
|
||||||
READONLY_TRUE_PROPERTY(target, "hasNodeOptions");
|
READONLY_TRUE_PROPERTY(target, "hasNodeOptions");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NODE_HAVE_I18N_SUPPORT
|
#endif // NODE_HAVE_I18N_SUPPORT
|
||||||
|
|
||||||
|
#if HAVE_INSPECTOR
|
||||||
|
READONLY_TRUE_PROPERTY(target, "hasInspector");
|
||||||
|
#else
|
||||||
|
READONLY_FALSE_PROPERTY(target, "hasInspector");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (env->abort_on_uncaught_exception())
|
if (env->abort_on_uncaught_exception())
|
||||||
READONLY_TRUE_PROPERTY(target, "shouldAbortOnUncaughtException");
|
READONLY_TRUE_PROPERTY(target, "shouldAbortOnUncaughtException");
|
||||||
|
|
||||||
|
@ -80,8 +80,7 @@ if (process.argv.length === 2 &&
|
|||||||
hasCrypto &&
|
hasCrypto &&
|
||||||
// If the binary is build without `intl` the inspect option is
|
// If the binary is build without `intl` the inspect option is
|
||||||
// invalid. The test itself should handle this case.
|
// invalid. The test itself should handle this case.
|
||||||
(process.config.variables.v8_enable_inspector !== 0 ||
|
(process.features.inspector || !flag.startsWith('--inspect'))) {
|
||||||
!flag.startsWith('--inspect'))) {
|
|
||||||
throw new Error(`Test has to be started with the flag: '${flag}'`);
|
throw new Error(`Test has to be started with the flag: '${flag}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -618,7 +617,7 @@ function expectsError(fn, settings, exact) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function skipIfInspectorDisabled() {
|
function skipIfInspectorDisabled() {
|
||||||
if (process.config.variables.v8_enable_inspector === 0) {
|
if (!process.features.inspector) {
|
||||||
skip('V8 inspector is disabled');
|
skip('V8 inspector is disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ const assert = require('assert');
|
|||||||
|
|
||||||
// This following check should be replaced by common.skipIfInspectorDisabled()
|
// This following check should be replaced by common.skipIfInspectorDisabled()
|
||||||
// if moved out of the known_issues directory.
|
// if moved out of the known_issues directory.
|
||||||
if (process.config.variables.v8_enable_inspector === 0) {
|
if (!process.features.inspector) {
|
||||||
// When the V8 inspector is disabled, using either --without-inspector or
|
// When the V8 inspector is disabled, using either --without-inspector or
|
||||||
// --without-ssl, this test will not fail which it is expected to do.
|
// --without-ssl, this test will not fail which it is expected to do.
|
||||||
// The following fail will allow this test to be skipped by failing it.
|
// The following fail will allow this test to be skipped by failing it.
|
||||||
|
@ -6,7 +6,7 @@ require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const spawn = require('child_process').spawnSync;
|
const spawn = require('child_process').spawnSync;
|
||||||
|
|
||||||
if (process.config.variables.v8_enable_inspector === 1) {
|
if (process.features.inspector) {
|
||||||
requiresArgument('--inspect-port');
|
requiresArgument('--inspect-port');
|
||||||
requiresArgument('--inspect-port=');
|
requiresArgument('--inspect-port=');
|
||||||
requiresArgument('--debug-port');
|
requiresArgument('--debug-port');
|
||||||
|
@ -22,10 +22,9 @@ function startPrintHelpTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateNodePrintHelp() {
|
function validateNodePrintHelp() {
|
||||||
const config = process.config;
|
|
||||||
const HAVE_OPENSSL = common.hasCrypto;
|
const HAVE_OPENSSL = common.hasCrypto;
|
||||||
const NODE_HAVE_I18N_SUPPORT = common.hasIntl;
|
const NODE_HAVE_I18N_SUPPORT = common.hasIntl;
|
||||||
const HAVE_INSPECTOR = config.variables.v8_enable_inspector === 1;
|
const HAVE_INSPECTOR = process.features.inspector;
|
||||||
|
|
||||||
const cliHelpOptions = [
|
const cliHelpOptions = [
|
||||||
{ compileConstant: HAVE_OPENSSL,
|
{ compileConstant: HAVE_OPENSSL,
|
||||||
|
@ -5,7 +5,5 @@ require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { builtinLibs } = require('internal/modules/cjs/helpers');
|
const { builtinLibs } = require('internal/modules/cjs/helpers');
|
||||||
|
|
||||||
const hasInspector = process.config.variables.v8_enable_inspector === 1;
|
const expectedLibs = process.features.inspector ? 34 : 33;
|
||||||
|
|
||||||
const expectedLibs = hasInspector ? 34 : 33;
|
|
||||||
assert.strictEqual(builtinLibs.length, expectedLibs);
|
assert.strictEqual(builtinLibs.length, expectedLibs);
|
||||||
|
@ -16,7 +16,7 @@ require('../common');
|
|||||||
'r',
|
'r',
|
||||||
'--stack-trace-limit=100',
|
'--stack-trace-limit=100',
|
||||||
'--stack-trace-limit=-=xX_nodejs_Xx=-',
|
'--stack-trace-limit=-=xX_nodejs_Xx=-',
|
||||||
].concat(process.config.variables.v8_enable_inspector ? [
|
].concat(process.features.inspector ? [
|
||||||
'--inspect-brk',
|
'--inspect-brk',
|
||||||
'inspect-brk',
|
'inspect-brk',
|
||||||
'--inspect_brk',
|
'--inspect_brk',
|
||||||
|
@ -6,6 +6,7 @@ const assert = require('assert');
|
|||||||
const keys = new Set(Object.keys(process.features));
|
const keys = new Set(Object.keys(process.features));
|
||||||
|
|
||||||
assert.deepStrictEqual(keys, new Set([
|
assert.deepStrictEqual(keys, new Set([
|
||||||
|
'inspector',
|
||||||
'debug',
|
'debug',
|
||||||
'uv',
|
'uv',
|
||||||
'ipv6',
|
'ipv6',
|
||||||
|
@ -29,7 +29,7 @@ const {
|
|||||||
} = require('../common/hijackstdio');
|
} = require('../common/hijackstdio');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const hasInspector = process.config.variables.v8_enable_inspector === 1;
|
const hasInspector = process.features.inspector;
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!common.isMainThread)
|
||||||
common.skip('process.chdir is not available in Workers');
|
common.skip('process.chdir is not available in Workers');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
if (!process.config.variables.v8_enable_inspector) return;
|
if (!process.features.inspector) return;
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
@ -289,8 +289,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
|||||||
testInitialized(req, 'SendWrap');
|
testInitialized(req, 'SendWrap');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.config.variables.v8_enable_inspector !== 0 &&
|
if (process.features.inspector && common.isMainThread) {
|
||||||
common.isMainThread) {
|
|
||||||
const binding = internalBinding('inspector');
|
const binding = internalBinding('inspector');
|
||||||
const handle = new binding.Connection(() => {});
|
const handle = new binding.Connection(() => {});
|
||||||
testInitialized(handle, 'Connection');
|
testInitialized(handle, 'Connection');
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
// This is to ensure that the sendInspectorCommand function calls the error
|
if (process.features.inspector) {
|
||||||
// function if its called with the v8_enable_inspector is disabled
|
common.skip('V8 inspector is enabled');
|
||||||
|
}
|
||||||
|
|
||||||
process.config.variables.v8_enable_inspector = 0;
|
|
||||||
const inspector = require('internal/util/inspector');
|
const inspector = require('internal/util/inspector');
|
||||||
|
|
||||||
inspector.sendInspectorCommand(
|
inspector.sendInspectorCommand(
|
||||||
|
@ -1653,8 +1653,8 @@ def Main():
|
|||||||
|
|
||||||
# We want to skip the inspector tests if node was built without the inspector.
|
# We want to skip the inspector tests if node was built without the inspector.
|
||||||
has_inspector = Execute([vm,
|
has_inspector = Execute([vm,
|
||||||
'-p', 'process.config.variables.v8_enable_inspector'], context)
|
'-p', 'process.features.inspector'], context)
|
||||||
if has_inspector.stdout.rstrip() == '0':
|
if has_inspector.stdout.rstrip() == 'false':
|
||||||
context.v8_enable_inspector = False
|
context.v8_enable_inspector = False
|
||||||
|
|
||||||
has_crypto = Execute([vm,
|
has_crypto = Execute([vm,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user