summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/lsan
diff options
context:
space:
mode:
authorKamil Rytarowski <n54@gmx.com>2019-07-11 06:22:35 +0000
committerKamil Rytarowski <n54@gmx.com>2019-07-11 06:22:35 +0000
commit983d7ddd0b278b45d815cbac9197205b39c4860a (patch)
tree5584fe6d50a8d43f69290076b2e788bd01590922 /compiler-rt/lib/lsan
parentf4954b52e4c0f2f83811b788bfa2a114ca3e356b (diff)
downloadbcm5719-llvm-983d7ddd0b278b45d815cbac9197205b39c4860a.tar.gz
bcm5719-llvm-983d7ddd0b278b45d815cbac9197205b39c4860a.zip
Add NetBSD LSan support
Summary: Combine few relatively small changes into one: - implement internal_ptrace() and internal_clone() for NetBSD - add support for stoptheworld based on the ptrace(2) API - define COMPILER_RT_HAS_LSAN for NetBSD - enable tests for NetBSD/amd64 Inspired by the original implementation by Christos Zoulas in netbsd/src for GCC. The implementation is in theory CPU independent through well defined macros across all NetBSD ports, however only the x86_64 version was tested. Reviewers: mgorny, dvyukov, vitalybuka, joerg, jfb Reviewed By: vitalybuka Subscribers: dexonsmith, jfb, srhines, kubamracek, llvm-commits, christos Tags: #llvm Differential Revision: https://reviews.llvm.org/D64057 llvm-svn: 365735
Diffstat (limited to 'compiler-rt/lib/lsan')
-rw-r--r--compiler-rt/lib/lsan/lsan_common.h6
-rw-r--r--compiler-rt/lib/lsan/lsan_common_linux.cc7
-rw-r--r--compiler-rt/lib/lsan/lsan_linux.cc6
3 files changed, 11 insertions, 8 deletions
diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h
index 682e5f7d8c5..58dc00faaee 100644
--- a/compiler-rt/lib/lsan/lsan_common.h
+++ b/compiler-rt/lib/lsan/lsan_common.h
@@ -21,8 +21,8 @@
#include "sanitizer_common/sanitizer_stoptheworld.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
-// LeakSanitizer relies on some Glibc's internals (e.g. TLS machinery) thus
-// supported for Linux only. Also, LSan doesn't like 32 bit architectures
+// LeakSanitizer relies on some Glibc's internals (e.g. TLS machinery) on Linux.
+// Also, LSan doesn't like 32 bit architectures
// because of "small" (4 bytes) pointer size that leads to high false negative
// ratio on large leaks. But we still want to have it for some 32 bit arches
// (e.g. x86), see https://github.com/google/sanitizers/issues/403.
@@ -40,6 +40,8 @@
#elif defined(__arm__) && \
SANITIZER_LINUX && !SANITIZER_ANDROID
#define CAN_SANITIZE_LEAKS 1
+#elif SANITIZER_NETBSD
+#define CAN_SANITIZE_LEAKS 1
#else
#define CAN_SANITIZE_LEAKS 0
#endif
diff --git a/compiler-rt/lib/lsan/lsan_common_linux.cc b/compiler-rt/lib/lsan/lsan_common_linux.cc
index 0e4abdce002..ef4f591d88f 100644
--- a/compiler-rt/lib/lsan/lsan_common_linux.cc
+++ b/compiler-rt/lib/lsan/lsan_common_linux.cc
@@ -7,14 +7,15 @@
//===----------------------------------------------------------------------===//
//
// This file is a part of LeakSanitizer.
-// Implementation of common leak checking functionality. Linux-specific code.
+// Implementation of common leak checking functionality. Linux/NetBSD-specific
+// code.
//
//===----------------------------------------------------------------------===//
#include "sanitizer_common/sanitizer_platform.h"
#include "lsan_common.h"
-#if CAN_SANITIZE_LEAKS && SANITIZER_LINUX
+#if CAN_SANITIZE_LEAKS && (SANITIZER_LINUX || SANITIZER_NETBSD)
#include <link.h>
#include "sanitizer_common/sanitizer_common.h"
@@ -136,4 +137,4 @@ void DoStopTheWorld(StopTheWorldCallback callback, void *argument) {
} // namespace __lsan
-#endif // CAN_SANITIZE_LEAKS && SANITIZER_LINUX
+#endif
diff --git a/compiler-rt/lib/lsan/lsan_linux.cc b/compiler-rt/lib/lsan/lsan_linux.cc
index c54f41ecefb..22d034280d7 100644
--- a/compiler-rt/lib/lsan/lsan_linux.cc
+++ b/compiler-rt/lib/lsan/lsan_linux.cc
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
//
-// This file is a part of LeakSanitizer. Linux-specific code.
+// This file is a part of LeakSanitizer. Linux/NetBSD-specific code.
//
//===----------------------------------------------------------------------===//
#include "sanitizer_common/sanitizer_platform.h"
-#if SANITIZER_LINUX
+#if SANITIZER_LINUX || SANITIZER_NETBSD
#include "lsan_allocator.h"
@@ -29,4 +29,4 @@ void ReplaceSystemMalloc() {}
} // namespace __lsan
-#endif // SANITIZER_LINUX
+#endif // SANITIZER_LINUX || SANITIZER_NETBSD
OpenPOWER on IntegriCloud