Home | History | Annotate | Download | only in sanitizer
      1 //===-- sanitizer/lsan_interface.h ------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file is a part of LeakSanitizer.
     11 //
     12 // Public interface header.
     13 //===----------------------------------------------------------------------===//
     14 #ifndef SANITIZER_LSAN_INTERFACE_H
     15 #define SANITIZER_LSAN_INTERFACE_H
     16 
     17 #include <sanitizer/common_interface_defs.h>
     18 
     19 #ifdef __cplusplus
     20 extern "C" {
     21 #endif
     22   // Allocations made between calls to __lsan_disable() and __lsan_enable() will
     23   // be treated as non-leaks. Disable/enable pairs may be nested.
     24   void __lsan_disable();
     25   void __lsan_enable();
     26   // The heap object into which p points will be treated as a non-leak.
     27   void __lsan_ignore_object(const void *p);
     28   // The user may optionally provide this function to disallow leak checking
     29   // for the program it is linked into (if the return value is non-zero). This
     30   // function must be defined as returning a constant value; any behavior beyond
     31   // that is unsupported.
     32   int __lsan_is_turned_off();
     33   // Calling this function makes LSan enter the leak checking phase immediately.
     34   // Use this if normal end-of-process leak checking happens too late (e.g. if
     35   // you have intentional memory leaks in your shutdown code). Calling this
     36   // function overrides end-of-process leak checking; it must be called at
     37   // most once per process. This function will terminate the process if there
     38   // are memory leaks and the exit_code flag is non-zero.
     39   void __lsan_do_leak_check();
     40 #ifdef __cplusplus
     41 }  // extern "C"
     42 
     43 namespace __lsan {
     44 class ScopedDisabler {
     45  public:
     46   ScopedDisabler() { __lsan_disable(); }
     47   ~ScopedDisabler() { __lsan_enable(); }
     48 };
     49 }  // namespace __lsan
     50 #endif
     51 
     52 #endif  // SANITIZER_LSAN_INTERFACE_H
     53