Skip to content

Commit

Permalink
lib: make tick processor detect xcodebuild errors
Browse files Browse the repository at this point in the history
`node --prof-process` on macOS calls out to nm(1) to look up C++
symbols. If Xcode hasn't been properly installed or its license
hasn't been accepted yet, it prints out an error and exits.

Before this commit, that error was swallowed and the output of
the tick processor was not showing the C++ entry points.

This commit detects that error message and turns it into an
exception. No regression test because this particular condition
is hard to test for without going to extreme lengths to mock
the output of nm.

Fixes: #29804

PR-URL: #29830
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
bnoordhuis authored and BridgeAR committed Oct 9, 2019
1 parent 600478a commit 60296a3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/internal/v8_prof_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ const os = {
}
let out = cp.spawnSync(name, args).stdout.toString();
// Auto c++filt names, but not [iItT]
if (process.platform === 'darwin' && name === 'nm')
if (process.platform === 'darwin' && name === 'nm') {
// nm prints an error along the lines of "Run xcodebuild -license" and
// exits when Xcode hasn't been properly installed or when its license
// hasn't been accepted yet. Basically any mention of xcodebuild in
// the output means the nm command is non-functional.
const match = out.match(/(?:^|\n)([^\n]*xcodebuild[^\n]*)(?:\n|$)/);
if (match) throw new Error(match[1]);
out = macCppfiltNm(out);
}
return out;
}
};
Expand Down

0 comments on commit 60296a3

Please sign in to comment.