| OLD | NEW |
| (Empty) | |
| 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 |
| 27 // The heap object into which p points will be treated as a non-leak. |
| 28 void __lsan_ignore_object(const void *p); |
| 29 |
| 30 // Memory regions registered through this interface will be treated as sources |
| 31 // of live pointers during leak checking. Useful if you store pointers in |
| 32 // mapped memory. |
| 33 // Points of note: |
| 34 // - __lsan_unregister_root_region() must be called with the same pointer and |
| 35 // size that have earlier been passed to __lsan_register_root_region() |
| 36 // - LSan will skip any inaccessible memory when scanning a root region. E.g., |
| 37 // if you map memory within a larger region that you have mprotect'ed, you can |
| 38 // register the entire large region. |
| 39 // - the implementation is not optimized for performance. This interface is |
| 40 // intended to be used for a small number of relatively static regions. |
| 41 void __lsan_register_root_region(const void *p, size_t size); |
| 42 void __lsan_unregister_root_region(const void *p, size_t size); |
| 43 |
| 44 // Calling this function makes LSan enter the leak checking phase immediately. |
| 45 // Use this if normal end-of-process leak checking happens too late (e.g. if |
| 46 // you have intentional memory leaks in your shutdown code). Calling this |
| 47 // function overrides end-of-process leak checking; it must be called at |
| 48 // most once per process. This function will terminate the process if there |
| 49 // are memory leaks and the exit_code flag is non-zero. |
| 50 void __lsan_do_leak_check(); |
| 51 |
| 52 // The user may optionally provide this function to disallow leak checking |
| 53 // for the program it is linked into (if the return value is non-zero). This |
| 54 // function must be defined as returning a constant value; any behavior beyond |
| 55 // that is unsupported. |
| 56 int __lsan_is_turned_off(); |
| 57 |
| 58 // This function may be optionally provided by the user and should return |
| 59 // a string containing LSan suppressions. |
| 60 const char *__lsan_default_suppressions(); |
| 61 #ifdef __cplusplus |
| 62 } // extern "C" |
| 63 |
| 64 namespace __lsan { |
| 65 class ScopedDisabler { |
| 66 public: |
| 67 ScopedDisabler() { __lsan_disable(); } |
| 68 ~ScopedDisabler() { __lsan_enable(); } |
| 69 }; |
| 70 } // namespace __lsan |
| 71 #endif |
| 72 |
| 73 #endif // SANITIZER_LSAN_INTERFACE_H |
| OLD | NEW |