summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2016-03-24 08:13:03 -0400
committerAndrew Morrow <acm@mongodb.com>2016-03-24 19:12:16 -0400
commit10b650835a78fbf7ebe9cf26926cc45556efd178 (patch)
tree41e2a43fd1096841e153e904803e90a3ee89f1af /src
parenta19406fdedac2bff515a0b162c8d496b11f4e455 (diff)
downloadmongo-10b650835a78fbf7ebe9cf26926cc45556efd178.tar.gz
SERVER-13476 Make the gperftools cpu profiler work again
Diffstat (limited to 'src')
-rw-r--r--src/mongo/util/SConscript16
-rw-r--r--src/mongo/util/quick_exit.cpp8
-rw-r--r--src/third_party/gperftools-2.2/SConscript2
3 files changed, 24 insertions, 2 deletions
diff --git a/src/mongo/util/SConscript b/src/mongo/util/SConscript
index 371b3f1c845..3e94e20e1ce 100644
--- a/src/mongo/util/SConscript
+++ b/src/mongo/util/SConscript
@@ -333,13 +333,27 @@ if has_option('gcov'):
],
)
+if has_option('use-cpu-profiler'):
+ quick_exit_env.Append(
+ CPPDEFINES=[
+ 'MONGO_CPU_PROFILER',
+ ],
+ )
+
+ if not use_system_version_of_library('tcmalloc'):
+ quick_exit_env.InjectThirdPartyIncludePaths(
+ 'tcmalloc'
+ )
+
quick_exit_env.Library(
target='quick_exit',
source=[
'quick_exit.cpp',
],
LIBDEPS=[
- # NOTE: You *must not* add any library dependencies to the quick_exit library
+ # NOTE: You *must not* add any other library dependencies to
+ # the quick_exit library
+ "$BUILD_DIR/third_party/shim_allocator",
]
)
diff --git a/src/mongo/util/quick_exit.cpp b/src/mongo/util/quick_exit.cpp
index e53c99420a4..586ccb0d4cd 100644
--- a/src/mongo/util/quick_exit.cpp
+++ b/src/mongo/util/quick_exit.cpp
@@ -62,6 +62,10 @@
#include <sanitizer/lsan_interface.h>
#endif
+#if defined(MONGO_CPU_PROFILER)
+#include <gperftools/profiler.h>
+#endif
+
#ifdef MONGO_GCOV
extern "C" void __gcov_flush();
#endif
@@ -78,6 +82,10 @@ void quickExit(int code) {
if (quickExitMutex)
quickExitMutex->lock();
+#if defined(MONGO_CPU_PROFILER)
+ ::ProfilerStop();
+#endif
+
#ifdef MONGO_GCOV
__gcov_flush();
#endif
diff --git a/src/third_party/gperftools-2.2/SConscript b/src/third_party/gperftools-2.2/SConscript
index 26012e7e21d..e3222950c34 100644
--- a/src/third_party/gperftools-2.2/SConscript
+++ b/src/third_party/gperftools-2.2/SConscript
@@ -74,7 +74,7 @@ conf.CheckMallocHookVolatile()
if has_option('use-cpu-profiler'):
if not conf.CheckLib('unwind', autoadd=False):
env.ConfError("Compiling with --use-cpu-profiler requires having libunwind installed")
- conf.env.AppendUnique(
+ conf.env.Append(
CPPDEFINES=["NO_FRAME_POINTER", ("HAVE_LIBUNWIND_H", "1")],
SYSLIBDEPS=['unwind']
)