Bug 1329111 - Supply SharedLibraryInfo with the absolute module path and debug path on all platforms. r=marco

MozReview-Commit-ID: 9R3ecPxGoMr

--HG--
extra : rebase_source : 3cc2af0e5c2b40f349f9e77e06731188d9af07ea
This commit is contained in:
Markus Stange 2017-03-14 18:26:50 -04:00
Родитель c76fa9b925
Коммит 13cdaa1908
7 изменённых файлов: 47 добавлений и 20 удалений

Просмотреть файл

@ -638,7 +638,7 @@ void EHAddrSpace::Update() {
// itself.
continue;
EHTable tab(reinterpret_cast<const void *>(lib.GetStart()),
lib.GetEnd() - lib.GetStart(), lib.GetNativeDebugName());
lib.GetEnd() - lib.GetStart(), lib.GetNativeDebugPath());
if (tab.isValid())
tables.push_back(tab);
}

Просмотреть файл

@ -1041,7 +1041,7 @@ AddSharedLibraryInfoToStream(std::ostream& aStream, const SharedLibrary& aLib)
aStream << "\"start\":" << aLib.GetStart();
aStream << ",\"end\":" << aLib.GetEnd();
aStream << ",\"offset\":" << aLib.GetOffset();
aStream << ",\"name\":\"" << aLib.GetNativeDebugName() << "\"";
aStream << ",\"name\":\"" << aLib.GetNativeDebugPath() << "\"";
const std::string& breakpadId = aLib.GetBreakpadId();
aStream << ",\"breakpadId\":\"" << breakpadId << "\"";
aStream << "}";

Просмотреть файл

@ -83,15 +83,18 @@ dl_iterate_callback(struct dl_phdr_info *dl_info, size_t size, void *data)
}
const char *path = dl_info->dlpi_name;
nsAutoString nameStr;
mozilla::Unused << NS_WARN_IF(NS_FAILED(NS_CopyNativeToUnicode(nsDependentCString(path), nameStr)));
nsAutoString pathStr;
mozilla::Unused << NS_WARN_IF(NS_FAILED(NS_CopyNativeToUnicode(nsDependentCString(path), pathStr)));
nsAutoString nameStr = pathStr;
int32_t pos = nameStr.RFindChar('/');
if (pos != kNotFound) {
nameStr.Cut(0, pos + 1);
}
SharedLibrary shlib(libStart, libEnd, 0, getId(path), nameStr, nameStr, "");
SharedLibrary shlib(libStart, libEnd, 0, getId(path),
nameStr, pathStr, nameStr, pathStr,
"");
info.AddSharedLibrary(shlib);
return 0;
@ -158,15 +161,18 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
}
#endif
nsAutoString nameStr;
mozilla::Unused << NS_WARN_IF(NS_FAILED(NS_CopyNativeToUnicode(nsDependentCString(modulePath), nameStr)));
nsAutoString pathStr;
mozilla::Unused << NS_WARN_IF(NS_FAILED(NS_CopyNativeToUnicode(nsDependentCString(modulePath), pathStr)));
nsAutoString nameStr = pathStr;
int32_t pos = nameStr.RFindChar('/');
if (pos != kNotFound) {
nameStr.Cut(0, pos + 1);
}
SharedLibrary shlib(start, end, offset, getId(name), nameStr, nameStr, "");
SharedLibrary shlib(start, end, offset, getId(path),
nameStr, pathStr, nameStr, pathStr,
"");
info.AddSharedLibrary(shlib);
if (count > 10000) {
LOG("Get maps failed");

Просмотреть файл

@ -72,16 +72,18 @@ void addSharedLibrary(const platform_mach_header* header, char *path, SharedLibr
uuid << '0';
}
nsAutoString nameStr;
mozilla::Unused << NS_WARN_IF(NS_FAILED(NS_CopyNativeToUnicode(nsDependentCString(path), nameStr)));
nsAutoString pathStr;
mozilla::Unused << NS_WARN_IF(NS_FAILED(NS_CopyNativeToUnicode(nsDependentCString(path), pathStr)));
nsAutoString nameStr = pathStr;
int32_t pos = nameStr.RFindChar('/');
if (pos != kNotFound) {
nameStr.Cut(0, pos + 1);
}
info.AddSharedLibrary(SharedLibrary(start, start + size, 0, uuid.str(),
nameStr, nameStr, ""));
nameStr, pathStr, nameStr, pathStr,
""));
}
// Use dyld to inspect the macho image information. We can build the SharedLibraryEntry structure

Просмотреть файл

@ -135,6 +135,7 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
for (unsigned int i = 0; i < modulesNum; i++) {
nsID pdbSig;
uint32_t pdbAge;
nsAutoString pdbPathStr;
nsAutoString pdbNameStr;
char *pdbName = NULL;
std::string breakpadId;
@ -175,14 +176,16 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
std::transform(breakpadId.begin(), breakpadId.end(),
breakpadId.begin(), toupper);
pdbNameStr = NS_ConvertUTF8toUTF16(pdbName);
pdbPathStr = NS_ConvertUTF8toUTF16(pdbName);
pdbNameStr = pdbPathStr;
int32_t pos = pdbNameStr.RFindChar('\\');
if (pos != kNotFound) {
pdbNameStr.Cut(0, pos + 1);
}
}
nsAutoString moduleNameStr(modulePath);
nsAutoString modulePathStr(modulePath);
nsAutoString moduleNameStr = modulePathStr;
int32_t pos = moduleNameStr.RFindChar('\\');
if (pos != kNotFound) {
moduleNameStr.Cut(0, pos + 1);
@ -193,7 +196,9 @@ SharedLibraryInfo SharedLibraryInfo::GetInfoForSelf()
0, // DLLs are always mapped at offset 0 on Windows
breakpadId,
moduleNameStr,
modulePathStr,
pdbNameStr,
pdbPathStr,
GetVersion(modulePath));
sharedLibraryInfo.AddSharedLibrary(shlib);

Просмотреть файл

@ -32,7 +32,7 @@ read_procmaps(lul::LUL* aLUL)
for (size_t i = 0; i < info.GetSize(); i++) {
const SharedLibrary& lib = info.GetEntry(i);
std::string nativeName = lib.GetNativeDebugName();
std::string nativePath = lib.GetNativeDebugPath();
# if defined(USE_FAULTY_LIB)
// We're using faulty.lib. Use a special-case object mapper.
@ -46,10 +46,10 @@ read_procmaps(lul::LUL* aLUL)
// to NotifyAfterMap().
void* image = nullptr;
size_t size = 0;
bool ok = mapper.Map(&image, &size, nativeName);
bool ok = mapper.Map(&image, &size, nativePath);
if (ok && image && size > 0) {
aLUL->NotifyAfterMap(lib.GetStart(), lib.GetEnd()-lib.GetStart(),
nativeName.c_str(), image);
nativePath.c_str(), image);
} else if (!ok && lib.GetDebugName().IsEmpty()) {
// The object has no name and (as a consequence) the mapper
// failed to map it. This happens on Linux, where

Просмотреть файл

@ -28,14 +28,18 @@ public:
uintptr_t aOffset,
const std::string& aBreakpadId,
const nsString& aModuleName,
const nsString& aModulePath,
const nsString& aDebugName,
const nsString& aDebugPath,
const std::string& aVersion)
: mStart(aStart)
, mEnd(aEnd)
, mOffset(aOffset)
, mBreakpadId(aBreakpadId)
, mModuleName(aModuleName)
, mModulePath(aModulePath)
, mDebugName(aDebugName)
, mDebugPath(aDebugPath)
, mVersion(aVersion)
{}
@ -45,7 +49,9 @@ public:
, mOffset(aEntry.mOffset)
, mBreakpadId(aEntry.mBreakpadId)
, mModuleName(aEntry.mModuleName)
, mModulePath(aEntry.mModulePath)
, mDebugName(aEntry.mDebugName)
, mDebugPath(aEntry.mDebugPath)
, mVersion(aEntry.mVersion)
{}
@ -59,7 +65,9 @@ public:
mOffset = aEntry.mOffset;
mBreakpadId = aEntry.mBreakpadId;
mModuleName = aEntry.mModuleName;
mModulePath = aEntry.mModulePath;
mDebugName = aEntry.mDebugName;
mDebugPath = aEntry.mDebugPath;
mVersion = aEntry.mVersion;
return *this;
}
@ -70,7 +78,9 @@ public:
(mEnd == other.mEnd) &&
(mOffset == other.mOffset) &&
(mModuleName == other.mModuleName) &&
(mModulePath == other.mModulePath) &&
(mDebugName == other.mDebugName) &&
(mDebugPath == other.mDebugPath) &&
(mBreakpadId == other.mBreakpadId) &&
(mVersion == other.mVersion);
}
@ -80,14 +90,16 @@ public:
uintptr_t GetOffset() const { return mOffset; }
const std::string &GetBreakpadId() const { return mBreakpadId; }
const nsString &GetModuleName() const { return mModuleName; }
const std::string GetNativeDebugName() const {
nsAutoCString debugNameStr;
const nsString &GetModulePath() const { return mModulePath; }
const std::string GetNativeDebugPath() const {
nsAutoCString debugPathStr;
NS_CopyUnicodeToNative(mDebugName, debugNameStr);
NS_CopyUnicodeToNative(mDebugPath, debugPathStr);
return debugNameStr.get();
return debugPathStr.get();
}
const nsString &GetDebugName() const { return mDebugName; }
const nsString &GetDebugPath() const { return mDebugPath; }
const std::string &GetVersion() const { return mVersion; }
private:
@ -98,7 +110,9 @@ private:
uintptr_t mOffset;
std::string mBreakpadId;
nsString mModuleName;
nsString mModulePath;
nsString mDebugName;
nsString mDebugPath;
std::string mVersion;
};