Bug 1423000 - Always log allocator function calls. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 30 Nov 2017 07:55:12 +0900
changeset 394986 fb91909e795aa37be434b56fcb69a9073573f572
parent 394985 eecbbe09235b0b63eb56702f096073fe6afc8db3
child 394987 d0de68944d4697e0f6153a5e5b15c8759aab2a06
push id33029
push usercsabou@mozilla.com
push dateTue, 05 Dec 2017 22:05:52 +0000
treeherdermozilla-central@f84f292333c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1423000
milestone59.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 1423000 - Always log allocator function calls. r=njn So far, logalloc has avoided logging calls that e.g. return null pointers, but both to make the code more generic and to enable logging of error conditions, we now log every call.
memory/replace/logalloc/LogAlloc.cpp
--- a/memory/replace/logalloc/LogAlloc.cpp
+++ b/memory/replace/logalloc/LogAlloc.cpp
@@ -77,100 +77,84 @@ class LogAllocBridge : public ReplaceMal
  * before any other allocation/free happens.
  */
 
 static void*
 replace_malloc(size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.malloc(aSize);
-  if (ptr) {
-    FdPrintf(sFd, "%zu %zu malloc(%zu)=%p\n", GetPid(), GetTid(), aSize, ptr);
-  }
+  FdPrintf(sFd, "%zu %zu malloc(%zu)=%p\n", GetPid(), GetTid(), aSize, ptr);
   return ptr;
 }
 
 static int
 replace_posix_memalign(void** aPtr, size_t aAlignment, size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   int ret = sFuncs.posix_memalign(aPtr, aAlignment, aSize);
-  if (ret == 0) {
-    FdPrintf(sFd, "%zu %zu posix_memalign(%zu,%zu)=%p\n", GetPid(), GetTid(),
-             aAlignment, aSize, *aPtr);
-  }
+  FdPrintf(sFd, "%zu %zu posix_memalign(%zu,%zu)=%p\n", GetPid(), GetTid(),
+           aAlignment, aSize, (ret == 0) ? *aPtr : nullptr);
   return ret;
 }
 
 static void*
 replace_aligned_alloc(size_t aAlignment, size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.aligned_alloc(aAlignment, aSize);
-  if (ptr) {
-    FdPrintf(sFd, "%zu %zu aligned_alloc(%zu,%zu)=%p\n", GetPid(), GetTid(),
-             aAlignment, aSize, ptr);
-  }
+  FdPrintf(sFd, "%zu %zu aligned_alloc(%zu,%zu)=%p\n", GetPid(), GetTid(),
+           aAlignment, aSize, ptr);
   return ptr;
 }
 
 static void*
 replace_calloc(size_t aNum, size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.calloc(aNum, aSize);
-  if (ptr) {
-    FdPrintf(sFd, "%zu %zu calloc(%zu,%zu)=%p\n", GetPid(), GetTid(), aNum,
-             aSize, ptr);
-  }
+  FdPrintf(sFd, "%zu %zu calloc(%zu,%zu)=%p\n", GetPid(), GetTid(), aNum,
+           aSize, ptr);
   return ptr;
 }
 
 static void*
 replace_realloc(void* aPtr, size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* new_ptr = sFuncs.realloc(aPtr, aSize);
-  if (new_ptr || !aSize) {
-    FdPrintf(sFd, "%zu %zu realloc(%p,%zu)=%p\n", GetPid(), GetTid(), aPtr,
-             aSize, new_ptr);
-  }
+  FdPrintf(sFd, "%zu %zu realloc(%p,%zu)=%p\n", GetPid(), GetTid(), aPtr,
+           aSize, new_ptr);
   return new_ptr;
 }
 
 static void
 replace_free(void* aPtr)
 {
   MutexAutoLock lock(sMutex);
-  if (aPtr) {
-    FdPrintf(sFd, "%zu %zu free(%p)\n", GetPid(), GetTid(), aPtr);
-  }
+  FdPrintf(sFd, "%zu %zu free(%p)\n", GetPid(), GetTid(), aPtr);
   sFuncs.free(aPtr);
 }
 
 static void*
 replace_memalign(size_t aAlignment, size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.memalign(aAlignment, aSize);
-  if (ptr) {
-    FdPrintf(sFd, "%zu %zu memalign(%zu,%zu)=%p\n", GetPid(), GetTid(),
-             aAlignment, aSize, ptr);
-  }
+  FdPrintf(sFd, "%zu %zu memalign(%zu,%zu)=%p\n", GetPid(), GetTid(),
+           aAlignment, aSize, ptr);
   return ptr;
 }
 
 static void*
 replace_valloc(size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.valloc(aSize);
-  if (ptr) {
-    FdPrintf(sFd, "%zu %zu valloc(%zu)=%p\n", GetPid(), GetTid(), aSize, ptr);
-  }
+  FdPrintf(sFd, "%zu %zu valloc(%zu)=%p\n", GetPid(), GetTid(), aSize, ptr);
   return ptr;
 }
 
 static void
 replace_jemalloc_stats(jemalloc_stats_t* aStats)
 {
   MutexAutoLock lock(sMutex);
   sFuncs.jemalloc_stats(aStats);