1 //===-- tsan_platform_mac.cc ----------------------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //===----------------------------------------------------------------------===//
13 #include "sanitizer_common/sanitizer_platform.h"
16 #include "sanitizer_common/sanitizer_common.h"
17 #include "sanitizer_common/sanitizer_libc.h"
18 #include "sanitizer_common/sanitizer_procmaps.h"
19 #include "tsan_platform.h"
21 #include "tsan_flags.h"
30 #include <sys/syscall.h>
32 #include <sys/types.h>
33 #include <sys/resource.h>
41 ScopedInRtl::ScopedInRtl() {
44 ScopedInRtl::~ScopedInRtl() {
47 uptr
GetShadowMemoryConsumption() {
51 void FlushShadowMemory() {
55 void InitializeShadowMemory() {
56 uptr shadow
= (uptr
)MmapFixedNoReserve(kLinuxShadowBeg
,
57 kLinuxShadowEnd
- kLinuxShadowBeg
);
58 if (shadow
!= kLinuxShadowBeg
) {
59 Printf("FATAL: ThreadSanitizer can not mmap the shadow memory\n");
60 Printf("FATAL: Make sure to compile with -fPIE and "
61 "to link with -pie.\n");
64 DPrintf("kLinuxShadow %zx-%zx (%zuGB)\n",
65 kLinuxShadowBeg
, kLinuxShadowEnd
,
66 (kLinuxShadowEnd
- kLinuxShadowBeg
) >> 30);
67 DPrintf("kLinuxAppMem %zx-%zx (%zuGB)\n",
68 kLinuxAppMemBeg
, kLinuxAppMemEnd
,
69 (kLinuxAppMemEnd
- kLinuxAppMemBeg
) >> 30);
73 const char *InitializePlatform() {
76 // Disable core dumps, dumping of 16TB usually takes a bit long.
77 // The following magic is to prevent clang from replacing it with memset.
81 setrlimit(RLIMIT_CORE
, (rlimit
*)&lim
);
84 return GetEnv(kTsanOptionsEnv
);
87 void FinalizePlatform() {
93 #endif // SANITIZER_MAC