Skip to content

Commit 87c3e1d

Browse files
davidmarkclementsMylesBorins
davidmarkclements
authored andcommitted
fix --prof-process --preprocess flag
This is a one-line fix to prevent the --preprocess option (used with --prof-process to output JSON) to cause an isolate log file profiling process to crash. PR-URL: #14966 Reviewed-By: Luca Maraschi <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 36b8b46 commit 87c3e1d

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

lib/internal/v8_prof_processor.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if (process.platform === 'darwin') {
3232
tickArguments.push.apply(tickArguments, process.argv.slice(1));
3333
script = `(function() {
3434
arguments = ${JSON.stringify(tickArguments)};
35+
function write (s) { process.stdout.write(s) }
3536
${script}
3637
})()`;
3738
eval(script);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
if (!common.enoughTestCpu)
5+
common.skip('test is CPU-intensive');
6+
7+
if (common.isWindows ||
8+
common.isSunOS ||
9+
common.isAIX ||
10+
common.isLinuxPPCBE ||
11+
common.isFreeBSD)
12+
common.skip('C++ symbols are not mapped for this os.');
13+
14+
const base = require('./tick-processor-base.js');
15+
16+
base.runTest({
17+
pattern: /^{/,
18+
code: `function f() {
19+
require('vm').runInDebugContext('Debug');
20+
setImmediate(function() { f(); });
21+
};
22+
f();`,
23+
profProcessFlags: ['--preprocess']
24+
});

test/tick-processor/tick-processor-base.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,25 @@ function runTest(test) {
2424

2525
// Try to match after timeout
2626
setTimeout(() => {
27-
match(test.pattern, proc, () => ticks);
27+
match(test.pattern, proc, () => ticks, test.profProcessFlags);
2828
}, RETRY_TIMEOUT);
2929
}
3030

31-
function match(pattern, parent, ticks) {
31+
function match(pattern, parent, ticks, flags = []) {
3232
// Store current ticks log
3333
fs.writeFileSync(LOG_FILE, ticks());
3434

3535
const proc = cp.spawn(process.execPath, [
3636
'--prof-process',
3737
'--call-graph-size=10',
38+
...flags,
3839
LOG_FILE
3940
], {
4041
stdio: [ 'ignore', 'pipe', 'inherit' ]
4142
});
4243

4344
let out = '';
45+
4446
proc.stdout.on('data', (chunk) => out += chunk);
4547
proc.stdout.once('end', () => {
4648
proc.once('exit', () => {

0 commit comments

Comments
 (0)