summaryrefslogtreecommitdiff
path: root/src/mongo/shell/shell_utils.cpp
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2014-06-27 13:15:59 -0400
committerAndrew Morrow <acm@mongodb.com>2014-06-30 14:24:10 -0400
commite9a6e9365cf4d6d13b4a3f94aec1f433dab9f704 (patch)
tree88c06637291735f2f190e43c65191d055a9b6c0b /src/mongo/shell/shell_utils.cpp
parent09d2bf2a43cbf6e7ac10d4dc89934528001d0b69 (diff)
downloadmongo-e9a6e9365cf4d6d13b4a3f94aec1f433dab9f704.tar.gz
SERVER-14293 Skip exit logging test when using address sanitizer
Diffstat (limited to 'src/mongo/shell/shell_utils.cpp')
-rw-r--r--src/mongo/shell/shell_utils.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp
index 11182c1714b..1e33c4d8eeb 100644
--- a/src/mongo/shell/shell_utils.cpp
+++ b/src/mongo/shell/shell_utils.cpp
@@ -144,6 +144,23 @@ namespace mongo {
#endif
}
+ BSONObj isAddressSanitizerActive(const BSONObj& a, void* data) {
+ bool isSanitized = false;
+ // See the following for information on how we detect address sanitizer in clang and gcc.
+ //
+ // - http://clang.llvm.org/docs/AddressSanitizer.html#has-feature-address-sanitizer
+ // - https://gcc.gnu.org/ml/gcc-patches/2012-11/msg01827.html
+ //
+#if defined(__has_feature)
+#if __has_feature(address_sanitizer)
+ isSanitized = true;
+#endif
+#elif defined(__SANITIZE_ADDRESS__)
+ isSanitized = true;
+#endif
+ return BSON( "" << isSanitized );
+ }
+
BSONObj getBuildInfo(const BSONObj& a, void* data) {
uassert( 16822, "getBuildInfo accepts no arguments", a.nFields() == 0 );
BSONObjBuilder b;
@@ -203,6 +220,7 @@ namespace mongo {
scope.injectNative( "_srand" , JSSrand );
scope.injectNative( "_rand" , JSRand );
scope.injectNative( "_isWindows" , isWindows );
+ scope.injectNative( "_isAddressSanitizerActive", isAddressSanitizerActive );
scope.injectNative( "interpreterVersion", interpreterVersion );
scope.injectNative( "getBuildInfo", getBuildInfo );
scope.injectNative( "isKeyTooLarge", isKeyTooLarge );