From e5083e30ed53ee38e3659111fa33414e0bfc3ac6 Mon Sep 17 00:00:00 2001 From: Carlos Espa Date: Wed, 12 Feb 2025 20:19:16 +0100 Subject: [PATCH] cli: allow --cpu-prof* in NODE_OPTIONS Fixes: https://github.com/nodejs/node/issues/56944 --- doc/api/cli.md | 4 ++++ src/node_options.cc | 12 ++++++++---- .../test-process-env-allowed-flags-are-documented.js | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index e76749afa0cf84..3fd3a1ed7b3d3a 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -3138,6 +3138,10 @@ one is included in the list below. * `--allow-wasi` * `--allow-worker` * `--conditions`, `-C` +* `--cpu-prof-dir` +* `--cpu-prof-interval` +* `--cpu-prof-name` +* `--cpu-prof` * `--diagnostic-dir` * `--disable-proto` * `--disable-sigusr1` diff --git a/src/node_options.cc b/src/node_options.cc index f96f9d2de9718e..45abd99aab2c3b 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -614,19 +614,23 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "Start the V8 CPU profiler on start up, and write the CPU profile " "to disk before exit. If --cpu-prof-dir is not specified, write " "the profile to the current working directory.", - &EnvironmentOptions::cpu_prof); + &EnvironmentOptions::cpu_prof, + kAllowedInEnvvar); AddOption("--cpu-prof-name", "specified file name of the V8 CPU profile generated with " "--cpu-prof", - &EnvironmentOptions::cpu_prof_name); + &EnvironmentOptions::cpu_prof_name, + kAllowedInEnvvar); AddOption("--cpu-prof-interval", "specified sampling interval in microseconds for the V8 CPU " "profile generated with --cpu-prof. (default: 1000)", - &EnvironmentOptions::cpu_prof_interval); + &EnvironmentOptions::cpu_prof_interval, + kAllowedInEnvvar); AddOption("--cpu-prof-dir", "Directory where the V8 profiles generated by --cpu-prof will be " "placed. Does not affect --prof.", - &EnvironmentOptions::cpu_prof_dir); + &EnvironmentOptions::cpu_prof_dir, + kAllowedInEnvvar); AddOption("--experimental-network-inspection", "experimental network inspection support", &EnvironmentOptions::experimental_network_inspection); diff --git a/test/parallel/test-process-env-allowed-flags-are-documented.js b/test/parallel/test-process-env-allowed-flags-are-documented.js index 89b41da638f2da..f3048373dc7347 100644 --- a/test/parallel/test-process-env-allowed-flags-are-documented.js +++ b/test/parallel/test-process-env-allowed-flags-are-documented.js @@ -93,6 +93,10 @@ const difference = (setA, setB) => { // Refs: https://github.com/nodejs/node/pull/54259#issuecomment-2308256647 if (!process.features.inspector) { [ + '--cpu-prof-dir', + '--cpu-prof-interval', + '--cpu-prof-name', + '--cpu-prof', '--heap-prof-dir', '--heap-prof-interval', '--heap-prof-name',