blob: df256c0e53847fe22eeda2b56052f7cbd1759c1d [file] [log] [blame]
Sergey Matveev5e719a72013-06-03 11:21:34 +00001//===-- 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
20extern "C" {
21#endif
22 // Allocations made between calls to __lsan_disable() and __lsan_enable() will
Sergey Matveevf93fa972013-07-18 14:06:07 +000023 // be treated as non-leaks. Disable/enable pairs may be nested.
Sergey Matveev5e719a72013-06-03 11:21:34 +000024 void __lsan_disable();
25 void __lsan_enable();
Sergey Matveevcd571e02013-06-06 14:17:56 +000026 // The heap object into which p points will be treated as a non-leak.
27 void __lsan_ignore_object(const void *p);
Alexey Samsonov9fbfd962013-06-27 09:35:50 +000028 // The user may optionally provide this function to disallow leak checking
Sergey Matveevf93fa972013-07-18 14:06:07 +000029 // 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 Samsonov9fbfd962013-06-27 09:35:50 +000032 int __lsan_is_turned_off();
Sergey Matveevf93fa972013-07-18 14:06:07 +000033 // 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 Samsonov53fbbf42013-08-05 13:20:39 +000038 // are memory leaks and the exit_code flag is non-zero.
Sergey Matveevf93fa972013-07-18 14:06:07 +000039 void __lsan_do_leak_check();
Sergey Matveev5e719a72013-06-03 11:21:34 +000040#ifdef __cplusplus
41} // extern "C"
42
43namespace __lsan {
44class ScopedDisabler {
45 public:
46 ScopedDisabler() { __lsan_disable(); }
47 ~ScopedDisabler() { __lsan_enable(); }
48};
49} // namespace __lsan
50#endif
51
52#endif // SANITIZER_LSAN_INTERFACE_H