From d8b6060f045d93d6b0cfb6a0d8e80fc100df1749 Mon Sep 17 00:00:00 2001 From: "glider@chromium.org" <glider@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Fri, 26 Mar 2010 09:41:22 +0000 Subject: [PATCH] Add the linux_use_heapchecker GYP variable that should turn the tcmalloc heap lleak checker on and off. Review URL: http://codereview.chromium.org/1334002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42740 0039d316-1c4b-4281-b951-d872f2087c98 --- base/allocator/allocator.gyp | 14 ++++++++++++-- base/leak_annotations.h | 2 +- build/build_config.h | 5 +++++ build/common.gypi | 9 +++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/base/allocator/allocator.gyp b/base/allocator/allocator.gyp index 0734d2eba215e..b8df28ff13aba 100644 --- a/base/allocator/allocator.gyp +++ b/base/allocator/allocator.gyp @@ -332,9 +332,19 @@ # Do the same for heap leak checker. '-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi', '-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl', + ]}, + }], + [ 'linux_use_heapchecker==0', { + # Do not compile and link the heapchecker source. + 'sources!': [ + '<(tcmalloc_dir)/src/heap-checker-bcad.cc', + '<(tcmalloc_dir)/src/heap-checker.cc', ], - }, - }], + # Disable the heap checker in tcmalloc. + 'cflags': [ + '-DNO_HEAP_CHECK', + ], + }], ], }, { diff --git a/base/leak_annotations.h b/base/leak_annotations.h index 8b5c2ad9fc2fc..a402acfbf236e 100644 --- a/base/leak_annotations.h +++ b/base/leak_annotations.h @@ -7,7 +7,7 @@ #include "build/build_config.h" -#if defined(OS_LINUX) && defined(USE_TCMALLOC) +#if defined(OS_LINUX) && defined(USE_HEAPCHECKER) #include "third_party/tcmalloc/chromium/src/google/heap-checker.h" diff --git a/build/build_config.h b/build/build_config.h index 29d55b3bc3ff9..154f237d72bd5 100644 --- a/build/build_config.h +++ b/build/build_config.h @@ -65,6 +65,11 @@ #define USE_TCMALLOC 1 #endif +// Use heapchecker. +#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_HEAPCHECKER) +#define USE_HEAPCHECKER 1 +#endif + // Compiler detection. #if defined(__GNUC__) #define COMPILER_GCC 1 diff --git a/build/common.gypi b/build/common.gypi index c22fb5c59c5ff..3b8f20e8c20bb 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -205,6 +205,9 @@ # Enable TCMalloc. 'linux_use_tcmalloc%': 1, + # Disable TCMalloc's heapchecker. + 'linux_use_heapchecker%': 0, + # Set to select the Title Case versions of strings in GRD files. 'use_titlecase_in_grd_files%': 0, @@ -965,9 +968,15 @@ }] ], }], + ['linux_use_heapchecker==1', { + 'variables': {'linux_use_tcmalloc%': 1}, + }], ['linux_use_tcmalloc==0', { 'defines': ['NO_TCMALLOC'], }], + ['linux_use_heapchecker==0', { + 'defines': ['NO_HEAPCHECKER'], + }], ], }, }], -- GitLab