summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
diff options
context:
space:
mode:
authorMarcos Pividori <mpividori@google.com>2017-02-02 23:01:59 +0000
committerMarcos Pividori <mpividori@google.com>2017-02-02 23:01:59 +0000
commitfe9288a6a06b9fe1cb616183290d0414da743d0c (patch)
tree5171c3e91499a212bf085acaf5615f9b2ed62d8f /compiler-rt/lib/sanitizer_common
parentee22156b789b1870502db414d325869d0cb0482d (diff)
downloadbcm5719-llvm-fe9288a6a06b9fe1cb616183290d0414da743d0c.tar.gz
bcm5719-llvm-fe9288a6a06b9fe1cb616183290d0414da743d0c.zip
[sanitizer] Move DescribeSignalOrException to sanitizer_common.
Differential Revision: https://reviews.llvm.org/D29459 llvm-svn: 293956
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix.cc14
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_win.cc26
3 files changed, 41 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 2dabb5066ec..37f26dacf5e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -382,6 +382,7 @@ void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded));
typedef void (*SignalHandlerType)(int, void *, void *);
bool IsHandledDeadlySignal(int signum);
void InstallDeadlySignalHandlers(SignalHandlerType handler);
+const char *DescribeSignalOrException(int signo);
// Alternative signal stack (POSIX-only).
void SetAlternateSignalStack();
void UnsetAlternateSignalStack();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
index c70d5a40cb4..b9cfb06bbfd 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -358,6 +358,20 @@ SignalContext SignalContext::Create(void *siginfo, void *context) {
return SignalContext(context, addr, pc, sp, bp, is_memory_access, write_flag);
}
+const char *DescribeSignalOrException(int signo) {
+ switch (signo) {
+ case SIGFPE:
+ return "FPE";
+ case SIGILL:
+ return "ILL";
+ case SIGABRT:
+ return "ABRT";
+ default:
+ return "SEGV";
+ }
+ return "UNKNOWN SIGNAL";
+}
+
} // namespace __sanitizer
#endif // SANITIZER_POSIX
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
index 247ad8a0875..66504d90957 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cc
@@ -863,6 +863,32 @@ bool IsHandledDeadlyException(DWORD exceptionCode) {
return false;
}
+const char *DescribeSignalOrException(int signo) {
+ unsigned code = signo;
+ // Get the string description of the exception if this is a known deadly
+ // exception.
+ switch (code) {
+ case EXCEPTION_ACCESS_VIOLATION: return "access-violation";
+ case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: return "array-bounds-exceeded";
+ case EXCEPTION_STACK_OVERFLOW: return "stack-overflow";
+ case EXCEPTION_DATATYPE_MISALIGNMENT: return "datatype-misalignment";
+ case EXCEPTION_IN_PAGE_ERROR: return "in-page-error";
+ case EXCEPTION_ILLEGAL_INSTRUCTION: return "illegal-instruction";
+ case EXCEPTION_PRIV_INSTRUCTION: return "priv-instruction";
+ case EXCEPTION_BREAKPOINT: return "breakpoint";
+ case EXCEPTION_FLT_DENORMAL_OPERAND: return "flt-denormal-operand";
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO: return "flt-divide-by-zero";
+ case EXCEPTION_FLT_INEXACT_RESULT: return "flt-inexact-result";
+ case EXCEPTION_FLT_INVALID_OPERATION: return "flt-invalid-operation";
+ case EXCEPTION_FLT_OVERFLOW: return "flt-overflow";
+ case EXCEPTION_FLT_STACK_CHECK: return "flt-stack-check";
+ case EXCEPTION_FLT_UNDERFLOW: return "flt-underflow";
+ case EXCEPTION_INT_DIVIDE_BY_ZERO: return "int-divide-by-zero";
+ case EXCEPTION_INT_OVERFLOW: return "int-overflow";
+ }
+ return "unknown exception";
+}
+
bool IsAccessibleMemoryRange(uptr beg, uptr size) {
SYSTEM_INFO si;
GetNativeSystemInfo(&si);
OpenPOWER on IntegriCloud