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 //===----------------------------------------------------------------------===//
15 #include "sanitizer_common/sanitizer_common.h"
16 #include "sanitizer_common/sanitizer_libc.h"
17 #include "sanitizer_common/sanitizer_procmaps.h"
18 #include "tsan_platform.h"
20 #include "tsan_flags.h"
29 #include <sys/syscall.h>
31 #include <sys/types.h>
32 #include <sys/resource.h>
40 ScopedInRtl::ScopedInRtl() {
43 ScopedInRtl::~ScopedInRtl() {
46 uptr
GetShadowMemoryConsumption() {
50 void FlushShadowMemory() {
54 void InitializeShadowMemory() {
55 uptr shadow
= (uptr
)MmapFixedNoReserve(kLinuxShadowBeg
,
56 kLinuxShadowEnd
- kLinuxShadowBeg
);
57 if (shadow
!= kLinuxShadowBeg
) {
58 Printf("FATAL: ThreadSanitizer can not mmap the shadow memory\n");
59 Printf("FATAL: Make sure to compile with -fPIE and "
60 "to link with -pie.\n");
63 DPrintf("kLinuxShadow %zx-%zx (%zuGB)\n",
64 kLinuxShadowBeg
, kLinuxShadowEnd
,
65 (kLinuxShadowEnd
- kLinuxShadowBeg
) >> 30);
66 DPrintf("kLinuxAppMem %zx-%zx (%zuGB)\n",
67 kLinuxAppMemBeg
, kLinuxAppMemEnd
,
68 (kLinuxAppMemEnd
- kLinuxAppMemBeg
) >> 30);
72 const char *InitializePlatform() {
75 // Disable core dumps, dumping of 16TB usually takes a bit long.
76 // The following magic is to prevent clang from replacing it with memset.
80 setrlimit(RLIMIT_CORE
, (rlimit
*)&lim
);
83 return GetEnv(kTsanOptionsEnv
);
86 void FinalizePlatform() {
94 void GetThreadStackAndTls(bool main
, uptr
*stk_addr
, uptr
*stk_size
,
95 uptr
*tls_addr
, uptr
*tls_size
) {
102 } // namespace __tsan
104 #endif // #ifdef __APPLE__