Skip to content

Commit

Permalink
Bug 1510574 - Remove shared memory segments from generated minidumps …
Browse files Browse the repository at this point in the history
…to cut down on the number of modules r=ted

Differential Revision: https://phabricator.services.mozilla.com/D16188

--HG--
extra : moz-landing-system : lando
  • Loading branch information
gabrielesvelto committed Jan 11, 2019
1 parent 2a44f0a commit a735a55
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ static const int DT_ANDROID_RELA = DT_LOOS + 4;
static const char kMappedFileUnsafePrefix[] = "/dev/";
static const char kDeletedSuffix[] = " (deleted)";
static const char kReservedFlags[] = " ---p";
static const char kMozillaIpcPrefix[] = "org.mozilla.ipc.";
static const char kChromiumPrefix[] = "org.chromium.";

inline static bool IsMappedFileOpenUnsafe(
const google_breakpad::MappingInfo& mapping) {
Expand Down Expand Up @@ -572,6 +574,16 @@ bool LinuxDumper::ReadAuxv() {
return res;
}

bool LinuxDumper::IsIPCSharedMemorySegment(const char* name) {
if ((my_strstr(name, kMozillaIpcPrefix) ||
my_strstr(name, kChromiumPrefix)) &&
my_strstr(name, kDeletedSuffix)) {
return true;
}

return false;
}

bool LinuxDumper::EnumerateMappings() {
char maps_path[NAME_MAX];
if (!BuildProcPath(maps_path, pid_, "maps"))
Expand Down Expand Up @@ -617,6 +629,11 @@ bool LinuxDumper::EnumerateMappings() {
name = kLinuxGateLibraryName;
offset = 0;
}
// Skip shared memory segments used for IPC
if (name && IsIPCSharedMemorySegment(name)) {
line_reader->PopLine(line_len);
continue;
}
// Merge adjacent mappings into one module, assuming they're a single
// library mapped by the dynamic linker.
if (name && !mappings_.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,10 @@ class LinuxDumper {
// Info from /proc/<pid>/auxv
wasteful_vector<elf_aux_val_t> auxv_;

private:
bool IsIPCSharedMemorySegment(const char* name);

#if defined(__ANDROID__)
private:
// Android M and later support packed ELF relocations in shared libraries.
// Packing relocations changes the vaddr of the LOAD segments, such that
// the effective load bias is no longer the same as the start address of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ const char* my_strrchr(const char* haystack, char needle) {
return ret;
}

const char* my_strstr(const char* haystack, const char* needle) {
while (*haystack != 0) {
if((*haystack == *needle) &&
(my_strncmp(haystack, needle, my_strlen(needle)) == 0)) {
return haystack;
}
haystack++;
}
return nullptr;
}

void* my_memchr(const void* src, int needle, size_t src_len) {
const unsigned char* p = (const unsigned char*)src;
const unsigned char* p_end = p + src_len;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ extern const char* my_strchr(const char* haystack, char needle);

extern const char* my_strrchr(const char* haystack, char needle);

extern const char *my_strstr(const char *haystack, const char *needle);

// Read a hex value
// result: (output) the resulting value
// s: a string
Expand Down

0 comments on commit a735a55

Please sign in to comment.