Bug 1339695 (part 3) - Introduce USE_FAULTY_LIB. r=jseward.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 15 Feb 2017 16:24:35 +1100
changeset 343215 b735a190b14f0a5ea0f0ccb0793624dd89291055
parent 343214 f6869c7b0707091d551285243c43993d7b235265
child 343216 002e9c45f121f951f205cc3d3ec7fb563f5a831c
push id31372
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:16:10 +0000
treeherdermozilla-central@2737f66ad6ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjseward
bugs1339695
milestone54.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 1339695 (part 3) - Introduce USE_FAULTY_LIB. r=jseward. This factors out some common preprocessor conditions.
tools/profiler/lul/AutoObjectMapper.cpp
tools/profiler/lul/AutoObjectMapper.h
tools/profiler/lul/platform-linux-lul.cpp
--- a/tools/profiler/lul/AutoObjectMapper.cpp
+++ b/tools/profiler/lul/AutoObjectMapper.cpp
@@ -11,17 +11,17 @@
 #include <fcntl.h>
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Sprintf.h"
 
 #include "PlatformMacros.h"
 #include "AutoObjectMapper.h"
 
-#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
+#if defined(USE_FAULTY_LIB)
 # include <dlfcn.h>
 # include "mozilla/Types.h"
   // FIXME move these out of mozglue/linker/ElfLoader.h into their
   // own header, so as to avoid conflicts arising from two definitions
   // of Array
   extern "C" {
     MFBT_API size_t
     __dl_get_mappable_length(void *handle);
@@ -103,17 +103,17 @@ bool AutoObjectMapperPOSIX::Map(/*OUT*/v
   close(fd);
   mIsMapped = true;
   mImage = *start  = image;
   mSize  = *length = sz;
   return true;
 }
 
 
-#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
+#if defined(USE_FAULTY_LIB)
 // A helper function for AutoObjectMapperFaultyLib::Map.  Finds out
 // where the installation's lib directory is, since we'll have to look
 // in there to get hold of libmozglue.so.  Returned C string is heap
 // allocated and the caller must deallocate it.
 static char*
 get_installation_lib_dir()
 {
   nsCOMPtr<nsIProperties>
@@ -199,9 +199,9 @@ bool AutoObjectMapperFaultyLib::Map(/*OU
 
     mHdl   = hdl;
     mImage = *start  = image;
     mSize  = *length = sz;
     return true;
   }
 }
 
-#endif // defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
+#endif // defined(USE_FAULTY_LIB)
--- a/tools/profiler/lul/AutoObjectMapper.h
+++ b/tools/profiler/lul/AutoObjectMapper.h
@@ -7,16 +7,20 @@
 #ifndef AutoObjectMapper_h
 #define AutoObjectMapper_h
 
 #include <string>
 
 #include "mozilla/Attributes.h"
 #include "PlatformMacros.h"
 
+#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
+#define USE_FAULTY_LIB
+#endif
+
 // A (nearly-) RAII class that maps an object in and then unmaps it on
 // destruction.  This base class version uses the "normal" POSIX
 // functions: open, fstat, close, mmap, munmap.
 
 class MOZ_STACK_CLASS AutoObjectMapperPOSIX {
 public:
   // The constructor does not attempt to map the file, because that
   // might fail.  Instead, once the object has been constructed,
@@ -56,18 +60,17 @@ private:
   AutoObjectMapperPOSIX& operator=(const AutoObjectMapperPOSIX&);
   // Disable heap allocation of this class.
   void* operator new(size_t);
   void* operator new[](size_t);
   void  operator delete(void*);
   void  operator delete[](void*);
 };
 
-
-#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
+#if defined(USE_FAULTY_LIB)
 // This is a variant of AutoObjectMapperPOSIX suitable for use in
 // conjunction with faulty.lib on Android.  How it behaves depends on
 // the name of the file to be mapped.  There are three possible cases:
 //
 // (1) /foo/bar/xyzzy/blah.apk!/libwurble.so
 //     We hand it as-is to faulty.lib and let it fish the relevant
 //     bits out of the APK.
 //
@@ -105,11 +108,11 @@ private:
   AutoObjectMapperFaultyLib& operator=(const AutoObjectMapperFaultyLib&);
   // Disable heap allocation of this class.
   void* operator new(size_t);
   void* operator new[](size_t);
   void  operator delete(void*);
   void  operator delete[](void*);
 };
 
-#endif // defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
+#endif // defined(USE_FAULTY_LIB)
 
 #endif // AutoObjectMapper_h
--- a/tools/profiler/lul/platform-linux-lul.cpp
+++ b/tools/profiler/lul/platform-linux-lul.cpp
@@ -27,17 +27,17 @@ read_procmaps(lul::LUL* aLUL)
   MOZ_ASSERT(aLUL->CountMappings() == 0);
 
 # if defined(SPS_OS_linux) || defined(SPS_OS_android) || defined(SPS_OS_darwin)
   SharedLibraryInfo info = SharedLibraryInfo::GetInfoForSelf();
 
   for (size_t i = 0; i < info.GetSize(); i++) {
     const SharedLibrary& lib = info.GetEntry(i);
 
-#   if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
+#   if defined(USE_FAULTY_LIB)
     // We're using faulty.lib.  Use a special-case object mapper.
     AutoObjectMapperFaultyLib mapper(aLUL->mLog);
 #   else
     // We can use the standard POSIX-based mapper.
     AutoObjectMapperPOSIX mapper(aLUL->mLog);
 #   endif
 
     // Ask |mapper| to map the object.  Then hand its mapped address