Index: include/sanitizer/common_interface_defs.h =================================================================== --- include/sanitizer/common_interface_defs.h +++ include/sanitizer/common_interface_defs.h @@ -85,6 +85,9 @@ const void *old_mid, const void *new_mid); + // Print the stack trace leading to this call. + void __sanitizer_print_stack_trace(); + #ifdef __cplusplus } // extern "C" #endif Index: lib/sanitizer_common/sanitizer_common_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_common_libcdep.cc +++ lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "sanitizer_common.h" +#include "sanitizer_stacktrace.h" namespace __sanitizer { @@ -35,3 +36,14 @@ return prints_to_tty; } } // namespace __sanitizer + +extern "C" { +void __sanitizer_print_stack_trace() { + GET_CURRENT_PC_BP_SP; + (void) sp; + StackTrace stack; + stack.Unwind(kStackTraceMax, pc, bp, 0 /* stack_top */, 0 /* stack_bottom */, + false /* request_fast_unwind */); + StackTrace::PrintStack(stack.trace, stack.size); +} +} // extern "C"