summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Pividori <mpividori@google.com>2017-02-02 23:01:51 +0000
committerMarcos Pividori <mpividori@google.com>2017-02-02 23:01:51 +0000
commitee22156b789b1870502db414d325869d0cb0482d (patch)
tree099f601eee74b457f22fac7412aaea159c9cf768
parent387210c6c8153ac5b438ceb34b72559e07549aa3 (diff)
downloadbcm5719-llvm-ee22156b789b1870502db414d325869d0cb0482d.tar.gz
bcm5719-llvm-ee22156b789b1870502db414d325869d0cb0482d.zip
[sanitizer] Move exception code to sanitizer_common.
Differential Revision: https://reviews.llvm.org/D29458 llvm-svn: 293955
-rw-r--r--compiler-rt/lib/asan/asan_win.cc30
-rw-r--r--compiler-rt/lib/sanitizer_common/CMakeLists.txt3
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_win.cc27
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_win.h26
4 files changed, 57 insertions, 29 deletions
diff --git a/compiler-rt/lib/asan/asan_win.cc b/compiler-rt/lib/asan/asan_win.cc
index a41620ed3ce..d77d9d64304 100644
--- a/compiler-rt/lib/asan/asan_win.cc
+++ b/compiler-rt/lib/asan/asan_win.cc
@@ -27,6 +27,7 @@
#include "asan_mapping.h"
#include "sanitizer_common/sanitizer_libc.h"
#include "sanitizer_common/sanitizer_mutex.h"
+#include "sanitizer_common/sanitizer_win.h"
#include "sanitizer_common/sanitizer_win_defs.h"
using namespace __asan; // NOLINT
@@ -236,33 +237,6 @@ void InitializePlatformExceptionHandlers() {
static LPTOP_LEVEL_EXCEPTION_FILTER default_seh_handler;
-// Check based on flags if we should report this exception.
-static bool ShouldReportDeadlyException(unsigned code) {
- switch (code) {
- case EXCEPTION_ACCESS_VIOLATION:
- case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
- case EXCEPTION_STACK_OVERFLOW:
- case EXCEPTION_DATATYPE_MISALIGNMENT:
- case EXCEPTION_IN_PAGE_ERROR:
- return common_flags()->handle_segv;
- case EXCEPTION_ILLEGAL_INSTRUCTION:
- case EXCEPTION_PRIV_INSTRUCTION:
- case EXCEPTION_BREAKPOINT:
- return common_flags()->handle_sigill;
- case EXCEPTION_FLT_DENORMAL_OPERAND:
- case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- case EXCEPTION_FLT_INEXACT_RESULT:
- case EXCEPTION_FLT_INVALID_OPERATION:
- case EXCEPTION_FLT_OVERFLOW:
- case EXCEPTION_FLT_STACK_CHECK:
- case EXCEPTION_FLT_UNDERFLOW:
- case EXCEPTION_INT_DIVIDE_BY_ZERO:
- case EXCEPTION_INT_OVERFLOW:
- return common_flags()->handle_sigfpe;
- }
- return false;
-}
-
// Return the textual name for this exception.
const char *DescribeSignalOrException(int signo) {
unsigned code = signo;
@@ -296,7 +270,7 @@ long __asan_unhandled_exception_filter(EXCEPTION_POINTERS *info) {
CONTEXT *context = info->ContextRecord;
// Continue the search if the signal wasn't deadly.
- if (!ShouldReportDeadlyException(exception_record->ExceptionCode))
+ if (!IsHandledDeadlyException(exception_record->ExceptionCode))
return EXCEPTION_CONTINUE_SEARCH;
// FIXME: Handle EXCEPTION_STACK_OVERFLOW here.
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 1f4b7745898..fe06328661b 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -126,7 +126,8 @@ set(SANITIZER_HEADERS
sanitizer_syscall_generic.inc
sanitizer_syscall_linux_x86_64.inc
sanitizer_syscall_linux_aarch64.inc
- sanitizer_thread_registry.h)
+ sanitizer_thread_registry.h
+ sanitizer_win.h)
include_directories(..)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
index 884b166ce2c..247ad8a0875 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
@@ -836,6 +836,33 @@ bool IsHandledDeadlySignal(int signum) {
return false;
}
+// Check based on flags if we should handle this exception.
+bool IsHandledDeadlyException(DWORD exceptionCode) {
+ switch (exceptionCode) {
+ case EXCEPTION_ACCESS_VIOLATION:
+ case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
+ case EXCEPTION_STACK_OVERFLOW:
+ case EXCEPTION_DATATYPE_MISALIGNMENT:
+ case EXCEPTION_IN_PAGE_ERROR:
+ return common_flags()->handle_segv;
+ case EXCEPTION_ILLEGAL_INSTRUCTION:
+ case EXCEPTION_PRIV_INSTRUCTION:
+ case EXCEPTION_BREAKPOINT:
+ return common_flags()->handle_sigill;
+ case EXCEPTION_FLT_DENORMAL_OPERAND:
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ case EXCEPTION_FLT_INEXACT_RESULT:
+ case EXCEPTION_FLT_INVALID_OPERATION:
+ case EXCEPTION_FLT_OVERFLOW:
+ case EXCEPTION_FLT_STACK_CHECK:
+ case EXCEPTION_FLT_UNDERFLOW:
+ case EXCEPTION_INT_DIVIDE_BY_ZERO:
+ case EXCEPTION_INT_OVERFLOW:
+ return common_flags()->handle_sigfpe;
+ }
+ return false;
+}
+
bool IsAccessibleMemoryRange(uptr beg, uptr size) {
SYSTEM_INFO si;
GetNativeSystemInfo(&si);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.h b/compiler-rt/lib/sanitizer_common/sanitizer_win.h
new file mode 100644
index 00000000000..23e01ab7504
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.h
@@ -0,0 +1,26 @@
+//===-- sanitizer_win.h -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Windows-specific declarations.
+//
+//===----------------------------------------------------------------------===//
+#ifndef SANITIZER_WIN_H
+#define SANITIZER_WIN_H
+
+#include "sanitizer_platform.h"
+#if SANITIZER_WINDOWS
+#include "sanitizer_internal_defs.h"
+
+namespace __sanitizer {
+// Check based on flags if we should handle the exception.
+bool IsHandledDeadlyException(DWORD exceptionCode);
+} // namespace __sanitizer
+
+#endif // SANITIZER_WINDOWS
+#endif // SANITIZER_WIN_H
OpenPOWER on IntegriCloud