Bug 1362861 - Pass the correct arch to nm on macOS. r=kmag
☠☠ backed out by 1343bf52cbfd ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Sun, 07 May 2017 11:30:01 -0400
changeset 391192 7cbae2bf514b54047a56cd3e4f2981b563c4b04c
parent 391191 903d3921e250855908266e5c31d7ef29eec20b46
child 391193 c7d2423b811173432615090f5e4b8b45698d3c9b
push id53
push userfmarier@mozilla.com
push dateMon, 15 May 2017 17:28:28 +0000
reviewerskmag
bugs1362861
milestone55.0a1
Bug 1362861 - Pass the correct arch to nm on macOS. r=kmag MozReview-Commit-ID: C8vfSUu8dM8
browser/components/extensions/ext-geckoProfiler.js
--- a/browser/components/extensions/ext-geckoProfiler.js
+++ b/browser/components/extensions/ext-geckoProfiler.js
@@ -131,21 +131,23 @@ async function spawnProcess(name, cmdArg
     const encoder = new TextEncoder("utf-8");
     proc.stdin.write(encoder.encode(stdin));
     proc.stdin.close();
   }
 
   await readAllData(proc.stdout, processData);
 }
 
-async function getSymbolsFromNM(path) {
+async function getSymbolsFromNM(path, arch) {
   const parser = new NMParser();
 
   const args = [path];
-  if (Services.appinfo.OS !== "Darwin") {
+  if (Services.appinfo.OS === "Darwin") {
+    args.unshift("-arch", arch);
+  } else {
     // Mac's `nm` doesn't support the demangle option, so we have to
     // post-process the symbols with c++filt.
     args.unshift("--demangle");
   }
 
   await spawnProcess("nm", args, data => parser.consume(data));
   await spawnProcess("nm", ["-D", ...args], data => parser.consume(data));
   let {syms, approximateLength} = parser.finish();
@@ -204,18 +206,18 @@ function filePathForSymFileInObjDir(bina
   return OS.Path.join(objDirDist,
                       "crashreporter-symbols",
                       ...pathComponentsForSymbolFile(debugName, breakpadId));
 }
 
 const symbolCache = new Map();
 
 function primeSymbolStore(libs) {
-  for (const {debugName, breakpadId, path} of libs) {
-    symbolCache.set(urlForSymFile(debugName, breakpadId), path);
+  for (const {debugName, breakpadId, path, arch} of libs) {
+    symbolCache.set(urlForSymFile(debugName, breakpadId), {path, arch});
   }
 }
 
 const isRunningObserver = {
   _observers: new Set(),
 
   observe(subject, topic, data) {
     switch (topic) {
@@ -300,17 +302,17 @@ this.geckoProfiler = class extends Exten
           return Services.profiler.getProfileDataAsync();
         },
 
         async getSymbols(debugName, breakpadId) {
           if (symbolCache.size === 0) {
             primeSymbolStore(Services.profiler.sharedLibraries);
           }
 
-          const path = symbolCache.get(urlForSymFile(debugName, breakpadId));
+          const {path, arch} = symbolCache.get(urlForSymFile(debugName, breakpadId));
 
           const symbolRules = Services.prefs.getCharPref(PREF_GET_SYMBOL_RULES, "localBreakpad,remoteBreakpad");
           const haveAbsolutePath = path && OS.Path.split(path).absolute;
 
           // We have multiple options for obtaining symbol information for the given
           // binary.
           //  "localBreakpad"  - Use existing symbol dumps stored in the object directory of a local
           //      Firefox build, generated using `mach buildsymbols` [requires path]
@@ -330,17 +332,17 @@ this.geckoProfiler = class extends Exten
                       return await parseSym({filepath});
                     }
                   }
                   break;
                 case "remoteBreakpad":
                   const url = urlForSymFile(debugName, breakpadId);
                   return await parseSym({url});
                 case "nm":
-                  return await getSymbolsFromNM(path);
+                  return await getSymbolsFromNM(path, arch);
               }
             } catch (e) {
               // Each of our options can go wrong for a variety of reasons, so on failure
               // we will try the next one.
               // "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.
               // "remoteBreakpad" will fail if this is not an official mozilla build (e.g. Nightly) or a
               // known system library.