2013-05-20 19:04:43 +08:00
|
|
|
//=-- lsan.h --------------------------------------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-05-20 19:04:43 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of LeakSanitizer.
|
|
|
|
// Private header for standalone LSan RTL.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-09-14 16:14:38 +08:00
|
|
|
#include "lsan_thread.h"
|
2020-01-25 08:55:11 +08:00
|
|
|
#if SANITIZER_POSIX
|
2021-12-08 02:44:24 +08:00
|
|
|
# include "lsan_posix.h"
|
2020-01-29 03:34:53 +08:00
|
|
|
#elif SANITIZER_FUCHSIA
|
2021-12-08 02:44:24 +08:00
|
|
|
# include "lsan_fuchsia.h"
|
2020-01-25 08:55:11 +08:00
|
|
|
#endif
|
2013-05-20 19:04:43 +08:00
|
|
|
#include "sanitizer_common/sanitizer_flags.h"
|
|
|
|
#include "sanitizer_common/sanitizer_stacktrace.h"
|
|
|
|
|
2021-12-08 02:44:24 +08:00
|
|
|
#define GET_STACK_TRACE(max_size, fast) \
|
|
|
|
__sanitizer::BufferedStackTrace stack; \
|
|
|
|
stack.Unwind(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), nullptr, fast, \
|
|
|
|
max_size);
|
2014-08-26 20:52:41 +08:00
|
|
|
|
|
|
|
#define GET_STACK_TRACE_FATAL \
|
|
|
|
GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal)
|
|
|
|
|
|
|
|
#define GET_STACK_TRACE_MALLOC \
|
|
|
|
GET_STACK_TRACE(__sanitizer::common_flags()->malloc_context_size, \
|
|
|
|
common_flags()->fast_unwind_on_malloc)
|
|
|
|
|
2017-06-20 03:21:31 +08:00
|
|
|
#define GET_STACK_TRACE_THREAD GET_STACK_TRACE(kStackTraceMax, true)
|
|
|
|
|
2013-05-20 19:04:43 +08:00
|
|
|
namespace __lsan {
|
|
|
|
|
|
|
|
void InitializeInterceptors();
|
2017-04-12 04:05:02 +08:00
|
|
|
void ReplaceSystemMalloc();
|
2020-01-29 03:34:53 +08:00
|
|
|
void LsanOnDeadlySignal(int signo, void *siginfo, void *context);
|
2017-04-12 04:05:02 +08:00
|
|
|
|
2021-12-08 02:44:24 +08:00
|
|
|
#define ENSURE_LSAN_INITED \
|
|
|
|
do { \
|
|
|
|
CHECK(!lsan_init_is_running); \
|
|
|
|
if (!lsan_inited) \
|
|
|
|
__lsan_init(); \
|
|
|
|
} while (0)
|
2013-05-20 19:04:43 +08:00
|
|
|
|
|
|
|
} // namespace __lsan
|
2013-11-25 22:25:36 +08:00
|
|
|
|
|
|
|
extern bool lsan_inited;
|
|
|
|
extern bool lsan_init_is_running;
|
|
|
|
|
2017-11-16 07:42:48 +08:00
|
|
|
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __lsan_init();
|