Bug 1414383 - Return an error if nm requires xcode license to be accepted during symbolication r=mstange
authorNazım Can Altınova <canaltinova@gmail.com>
Tue, 09 Oct 2018 03:08:43 +0000
changeset 488556 39ca0cb416f9da20198b93a3214df1aa2683efcc
parent 488555 1bae9022b97eed6aa80b4c6beb800eb7e105ce7e
child 488557 43866f1787dbd36e32b90bd472715344106f3025
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersmstange
bugs1414383
milestone64.0a1
Bug 1414383 - Return an error if nm requires xcode license to be accepted during symbolication r=mstange Differential Revision: https://phabricator.services.mozilla.com/D8037
browser/components/extensions/parent/ext-geckoProfiler.js
--- a/browser/components/extensions/parent/ext-geckoProfiler.js
+++ b/browser/components/extensions/parent/ext-geckoProfiler.js
@@ -86,16 +86,17 @@ const spawnProcess = async function(name
 
   if (stdin) {
     const encoder = new TextEncoder("utf-8");
     proc.stdin.write(encoder.encode(stdin));
     proc.stdin.close();
   }
 
   await readAllData(proc.stdout, processData);
+  return proc.exitCode;
 };
 
 const runCommandAndGetOutputAsString = async function(command, cmdArgs) {
   const opts = {
     command,
     arguments: cmdArgs,
     stderr: "pipe",
   };
@@ -108,17 +109,23 @@ const runCommandAndGetOutputAsString = a
 const getSymbolsFromNM = async function(path, arch) {
   const parser = new NMParser();
 
   const args = [path];
   if (Services.appinfo.OS === "Darwin") {
     args.unshift("-arch", arch);
   }
 
-  await spawnProcess("nm", args, data => parser.consume(data));
+  const exitCode = await spawnProcess("nm", args, data => parser.consume(data));
+  if (exitCode === 69) {
+    throw new ExtensionError("Symbolication requires the Xcode command line tools to be installed " +
+                             "and the license accepted. Please run the following from the command " +
+                             "line to accept the xcode license:\n\n" +
+                             "sudo xcodebuild -license");
+  }
   if (Services.appinfo.OS !== "Darwin") {
     // Darwin nm does not support the -D option.
     await spawnProcess("nm", ["-D", ...args], data => parser.consume(data));
   }
   return parser.finish();
 };
 
 const getEnvVarCaseInsensitive = function(env, name) {
@@ -405,22 +412,26 @@ this.geckoProfiler = class extends Exten
                     previouslySuccessfulDumpSymsPath = dumpSymsPath;
                     return result;
                   }
                   break;
               }
             } catch (e) {
               // Each of our options can go wrong for a variety of reasons, so on failure
               // we will try the next one.
+              // But we should still throw the explicit ExtensionErrors if there are any.
               // "localBreakpad" will fail if this is not a local build that's running from the object
               // directory or if the user hasn't run `mach buildsymbols` on it.
               // "nm" will fail if `nm` is not available.
               // "dump_syms.exe" will fail if this is not a local build that's running from the object
               // directory, or if dump_syms.exe doesn't exist in the object directory, or if
               // dump_syms.exe failed for other reasons.
+              if (e instanceof ExtensionError) {
+                throw e;
+              }
             }
           }
 
           throw new Error(`Ran out of options to get symbols from library ${debugName} ${breakpadId}.`);
         },
 
         onRunning: new EventManager({
           context,