Skip to content
Permalink
Browse files

lib: make tick processor detect xcodebuild errors

`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 <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
bnoordhuis authored and Trott committed Oct 3, 2019
1 parent afdc3d0 commit 870eea303ad4f7d821b558d0f6fefbe738c33afc
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/internal/v8_prof_polyfill.js
@@ -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;
}
};

0 comments on commit 870eea3

Please sign in to comment.
You can’t perform that action at this time.