Bug 1329111 - Record shared library architecture on Mac. r=glandium,njn

This is interesting information on Mac because some system libraries come in
two 64 bit versions: a regular one, and one that contains Haswell-specific
instructions. The former 'architecture' is called x86_64 and the latter is
called x86_64h (h for Haswell).

We set arch to the empty string on non-Mac platforms. It's not all that
interesting on those platforms because there will be only one architecture
in the binary at the given path, unlike on Mac where you can have fat
binaries with multiple architectures.

MozReview-Commit-ID: Dgnslv0D3Ug

--HG--
extra : rebase_source : cf1fcfc1635d373eaeea35aad2f73b235097c748
This commit is contained in:
Markus Stange 2017-03-13 17:51:41 -04:00
parent 13cdaa1908
commit 5fdbdd6b74
4 changed files with 19 additions and 6 deletions

View File

@ -94,7 +94,7 @@ dl_iterate_callback(struct dl_phdr_info *dl_info, size_t size, void *data)
SharedLibrary shlib(libStart, libEnd, 0, getId(path),
nameStr, pathStr, nameStr, pathStr,
"");
"", "");
info.AddSharedLibrary(shlib);
return 0;
@ -172,7 +172,7 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
SharedLibrary shlib(start, end, offset, getId(path),
nameStr, pathStr, nameStr, pathStr,
"");
"", "");
info.AddSharedLibrary(shlib);
if (count > 10000) {
LOG("Get maps failed");

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <AvailabilityMacros.h>
#include <mach-o/arch.h>
#include <mach-o/loader.h>
#include <mach-o/dyld_images.h>
#include <mach/task_info.h>
@ -81,9 +82,13 @@ void addSharedLibrary(const platform_mach_header* header, char *path, SharedLibr
nameStr.Cut(0, pos + 1);
}
const NXArchInfo* archInfo =
NXGetArchInfoFromCpuType(header->cputype, header->cpusubtype);
info.AddSharedLibrary(SharedLibrary(start, start + size, 0, uuid.str(),
nameStr, pathStr, nameStr, pathStr,
""));
"",
archInfo ? archInfo->name : ""));
}
// Use dyld to inspect the macho image information. We can build the SharedLibraryEntry structure

View File

@ -199,7 +199,8 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
modulePathStr,
pdbNameStr,
pdbPathStr,
GetVersion(modulePath));
GetVersion(modulePath),
"");
sharedLibraryInfo.AddSharedLibrary(shlib);
FreeLibrary(handleLock); // ok to free null handles

View File

@ -31,7 +31,8 @@ public:
const nsString& aModulePath,
const nsString& aDebugName,
const nsString& aDebugPath,
const std::string& aVersion)
const std::string& aVersion,
const char* aArch)
: mStart(aStart)
, mEnd(aEnd)
, mOffset(aOffset)
@ -41,6 +42,7 @@ public:
, mDebugName(aDebugName)
, mDebugPath(aDebugPath)
, mVersion(aVersion)
, mArch(aArch)
{}
SharedLibrary(const SharedLibrary& aEntry)
@ -53,6 +55,7 @@ public:
, mDebugName(aEntry.mDebugName)
, mDebugPath(aEntry.mDebugPath)
, mVersion(aEntry.mVersion)
, mArch(aEntry.mArch)
{}
SharedLibrary& operator=(const SharedLibrary& aEntry)
@ -69,6 +72,7 @@ public:
mDebugName = aEntry.mDebugName;
mDebugPath = aEntry.mDebugPath;
mVersion = aEntry.mVersion;
mArch = aEntry.mArch;
return *this;
}
@ -82,7 +86,8 @@ public:
(mDebugName == other.mDebugName) &&
(mDebugPath == other.mDebugPath) &&
(mBreakpadId == other.mBreakpadId) &&
(mVersion == other.mVersion);
(mVersion == other.mVersion) &&
(mArch == other.mArch);
}
uintptr_t GetStart() const { return mStart; }
@ -101,6 +106,7 @@ public:
const nsString &GetDebugName() const { return mDebugName; }
const nsString &GetDebugPath() const { return mDebugPath; }
const std::string &GetVersion() const { return mVersion; }
const std::string &GetArch() const { return mArch; }
private:
SharedLibrary() {}
@ -114,6 +120,7 @@ private:
nsString mDebugName;
nsString mDebugPath;
std::string mVersion;
std::string mArch;
};
static bool