diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2019-10-03 10:53:42 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-10-06 05:21:07 +0300 |
commit | 870eea303ad4f7d821b558d0f6fefbe738c33afc (patch) | |
tree | b078e8e62f5be68e4d4beb004db173e007330a41 /lib/internal/v8_prof_polyfill.js | |
parent | afdc3d0d187e4e3a336937df17a4c90092405e2a (diff) |
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: https://github.com/nodejs/node/issues/29804
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib/internal/v8_prof_polyfill.js')
-rw-r--r-- | lib/internal/v8_prof_polyfill.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/internal/v8_prof_polyfill.js b/lib/internal/v8_prof_polyfill.js index 59e1b8947ee..7d8d3ff0202 100644 --- a/lib/internal/v8_prof_polyfill.js +++ b/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; } }; |