| Sergey Matveev | 5e719a7 | 2013-06-03 11:21:34 +0000 | [diff] [blame] | 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 |
| Sergey Matveev | f93fa97 | 2013-07-18 14:06:07 +0000 | [diff] [blame] | 23 | // be treated as non-leaks. Disable/enable pairs may be nested. |
| Sergey Matveev | 5e719a7 | 2013-06-03 11:21:34 +0000 | [diff] [blame] | 24 | void __lsan_disable(); |
| 25 | void __lsan_enable(); |
| Sergey Matveev | cd571e0 | 2013-06-06 14:17:56 +0000 | [diff] [blame] | 26 | // The heap object into which p points will be treated as a non-leak. |
| 27 | void __lsan_ignore_object(const void *p); |
| Alexey Samsonov | 9fbfd96 | 2013-06-27 09:35:50 +0000 | [diff] [blame] | 28 | // The user may optionally provide this function to disallow leak checking |
| Sergey Matveev | f93fa97 | 2013-07-18 14:06:07 +0000 | [diff] [blame] | 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. |
| Alexey Samsonov | 9fbfd96 | 2013-06-27 09:35:50 +0000 | [diff] [blame] | 32 | int __lsan_is_turned_off(); |
| Sergey Matveev | f93fa97 | 2013-07-18 14:06:07 +0000 | [diff] [blame] | 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 |
| Alexey Samsonov | 53fbbf4 | 2013-08-05 13:20:39 +0000 | [diff] [blame] | 38 | // are memory leaks and the exit_code flag is non-zero. |
| Sergey Matveev | f93fa97 | 2013-07-18 14:06:07 +0000 | [diff] [blame] | 39 | void __lsan_do_leak_check(); |
| Sergey Matveev | 5e719a7 | 2013-06-03 11:21:34 +0000 | [diff] [blame] | 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 |