[PATCH] [sanitizer] Expose __sanitizer_print_stack_trace().

Alexey Samsonov samsonov at google.com
Wed Nov 20 00:46:26 PST 2013



================
Comment at: include/sanitizer/common_interface_defs.h:88
@@ -87,1 +87,3 @@
 
+  // Print the stack trace leading to this call.
+  void __sanitizer_print_stack_trace();
----------------
Specify that this is useful for debugging purposes only.

================
Comment at: lib/sanitizer_common/sanitizer_common_libcdep.cc:41
@@ +40,3 @@
+extern "C" {
+void __sanitizer_print_stack_trace() {
+  GET_CURRENT_PC_BP_SP;
----------------
Looks like this should go to sanitizer_stacktrace_libcdep.cc

================
Comment at: lib/sanitizer_common/sanitizer_common_libcdep.cc:45
@@ +44,3 @@
+  StackTrace stack;
+  stack.Unwind(kStackTraceMax, pc, bp, 0 /* stack_top */, 0 /* stack_bottom */,
+               false /* request_fast_unwind */);
----------------
What if slow unwind is unavailable (caller can learn about this via StackTrace::WillUseFastUnwind function)?
Also, unwinding a stack from the sanitizer runtime and is (unfortunately) tool-specific. See complicated GET_STACK_TRACE_WITH_PC_AND_BP in ASan runtime and GetStackTrace in MSan runtime. It would be cool to
generalize it somehow, but we're not there at the moment. But we should probably address this before adding a generic
interface usable with all sanitizers - just imagine that you call __sanitizer_print_stack_trace() in your program or in gdb,
and suddenly see an MSan report caused by unblocked interceptors called during _Unwind_Backtrace.

You'll also need lit tests.


http://llvm-reviews.chandlerc.com/D2221



More information about the llvm-commits mailing list