Bug 1350500 - Compute the breakpadId for Firefox libraries on Android by mapping them into memory. r=glandium
authorMarkus Stange <mstange@themasta.com>
Fri, 27 Apr 2018 19:51:20 +0900
changeset 416039 81e24b24a789631e7271721fc59eb3a9a36d9b08
parent 416038 b543167ab064bc66d789e54711243fda677a453f
child 416040 cdd70d25704ec2791fe02cd26104b8fd7b45df34
push id33915
push userncsoregi@mozilla.com
push dateFri, 27 Apr 2018 21:53:44 +0000
treeherdermozilla-central@8b2c1fc3d6c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1350500
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1350500 - Compute the breakpadId for Firefox libraries on Android by mapping them into memory. r=glandium
tools/profiler/core/shared-libraries-linux.cc
tools/profiler/moz.build
--- a/tools/profiler/core/shared-libraries-linux.cc
+++ b/tools/profiler/core/shared-libraries-linux.cc
@@ -25,16 +25,17 @@
 #include <algorithm>
 #include <dlfcn.h>
 #include <features.h>
 #include <sys/types.h>
 
 #if defined(GP_OS_linux)
 # include <link.h>      // dl_phdr_info
 #elif defined(GP_OS_android)
+# include "AutoObjectMapper.h"
 # include "ElfLoader.h" // dl_phdr_info
 extern "C" MOZ_EXPORT __attribute__((weak))
 int dl_iterate_phdr(
           int (*callback)(struct dl_phdr_info *info, size_t size, void *data),
           void *data);
 #else
 # error "Unexpected configuration"
 #endif
@@ -43,16 +44,29 @@ int dl_iterate_phdr(
 static std::string getId(const char *bin_name)
 {
   using namespace google_breakpad;
   using namespace std;
 
   PageAllocator allocator;
   auto_wasteful_vector<uint8_t, sizeof(MDGUID)> identifier(&allocator);
 
+#if defined(GP_OS_android)
+  if (nsCString(bin_name).Find("!/") != kNotFound) {
+    AutoObjectMapperFaultyLib mapper(nullptr);
+    void* image = nullptr;
+    size_t size = 0;
+    if (mapper.Map(&image, &size, bin_name) && image && size) {
+      if (FileID::ElfFileIdentifierFromMappedFile(image, identifier)) {
+        return FileID::ConvertIdentifierToUUIDString(identifier) + "0";
+      }
+    }
+  }
+#endif
+
   FileID file_id(bin_name);
   if (file_id.ElfFileIdentifier(identifier)) {
     return FileID::ConvertIdentifierToUUIDString(identifier) + "0";
   }
 
   return "";
 }
 
--- a/tools/profiler/moz.build
+++ b/tools/profiler/moz.build
@@ -94,16 +94,17 @@ if CONFIG['MOZ_GECKO_PROFILER']:
     ]
 
     if CONFIG['OS_TARGET'] == 'Android':
         DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION']
         DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION']
         LOCAL_INCLUDES += [
             # We need access to Breakpad's getcontext(3) which is suitable for Android
             '/toolkit/crashreporter/google-breakpad/src/common/android/include',
+            'lul',
         ]
 
     if not CONFIG['MOZ_CRASHREPORTER'] and CONFIG['OS_TARGET'] == 'Android':
         SOURCES += ['/toolkit/crashreporter/google-breakpad/src/common/android/breakpad_getcontext.S']
 
     if CONFIG['ENABLE_TESTS']:
         DIRS += ['tests/gtest']