summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/ubsan
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2017-05-05 09:02:28 +0000
committerAlexander Potapenko <glider@google.com>2017-05-05 09:02:28 +0000
commit416c14d4093e333803d09fe3a57e945a4bd9b0fa (patch)
tree5cd96870cff500d3d3ccbe0617aef9126044d583 /compiler-rt/lib/ubsan
parentc1267b9baa3f624b3dae547df0d2b722fba81adc (diff)
downloadbcm5719-llvm-416c14d4093e333803d09fe3a57e945a4bd9b0fa.tar.gz
bcm5719-llvm-416c14d4093e333803d09fe3a57e945a4bd9b0fa.zip
[ubsan] Implement __sanitizer_print_stack_trace for standalone UBSan runtime.
Patch by Max Moroz, reviewed at https://reviews.llvm.org/D32542 llvm-svn: 302218
Diffstat (limited to 'compiler-rt/lib/ubsan')
-rw-r--r--compiler-rt/lib/ubsan/CMakeLists.txt1
-rw-r--r--compiler-rt/lib/ubsan/ubsan_diag_standalone.cc37
2 files changed, 38 insertions, 0 deletions
diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt
index f35b40f3b1c..7e10456e314 100644
--- a/compiler-rt/lib/ubsan/CMakeLists.txt
+++ b/compiler-rt/lib/ubsan/CMakeLists.txt
@@ -9,6 +9,7 @@ set(UBSAN_SOURCES
)
set(UBSAN_STANDALONE_SOURCES
+ ubsan_diag_standalone.cc
ubsan_init_standalone.cc
)
diff --git a/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc b/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc
new file mode 100644
index 00000000000..df8ed5fcdf6
--- /dev/null
+++ b/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc
@@ -0,0 +1,37 @@
+//===-- ubsan_diag_standalone.cc ------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Diagnostic reporting for the standalone UBSan runtime.
+//
+//===----------------------------------------------------------------------===//
+
+#include "ubsan_platform.h"
+#if CAN_SANITIZE_UB
+#include "ubsan_diag.h"
+
+using namespace __ubsan;
+
+extern "C" {
+SANITIZER_INTERFACE_ATTRIBUTE
+void __sanitizer_print_stack_trace() {
+ uptr top = 0;
+ uptr bottom = 0;
+ bool request_fast_unwind = common_flags()->fast_unwind_on_fatal;
+ if (request_fast_unwind)
+ __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);
+
+ GET_REPORT_OPTIONS(false);
+ BufferedStackTrace stack;
+ stack.Unwind(kStackTraceMax, Opts.pc, Opts.bp, nullptr, top, bottom,
+ request_fast_unwind);
+ stack.Print();
+}
+} // extern "C"
+
+#endif // CAN_SANITIZE_UB
OpenPOWER on IntegriCloud