xref: /aosp_15_r20/external/compiler-rt/lib/asan/asan_stack.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot //===-- asan_stack.cc -----------------------------------------------------===//
2*7c3d14c8STreehugger Robot //
3*7c3d14c8STreehugger Robot //                     The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot //
5*7c3d14c8STreehugger Robot // This file is distributed under the University of Illinois Open Source
6*7c3d14c8STreehugger Robot // License. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot //
8*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
9*7c3d14c8STreehugger Robot //
10*7c3d14c8STreehugger Robot // This file is a part of AddressSanitizer, an address sanity checker.
11*7c3d14c8STreehugger Robot //
12*7c3d14c8STreehugger Robot // Code for ASan stack trace.
13*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
14*7c3d14c8STreehugger Robot #include "asan_internal.h"
15*7c3d14c8STreehugger Robot #include "asan_stack.h"
16*7c3d14c8STreehugger Robot #include "sanitizer_common/sanitizer_atomic.h"
17*7c3d14c8STreehugger Robot 
18*7c3d14c8STreehugger Robot namespace __asan {
19*7c3d14c8STreehugger Robot 
20*7c3d14c8STreehugger Robot static atomic_uint32_t malloc_context_size;
21*7c3d14c8STreehugger Robot 
SetMallocContextSize(u32 size)22*7c3d14c8STreehugger Robot void SetMallocContextSize(u32 size) {
23*7c3d14c8STreehugger Robot   atomic_store(&malloc_context_size, size, memory_order_release);
24*7c3d14c8STreehugger Robot }
25*7c3d14c8STreehugger Robot 
GetMallocContextSize()26*7c3d14c8STreehugger Robot u32 GetMallocContextSize() {
27*7c3d14c8STreehugger Robot   return atomic_load(&malloc_context_size, memory_order_acquire);
28*7c3d14c8STreehugger Robot }
29*7c3d14c8STreehugger Robot 
30*7c3d14c8STreehugger Robot }  // namespace __asan
31*7c3d14c8STreehugger Robot 
32*7c3d14c8STreehugger Robot // ------------------ Interface -------------- {{{1
33*7c3d14c8STreehugger Robot 
34*7c3d14c8STreehugger Robot extern "C" {
35*7c3d14c8STreehugger Robot SANITIZER_INTERFACE_ATTRIBUTE
__sanitizer_print_stack_trace()36*7c3d14c8STreehugger Robot void __sanitizer_print_stack_trace() {
37*7c3d14c8STreehugger Robot   using namespace __asan;
38*7c3d14c8STreehugger Robot   PRINT_CURRENT_STACK();
39*7c3d14c8STreehugger Robot }
40*7c3d14c8STreehugger Robot }  // extern "C"
41