Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
leak_sanitizer.h
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_PLATFORM_LEAK_SANITIZER_H_
6#define RUNTIME_PLATFORM_LEAK_SANITIZER_H_
7
8#include "platform/globals.h"
9
10#if __SANITIZE_ADDRESS__
11#define USING_LEAK_SANITIZER
12#elif defined(__has_feature)
13#if __has_feature(leak_sanitizer) || __has_feature(address_sanitizer)
14#define USING_LEAK_SANITIZER
15#endif
16#endif
17
18#if defined(USING_LEAK_SANITIZER)
19extern "C" void __lsan_register_root_region(const void* p, size_t size);
20extern "C" void __lsan_unregister_root_region(const void* p, size_t size);
21#define LSAN_REGISTER_ROOT_REGION(ptr, len) \
22 __lsan_register_root_region(ptr, len)
23#define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \
24 __lsan_unregister_root_region(ptr, len)
25#else // defined(USING_LEAK_SANITIZER)
26#define LSAN_REGISTER_ROOT_REGION(ptr, len) \
27 do { \
28 } while (false && (ptr) == nullptr && (len) == 0)
29#define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \
30 do { \
31 } while (false && (ptr) == nullptr && (len) == 0)
32#endif // defined(USING_LEAK_SANITIZER)
33
34#endif // RUNTIME_PLATFORM_LEAK_SANITIZER_H_