Skip to content

Commit

Permalink
fix --prof-process --preprocess flag
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
davidmarkclements authored and MylesBorins committed Sep 12, 2017
1 parent 36b8b46 commit 87c3e1d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/internal/v8_prof_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if (process.platform === 'darwin') {
tickArguments.push.apply(tickArguments, process.argv.slice(1));
script = `(function() {
arguments = ${JSON.stringify(tickArguments)};
function write (s) { process.stdout.write(s) }
${script}
})()`;
eval(script);
24 changes: 24 additions & 0 deletions test/tick-processor/test-tick-processor-preprocess-flag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';
const common = require('../common');

if (!common.enoughTestCpu)
common.skip('test is CPU-intensive');

if (common.isWindows ||
common.isSunOS ||
common.isAIX ||
common.isLinuxPPCBE ||
common.isFreeBSD)
common.skip('C++ symbols are not mapped for this os.');

const base = require('./tick-processor-base.js');

base.runTest({
pattern: /^{/,
code: `function f() {
require('vm').runInDebugContext('Debug');
setImmediate(function() { f(); });
};
f();`,
profProcessFlags: ['--preprocess']
});
6 changes: 4 additions & 2 deletions test/tick-processor/tick-processor-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@ function runTest(test) {

// Try to match after timeout
setTimeout(() => {
match(test.pattern, proc, () => ticks);
match(test.pattern, proc, () => ticks, test.profProcessFlags);
}, RETRY_TIMEOUT);
}

function match(pattern, parent, ticks) {
function match(pattern, parent, ticks, flags = []) {
// Store current ticks log
fs.writeFileSync(LOG_FILE, ticks());

const proc = cp.spawn(process.execPath, [
'--prof-process',
'--call-graph-size=10',
...flags,
LOG_FILE
], {
stdio: [ 'ignore', 'pipe', 'inherit' ]
});

let out = '';

proc.stdout.on('data', (chunk) => out += chunk);
proc.stdout.once('end', () => {
proc.once('exit', () => {
Expand Down

0 comments on commit 87c3e1d

Please sign in to comment.