summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_mac.cc
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2014-01-31 13:10:07 +0000
committerAlexander Potapenko <glider@google.com>2014-01-31 13:10:07 +0000
commit4c26afdb206b13ae5cdc5e2a074a6cadc0d969a5 (patch)
treeec3f7f602ad4f68a2bef7b9765cf07d507f536fe /lib/sanitizer_common/sanitizer_mac.cc
parent7c8ecc28166e5f23cc8479ebcf69effe9a006dad (diff)
[ASan] Move the SIGSEGV/SIGBUS handling to sanitizer_common
This change is a part of refactoring intended to have common signal handling behavior in all tools. This particular CL moves InstallSignalHandlers() into sanitizer_common (making it InstallDeadlySignalHandlers()), but doesn't enable default signal handlers for any tool other than ASan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200542 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_mac.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_mac.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_mac.cc b/lib/sanitizer_common/sanitizer_mac.cc
index 3cc3a6b5b..e6c95bb69 100644
--- a/lib/sanitizer_common/sanitizer_mac.cc
+++ b/lib/sanitizer_common/sanitizer_mac.cc
@@ -23,6 +23,7 @@
#include <stdio.h>
#include "sanitizer_common.h"
+#include "sanitizer_flags.h"
#include "sanitizer_internal_defs.h"
#include "sanitizer_libc.h"
#include "sanitizer_placement_new.h"
@@ -32,6 +33,7 @@
#include <fcntl.h>
#include <pthread.h>
#include <sched.h>
+#include <signal.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/stat.h>
@@ -118,6 +120,11 @@ uptr internal_getpid() {
return getpid();
}
+int internal_sigaction(int signum, const void *act, void *oldact) {
+ return sigaction(signum,
+ (struct sigaction *)act, (struct sigaction *)oldact);
+}
+
// ----------------- sanitizer_common.h
bool FileExists(const char *filename) {
struct stat st;
@@ -238,6 +245,10 @@ uptr GetListOfModules(LoadedModule *modules, uptr max_modules,
return memory_mapping.DumpListOfModules(modules, max_modules, filter);
}
+bool IsDeadlySignal(int signum) {
+ return (signum == SIGSEGV || signum == SIGBUS) && common_flags()->handle_segv;
+}
+
} // namespace __sanitizer
#endif // SANITIZER_MAC