Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bc07612

Browse filesBrowse files
addaleaxtargos
authored andcommitted
src: fix --prof-process CLI argument handling
Make sure that options after `--prof-process` are not treated as Node.js options. Fixes: #22786 PR-URL: #22790 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 24a35f9 commit bc07612
Copy full SHA for bc07612

File tree

Expand file treeCollapse file tree

3 files changed

+39
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+39
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/bootstrap/node.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/node.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,11 @@
642642
for (const [ from, expansion ] of aliases) {
643643
let isAccepted = true;
644644
for (const to of expansion) {
645-
if (!to.startsWith('-')) continue;
645+
if (!to.startsWith('-') || to === '--') continue;
646646
const recursiveExpansion = aliases.get(to);
647647
if (recursiveExpansion) {
648+
if (recursiveExpansion[0] === to)
649+
recursiveExpansion.splice(0, 1);
648650
expansion.push(...recursiveExpansion);
649651
continue;
650652
}
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
108108
AddOption("--prof-process",
109109
"process V8 profiler output generated using --prof",
110110
&EnvironmentOptions::prof_process);
111+
// Options after --prof-process are passed through to the prof processor.
112+
AddAlias("--prof-process", { "--prof-process", "--" });
111113
AddOption("--redirect-warnings",
112114
"write warnings to file instead of stderr",
113115
&EnvironmentOptions::redirect_warnings,
Collapse file
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
const common = require('../common');
3+
const tmpdir = require('../common/tmpdir');
4+
const fs = require('fs');
5+
const assert = require('assert');
6+
const { spawnSync } = require('child_process');
7+
8+
if (!common.isMainThread)
9+
common.skip('chdir not available in workers');
10+
if (!common.enoughTestMem)
11+
common.skip('skipped due to memory requirements');
12+
if (common.isAIX)
13+
common.skip('does not work on AIX');
14+
15+
tmpdir.refresh();
16+
process.chdir(tmpdir.path);
17+
18+
// Generate log file.
19+
spawnSync(process.execPath, [ '--prof', '-p', '42' ]);
20+
21+
const logfile = fs.readdirSync('.').filter((name) => name.endsWith('.log'))[0];
22+
assert(logfile);
23+
24+
// Make sure that the --preprocess argument is passed through correctly,
25+
// as an example flag listed in deps/v8/tools/tickprocessor.js.
26+
// Any of the other flags there should work for this test too, if --preprocess
27+
// is ever removed.
28+
const { stdout } = spawnSync(
29+
process.execPath,
30+
[ '--prof-process', '--preprocess', logfile ],
31+
{ encoding: 'utf8' });
32+
33+
// Make sure that the result is valid JSON.
34+
JSON.parse(stdout);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.