xref: /freebsd-src/contrib/llvm-project/compiler-rt/lib/lsan/lsan_common.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric //=-- lsan_common.h -------------------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file is a part of LeakSanitizer.
100b57cec5SDimitry Andric // Private LSan header.
110b57cec5SDimitry Andric //
120b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #ifndef LSAN_COMMON_H
150b57cec5SDimitry Andric #define LSAN_COMMON_H
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_allocator.h"
180b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_common.h"
190b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_internal_defs.h"
200b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_platform.h"
2106c3fb27SDimitry Andric #include "sanitizer_common/sanitizer_range.h"
22349cc55cSDimitry Andric #include "sanitizer_common/sanitizer_stackdepot.h"
230b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_stoptheworld.h"
240b57cec5SDimitry Andric #include "sanitizer_common/sanitizer_symbolizer.h"
25bdd1243dSDimitry Andric #include "sanitizer_common/sanitizer_thread_registry.h"
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric // LeakSanitizer relies on some Glibc's internals (e.g. TLS machinery) on Linux.
280b57cec5SDimitry Andric // Also, LSan doesn't like 32 bit architectures
290b57cec5SDimitry Andric // because of "small" (4 bytes) pointer size that leads to high false negative
300b57cec5SDimitry Andric // ratio on large leaks. But we still want to have it for some 32 bit arches
310b57cec5SDimitry Andric // (e.g. x86), see https://github.com/google/sanitizers/issues/403.
320b57cec5SDimitry Andric // To enable LeakSanitizer on a new architecture, one needs to implement the
330b57cec5SDimitry Andric // internal_clone function as well as (probably) adjust the TLS machinery for
340b57cec5SDimitry Andric // the new architecture inside the sanitizer library.
35e8d8bef9SDimitry Andric // Exclude leak-detection on arm32 for Android because `__aeabi_read_tp`
36e8d8bef9SDimitry Andric // is missing. This caused a link error.
37e8d8bef9SDimitry Andric #if SANITIZER_ANDROID && (__ANDROID_API__ < 28 || defined(__arm__))
38e8d8bef9SDimitry Andric #  define CAN_SANITIZE_LEAKS 0
3981ad6265SDimitry Andric #elif (SANITIZER_LINUX || SANITIZER_APPLE) && (SANITIZER_WORDSIZE == 64) && \
400b57cec5SDimitry Andric     (defined(__x86_64__) || defined(__mips64) || defined(__aarch64__) ||  \
415ffd83dbSDimitry Andric      defined(__powerpc64__) || defined(__s390x__))
420b57cec5SDimitry Andric #  define CAN_SANITIZE_LEAKS 1
4381ad6265SDimitry Andric #elif defined(__i386__) && (SANITIZER_LINUX || SANITIZER_APPLE)
440b57cec5SDimitry Andric #  define CAN_SANITIZE_LEAKS 1
45e8d8bef9SDimitry Andric #elif defined(__arm__) && SANITIZER_LINUX
460b57cec5SDimitry Andric #  define CAN_SANITIZE_LEAKS 1
47bdd1243dSDimitry Andric #elif SANITIZER_LOONGARCH64 && SANITIZER_LINUX
48bdd1243dSDimitry Andric #  define CAN_SANITIZE_LEAKS 1
49fe6060f1SDimitry Andric #elif SANITIZER_RISCV64 && SANITIZER_LINUX
50fe6060f1SDimitry Andric #  define CAN_SANITIZE_LEAKS 1
515ffd83dbSDimitry Andric #elif SANITIZER_NETBSD || SANITIZER_FUCHSIA
520b57cec5SDimitry Andric #  define CAN_SANITIZE_LEAKS 1
530b57cec5SDimitry Andric #else
540b57cec5SDimitry Andric #  define CAN_SANITIZE_LEAKS 0
550b57cec5SDimitry Andric #endif
560b57cec5SDimitry Andric 
570b57cec5SDimitry Andric namespace __sanitizer {
580b57cec5SDimitry Andric class FlagParser;
590b57cec5SDimitry Andric class ThreadRegistry;
60e8d8bef9SDimitry Andric class ThreadContextBase;
610b57cec5SDimitry Andric struct DTLS;
620b57cec5SDimitry Andric }
630b57cec5SDimitry Andric 
64bdd1243dSDimitry Andric // This section defines function and class prototypes which must be implemented
65bdd1243dSDimitry Andric // by the parent tool linking in LSan. There are implementations provided by the
66bdd1243dSDimitry Andric // LSan library which will be linked in when LSan is used as a standalone tool.
670b57cec5SDimitry Andric namespace __lsan {
680b57cec5SDimitry Andric 
690b57cec5SDimitry Andric // Chunk tags.
700b57cec5SDimitry Andric enum ChunkTag {
710b57cec5SDimitry Andric   kDirectlyLeaked = 0,  // default
720b57cec5SDimitry Andric   kIndirectlyLeaked = 1,
730b57cec5SDimitry Andric   kReachable = 2,
740b57cec5SDimitry Andric   kIgnored = 3
750b57cec5SDimitry Andric };
760b57cec5SDimitry Andric 
77bdd1243dSDimitry Andric enum IgnoreObjectResult {
78bdd1243dSDimitry Andric   kIgnoreObjectSuccess,
79bdd1243dSDimitry Andric   kIgnoreObjectAlreadyIgnored,
80bdd1243dSDimitry Andric   kIgnoreObjectInvalid
81bdd1243dSDimitry Andric };
82bdd1243dSDimitry Andric 
83bdd1243dSDimitry Andric //// --------------------------------------------------------------------------
84bdd1243dSDimitry Andric //// Poisoning prototypes.
85bdd1243dSDimitry Andric //// --------------------------------------------------------------------------
86bdd1243dSDimitry Andric 
87bdd1243dSDimitry Andric // Returns true if [addr, addr + sizeof(void *)) is poisoned.
88bdd1243dSDimitry Andric bool WordIsPoisoned(uptr addr);
89bdd1243dSDimitry Andric 
90bdd1243dSDimitry Andric //// --------------------------------------------------------------------------
91bdd1243dSDimitry Andric //// Thread prototypes.
92bdd1243dSDimitry Andric //// --------------------------------------------------------------------------
93bdd1243dSDimitry Andric 
94bdd1243dSDimitry Andric // Wrappers for ThreadRegistry access.
9506c3fb27SDimitry Andric void LockThreads() SANITIZER_NO_THREAD_SAFETY_ANALYSIS;
9606c3fb27SDimitry Andric void UnlockThreads() SANITIZER_NO_THREAD_SAFETY_ANALYSIS;
97bdd1243dSDimitry Andric // If called from the main thread, updates the main thread's TID in the thread
98bdd1243dSDimitry Andric // registry. We need this to handle processes that fork() without a subsequent
99bdd1243dSDimitry Andric // exec(), which invalidates the recorded TID. To update it, we must call
100bdd1243dSDimitry Andric // gettid() from the main thread. Our solution is to call this function before
101bdd1243dSDimitry Andric // leak checking and also before every call to pthread_create() (to handle cases
102bdd1243dSDimitry Andric // where leak checking is initiated from a non-main thread).
103bdd1243dSDimitry Andric void EnsureMainThreadIDIsCorrect();
104bdd1243dSDimitry Andric 
105bdd1243dSDimitry Andric bool GetThreadRangesLocked(tid_t os_id, uptr *stack_begin, uptr *stack_end,
106bdd1243dSDimitry Andric                            uptr *tls_begin, uptr *tls_end, uptr *cache_begin,
107bdd1243dSDimitry Andric                            uptr *cache_end, DTLS **dtls);
108bdd1243dSDimitry Andric void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches);
109bdd1243dSDimitry Andric void GetThreadExtraStackRangesLocked(InternalMmapVector<Range> *ranges);
110bdd1243dSDimitry Andric void GetThreadExtraStackRangesLocked(tid_t os_id,
111bdd1243dSDimitry Andric                                      InternalMmapVector<Range> *ranges);
112bdd1243dSDimitry Andric void GetAdditionalThreadContextPtrsLocked(InternalMmapVector<uptr> *ptrs);
113bdd1243dSDimitry Andric void GetRunningThreadsLocked(InternalMmapVector<tid_t> *threads);
114bdd1243dSDimitry Andric 
115bdd1243dSDimitry Andric //// --------------------------------------------------------------------------
116bdd1243dSDimitry Andric //// Allocator prototypes.
117bdd1243dSDimitry Andric //// --------------------------------------------------------------------------
118bdd1243dSDimitry Andric 
119bdd1243dSDimitry Andric // Wrappers for allocator's ForceLock()/ForceUnlock().
120bdd1243dSDimitry Andric void LockAllocator();
121bdd1243dSDimitry Andric void UnlockAllocator();
122bdd1243dSDimitry Andric 
123*5f757f3fSDimitry Andric // Lock/unlock global mutext.
124*5f757f3fSDimitry Andric void LockGlobal();
125*5f757f3fSDimitry Andric void UnlockGlobal();
126*5f757f3fSDimitry Andric 
127bdd1243dSDimitry Andric // Returns the address range occupied by the global allocator object.
128bdd1243dSDimitry Andric void GetAllocatorGlobalRange(uptr *begin, uptr *end);
129bdd1243dSDimitry Andric // If p points into a chunk that has been allocated to the user, returns its
130bdd1243dSDimitry Andric // user-visible address. Otherwise, returns 0.
131bdd1243dSDimitry Andric uptr PointsIntoChunk(void *p);
132bdd1243dSDimitry Andric // Returns address of user-visible chunk contained in this allocator chunk.
133bdd1243dSDimitry Andric uptr GetUserBegin(uptr chunk);
13406c3fb27SDimitry Andric // Returns user-visible address for chunk. If memory tagging is used this
13506c3fb27SDimitry Andric // function will return the tagged address.
13606c3fb27SDimitry Andric uptr GetUserAddr(uptr chunk);
137bdd1243dSDimitry Andric 
138bdd1243dSDimitry Andric // Wrapper for chunk metadata operations.
139bdd1243dSDimitry Andric class LsanMetadata {
140bdd1243dSDimitry Andric  public:
141bdd1243dSDimitry Andric   // Constructor accepts address of user-visible chunk.
142bdd1243dSDimitry Andric   explicit LsanMetadata(uptr chunk);
143bdd1243dSDimitry Andric   bool allocated() const;
144bdd1243dSDimitry Andric   ChunkTag tag() const;
145bdd1243dSDimitry Andric   void set_tag(ChunkTag value);
146bdd1243dSDimitry Andric   uptr requested_size() const;
147bdd1243dSDimitry Andric   u32 stack_trace_id() const;
148bdd1243dSDimitry Andric 
149bdd1243dSDimitry Andric  private:
150bdd1243dSDimitry Andric   void *metadata_;
151bdd1243dSDimitry Andric };
152bdd1243dSDimitry Andric 
153bdd1243dSDimitry Andric // Iterate over all existing chunks. Allocator must be locked.
154bdd1243dSDimitry Andric void ForEachChunk(ForEachChunkCallback callback, void *arg);
155bdd1243dSDimitry Andric 
156bdd1243dSDimitry Andric // Helper for __lsan_ignore_object().
15706c3fb27SDimitry Andric IgnoreObjectResult IgnoreObject(const void *p);
158bdd1243dSDimitry Andric 
159bdd1243dSDimitry Andric // The rest of the LSan interface which is implemented by library.
160bdd1243dSDimitry Andric 
161bdd1243dSDimitry Andric struct ScopedStopTheWorldLock {
ScopedStopTheWorldLockScopedStopTheWorldLock162bdd1243dSDimitry Andric   ScopedStopTheWorldLock() {
16306c3fb27SDimitry Andric     LockThreads();
164bdd1243dSDimitry Andric     LockAllocator();
165bdd1243dSDimitry Andric   }
166bdd1243dSDimitry Andric 
~ScopedStopTheWorldLockScopedStopTheWorldLock167bdd1243dSDimitry Andric   ~ScopedStopTheWorldLock() {
168bdd1243dSDimitry Andric     UnlockAllocator();
16906c3fb27SDimitry Andric     UnlockThreads();
170bdd1243dSDimitry Andric   }
171bdd1243dSDimitry Andric 
172bdd1243dSDimitry Andric   ScopedStopTheWorldLock &operator=(const ScopedStopTheWorldLock &) = delete;
173bdd1243dSDimitry Andric   ScopedStopTheWorldLock(const ScopedStopTheWorldLock &) = delete;
174bdd1243dSDimitry Andric };
175bdd1243dSDimitry Andric 
1760b57cec5SDimitry Andric struct Flags {
1770b57cec5SDimitry Andric #define LSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;
1780b57cec5SDimitry Andric #include "lsan_flags.inc"
1790b57cec5SDimitry Andric #undef LSAN_FLAG
1800b57cec5SDimitry Andric 
1810b57cec5SDimitry Andric   void SetDefaults();
pointer_alignmentFlags1820b57cec5SDimitry Andric   uptr pointer_alignment() const {
1830b57cec5SDimitry Andric     return use_unaligned ? 1 : sizeof(uptr);
1840b57cec5SDimitry Andric   }
1850b57cec5SDimitry Andric };
1860b57cec5SDimitry Andric 
1870b57cec5SDimitry Andric extern Flags lsan_flags;
flags()1880b57cec5SDimitry Andric inline Flags *flags() { return &lsan_flags; }
1890b57cec5SDimitry Andric void RegisterLsanFlags(FlagParser *parser, Flags *f);
1900b57cec5SDimitry Andric 
1910eae32dcSDimitry Andric struct LeakedChunk {
1920eae32dcSDimitry Andric   uptr chunk;
1930eae32dcSDimitry Andric   u32 stack_trace_id;
1940eae32dcSDimitry Andric   uptr leaked_size;
1950eae32dcSDimitry Andric   ChunkTag tag;
1960eae32dcSDimitry Andric };
1970eae32dcSDimitry Andric 
1980eae32dcSDimitry Andric using LeakedChunks = InternalMmapVector<LeakedChunk>;
1990eae32dcSDimitry Andric 
2000b57cec5SDimitry Andric struct Leak {
2010b57cec5SDimitry Andric   u32 id;
2020b57cec5SDimitry Andric   uptr hit_count;
2030b57cec5SDimitry Andric   uptr total_size;
2040b57cec5SDimitry Andric   u32 stack_trace_id;
2050b57cec5SDimitry Andric   bool is_directly_leaked;
2060b57cec5SDimitry Andric   bool is_suppressed;
2070b57cec5SDimitry Andric };
2080b57cec5SDimitry Andric 
2090b57cec5SDimitry Andric struct LeakedObject {
2100b57cec5SDimitry Andric   u32 leak_id;
2110b57cec5SDimitry Andric   uptr addr;
2120b57cec5SDimitry Andric   uptr size;
2130b57cec5SDimitry Andric };
2140b57cec5SDimitry Andric 
2150b57cec5SDimitry Andric // Aggregates leaks by stack trace prefix.
2160b57cec5SDimitry Andric class LeakReport {
2170b57cec5SDimitry Andric  public:
LeakReport()2180b57cec5SDimitry Andric   LeakReport() {}
2190eae32dcSDimitry Andric   void AddLeakedChunks(const LeakedChunks &chunks);
2200b57cec5SDimitry Andric   void ReportTopLeaks(uptr max_leaks);
2210b57cec5SDimitry Andric   void PrintSummary();
222e8d8bef9SDimitry Andric   uptr ApplySuppressions();
2230b57cec5SDimitry Andric   uptr UnsuppressedLeakCount();
224e8d8bef9SDimitry Andric   uptr IndirectUnsuppressedLeakCount();
2250b57cec5SDimitry Andric 
2260b57cec5SDimitry Andric  private:
2270b57cec5SDimitry Andric   void PrintReportForLeak(uptr index);
2280b57cec5SDimitry Andric   void PrintLeakedObjectsForLeak(uptr index);
2290b57cec5SDimitry Andric 
2300b57cec5SDimitry Andric   u32 next_id_ = 0;
2310b57cec5SDimitry Andric   InternalMmapVector<Leak> leaks_;
2320b57cec5SDimitry Andric   InternalMmapVector<LeakedObject> leaked_objects_;
2330b57cec5SDimitry Andric };
2340b57cec5SDimitry Andric 
2350b57cec5SDimitry Andric typedef InternalMmapVector<uptr> Frontier;
2360b57cec5SDimitry Andric 
2370b57cec5SDimitry Andric // Platform-specific functions.
2380b57cec5SDimitry Andric void InitializePlatformSpecificModules();
2390b57cec5SDimitry Andric void ProcessGlobalRegions(Frontier *frontier);
2400b57cec5SDimitry Andric void ProcessPlatformSpecificAllocations(Frontier *frontier);
2410b57cec5SDimitry Andric 
2425ffd83dbSDimitry Andric // LockStuffAndStopTheWorld can start to use Scan* calls to collect into
2435ffd83dbSDimitry Andric // this Frontier vector before the StopTheWorldCallback actually runs.
2445ffd83dbSDimitry Andric // This is used when the OS has a unified callback API for suspending
2455ffd83dbSDimitry Andric // threads and enumerating roots.
2465ffd83dbSDimitry Andric struct CheckForLeaksParam {
2475ffd83dbSDimitry Andric   Frontier frontier;
2480eae32dcSDimitry Andric   LeakedChunks leaks;
249bdd1243dSDimitry Andric   tid_t caller_tid;
250bdd1243dSDimitry Andric   uptr caller_sp;
2515ffd83dbSDimitry Andric   bool success = false;
2525ffd83dbSDimitry Andric };
2535ffd83dbSDimitry Andric 
25406c3fb27SDimitry Andric using Region = Range;
25506c3fb27SDimitry Andric 
25606c3fb27SDimitry Andric bool HasRootRegions();
25706c3fb27SDimitry Andric void ScanRootRegions(Frontier *frontier,
25806c3fb27SDimitry Andric                      const InternalMmapVectorNoCtor<Region> &region);
25968d75effSDimitry Andric // Run stoptheworld while holding any platform-specific locks, as well as the
26068d75effSDimitry Andric // allocator and thread registry locks.
2615ffd83dbSDimitry Andric void LockStuffAndStopTheWorld(StopTheWorldCallback callback,
2625ffd83dbSDimitry Andric                               CheckForLeaksParam* argument);
2630b57cec5SDimitry Andric 
2640b57cec5SDimitry Andric void ScanRangeForPointers(uptr begin, uptr end,
2650b57cec5SDimitry Andric                           Frontier *frontier,
2660b57cec5SDimitry Andric                           const char *region_type, ChunkTag tag);
2670b57cec5SDimitry Andric void ScanGlobalRange(uptr begin, uptr end, Frontier *frontier);
268bdd1243dSDimitry Andric void ScanExtraStackRanges(const InternalMmapVector<Range> &ranges,
269bdd1243dSDimitry Andric                           Frontier *frontier);
2700b57cec5SDimitry Andric 
2710b57cec5SDimitry Andric // Functions called from the parent tool.
2720b57cec5SDimitry Andric const char *MaybeCallLsanDefaultOptions();
2730b57cec5SDimitry Andric void InitCommonLsan();
2740b57cec5SDimitry Andric void DoLeakCheck();
2750b57cec5SDimitry Andric void DoRecoverableLeakCheckVoid();
2760b57cec5SDimitry Andric void DisableCounterUnderflow();
2770b57cec5SDimitry Andric bool DisabledInThisThread();
2780b57cec5SDimitry Andric 
2790b57cec5SDimitry Andric // Used to implement __lsan::ScopedDisabler.
2800b57cec5SDimitry Andric void DisableInThisThread();
2810b57cec5SDimitry Andric void EnableInThisThread();
2820b57cec5SDimitry Andric // Can be used to ignore memory allocated by an intercepted
2830b57cec5SDimitry Andric // function.
2840b57cec5SDimitry Andric struct ScopedInterceptorDisabler {
ScopedInterceptorDisablerScopedInterceptorDisabler2850b57cec5SDimitry Andric   ScopedInterceptorDisabler() { DisableInThisThread(); }
~ScopedInterceptorDisablerScopedInterceptorDisabler2860b57cec5SDimitry Andric   ~ScopedInterceptorDisabler() { EnableInThisThread(); }
2870b57cec5SDimitry Andric };
2880b57cec5SDimitry Andric 
2890b57cec5SDimitry Andric // According to Itanium C++ ABI array cookie is a one word containing
2900b57cec5SDimitry Andric // size of allocated array.
IsItaniumABIArrayCookie(uptr chunk_beg,uptr chunk_size,uptr addr)2910b57cec5SDimitry Andric static inline bool IsItaniumABIArrayCookie(uptr chunk_beg, uptr chunk_size,
2920b57cec5SDimitry Andric                                            uptr addr) {
2930b57cec5SDimitry Andric   return chunk_size == sizeof(uptr) && chunk_beg + chunk_size == addr &&
2940b57cec5SDimitry Andric          *reinterpret_cast<uptr *>(chunk_beg) == 0;
2950b57cec5SDimitry Andric }
2960b57cec5SDimitry Andric 
2970b57cec5SDimitry Andric // According to ARM C++ ABI array cookie consists of two words:
2980b57cec5SDimitry Andric // struct array_cookie {
2990b57cec5SDimitry Andric //   std::size_t element_size; // element_size != 0
3000b57cec5SDimitry Andric //   std::size_t element_count;
3010b57cec5SDimitry Andric // };
IsARMABIArrayCookie(uptr chunk_beg,uptr chunk_size,uptr addr)3020b57cec5SDimitry Andric static inline bool IsARMABIArrayCookie(uptr chunk_beg, uptr chunk_size,
3030b57cec5SDimitry Andric                                        uptr addr) {
3040b57cec5SDimitry Andric   return chunk_size == 2 * sizeof(uptr) && chunk_beg + chunk_size == addr &&
3050b57cec5SDimitry Andric          *reinterpret_cast<uptr *>(chunk_beg + sizeof(uptr)) == 0;
3060b57cec5SDimitry Andric }
3070b57cec5SDimitry Andric 
3080b57cec5SDimitry Andric // Special case for "new T[0]" where T is a type with DTOR.
3090b57cec5SDimitry Andric // new T[0] will allocate a cookie (one or two words) for the array size (0)
3100b57cec5SDimitry Andric // and store a pointer to the end of allocated chunk. The actual cookie layout
3110b57cec5SDimitry Andric // varies between platforms according to their C++ ABI implementation.
IsSpecialCaseOfOperatorNew0(uptr chunk_beg,uptr chunk_size,uptr addr)3120b57cec5SDimitry Andric inline bool IsSpecialCaseOfOperatorNew0(uptr chunk_beg, uptr chunk_size,
3130b57cec5SDimitry Andric                                         uptr addr) {
3140b57cec5SDimitry Andric #if defined(__arm__)
3150b57cec5SDimitry Andric   return IsARMABIArrayCookie(chunk_beg, chunk_size, addr);
3160b57cec5SDimitry Andric #else
3170b57cec5SDimitry Andric   return IsItaniumABIArrayCookie(chunk_beg, chunk_size, addr);
3180b57cec5SDimitry Andric #endif
3190b57cec5SDimitry Andric }
3200b57cec5SDimitry Andric 
3210b57cec5SDimitry Andric // Return the linker module, if valid for the platform.
3220b57cec5SDimitry Andric LoadedModule *GetLinker();
3230b57cec5SDimitry Andric 
3240b57cec5SDimitry Andric // Return true if LSan has finished leak checking and reported leaks.
3250b57cec5SDimitry Andric bool HasReportedLeaks();
3260b57cec5SDimitry Andric 
3270b57cec5SDimitry Andric // Run platform-specific leak handlers.
3280b57cec5SDimitry Andric void HandleLeaks();
3290b57cec5SDimitry Andric 
3300b57cec5SDimitry Andric }  // namespace __lsan
3310b57cec5SDimitry Andric 
3320b57cec5SDimitry Andric extern "C" {
3330b57cec5SDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
3340b57cec5SDimitry Andric const char *__lsan_default_options();
3350b57cec5SDimitry Andric 
3360b57cec5SDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
3370b57cec5SDimitry Andric int __lsan_is_turned_off();
3380b57cec5SDimitry Andric 
3390b57cec5SDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
3400b57cec5SDimitry Andric const char *__lsan_default_suppressions();
341349cc55cSDimitry Andric 
342349cc55cSDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE
343349cc55cSDimitry Andric void __lsan_register_root_region(const void *p, __lsan::uptr size);
344349cc55cSDimitry Andric 
345349cc55cSDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE
346349cc55cSDimitry Andric void __lsan_unregister_root_region(const void *p, __lsan::uptr size);
347349cc55cSDimitry Andric 
3480b57cec5SDimitry Andric }  // extern "C"
3490b57cec5SDimitry Andric 
3500b57cec5SDimitry Andric #endif  // LSAN_COMMON_H
351