2012-11-22 23:03:11 +01:00
|
|
|
//===-- tsan_platform_mac.cc ----------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of ThreadSanitizer (TSan), a race detector.
|
|
|
|
//
|
|
|
|
// Mac-specific code.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
#include "sanitizer_common/sanitizer_platform.h"
|
|
|
|
#if SANITIZER_MAC
|
2012-11-22 23:03:11 +01:00
|
|
|
|
|
|
|
#include "sanitizer_common/sanitizer_common.h"
|
|
|
|
#include "sanitizer_common/sanitizer_libc.h"
|
|
|
|
#include "sanitizer_common/sanitizer_procmaps.h"
|
|
|
|
#include "tsan_platform.h"
|
|
|
|
#include "tsan_rtl.h"
|
|
|
|
#include "tsan_flags.h"
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sched.h>
|
|
|
|
|
|
|
|
namespace __tsan {
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
uptr GetShadowMemoryConsumption() {
|
|
|
|
return 0;
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
void FlushShadowMemory() {
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2014-09-23 19:59:53 +02:00
|
|
|
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive) {
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
uptr GetRSS() {
|
|
|
|
return 0;
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-11-23 15:46:25 +01:00
|
|
|
#ifndef TSAN_GO
|
2012-11-22 23:03:11 +01:00
|
|
|
void InitializeShadowMemory() {
|
2014-11-13 21:41:38 +01:00
|
|
|
uptr shadow = (uptr)MmapFixedNoReserve(kShadowBeg,
|
|
|
|
kShadowEnd - kShadowBeg);
|
|
|
|
if (shadow != kShadowBeg) {
|
2012-11-23 15:46:25 +01:00
|
|
|
Printf("FATAL: ThreadSanitizer can not mmap the shadow memory\n");
|
|
|
|
Printf("FATAL: Make sure to compile with -fPIE and "
|
|
|
|
"to link with -pie.\n");
|
2012-11-22 23:03:11 +01:00
|
|
|
Die();
|
|
|
|
}
|
2014-11-13 21:41:38 +01:00
|
|
|
DPrintf("kShadow %zx-%zx (%zuGB)\n",
|
|
|
|
kShadowBeg, kShadowEnd,
|
|
|
|
(kShadowEnd - kShadowBeg) >> 30);
|
|
|
|
DPrintf("kAppMem %zx-%zx (%zuGB)\n",
|
|
|
|
kAppMemBeg, kAppMemEnd,
|
|
|
|
(kAppMemEnd - kAppMemBeg) >> 30);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
2012-11-23 15:46:25 +01:00
|
|
|
#endif
|
2012-11-22 23:03:11 +01:00
|
|
|
|
2014-09-23 19:59:53 +02:00
|
|
|
void InitializePlatform() {
|
|
|
|
DisableCoreDumperIfNecessary();
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2014-05-22 09:09:21 +02:00
|
|
|
#ifndef TSAN_GO
|
|
|
|
int call_pthread_cancel_with_cleanup(int(*fn)(void *c, void *m,
|
|
|
|
void *abstime), void *c, void *m, void *abstime,
|
|
|
|
void(*cleanup)(void *arg), void *arg) {
|
|
|
|
// pthread_cleanup_push/pop are hardcore macros mess.
|
|
|
|
// We can't intercept nor call them w/o including pthread.h.
|
|
|
|
int res;
|
|
|
|
pthread_cleanup_push(cleanup, arg);
|
|
|
|
res = fn(c, m, abstime);
|
|
|
|
pthread_cleanup_pop(0);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-22 23:03:11 +01:00
|
|
|
} // namespace __tsan
|
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
#endif // SANITIZER_MAC
|