[compiler-rt] 3597fba - Add a simple stack trace printer for DFSan
Jianzhou Zhao via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 11 11:02:01 PST 2020
Author: Jianzhou Zhao
Date: 2020-11-11T19:00:59Z
New Revision: 3597fba4e5e46dfeb035cec8be474f3fd3102fc0
URL: https://github.com/llvm/llvm-project/commit/3597fba4e5e46dfeb035cec8be474f3fd3102fc0
DIFF: https://github.com/llvm/llvm-project/commit/3597fba4e5e46dfeb035cec8be474f3fd3102fc0.diff
LOG: Add a simple stack trace printer for DFSan
Reviewed-by: morehouse
Differential Revision: https://reviews.llvm.org/D91235
Added:
Modified:
compiler-rt/lib/dfsan/CMakeLists.txt
compiler-rt/lib/dfsan/dfsan.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/dfsan/CMakeLists.txt b/compiler-rt/lib/dfsan/CMakeLists.txt
index 051215edbeb7..a29de8deff1b 100644
--- a/compiler-rt/lib/dfsan/CMakeLists.txt
+++ b/compiler-rt/lib/dfsan/CMakeLists.txt
@@ -31,6 +31,7 @@ foreach(arch ${DFSAN_SUPPORTED_ARCH})
$<TARGET_OBJECTS:RTInterception.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
ADDITIONAL_HEADERS ${DFSAN_RTL_HEADERS}
CFLAGS ${DFSAN_CFLAGS}
PARENT_TARGET dfsan)
diff --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp
index 5da2138a263e..36381c6896ae 100644
--- a/compiler-rt/lib/dfsan/dfsan.cpp
+++ b/compiler-rt/lib/dfsan/dfsan.cpp
@@ -27,6 +27,7 @@
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
using namespace __dfsan;
@@ -407,6 +408,22 @@ dfsan_dump_labels(int fd) {
}
}
+#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) \
+ BufferedStackTrace stack; \
+ stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal);
+
+void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
+ void *context,
+ bool request_fast,
+ u32 max_depth) {
+ Unwind(max_depth, pc, bp, context, 0, 0, false);
+}
+
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_print_stack_trace() {
+ GET_FATAL_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME());
+ stack.Print();
+}
+
void Flags::SetDefaults() {
#define DFSAN_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
#include "dfsan_flags.inc"
More information about the llvm-commits
mailing list