Bug 1350500 - Compute the breakpadId for Firefox libraries on Android by mapping them into memory. r?glandium
MozReview-Commit-ID: 6OevthY6uWk
--- 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
@@ -91,16 +91,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['ANDROID_CPU_ARCH'] == 'armeabi':
DEFINES['ARCH_ARMV6'] = True