[asan] move more stuff to OS-specific files

llvm-svn: 147647
This commit is contained in:
Kostya Serebryany 2012-01-06 02:12:25 +00:00
parent 4017fa399b
commit 2b08718bba
5 changed files with 17 additions and 12 deletions

View File

@ -35,10 +35,6 @@
#include "asan_thread.h"
#include "asan_thread_registry.h"
#include <stdint.h>
#include <string.h>
#include <unistd.h>
namespace __asan {
#define REDZONE FLAG_redzone

View File

@ -99,6 +99,8 @@ void *AsanMprotect(uintptr_t fixed_addr, size_t size);
void *AsanMmapSomewhereOrDie(size_t size, const char *where);
void AsanUnmapOrDie(void *ptr, size_t size);
void AsanDisableCoreDumper();
ssize_t AsanRead(int fd, void *buf, size_t count);
ssize_t AsanWrite(int fd, const void *buf, size_t count);
int AsanClose(int fd);

View File

@ -244,6 +244,12 @@ void AsanThread::SetThreadStackTopAndBottom() {
CHECK(AddrIsInStack((uintptr_t)&attr));
}
void AsanDisableCoreDumper() {
struct rlimit nocore;
nocore.rlim_cur = 0;
nocore.rlim_max = 0;
setrlimit(RLIMIT_CORE, &nocore);
}
} // namespace __asan

View File

@ -22,6 +22,7 @@
#include "asan_thread_registry.h"
#include <sys/mman.h>
#include <sys/resource.h>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
@ -113,6 +114,13 @@ void AsanThread::SetThreadStackTopAndBottom() {
CHECK(AddrIsInStack((uintptr_t)&local));
}
void AsanDisableCoreDumper() {
struct rlimit nocore;
nocore.rlim_cur = 0;
nocore.rlim_max = 0;
setrlimit(RLIMIT_CORE, &nocore);
}
// Support for the following functions from libdispatch on Mac OS:
// dispatch_async_f()
// dispatch_async()

View File

@ -26,7 +26,6 @@
#include <new>
#include <dlfcn.h>
#include <execinfo.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
@ -40,9 +39,6 @@
#ifndef ANDROID
#include <sys/ucontext.h>
#endif
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
// must not include <setjmp.h> on Linux
namespace __asan {
@ -775,10 +771,7 @@ void __asan_init() {
if (__WORDSIZE == 64) {
// Disable core dumper -- it makes little sense to dump 16T+ core.
struct rlimit nocore;
nocore.rlim_cur = 0;
nocore.rlim_max = 0;
setrlimit(RLIMIT_CORE, &nocore);
AsanDisableCoreDumper();
}
{