summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsanitizer/ubsan/ubsan_diag.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/libsanitizer/ubsan/ubsan_diag.cc b/libsanitizer/ubsan/ubsan_diag.cc
index dac0937e819..9adfb6b21fc 100644
--- a/libsanitizer/ubsan/ubsan_diag.cc
+++ b/libsanitizer/ubsan/ubsan_diag.cc
@@ -25,11 +25,7 @@
using namespace __ubsan;
-static void MaybePrintStackTrace(uptr pc, uptr bp) {
- // We assume that flags are already parsed, as UBSan runtime
- // will definitely be called when we print the first diagnostics message.
- if (!flags()->print_stacktrace)
- return;
+static void PrintStackTrace(uptr pc, uptr bp) {
// We can only use slow unwind, as we don't have any information about stack
// top/bottom.
// FIXME: It's better to respect "fast_unwind_on_fatal" runtime flag and
@@ -42,6 +38,15 @@ static void MaybePrintStackTrace(uptr pc, uptr bp) {
stack.Print();
}
+static void MaybePrintStackTrace(uptr pc, uptr bp) {
+ // We assume that flags are already parsed, as UBSan runtime
+ // will definitely be called when we print the first diagnostics message.
+ if (!flags()->print_stacktrace)
+ return;
+
+ PrintStackTrace(pc, bp);
+}
+
static const char *ConvertTypeToString(ErrorType Type) {
switch (Type) {
#define UBSAN_CHECK(Name, SummaryKind, FSanitizeFlagName) \
@@ -476,4 +481,13 @@ bool __ubsan::IsISanFunctionCheckSuppressed(ReportOptions *Opts) {
return false;
}
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE
+void __sanitizer_print_stack_trace() {
+ using namespace __ubsan;
+
+ GET_REPORT_OPTIONS(false);
+
+ PrintStackTrace(Opts.pc, Opts.bp);
+}
+
#endif // CAN_SANITIZE_UB